-
Notifications
You must be signed in to change notification settings - Fork 15
/
fastq2fasta.pl
executable file
·49 lines (45 loc) · 943 Bytes
/
fastq2fasta.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
46
47
48
49
#!/usr/bin/perl
use warnings;
use strict;
use Getopt::Long qw(:config auto_help pass_through);
my $minLength = 0;
my $singleLine = 0;
GetOptions("minLength=i" => \$minLength, "singleLine!" => \$singleLine) or
die("Error in command line arguments");
my $inQual = 0; # false
my $seqID = "";
my $qualID = "";
my $seq = "";
my $qual = "";
while(<>){
chomp;
chomp;
if(/^\s+$/){
next;
}
if(!$inQual){
if(/^@(.+)$/){
$seqID = $1;
$seq = "";
} elsif(/^\+(.*)$/) {
$inQual = 1; # true
$qualID = $1;
$qual = "";
if(length($seq) > $minLength){
my $printedSeq = $seq;
if(!$singleLine){
$printedSeq =~ s/(.{60})/$1\n/g;
$printedSeq =~ s/\n$//g;
}
printf(">%s\n%s\n", $seqID, $printedSeq);
}
} else {
$seq .= $_;
}
} else {
$qual .= $_;
if(length($qual) >= length($seq)){
$inQual = 0; # false
}
}
}