[Biojava-l] Re: Biojava-l Digest, Vol 6, Issue 13

Robert Stones r.stones at csl.gov.uk
Fri Jun 13 10:27:33 EDT 2003


Cheers

biojava-l-request at biojava.org wrote:
> 
> Send Biojava-l mailing list submissions to
>         biojava-l at biojava.org
> 
> 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
>         biojava-l-request at biojava.org
> 
> You can reach the person managing the list at
>         biojava-l-owner at biojava.org
> 
> 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 <kdj at sanger.ac.uk>
> Subject: Re: [Biojava-l] remove features
> To: Robert Stones <r.stones at csl.gov.uk>
> Cc: biojava-l at biojava.org
> Message-ID:
>         <sc4d6hj8lhl.fsf at maul.i-did-not-set--mail-host-address--so-shoot-me>
> Content-Type: text/plain; charset=us-ascii
> 
> >>>>> "Robert" == Robert Stones <r.stones at csl.gov.uk> 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 <kdj at sanger.ac.uk> bioinformatics programming support -
> - Pathogen Sequencing Unit, The Wellcome Trust Sanger Institute, UK -
> 
> ------------------------------
> 
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l at biojava.org
> http://biojava.org/mailman/listinfo/biojava-l
> 
> End of Biojava-l Digest, Vol 6, Issue 13
> ****************************************


More information about the Biojava-l mailing list