A
Amy Lee
Hello,
I make a small perl script to count how many sequences in a fasta
formation file. In fasta formation file every sequence starts with a ">",
so I can count how many ">" in a file.
There's my code:
if (@ARGV != 0)
{
foreach $file (@ARGV)
{
unless (-e $file)
{
print "***Error: $file dose not exist.\n";
next;
}
unless (open $FILE_IN, '<', $file)
{
print "***Error: Cannot read $file.\n";
next;
}
$full_size = (stat($file))[7];
while (<$FILE_IN>)
{
s/>//g;
}
$mod_size = (stat($FILE_IN))[7];
$num = $full_size-$mod_size;
close $FILE_IN;
print "$file ==> $num seq.\n"
}
}
However, when I run this script, it always shows "0 seqs". I don't know
what happened. And is there any better way to count ">"?
Thank you very much~
Regards,
Amy Lee
I make a small perl script to count how many sequences in a fasta
formation file. In fasta formation file every sequence starts with a ">",
so I can count how many ">" in a file.
There's my code:
if (@ARGV != 0)
{
foreach $file (@ARGV)
{
unless (-e $file)
{
print "***Error: $file dose not exist.\n";
next;
}
unless (open $FILE_IN, '<', $file)
{
print "***Error: Cannot read $file.\n";
next;
}
$full_size = (stat($file))[7];
while (<$FILE_IN>)
{
s/>//g;
}
$mod_size = (stat($FILE_IN))[7];
$num = $full_size-$mod_size;
close $FILE_IN;
print "$file ==> $num seq.\n"
}
}
However, when I run this script, it always shows "0 seqs". I don't know
what happened. And is there any better way to count ">"?
Thank you very much~
Regards,
Amy Lee