Hi there
Some of you might remember me posting a problem called 'headache with array'. I got a wealth of good advice and went away to implement it.
Anyway, i still appear to be doing something wrong because i cant get the contents of the hash of arrays to print at the end of the script. What I want the script to do is to populate the array using all the files in the directory and then print it. I've managed to print the array for each file, but I actually need it after all the files have been processed if that makes sense.
Here is the relevant bit of the script. Any advice much appreciated.
for($i = -180; $i < 181; $i = $i+5)
{
$j = $i+5;
$n++;
$o = 0;
for($k = -180; $k < 181; $k = $k+5)
{
$m = $k+5;
$o++;
my @ranges = ([$i, $j, $k, $m]);
my @range_counts = (0) x @ranges;
# open .out file created by secondary_structure.pl script to c
+heck date of crystal structure
# was structure created before or after the advent of procheck
+?
open(FILE, "$dir$file") || die "ERROR: Unable to open $dir$fil
+e FILE: $!\n";
@file = <FILE>;
foreach $record(@file)
{
# print "$record\n";
#extract relevant information from file
# is residue a GLY or a NON-GLY residue?
$residue = substr($record, 0, 3);
if($residue ne "GLY")
{
$residue = "NONGLY";
}
$phi = substr($record, 7, 6);
$psi = substr($record, 14, 6);
$secondary_structure = substr($record, 21, 1);
#print "1 $secondary_structure $residue $procheck\n";
#print "2 $sec_struct $selectresidue $selectprocheck\n";
if(("$secondary_structure" eq "$sec_struct")
&& ("$residue" eq "$selectresidue")
&& ("$procheck" eq "$selectprocheck"))
{
for my $R (0..$#ranges)
{
if ($phi >=$ranges[$R][0] and $phi < $ranges[$R][1]
and $psi >= $ranges[$R][2] and $psi < $ranges[$R][3])
{
++$range_counts[$R];
}
}
}
}
}
}
}
for my $R (0..$#ranges)
{
if($v < 73)
{
printf "%d, ", $range_counts[$R];
$v++;
}
else
{
print "\n";
$v = 0;
}
}
Thanks a lot
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.