de.jstacs.data.bioJava
Class BioJavaAdapter
java.lang.Object
de.jstacs.data.bioJava.BioJavaAdapter
public class BioJavaAdapter
- extends Object
This class provides static methods to convert BioJava datatypes (SequenceIterator
, Sequence
) to
Sample
s and vice versa.
Here are two small examples how to create a RichSequenceIterator
that can be used to create a sample.
GenbankRichSequenceDB db = new GenbankRichSequenceDB();
org.biojava.bio.seq.Sequence seq = db.getSequence( id );
RichSequenceIterator iter = new RichSequence.IOTools.SingleRichSeqIterator(seq);
or
RichSequenceIterator iter = RichSequence.IOTools.readFile( new File( fName ), null );
- Author:
- Jens Keilwagen, Jan Grau
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BioJavaAdapter
public BioJavaAdapter()
sequenceIteratorToSample
public static Sample sequenceIteratorToSample(SequenceIterator it,
FeatureFilter filter)
throws Exception
- This method creates a new Sample from a
SequenceIterator
. In cases, where BioJava does return Sequence
s
instead of a SequenceIterator
, you can use a SimpleSequenceIterator
to wrap them up.
- Parameters:
it
- the sequence iteratorfilter
- null
or an arbitrary feature filter, that determines which features will be adopted
- Returns:
- the
Sequence
s in it
converted to a Sample
- Throws:
Exception
sampleToSequenceIterator
public static SequenceIterator sampleToSequenceIterator(Sample sample,
boolean flat)
throws WrongAlphabetException,
BioException
- Creates a
SequenceIterator
from sample
preserving
as much annotation as possible. This method works only for discrete
alphabets.
- Parameters:
sample
- the sampleflat
- true if the features should be flattened. This may be necessary to preserve all features, because some data formats do
not support hierarchical features
- Returns:
- the corresponding sequence iterator
- Throws:
WrongAlphabetException
- is thrown if the alphabet of the sample is not discrete
BioException
- forwarded BioJava exceptions