-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfastaNamesSizes.pl
More file actions
executable file
·61 lines (48 loc) · 1.12 KB
/
Copy pathfastaNamesSizes.pl
File metadata and controls
executable file
·61 lines (48 loc) · 1.12 KB
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
#!/usr/bin/perl -w
=head1 SYNOPSIS
fastaNamesSizes.pl - returns a tab list with name and size of sequences
in a fasta file
=head1 USAGE
fastaNamesSizes.pl [-f format] fasta_file1 fasta_file2...
=head2 -f format
Format
=head1 AUTHOR
Lionel Guy (lionel.guy@icm.uu.se)
=cut
use strict;
use Getopt::Std;
use Bio::SeqIO;
our $opt_f;
getopts('f:');
usage() unless @ARGV;
foreach my $file (@ARGV){
my $count = 0;
my $sum = 0;
my $min;
my $max;
my $seq_io;
if ($opt_f){
$seq_io = Bio::SeqIO->new(-file => "$file", -format => $opt_f);
}
else {
$seq_io = Bio::SeqIO->new(-file => "$file");
}
while (my $seq = $seq_io->next_seq){
my $id = $seq->display_id;
my $len = $seq->length;
print "$id\t$len\n";
# stats
$count++;
$sum += $len;
$min = $len if (!$min || $len < $min);
$max = $len if (!$max || $len > $max);
}
my $average = int($sum/$count+0.5);
print STDERR "# File $file\n";
print STDERR "# $count sequences, total length $sum.\n";
print STDERR "# Minimum len: $min. Max: $max. Average: $average\n";
}
sub usage{
system("perldoc $0");
exit;
}