-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseq_stat.pl
More file actions
37 lines (33 loc) · 748 Bytes
/
seq_stat.pl
File metadata and controls
37 lines (33 loc) · 748 Bytes
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
my $inputFile = $ARGV[0];
my $outputFile = $ARGV[1];
open("FH",$inputFile) or die("File not found");
%hash = {};
while($line=<FH>){
if($line=~/^>/){
$header = $line;
$seq = "";
}else{
$seq = $seq.$line
}
$hash{$header} = $seq;
}
open(OUT,">$outputFile");
foreach$header(sort keys %hash){
%count = {};
$seq = $hash{$header};
$seq =~ s/\n//g;
@seq = split("",$seq);
foreach$letter(@seq){
$count{$letter}++;
}
$header=~s/>//g;
$header =~ s/\n//g;
print OUT "$header\t";
foreach(sort keys %count){
if($_ !~ m/^HASH/){
print OUT "$_=$count{$_}\t";
}
}
$lenOfSeq = scalar(@seq);
print OUT "SequenceLength=$lenOfSeq \n";
}