Skip to content

Instantly share code, notes, and snippets.

@spock
Created February 24, 2016 10:56
Show Gist options
  • Save spock/7d4e46e1158e2e4a46d4 to your computer and use it in GitHub Desktop.
Save spock/7d4e46e1158e2e4a46d4 to your computer and use it in GitHub Desktop.
quick and dirty prinseq-lite.pl (versions 0.20.3/0.20.4) patch to enable mkfifo named pipes as input files; beware, this patch disables input file format checking
diff --git a/prinseq-lite.pl b/prinseq-lite.pl
index cad531a..de1eff3 100755
--- a/prinseq-lite.pl
+++ b/prinseq-lite.pl
@@ -583,7 +583,7 @@ if(exists $params{fasta} && exists $params{fastq}) {
}
} elsif(-e $params{fasta}) {
#check for file format
- my $format = &checkFileFormat($file1);
+ my $format = &checkFileFormat($file1, 'fasta');
unless($format eq 'fasta') {
&printError('input file for -fasta is in '.uc($format).' format not in FASTA format');
}
@@ -600,7 +600,7 @@ if(exists $params{fasta} && exists $params{fastq}) {
}
} elsif(-e $params{fastq}) {
#check for file format
- my $format = &checkFileFormat($file1);
+ my $format = &checkFileFormat($file1, 'fastq');
unless($format eq 'fastq') {
&printError('input file for -fastq is in '.uc($format).' format not in FASTQ format');
}
@@ -618,7 +618,7 @@ if(exists $params{fastq} && exists $params{qual}) {
&printError('QUAL data cannot be read from STDIN');
} elsif(-e $params{qual}) {
#check for file format
- my $format = &checkFileFormat($params{qual});
+ my $format = &checkFileFormat($params{qual}, 'qual');
unless($format eq 'qual') {
&printError('input file for -qual is in '.uc($format).' format not in QUAL format');
}
@@ -640,7 +640,7 @@ if(exists $params{fasta2} && exists $params{fastq2}) {
&printError('paired-end data cannot be processed from STDIN');
} elsif(-e $params{fasta2}) {
#check for file format
- my $format = &checkFileFormat($file2);
+ my $format = &checkFileFormat($file2, 'fasta');
unless($format eq 'fasta') {
&printError('input file for -fasta2 is in '.uc($format).' format not in FASTA format');
}
@@ -661,7 +661,7 @@ if(exists $params{fasta2} && exists $params{fastq2}) {
&printError('paired-end data cannot be processed from STDIN');
} elsif(-e $params{fastq2}) {
#check for file format
- my $format = &checkFileFormat($file2);
+ my $format = &checkFileFormat($file2, 'fastq');
unless($format eq 'fastq') {
&printError('input file for -fastq2 is in '.uc($format).' format not in FASTQ format');
}
@@ -2370,6 +2370,17 @@ sub readParamsFile {
sub checkFileFormat {
my $file = shift;
+ # The proper FIFO fix would be:
+ # - only open file once, and close it also once - after processing is done;
+ # - if necessary - pass the file handle around;
+ # - for format checking, use the same method as for STDIN processing, namely
+ # - read the first 3 lines into a variable;
+ # - check format of those 3 lines;
+ # - if the format is correct, then first process those lines from the variable,
+ # and keep reading the file from line 4.
+ my $expected = shift;
+ # To (temporarily) undo the FIFO patch: comment out the return statement below.
+ return $expected;
my ($format,$count,$id,$fasta,$fastq,$qual);
$count = 3;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment