Which prints:use strict; use warnings; my $str1 = "LTIEAVPSNAAEGKEVLLLVHNLPQDPRGYNWYKGETVDANRRIIGYVISNQQITPGP +AYSNRETIYPNASLLMRNVTRNDTGSYTLQVIKLNLMSEEVTGQ-FSVHPETPKPSISSNNSNPVEDKD +AVAFTCEPETQNTTYLWWVNGQSLPVSP"; my $str2 = "PTISPSYTYYRPGVNLSLSCHAASNPPAQYSWLIDGNIQQHTQE-------------- +-------------LFISNITEKNSGLYTCQANNSASGHSRTTVKTITVSAELPKPSISSNNSKPVEDKD +AVAFTCEPEAQNTTYLWWVNGQSLPVSP"; my %hash; my @a = split('',$str1); my @b = split('',$str2); my $a_index = 36; #Start counting at residue number my $b_index = 206; for my $i (0 .. $#b) { #Loop through arrays if ($b[$i] eq "-") { #Check for a gap in str2, if so increment a_i +ndex and go to the next residue $a_index++; next; } if ($a[$i] eq "-") { #Check for a gap in str1, if so store the gap + in the hash without a residue #, increment b_index, and go to the ne +xt residue $hash{$b[$i].$b_index}=$a[$i]; $b_index++; next; } $hash{$b[$i].$b_index}=$a[$i].$a_index; #Else store residue pair i +n hash $b_index++; $a_index++; } print "value of N254 is $hash{'N254'}\n"; print "value of I255 is $hash{'I255'}\n"; print "value of K280 is $hash{'K280'}\n"; print "value of T281 is $hash{'T281'}\n"; print "value of I282 is $hash{'I282'}\n";
value of N254 is N111 value of I255 is V112 value of K280 is Q137 value of T281 is - value of I282 is F138It seems to be working OK, but now I need to run this on thousands of alignments for an arbitrary number of residues per alignment. If you see any room for improvement or optimization, or errors, please let me know. Thanks again for the help!
In reply to Re: Per residue sequence alignment - per character string comparison?
by proteins
in thread Per residue sequence alignment - per character string comparison?
by proteins
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |