[Bioperl-l] Search for sequence inside sequence

Kevin Brown Kevin.M.Brown at asu.edu
Tue Feb 21 01:12:33 UTC 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...

-----Original Message-----
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

Hi everyone

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,
Carnë

_______________________________________________
Bioperl-l mailing list
Bioperl-l at lists.open-bio.org
http://lists.open-bio.org/mailman/listinfo/bioperl-l




More information about the Bioperl-l mailing list