using 2 sets of incremental file handles
Yael Soffer (ysofer@md.huji.ac.il)
Sun, 31 Jan 1999 10:16:18 +0200
Please help me,
I'm using 2 sets of incremental file handles in my script and it seems I
get
wierd error messages, like:
Use of uninitialized value at test3.pl line 43,<protein0153> chunk 96.
Use of uninitialized value at test3.pl line 43, <protein0163> chunk 60
... and lots and lots of messages like this on my screen.
Protein0000 is the name of the incremental file handle.
Line 43 is the line in which I use "while($loopfiles[$j]){" to read from
the new incremental filehandle.
And after that the screen is filled with messages like these:
Read on closed filehandle <protein0199> at test3.pl line 85.
Read on closed filehandle <protein0200> at test3.pl line 85.
Read on closed filehandle <protein0201> at test3.pl line 85.
Read on closed filehandle <protein0202> at test3.pl line 30.
Read on closed filehandle <protein0203> at test3.pl line 85.
Eventhough I don't use the close statement to close the file handle
proteinXXXX.
If I haven't managed to clear myself, here's a copy of the script.
Thank you,
Yael.
p.s.
the script:
#!/usr/bin/perl -w # program for finding something in file
$model=$ARGV[0]; #model is the name of the model/wanted protein and also
the directory of all the loop sequence #files. %score=();
$place="/usr/people/ysofer/3d_proteins"; opendir PROTEINS, $place or die
"can\'t open directory!"; @allfiles=grep -T, map "$place/$_", readdir
PROTEINS; closedir PROTEINS; $i=1; #because first file is rubbish opendir
LOOPS, $place or die "can\'t open directory!"; @loopfiles=grep -T, map
"$model/$_", readdir LOOPS; closedir LOOPS; @n=(); $protein='protein0000';
#incremental fileHandle while($allfiles[$i]){
print "File number: ",$i,"\n";
print "File name: $allfiles[$i] \n";
$counter=1;
$protein++;
print "file handle = $protein \n";
#Read files from directory, searching for the begining of the
sequence
@n=split /\./,$allfiles[$i];
print "extension: ",$n[1], "\n";
# look for ".." only in swissprot, owl, pir, genpept files.
if(($n[1] eq "swissprot") or ($n[1] eq "genpept") or ($n[1] eq
"owl")
or($n[1] eq "sp_plant") or($n[1]=~ /p\w/g)){
open($protein, "<$allfiles[$i]");
$line=<$protein>;
while($line){
if($line=~/\.\./g){
# maybe better to send to subroutine (from
other if, too)
@sequence=<$protein>;
$sequence="@sequence";
chop($sequence);
$sequence=~ s/\d*//g;
$sequence=~ s/\s+//g;
$loops='loop0000'; #incremental fileHandle
$j=1;
$loops++;
open($loops, "<$loopfiles[$j]");
while($loopfiles[$j]){
print $model."seq";
if($loopfiles[$j] ne
($model.".seq")){
# don't search in original
seq file
$peptide=<$loops>;
$k=1; #counter for number
of matches
#searchin'
while(length($peptide)>3){
#cutoff for length
to look for
if($sequence=~
m/($peptide)/g){
$score{$sequence}[$k]=pos($sequence)+1-length($peptide);
$prot=$sequence;
$k++;
}
&MoreSearch($sequence,$peptide);
$peptide=substr
$peptide,1;
}
sub MoreSearch{
print "In here!!
\n";
my
$peptide=$peptide;
$peptide=substr
$peptide,0,-1;
while(length($peptide)>3){
if($sequence=~ m/($peptide)/g){
$score{$sequence}[$k]=pos($sequence)+1-length($peptide);
$k++;
}
$peptide=substr $peptide,0,-1;
}
}
#close($loops);
$j++;
open($loops,
"<$loopfiles[$j]");
}
}
}
$line=<$protein>;
}
}
# look for "gb_ro, gb_vi, gb_ov, gb_om" and em
if (($n[1]=~ /gb\w/g) or ($n[1]=~ /em\w/g)){
open($protein, "<$allfiles[$i]");
$line=<$protein>;
while($line){
if($line=~/translation/g){
print "At file: $allfiles[$i] \n";
print "I found the bastard at line
no. ",$counter,"\n";
}
else{
$counter++;
}
$line=<$protein>;
}
}
$i++;
for($j=0; $j<$#n; $j++) {
$n[$j]="";
} } print "and now: \n"; print
"$score{$prot}[1]";
foreach $prot(keys %score){
print "\n At file= $prot \n";
foreach $z(1..$#{$score{$prot}}){
print "Res. number: $score{$prot}[$z]";
}
}