Ugh, its too late to finish my golf game....
warning: not necessarily portable since it uses 'glob'.
#!/usr/bin/perl -w
use strict;
my $seq="APKLGIYSPRIGLYHFHKLDTPRLGAKLJHHDGFYSDA";
my @motif=("ST","P","RK","ILVF","G","ILVFM","Y");
my @a = my @b = my @c = @motif; my %m;
while(my$r=!$|++&&\@a||pop@a&&\@a||shift@b&&\@b){for(glob('{'.
join('',map{'{'.(join',',split(//)).'}'}@$r).'}')){length($_)>
2&&$seq=~/$_/&&$m{$_}++;}}for(sort{length($b)<=>length($a)}keys
%m){print"$_ at ",index($seq,$_)+1,"\n"}
=OUTPUT
SPRIGLY at 8
PRIGLY at 9
PKLGIY at 2
SPRIGL at 8
KLGIY at 3
RIGLY at 10
SPRIG at 8
TPRLG at 21
TPRL at 21
IGLY at 11
LGIY at 4
SPRI at 8
GFY at 33
GIY at 5
TPR at 21
GLY at 12
SPR at 8
-Blake
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.