Skip to content

Commit

Permalink
perltidy
Browse files Browse the repository at this point in the history
  • Loading branch information
akotlar committed Feb 21, 2024
1 parent 49def01 commit 5e4bde9
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 172 deletions.
69 changes: 38 additions & 31 deletions perl/lib/Seq/Role/IO.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use 5.10.0;
use strict;
use warnings;

package Seq::Role::IO;

our $VERSION = '0.001';
Expand Down Expand Up @@ -44,25 +45,25 @@ has cat => (

has gzip => (
is => 'ro',
lazy => 1,
default => sub {
lazy => 1,
default => sub {
return which('bgzip') || which('pigz') || which('gzip');
},
);

has lz4 => (
is => 'ro',
lazy => 1,
default => sub {
lazy => 1,
default => sub {
return which('lz4');
},
);

has gzipDcmpArgs => (
is => 'ro',
lazy => 1,
is => 'ro',
lazy => 1,
init_arg => undef,
default => sub {
default => sub {
my $self = shift;

my $gzip = $self->gzip;
Expand All @@ -76,10 +77,10 @@ has gzipDcmpArgs => (
);

has gzipCmpArgs => (
is => 'ro',
lazy => 1,
is => 'ro',
lazy => 1,
init_arg => undef,
default => sub {
default => sub {
my $self = shift;
my $gzip = $self->gzip;

Expand Down Expand Up @@ -119,18 +120,17 @@ has zip => (
},
);


sub getReadArgs {
my ( $self, $filePath ) = @_;

my ( $remoteCpCmd, $remoteFileSizeCmd ) = $self->getRemoteProg($filePath);
my $outerCommand = $self->getDecompressProgWithArgs($filePath);

if ($remoteCpCmd) {
if ($outerCommand != $self->cat) {
if ( $outerCommand != $self->cat ) {
# If we're piping to unzip, that won't work with standard unzip
# For now raise an exception
if (index($outerCommand, $self->unzip) != -1) {
if ( index( $outerCommand, $self->unzip ) != -1 ) {
die "Cannot pipe to unzip with remote files";
}

Expand Down Expand Up @@ -260,7 +260,7 @@ sub getWriteFh {

my $fh;

( $err, my $cmd ) = $self->getCompresssedWriteCmd( $file );
( $err, my $cmd ) = $self->getCompresssedWriteCmd($file);

if ($err) {
return ( $err, undef );
Expand All @@ -280,33 +280,40 @@ sub getCompresssedWriteCmd {
my ( $self, $file ) = @_;

my $hasGz = $file =~ /[.]gz$/ || $file =~ /[.]bgz$/;
my $hasZip = $file =~ /[.]zip$/;
my $hasZip = $file =~ /[.]zip$/;
my $hasLz4 = $file =~ /[.]lz4$/;

if ( $hasLz4 ) {
if(!$self->lz4) {
return ("lz4 requested but lz4 program not passed to Seq::Role::IO or not found in system", undef)
if ($hasLz4) {
if ( !$self->lz4 ) {
return (
"lz4 requested but lz4 program not passed to Seq::Role::IO or not found in system",
undef );
}
return (undef, $self->lz4 . " > $file");
return ( undef, $self->lz4 . " > $file" );
}

if ( $hasGz ) {
if(!$self->gzip) {
return ("gzip requested but gzip-compatible program not passed to Seq::Role::IO or not found in system", undef)
if ($hasGz) {
if ( !$self->gzip ) {
return (
"gzip requested but gzip-compatible program not passed to Seq::Role::IO or not found in system",
undef
);
}

return (undef, $self->gzip . " " . $self->gzipCmpArgs . " > $file");
return ( undef, $self->gzip . " " . $self->gzipCmpArgs . " > $file" );
}

if ( $hasZip ) {
if(!$self->zip) {
return ("zip requested but zip program not passed to Seq::Role::IO or not found in system", undef)
if ($hasZip) {
if ( !$self->zip ) {
return (
"zip requested but zip program not passed to Seq::Role::IO or not found in system",
undef );
}

return (undef, $self->zip . " -q > $file");
return ( undef, $self->zip . " -q > $file" );
}

return (undef, undef);
return ( undef, undef );
}

# Allows user to return an error; dies with logging by default
Expand Down Expand Up @@ -464,12 +471,12 @@ sub compressDirIntoTarball {
return 'Directory is empty';
}

my $tar = $self->tar;
my $tar = $self->tar;
my $gzip = $self->gzip;
my $lz4 = $self->lz4;
my $lz4 = $self->lz4;

my $tarProg =
$tarballName =~ /tar.gz$/
$tarballName =~ /tar.gz$/
? "$tar --use-compress-program=$gzip"
: ( $tarballName =~ /tar.lz4$/ ? "$tar --use-compress-program=$lz4" : "tar" );
my $tarCommand = sprintf(
Expand Down
2 changes: 1 addition & 1 deletion perl/lib/Seq/Tracks/Vcf/Build.pm
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ sub _openVcfPipe {
my $outputter = Seq::Output::Delimiters->new();

my $delim = $outputter->emptyFieldChar;
my $prog = $self->getDecompressProgWithArgs($file);
my $prog = $self->getDecompressProgWithArgs($file);

my $errPath = $file . ".build." . localtime() . ".log";

Expand Down
Loading

0 comments on commit 5e4bde9

Please sign in to comment.