in reply to remove part of string (DNA)
An important question is whether you need both primer/adapters (forward and reverse) to match (presumably either side of a sequenced insert)? If so, you will also need to reverse-complement one of the primers or you have to check both in both orientations unless you are sequencing from the forward primer. To match and remove a string you can use s//. Here is a Perl one-liner that illsutrates how you can test if something matches and remove it at the same time:use Bio::SeqIO; my $seqio_obj = Bio::SeqIO->new(-file => "sequence.fasta", -format => +"fasta" ); while (my $seq_obj = $seqio_obj->next_seq){ print "Sequence id: ".$seq_obj->display_id."\n"; print "Sequence: "$seq_obj->seq."\n"; }
Just run the above line in a terminal to see it in action. It will reduce "get_rid_of_some_string" to "of_some_string" if "get_rid_" can be found (and removed) from teh beginning.perl -e '$s="get_rid_of_some_string";print "remaining string: $s\n" if + $s=~s/^get_rid_//;'
This will have the same result as above but the pattern was just "rid_" and the regular expression says: remove everything from teh beginning of the string, optionally followed by some characters, then followed by "rid_", with nothing (i.e. just strip it off). Hope this helps to get you started.perl -e '$s="get_rid_of_some_string";print "remaining string: $s\n" if + $s=~s/^.*rid_//;'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: remove part of string (DNA)
by tospo (Hermit) on Apr 12, 2011 at 16:43 UTC | |
by Furor (Novice) on Apr 13, 2011 at 08:00 UTC | |
by mrguy123 (Hermit) on Apr 13, 2011 at 11:10 UTC |