forked from gringer/bioinfscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fastqcat.pl
executable file
·45 lines (40 loc) · 890 Bytes
/
fastqcat.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl
use warnings;
use strict;
use Getopt::Long qw(:config auto_version auto_help pass_through); # for option parsing
my $inQual = 0; # false
my $seqID = "";
my $qualID = "";
my $seq = "";
my $qual = "";
my $minLen = 0;
GetOptions('minlength=i' => \$minLen) or
die("Error in command line arguments");
while(<>){
chomp;
chomp;
if(!$inQual){
if(/^@(.+)$/){
my $newSeqID = $1;
if($seqID && (length($seq) >= $minLen)){
printf("@%s\n%s\n+\n%s\n", $seqID, $seq, $qual);
}
$seq = "";
$qual = "";
$seqID = $newSeqID;
} elsif(/^\+(.*)$/) {
$inQual = 1; # true
$qualID = $1;
} else {
$seq .= $_;
}
} else {
$qual .= $_;
if(length($qual) >= length($seq)){
$inQual = 0; # false
}
}
}
if($seqID && (length($seq) >= $minLen)){
printf("@%s\n%s\n+\n%s\n", $seqID, $seq, $qual);
}