Hi all,
am using the following script to parse a long list of files. funnily
enough, it works fine when i try a couple sample files, but when i'm
using a long list of files, it comes up with this error:
readline() on closed filehandle FILE at hashing22.pl line 29, <FILE> line
13 (#1)
(W closed) The filehandle you're reading from got itself closed
sometime
before now. Check your logic flow.
i dont know what could be causing this- any ideas?
here's the script:
#!/usr/bin/perl-w
# takes a file where the first line specifies query length, puts in ahash
# the seqid and numbers listed, adds up the numbers, divides by qlen
# and give len coverage.
use diagnostics;
$out_dir = "post_parsing_len_cov_files";
mkdir $out_dir, 0777 unless (-e $out_dir);
$| = 1;
$files= "./listofnames2";
open (FH,"$files") or die "cannot create list :$!";
while (<FH>) {
push (@list, $_);
}
foreach (@list) {
$filename=$_;
open (FILE, $filename);
open (HASH_OUT, ">$out_dir/$filename.stats");
my %hash;
while (<FILE>)
{
if (/^Query : (.*)\S/m){
$qname = "$1";
print HASH_OUT "Query : $qname\n";
}
else
{
if (/^qlen = (\d+)/m){
$qlen = "$1";
print HASH_OUT "querylen = $qlen\n";
}
else
{@line = split (/\n/);
foreach $line (@line){
($key,$value) = split (/:/);
$hash {$key} = $value;
#print " $value";
@nums = split (" ",$value);
#print "$key: @nums";
$tot = &total(@nums);
$cov = $tot/$qlen * 100 ;
if ($cov >= 50){
print HASH_OUT "$key : $cov\n";
}}}
}}}
close FILE;
sub total {
my $sum;
foreach (@_){
$sum += $_;
}
$sum;
}
------------------------------
a typical file to be read by this script is would look like this:
Query : MAL13P1.227_ubiquitin-conjugatin
qlen = 278
>CpType1H_3652:111 81
>CpIowa_1214.266:111 121
>CpGSS_AQ842837:98
>CpType1H_3631:118
>CpIowa_1214.272:118 74 26
>CpIowa_1214.275:77 90 141 17 10 17
>CpEST_AA390251:117
>CpEST_AA390240:102
>CpType1H_3267:77 143
>CpGSS_AQ842682:98
----------------------------------
SOME files also don't have any lines in them after the first two.
any suggestions on improving my long winded coding skills (or lack
thereof) are most welcome.
thanks,
-nandita
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]