Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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

Constructor Summary
`BioJavaAdapter()`

Method Summary
`static SequenceIterator` | `sampleToSequenceIterator(Sample sample, boolean flat)` Creates a `SequenceIterator` from the `Sample` `sample` preserving as much annotation as possible.
`static Sample` | `sequenceIteratorToSample(SequenceIterator it, FeatureFilter filter)` This method creates a new `Sample` from a `SequenceIterator`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### BioJavaAdapter

    public BioJavaAdapter()

Method Detail

### 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 iterator
    `filter` - `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` - if something went wrong

### sampleToSequenceIterator

    public static SequenceIterator sampleToSequenceIterator(Sample sample,
                                                            boolean flat)
                                                     throws WrongAlphabetException,
                                                            BioException

  Creates a `SequenceIterator` from the `Sample` `sample` preserving as much annotation as possible. This method works only for discrete alphabets.

  Parameters:
    `sample` - the `Sample`
    `flat` - indicates 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 `SequenceIterator`
  Throws:
    `WrongAlphabetException` - if the alphabet of the `Sample` is not discrete
    `BioException` - if forwarded from BioJava

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD