Instance 2 (score 16)....... ....... ...... GATTACGAGTGGCGCTCGTGTAACGGCA GATTACG GCGCTCG AACGGCA
Instance 3 (score 17)......... ....... GATTACGAGTGGCGCTCGTGTAACGGCA GATTACG TTACGAG CGTGTAA
UPDATE: Instance 4 (score 4)GCTCGTG .................. GATTACGAGTGGCGCTCGTGTAACGGCA TACGAGT GTGGCGC
I wonder if there is a way to solve this... .. GATTACGAGTGGCGCTCGTGTAACGGCA GG GG
UPDATE 2: Renamed title.#!/usr/bin/perl -w use strict; use Data::Dumper; my $s1 = 'GATTACGAGTGGCGCTCGTGTAACGGCA'; # Here are the array of the substrings, note that the number of # substrings may differ from array to array # and length of the substring may vary (defined as a parameter) my @ar = ('GATTACG','GCGCTCG','AACGGCA'); #21 (0,11,21) my @ar2 = ('GATTACG','TTACGAG','CGTGTAA'); #16 my @ar3 = ('TACGAGT','GTGGCGC','GCTCGTG'); #17 my @ar4 = ('GG','GG'); #4 score($s1,\@ar2); sub score{ my ($str,$array) = @_; my @pos; my $sub_len = length @$array[1]; foreach (@$array){ my $idx = index $s1, $_; push @pos, $idx; print "$idx\n"; } # I'm not sure where to go from here for (0..$#pos){ my $sum = $pos[$_]+$sub_len; } }
In reply to Measuring Substrings Problem by monkfan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |