TreeNode 1.5.2
A library to manipulate phylogenetic trees
Loading...
Searching...
No Matches
PhyloTree.Formats.BinaryTree Class Reference

Contains methods to read and write tree files in binary format. More...

Static Public Member Functions

static bool HasValidTrailer (Stream inputStream, bool keepOpen=false)
 Determines whether the tree file stream has a valid trailer. More...
 
static bool IsValidStream (Stream inputStream, bool keepOpen=false)
 Determines whether the tree file stream is valid (i.e. it has a valid header). More...
 
static BinaryTreeMetadata ParseMetadata (Stream inputStream, bool keepOpen=false, BinaryReader reader=null, Action< double > progressAction=null)
 Reads the metadata from a file containing trees in binary format. More...
 
static IEnumerable< TreeNodeParseTrees (Stream inputStream, bool keepOpen=false, Action< double > progressAction=null)
 Lazily parses trees from a file in binary format. Each tree in the file is not read and parsed until it is requested. More...
 
static List< TreeNodeParseAllTrees (Stream inputStream, bool keepOpen=false, Action< double > progressAction=null)
 Parses trees from a file in binary format and completely loads them in memory. More...
 
static IEnumerable< TreeNodeParseTrees (string inputFile, Action< double > progressAction=null)
 Lazily parses trees from a file in binary format. Each tree in the file is not read and parsed until it is requested. More...
 
static List< TreeNodeParseAllTrees (string inputFile, Action< double > progressAction=null)
 Parses trees from a file in binary format and completely loads them in memory. More...
 
static void WriteTree (TreeNode tree, Stream outputStream, bool keepOpen=false, Stream additionalDataToCopy=null)
 Writes a single tree in Binary format. More...
 
static void WriteTree (TreeNode tree, string outputFile, bool append=false, Stream additionalDataToCopy=null)
 Writes a single tree in Binary format. More...
 
static void WriteAllTrees (IEnumerable< TreeNode > trees, string outputFile, bool append=false, Action< int > progressAction=null, Stream additionalDataToCopy=null)
 Writes trees in binary format. More...
 
static void WriteAllTrees (IEnumerable< TreeNode > trees, Stream outputStream, bool keepOpen=false, Action< int > progressAction=null, Stream additionalDataToCopy=null)
 Writes trees in binary format. More...
 
static void WriteAllTrees (IList< TreeNode > trees, string outputFile, bool append=false, Action< double > progressAction=null, Stream additionalDataToCopy=null)
 Writes trees in binary format. More...
 
static void WriteAllTrees (IList< TreeNode > trees, Stream outputStream, bool keepOpen=false, Action< double > progressAction=null, Stream additionalDataToCopy=null)
 Writes trees in binary format. More...
 

Detailed Description

Contains methods to read and write tree files in binary format.

Definition at line 16 of file Binary.cs.

Member Function Documentation

◆ HasValidTrailer()

static bool PhyloTree.Formats.BinaryTree.HasValidTrailer ( Stream  inputStream,
bool  keepOpen = false 
)
static

Determines whether the tree file stream has a valid trailer.

Parameters
inputStreamThe Stream from which the file should be read. Its Stream.CanSeek must be true. It does not have to be a FileStream.
keepOpenDetermines whether the stream should be disposed at the end of this method or not.
Returns
true if the inputStream has a valid trailer, false otherwise.

Definition at line 24 of file Binary.cs.

◆ IsValidStream()

static bool PhyloTree.Formats.BinaryTree.IsValidStream ( Stream  inputStream,
bool  keepOpen = false 
)
static

Determines whether the tree file stream is valid (i.e. it has a valid header).

Parameters
inputStreamThe Stream from which the file should be read. Its Stream.CanSeek must be true. It does not have to be a FileStream.
keepOpenDetermines whether the stream should be disposed at the end of this method or not.
Returns
true if the inputStream has a valid header, false otherwise.

Definition at line 61 of file Binary.cs.

◆ ParseAllTrees() [1/2]

static List< TreeNode > PhyloTree.Formats.BinaryTree.ParseAllTrees ( Stream  inputStream,
bool  keepOpen = false,
Action< double >  progressAction = null 
)
static

Parses trees from a file in binary format and completely loads them in memory.

Parameters
inputStreamThe Stream from which the file should be read. Its Stream.CanSeek must be true. It does not have to be a FileStream.
keepOpenDetermines whether the stream should be disposed at the end of this method or not.
progressActionAn Action that might be called after each tree is parsed, with the approximate progress (as determined by the position in the stream), ranging from 0 to 1.
Returns
A List<T> containing the trees defined in the file.

Definition at line 384 of file Binary.cs.

◆ ParseAllTrees() [2/2]

static List< TreeNode > PhyloTree.Formats.BinaryTree.ParseAllTrees ( string  inputFile,
Action< double >  progressAction = null 
)
static

Parses trees from a file in binary format and completely loads them in memory.

Parameters
inputFileThe path to the input file.
progressActionAn Action that might be called after each tree is parsed, with the approximate progress (as determined by the position in the stream), ranging from 0 to 1.
Returns
A List<T> containing the trees defined in the file.

Definition at line 407 of file Binary.cs.

◆ ParseMetadata()

static BinaryTreeMetadata PhyloTree.Formats.BinaryTree.ParseMetadata ( Stream  inputStream,
bool  keepOpen = false,
BinaryReader  reader = null,
Action< double >  progressAction = null 
)
static

Reads the metadata from a file containing trees in binary format.

