[Bioperl-l] Search for sequence inside sequence

Fields, Christopher J cjfields at illinois.edu
Mon Feb 20 21:28:03 EST 2012


There is a BioPerl-ish way of doing this, namely Bio::Tools::SeqPattern.  Might be worth a look (though a simple regex should also suffice).

chris

On Feb 20, 2012, at 7:12 PM, Kevin Brown wrote:

> 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
> 
> _______________________________________________
> 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