bisimen has asked for the wisdom of the Perl Monks concerning the following question:
This sub works, but say this is my DNA: AGCTTCTTGCGCTTCTT and this is what i'm looking for: GCTTCTTGC
It will return 2. Which it correct, but since the next match blends into the first one, it dosen't detect it.
So it should return: 2 9
I guess I need to change the regular expression somehow...
sub match_positions { my ($regexp, $sequence) = @_; use strict; my @positions = ( ); while ( $sequence =~ m/$regexp/ig ) { push ( @positions, pos($sequence) - length($&) + 1 ); } return "@positions "; }
Thanks for any answers!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Double check for positions
by choroba (Cardinal) on Oct 18, 2017 at 13:17 UTC | |
|
Re: Double check for positions
by hippo (Archbishop) on Oct 18, 2017 at 12:50 UTC | |
by bisimen (Acolyte) on Oct 18, 2017 at 13:22 UTC | |
by hippo (Archbishop) on Oct 18, 2017 at 13:27 UTC | |
by bisimen (Acolyte) on Oct 18, 2017 at 13:35 UTC | |
by soonix (Chancellor) on Oct 18, 2017 at 13:38 UTC | |
|
Re: Double check for positions
by tybalt89 (Monsignor) on Oct 18, 2017 at 13:16 UTC | |
|
Re: Double check for positions
by 1nickt (Canon) on Oct 18, 2017 at 12:41 UTC | |
by bisimen (Acolyte) on Oct 18, 2017 at 13:01 UTC | |
|
Re: Double check for positions
by Anonymous Monk on Oct 18, 2017 at 16:08 UTC |