Parameters
inputStreamThe Stream from which the file should be read. Its Stream.CanSeek must be true. It does not have to be a FileStream.
keepOpenDetermines whether the stream should be disposed at the end of this method or not.
readerA BinaryReader to read from the inputStream . If this is null, a new BinaryReader will be initialised and disposed within this method.
progressActionAn Action that may be invoked while parsing the tree file, with an argument ranging from 0 to 1 describing the progress made in reading the file (determined by the position in the stream).
Returns
A BinaryTreeMetadata object containing metadata information about the tree file.

Definition at line 108 of file Binary.cs.

◆ ParseTrees() [1/2]

static IEnumerable< TreeNode > PhyloTree.Formats.BinaryTree.ParseTrees ( Stream  inputStream,
bool  keepOpen = false,
Action< double >  progressAction = null 
)
static

Lazily parses trees from a file in binary format. Each tree in the file is not read and parsed until it is requested.

Parameters
inputStreamThe Stream from which the file should be read. Its Stream.CanSeek must be true. It does not have to be a FileStream.
keepOpenDetermines whether the stream should be disposed at the end of this method or not.
progressActionAn Action that might be called after each tree is parsed, with the approximate progress (as determined by the position in the stream), ranging from 0 to 1.
Returns
A lazy IEnumerable<T> containing the trees defined in the file.

Definition at line 252 of file Binary.cs.

◆ ParseTrees() [2/2]

static IEnumerable< TreeNode > PhyloTree.Formats.BinaryTree.ParseTrees ( string  inputFile,
Action< double >  progressAction = null 
)
static

Lazily parses trees from a file in binary format. Each tree in the file is not read and parsed until it is requested.

Parameters
inputFileThe path to the input file.
progressActionAn Action that might be called after each tree is parsed, with the approximate progress (as determined by the position in the stream), ranging from 0 to 1.
Returns
A lazy IEnumerable<T> containing the trees defined in the file.

Definition at line 395 of file Binary.cs.

◆ WriteAllTrees() [1/4]

static void PhyloTree.Formats.BinaryTree.WriteAllTrees ( IEnumerable< TreeNode trees,
Stream  outputStream,
bool  keepOpen = false,
Action< int >  progressAction = null,
Stream  additionalDataToCopy = null 
)
static

Writes trees in binary format.

Parameters
treesAn IEnumerable<T> containing the trees to be written. It will ony be enumerated once.
outputStreamThe Stream on which the trees should be written.
keepOpenDetermines whether the outputStream should be kept open after the end of this method.
progressActionAn Action that will be invoked after each tree is written, with the number of trees written so far.
additionalDataToCopyA stream containing additional data that will be copied into the binary file.

Definition at line 460 of file Binary.cs.

◆ WriteAllTrees() [2/4]

static void PhyloTree.Formats.BinaryTree.WriteAllTrees ( IEnumerable< TreeNode trees,
string  outputFile,
bool  append = false,
Action< int >  progressAction = null,
Stream  additionalDataToCopy = null 
)
static

Writes trees in binary format.

Parameters
treesAn IEnumerable<T> containing the trees to be written. It will ony be enumerated once.
outputFileThe file on which the trees should be written.
appendSpecifies whether the file should be overwritten or appended to.
progressActionAn Action that will be invoked after each tree is written, with the number of trees written so far.
additionalDataToCopyA stream containing additional data that will be copied into the binary file.

Definition at line 446 of file Binary.cs.

◆ WriteAllTrees() [3/4]

static void PhyloTree.Formats.BinaryTree.WriteAllTrees ( IList< TreeNode trees,
Stream  outputStream,
bool  keepOpen = false,
Action< double >  progressAction = null,
Stream  additionalDataToCopy = null 
)
static

Writes trees in binary format.

Parameters
treesA collection of trees to be written. Each tree will be accessed twice.
outputStreamThe Stream on which the trees should be written.
keepOpenDetermines whether the outputStream should be kept open after the end of this method.
progressActionAn Action that will be invoked after each tree is written, with a value between 0 and 1 depending on how many trees have been written so far.
additionalDataToCopyA stream containing additional data that will be copied into the binary file.

Definition at line 524 of file Binary.cs.

◆ WriteAllTrees() [4/4]

static void PhyloTree.Formats.BinaryTree.WriteAllTrees ( IList< TreeNode trees,
string  outputFile,
bool  append = false,
Action< double >  progressAction = null,
Stream  additionalDataToCopy = null 
)
static

Writes trees in binary format.

Parameters
treesA collection of trees to be written. Each tree will be accessed twice.
outputFileThe file on which the trees should be written.
appendSpecifies whether the file should be overwritten or appended to.
progressActionAn Action that will be invoked after each tree is written, with a value between 0 and 1 depending on how many trees have been written so far.
additionalDataToCopyA stream containing additional data that will be copied into the binary file.

Definition at line 509 of file Binary.cs.

◆ WriteTree() [1/2]

static void PhyloTree.Formats.BinaryTree.WriteTree ( TreeNode  tree,
Stream  outputStream,
bool  keepOpen = false,
Stream  additionalDataToCopy = null 
)
static

Writes a single tree in Binary format.

Parameters
treeThe tree to be written.
outputStreamThe Stream on which the tree should be written.
keepOpenDetermines whether the outputStream should be kept open after the end of this method.
additionalDataToCopyA stream containing additional data that will be copied into the binary file.

Definition at line 420 of file Binary.cs.

◆ WriteTree() [2/2]

static void PhyloTree.Formats.BinaryTree.WriteTree ( TreeNode  tree,
string  outputFile,
bool  append = false,
Stream  additionalDataToCopy = null 
)
static

Writes a single tree in Binary format.

Parameters
treeThe tree to be written.
outputFileThe file on which the trees should be written.
appendSpecifies whether the file should be overwritten or appended to.
additionalDataToCopyA stream containing additional data that will be copied into the binary file.

Definition at line 432 of file Binary.cs.


The documentation for this class was generated from the following file: