[Bioperl-l] Search for sequence inside sequence
Kevin.M.Brown at asu.edu
Mon Feb 20 20:12:33 EST 2012
Build up the Regexp outside of that line and then use it in there.
$string = "[GC]TAAGGACAA[AC]...";
print "Found in $file" if $seq->seq =~ /$string/I;
If you want your code to do substitution for the extra characters, then you'll need to interpret them into their regex equivalents. Such as reading in the string desired, and doing s/s/\[gc\]/I, etc...
From: bioperl-l-bounces at lists.open-bio.org [mailto:bioperl-l-bounces at lists.open-bio.org] On Behalf Of Carnë Draug
Sent: Monday, February 20, 2012 5:44 PM
To: bioperl mailing list
Subject: [Bioperl-l] Search for sequence inside sequence
is there a method to check if a sequence exists inside another one? I have a sequence object and a small string of a sequence. I'd like to know if it's present? Currently I only have
say "Found on $file" if $seq->seq =~ /$string/i;
It solves my problem but this doesn't look very smart to me. Is there a better way? Maybe even something that would also accept S to match against [G|C] for example?
Thanks in advance,
Bioperl-l mailing list
Bioperl-l at lists.open-bio.org
More information about the Bioperl-l