-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatistic_seq_length.pl
70 lines (60 loc) · 1.19 KB
/
statistic_seq_length.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/perl
use strict;
use warings;
use Cwd qw(abs_path getcwd);
use FindBin '$Bin';
use Getopt::Long;
use File::Basename qw(basename dirname fileparse);
my($fasta,$od);
GetOptions(
"fa:s" => \$fasta,
"od:s" => \$od,
"h|?" => \$USAGE,
) or &USAGE;
&USAGE unless(!defined $fastq and !defined $od);
if(!defined $fasta and !defined $od){
print "program must get the input file\n";
&graphic;
}
sub graphic{
my $graphic_pi=<<"USAGE";
.
.
...............
. .
. .
. ........
. . .
. .
. . .
USAGE #must be flush left
print $graphic_pi;
exit(1);
}
my %seq=();
open(my $in,"$fasta") || die $!;
open(my $out,">","$od");
for my $line(<$in>){
chomp $line;
next if(/^\>/);
my $length=length($line);
$seq{$length}++;
}
close $in;
#print
foreach my $key(sort{$a<=>$b} keys %seq){
print "$key","\n";
print "$seq{$key}","\n";
}
close $out;
sub USAGE{
my $usage=<<"USAGE";
----------------------------------
-fa input fasta file,forced
-od output file,forced
-h output help,selected
----------------------------------
USAGE
print "$usage";
exit(1);
}