Cheers
[EMAIL PROTECTED] wrote: > > Send Biojava-l mailing list submissions to > [EMAIL PROTECTED] > > To subscribe or unsubscribe via the World Wide Web, visit > http://biojava.org/mailman/listinfo/biojava-l > or, via email, send a message with subject or body 'help' to > [EMAIL PROTECTED] > > You can reach the person managing the list at > [EMAIL PROTECTED] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Biojava-l digest..." > > Today's Topics: > > 1. Re: remove features (Keith James) > > ---------------------------------------------------------------------- > > Message: 1 > Date: 12 Jun 2003 14:37:58 +0100 > From: Keith James <[EMAIL PROTECTED]> > Subject: Re: [Biojava-l] remove features > To: Robert Stones <[EMAIL PROTECTED]> > Cc: [EMAIL PROTECTED] > Message-ID: > <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=us-ascii > > >>>>> "Robert" == Robert Stones <[EMAIL PROTECTED]> writes: > > Robert> Could anyone give me an example where you can remove > Robert> features from a Sequence Object. > > Try something like > > import java.io.*; > import java.util.*; > > import org.biojava.bio.*; > import org.biojava.bio.seq.*; > import org.biojava.bio.seq.io.*; > > public class RemoveFeatures > { > public static void main(String [] argv) throws Exception > { > BufferedReader br = new BufferedReader(new FileReader(argv[0])); > > SequenceIterator seqI = SeqIOTools.readEmbl(br); > > while (seqI.hasNext()) > { > Sequence seq = seqI.nextSequence(); > FeatureHolder fh = > seq.filter(new FeatureFilter.StrandFilter(StrandedFeature.POSITIVE)); > > for (Iterator i = fh.features(); i.hasNext();) > { > seq.removeFeature((Feature) i.next()); > } > > SeqIOTools.writeEmbl(System.out, seq); > } > } > } > > Run this on e.g. demos/files/AL121903.embl and it will only print the > complement strand features (compiled & tested here). Filtering creates > a new holder and eliminates the concurrent modification error as Mark > described. > > In general you will most likely be better off using a FeatureFilter > like this rather than individually checking Feature types (in your > previous example you need FeatureFilter.ByType) because wou will be > more likely to benefit from any filtering optimizations present in the > implementation of Sequence which you are using. > > hth, Keith > > -- > > - Keith James <[EMAIL PROTECTED]> bioinformatics programming support - > - Pathogen Sequencing Unit, The Wellcome Trust Sanger Institute, UK - > > ------------------------------ > > _______________________________________________ > Biojava-l mailing list - [EMAIL PROTECTED] > http://biojava.org/mailman/listinfo/biojava-l > > End of Biojava-l Digest, Vol 6, Issue 13 > **************************************** _______________________________________________ Biojava-l mailing list - [EMAIL PROTECTED] http://biojava.org/mailman/listinfo/biojava-l