forked from gringer/bioinfscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fastx2fastm.pl
executable file
·53 lines (50 loc) · 911 Bytes
/
fastx2fastm.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
50
51
52
53
#!/usr/bin/perl
use warnings;
use strict;
my $inQual = 0; # false
my $seqID = "";
my $qualID = "";
my $seq = "";
my $qual = "";
while(<>){
if(!$inQual){
if(/^(>|@)((.+?)( .*?\s*)?)$/){
my $newSeqID = $2;
if($seq){
$seq =~ s/\n/\n /g;
$seq =~ s/ $//;
printf("#seq:%s\n", $seqID);
printf(" %s", $seq);
if($qual){
$qual =~ s/\n/\n /g;
$qual =~ s/ $//;
printf("#qual:%s\n", $seqID);
printf(" %s", $qual);
}
}
$seq = "";
$qual = "";
$seqID = $newSeqID;
chomp $seqID;
chomp $seqID;
} elsif(/^\+(.*)$/) {
$inQual = 1; # true
$qualID = $1;
} else {
$seq .= $_;
}
} else {
$qual .= $_;
if(length($qual) >= length($seq)){
$inQual = 0; # false
}
}
}
if($seqID){
printf("#seq:%s\n", $seqID);
printf(" %s", $seq);
if($qual){
printf("#qual:%s\n", $seqID);
printf(" %s", $qual);
}
}