I am writing a fairly simple script that is supposed to print out lines from a txt file and group them based on where I want them. The general format of the files I am using the script on is as follows:
662376 [S] |GCGG | | |
662375 [S] |CGCC | | |
662374 [S] |GCGG | | |
662373 [H] |CATC | | |
662371 [Y] |TCCC | | |
662369 [M] |CACCC| | |
662367 [Y] |TCTTT| | |
662365 [S] |GCGGG| | |
662364 [R] |AGAAA| | |
662360 [M] |CACCC| | |
662359 [W] |ATAAA| | |
662358 [S] |CGCCC| | |
662357 [M] |ACAAA| | |
662356 [R] |GAAAG| | |
662354 [S] |GCGGG| | |
662353 [R] |AGAAA| | |
662352 [R] |GAGGG| | |
662350 [K] |TGTTT| | |
662349 [Y] |CTCCC| | |
662348 [M] |ACAAA| | |
662347 [R] |GAGGG| | |
662376 [S] |GCGG | | |
662375 [S] |CGCC | | |
662374 [S] |GCGG | | |
662373 [H] |CATC | | |
662371 [Y] |TCCC | | |
662369 [M] |CACCC| | |
662367 [Y] |TCTTT| | |
662365 [S] |GCGGG| | |
662364 [R] |AGAAA| | |
662360 [M] |CACCC| | |
662359 [W] |ATAAA| | |
662358 [S] |CGCCC| | |
662357 [M] |ACAAA| | |
662356 [R] |GAAAG| | |
662354 [S] |GCGGG| | |
662353 [R] |AGAAA| | |
662352 [R] |GAGGG| | |
662350 [K] |TGTTT| | |
662349 [Y] |CTCCC| | |
662348 [M] |ACAAA| | |
662347 [R] |GAGGG| | |
and here is the code:
Basically the problem I am having is that the while loop withing the foreach loop is not recognizing the position variable as a number, I tried to remove the white space, thinking that was an issue, but it did not work. Any suggestions?
662376 [S] |GCGG | | |
662375 [S] |CGCC | | |
662374 [S] |GCGG | | |
662373 [H] |CATC | | |
662371 [Y] |TCCC | | |
662369 [M] |CACCC| | |
662367 [Y] |TCTTT| | |
662365 [S] |GCGGG| | |
662364 [R] |AGAAA| | |
662360 [M] |CACCC| | |
662359 [W] |ATAAA| | |
662358 [S] |CGCCC| | |
662357 [M] |ACAAA| | |
662356 [R] |GAAAG| | |
662354 [S] |GCGGG| | |
662353 [R] |AGAAA| | |
662352 [R] |GAGGG| | |
662350 [K] |TGTTT| | |
662349 [Y] |CTCCC| | |
662348 [M] |ACAAA| | |
662347 [R] |GAGGG| | |
662376 [S] |GCGG | | |
662375 [S] |CGCC | | |
662374 [S] |GCGG | | |
662373 [H] |CATC | | |
662371 [Y] |TCCC | | |
662369 [M] |CACCC| | |
662367 [Y] |TCTTT| | |
662365 [S] |GCGGG| | |
662364 [R] |AGAAA| | |
662360 [M] |CACCC| | |
662359 [W] |ATAAA| | |
662358 [S] |CGCCC| | |
662357 [M] |ACAAA| | |
662356 [R] |GAAAG| | |
662354 [S] |GCGGG| | |
662353 [R] |AGAAA| | |
662352 [R] |GAGGG| | |
662350 [K] |TGTTT| | |
662349 [Y] |CTCCC| | |
662348 [M] |ACAAA| | |
662347 [R] |GAGGG| | |
and here is the code:
Code:
print "What is the start of the ORF?\n";
$orf_beg = <STDIN>;
open (IN, '/home/asession/pracperl/bin/SNPYNR+-1kb.txt') || die "nope\n";
while (<IN>) {
chomp;
$position = substr $_, 1, 11; # extract the position
$type_of_polymorphism = substr $_, 13, 3; # extract the polymorphism type, same as ref if no polymorphism
$ref_seq = substr $_, 17, 1; # extract the cerevisiae ref sequence
$para_seq = substr $_, 18, 1; # extract the paradoxus sequence
$mika_seq = substr $_, 19, 1; # extract the mika sequence
$kudr_seq = substr $_, 20, 1; # extract the kudr sequence
$baya_seq = substr $_, 21, 1; # extract the bayanus sequence
$baya_seq =~ s/\s+/x/g;
#$position =~ tr/ //d;
foreach ($position) {
while ($postion > $orf_beg) {
print "$position $ref_seq $para_seq $baya_seq\n";
}}
}
close (IN);
print "\n";
Comment