jebl.evolution.io
Class NexusImporter

java.lang.Object
  extended by jebl.evolution.io.NexusImporter
All Implemented Interfaces:
Iterable<Tree>, AlignmentImporter, DistanceMatrixImporter, SequenceImporter, TreeImporter

public class NexusImporter
extends Object
implements AlignmentImporter, SequenceImporter, TreeImporter, DistanceMatrixImporter

Class for importing NEXUS file format

Author:
Andrew Rambaut, Alexei Drummond

Nested Class Summary
static class NexusImporter.MissingBlockException
           
static class NexusImporter.NexusBlock
           
 
Nested classes/interfaces inherited from interface jebl.evolution.io.DistanceMatrixImporter
DistanceMatrixImporter.Triangle
 
Field Summary
protected  ImportHelper helper
           
 
Constructor Summary
NexusImporter(Reader reader)
          Constructor
NexusImporter(Reader reader, boolean compactTrees)
           
 
Method Summary
 void findEndBlock()
          Finds the end of the current block.
 NexusImporter.NexusBlock findNextBlock()
          This function returns an integer to specify what the next block in the file is.
 String getNextBlockName()
           
 boolean hasTree()
          return whether another tree is available.
 List<Alignment> importAlignments()
          importAlignment.
 List<DistanceMatrix> importDistanceMatrices()
          importDistances.
 Tree importNextTree()
          import the next tree.
 List<Sequence> importSequences()
          importSequences.
 List<Tree> importTrees()
          Import all the trees
 Iterator<Tree> iterator()
          Returns an iterator over a set of elements of type T.
 List<Sequence> parseCharactersBlock(List<Taxon> taxonList)
          Parses a 'CHARACTERS' block.
 List<Sequence> parseDataBlock(List<Taxon> taxonList)
          Parses a 'DATA' block.
 DistanceMatrix parseDistancesBlock(List<Taxon> taxonList)
           
 List<Taxon> parseTaxaBlock()
          Parses a 'TAXA' block.
 List<Tree> parseTreesBlock(List<Taxon> taxonList)
          Parses a 'TREES' block.
 boolean startReadingTrees()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

helper

protected final ImportHelper helper
Constructor Detail

NexusImporter

public NexusImporter(Reader reader)
Constructor


NexusImporter

public NexusImporter(Reader reader,
                     boolean compactTrees)
Method Detail

findNextBlock

public NexusImporter.NexusBlock findNextBlock()
                                       throws IOException
This function returns an integer to specify what the next block in the file is. The internal variable nextBlock is also set to this value. This should be overridden to provide support for other blocks. Once the block is read in, nextBlock is automatically set to UNKNOWN_BLOCK by findEndBlock.

Throws:
IOException

getNextBlockName

public String getNextBlockName()

iterator

public Iterator<Tree> iterator()
Returns an iterator over a set of elements of type T.

Specified by:
iterator in interface Iterable<Tree>
Returns:
an Iterator.

parseTaxaBlock

public List<Taxon> parseTaxaBlock()
                           throws ImportException,
                                  IOException
Parses a 'TAXA' block.

Throws:
ImportException
IOException

parseCharactersBlock

public List<Sequence> parseCharactersBlock(List<Taxon> taxonList)
                                    throws ImportException,
                                           IOException
Parses a 'CHARACTERS' block.

Throws:
ImportException
IOException

parseDataBlock

public List<Sequence> parseDataBlock(List<Taxon> taxonList)
                              throws ImportException,
                                     IOException
Parses a 'DATA' block.

Throws:
ImportException
IOException

parseTreesBlock

public List<Tree> parseTreesBlock(List<Taxon> taxonList)
                           throws ImportException,
                                  IOException
Parses a 'TREES' block.

Throws:
ImportException
IOException

parseDistancesBlock

public DistanceMatrix parseDistancesBlock(List<Taxon> taxonList)
                                   throws ImportException,
                                          IOException
Throws:
ImportException
IOException

importAlignments

public List<Alignment> importAlignments()
                                 throws IOException,
                                        ImportException
importAlignment.

Specified by:
importAlignments in interface AlignmentImporter
Throws:
IOException
ImportException

importSequences

public List<Sequence> importSequences()
                               throws IOException,
                                      ImportException
importSequences.

Specified by:
importSequences in interface SequenceImporter
Throws:
IOException
ImportException

hasTree

public boolean hasTree()
                throws IOException,
                       ImportException
return whether another tree is available.

Specified by:
hasTree in interface TreeImporter
Throws:
IOException
ImportException

importNextTree

public Tree importNextTree()
                    throws IOException,
                           ImportException
import the next tree. return the tree or null if no more trees are available

Specified by:
importNextTree in interface TreeImporter
Returns:
the tree
Throws:
IOException
ImportException

importTrees

public List<Tree> importTrees()
                       throws IOException,
                              ImportException
Description copied from interface: TreeImporter
Import all the trees

Specified by:
importTrees in interface TreeImporter
Returns:
the list of trees
Throws:
IOException
ImportException - Any type of tree is fine.

startReadingTrees

public boolean startReadingTrees()
                          throws IOException,
                                 ImportException
Throws:
IOException
ImportException

importDistanceMatrices

public List<DistanceMatrix> importDistanceMatrices()
                                            throws IOException,
                                                   ImportException
importDistances.

Specified by:
importDistanceMatrices in interface DistanceMatrixImporter
Throws:
IOException
ImportException

findEndBlock

public void findEndBlock()
                  throws IOException
Finds the end of the current block.

Throws:
IOException