public class IOTools extends java.lang.Object
AlignmentModel
s to file
formats supported by JPhyloIO.AlignmentDataReader
,
AlignmentModelDataAdapter
Constructor and Description |
---|
IOTools() |
Modifier and Type | Method and Description |
---|---|
static <T> info.bioinfweb.jphyloio.dataadapters.implementations.ListBasedDocumentDataAdapter |
createDocumentAdapter(AlignmentModel<T> model)
Creates a document data adapter that allows to write the contents of
model to a file using e.g. |
static <T> info.bioinfweb.jphyloio.dataadapters.implementations.ListBasedDocumentDataAdapter |
createDocumentAdapter(AlignmentModel<T> model,
java.lang.String alignmentLabel)
Creates a document data adapter that allows to write the contents of
model to a file using e.g. |
static <T> info.bioinfweb.jphyloio.dataadapters.implementations.ListBasedDocumentDataAdapter |
createDocumentAdapter(AlignmentModel<T> model,
java.lang.String alignmentLabel,
boolean linkOTUs)
Creates a document data adapter that allows to write the contents of
model to a file using e.g. |
static java.util.List<AlignmentModel<?>> |
readAlignments(java.io.File file)
Reads a set of alignments from a file into a list of alignment model instances.
|
static java.util.List<AlignmentModel<?>> |
readAlignments(java.io.File file,
info.bioinfweb.jphyloio.ReadWriteParameterMap parameters)
Reads a set of alignments from a file into a list of alignment model instances.
|
static <T> void |
writeSingleAlignment(AlignmentModel<T> model,
java.lang.String alignmentLabel,
java.io.File file,
java.lang.String format)
Writes the contents of an alignment model to a file in the specified format.
|
static <T> void |
writeSingleAlignment(AlignmentModel<T> model,
java.lang.String alignmentLabel,
java.io.File file,
java.lang.String format,
info.bioinfweb.jphyloio.ReadWriteParameterMap parameters)
Writes the contents of an alignment model to a file in the specified format.
|
static <T> void |
writeSingleAlignment(AlignmentModel<T> model,
java.lang.String alignmentLabel,
java.io.OutputStream stream,
java.lang.String format)
Writes the contents of an alignment model to a file in the specified format.
|
static <T> void |
writeSingleAlignment(AlignmentModel<T> model,
java.lang.String alignmentLabel,
java.io.OutputStream stream,
java.lang.String format,
info.bioinfweb.jphyloio.ReadWriteParameterMap parameters)
Writes the contents of an alignment model to a file in the specified format.
|
static <T> void |
writeSingleAlignment(AlignmentModel<T> model,
java.lang.String alignmentLabel,
java.io.Writer writer,
java.lang.String format)
Writes the contents of an alignment model to a file in the specified format.
|
static <T> void |
writeSingleAlignment(AlignmentModel<T> model,
java.lang.String alignmentLabel,
java.io.Writer writer,
java.lang.String format,
info.bioinfweb.jphyloio.ReadWriteParameterMap parameters)
Writes the contents of an alignment model to a file in the specified format.
|
public IOTools()
public static java.util.List<AlignmentModel<?>> readAlignments(java.io.File file, info.bioinfweb.jphyloio.ReadWriteParameterMap parameters) throws java.lang.Exception
This is a convenience method that uses AlignmentDataReader
and
BioPolymerCharAlignmentModelFactory
internally.
file
- the file to read the alignment(s) fromparameters
- the writer parameters for the JPhyloIO writer that is used internallyjava.lang.Exception
- if an exception occurs while reading the file (See
AlignmentDataReader.readAll()
and the documentation of its constructor for
details on exceptions that could occur.)public static java.util.List<AlignmentModel<?>> readAlignments(java.io.File file) throws java.lang.Exception
This is a convenience method that uses AlignmentDataReader
and
BioPolymerCharAlignmentModelFactory
internally. It uses an empty parameter
list for the JPhyloIO writer. Use readAlignments(File, ReadWriteParameterMap)
instead, if you want to specify parameters.
file
- the file to read the alignment(s) fromjava.lang.Exception
- if an exception occurs while reading the file (See
AlignmentDataReader.readAll()
and the documentation of its constructor for
details on exceptions that could occur.)public static <T> info.bioinfweb.jphyloio.dataadapters.implementations.ListBasedDocumentDataAdapter createDocumentAdapter(AlignmentModel<T> model, java.lang.String alignmentLabel, boolean linkOTUs)
model
to a file using e.g.
JPhyloIOEventWriter.writeDocument(info.bioinfweb.jphyloio.dataadapters.DocumentDataAdapter, File, ReadWriteParameterMap)
.
The result is a list based document data adapter that allows to add additional adapter instances for e.g. alignments, OTU lists or trees.
This is a convenience method. Application code may also create instances of ListBasedDocumentDataAdapter
and AlignmentModelDataAdapter
directly.
model
- the alignment model providing the content to be writtenalignmentLabel
- the label of the alignment to be written (Maybe null
.)linkOTUs
- Specify true
here, if each sequence shall link an OTU or false
otherwise.
(If true
is specified, a respective OTU list adapter must be added to the returned document
adapter. See #getLinkedOTUID(int)
for details on how OTU IDs are generated.)model
AlignmentModelDataAdapter
public static <T> info.bioinfweb.jphyloio.dataadapters.implementations.ListBasedDocumentDataAdapter createDocumentAdapter(AlignmentModel<T> model, java.lang.String alignmentLabel)
model
to a file using e.g.
JPhyloIOEventWriter.writeDocument(info.bioinfweb.jphyloio.dataadapters.DocumentDataAdapter, File, ReadWriteParameterMap)
.
The result is a list based document data adapter that allows to add additional adapter instances for e.g.
alignments, OTU lists or trees. The contained matrix adapter does not link any OTUs to sequences. Use
createDocumentAdapter(AlignmentModel, String, boolean)
instead if you model OTUs.
This is a convenience method. Application code may also create instances of ListBasedDocumentDataAdapter
and AlignmentModelDataAdapter
directly.
model
- the alignment model providing the content to be writtenalignmentLabel
- the label of the alignment to be written (Maybe null
.)model
AlignmentModelDataAdapter
public static <T> info.bioinfweb.jphyloio.dataadapters.implementations.ListBasedDocumentDataAdapter createDocumentAdapter(AlignmentModel<T> model)
model
to a file using e.g.
JPhyloIOEventWriter.writeDocument(info.bioinfweb.jphyloio.dataadapters.DocumentDataAdapter, File, ReadWriteParameterMap)
.
The result is a list based document data adapter that allows to add additional adapter instances for e.g.
alignments, OTU lists or trees. The contained matrix adapter does not specify a name for the alignment or link
any OTUs to sequences. Use createDocumentAdapter(AlignmentModel, String, boolean)
instead if you want
to specify.
This is a convenience method. Application code may also create instances of ListBasedDocumentDataAdapter
and AlignmentModelDataAdapter
directly.
model
- the alignment model providing the content to be writtenmodel
AlignmentModelDataAdapter
public static <T> void writeSingleAlignment(AlignmentModel<T> model, java.lang.String alignmentLabel, java.io.Writer writer, java.lang.String format) throws java.io.IOException
Note that this method is a convenience method, which cannot be used if more than one alignment should be written to a single file or if additional data or metadata should be included.
model
- the alignment model providing the content to be writtenwriter
- the writer to write the output to (Note that application code is responsible for
closing the writer. This method does not close it.)format
- the format of the output (Any format constant defined in JPhyloIOFormatIDs
can
be passed here.)java.io.IOException
- if the underlying JPhyloIO writer thrown an exception during writing to the
writerpublic static <T> void writeSingleAlignment(AlignmentModel<T> model, java.lang.String alignmentLabel, java.io.Writer writer, java.lang.String format, info.bioinfweb.jphyloio.ReadWriteParameterMap parameters) throws java.io.IOException
Note that this method is a convenience method, which cannot be used if more than one alignment should be written to a single file or if additional data or metadata should be included.
model
- the alignment model providing the content to be writtenwriter
- the writer to write the output to (Note that application code is responsible for
closing the writer. This method does not close it.)format
- the format of the output (Any format constant defined in JPhyloIOFormatIDs
can
be passed here.)parameters
- the reader parameters for the JPhyloIO reader that is used internallyjava.io.IOException
- if the underlying JPhyloIO writer thrown an exception during writing to the
writerpublic static <T> void writeSingleAlignment(AlignmentModel<T> model, java.lang.String alignmentLabel, java.io.OutputStream stream, java.lang.String format) throws java.io.IOException
Note that this method is a convenience method, which cannot be used if more than one alignment should be written to a single file or if additional data or metadata should be included.
model
- the alignment model providing the content to be writtenstream
- the output stream to write the output to (Note that application code is responsible for
closing the stream. This method does not close it.)format
- the format of the output (Any format constant defined in JPhyloIOFormatIDs
can
be passed here.)java.io.IOException
- if the underlying JPhyloIO writer thrown an exception during writing to the
streampublic static <T> void writeSingleAlignment(AlignmentModel<T> model, java.lang.String alignmentLabel, java.io.OutputStream stream, java.lang.String format, info.bioinfweb.jphyloio.ReadWriteParameterMap parameters) throws java.io.IOException
Note that this method is a convenience method, which cannot be used if more than one alignment should be written to a single file or if additional data or metadata should be included.
model
- the alignment model providing the content to be writtenstream
- the output stream to write the output to (Note that application code is responsible for
closing the stream. This method does not close it.)format
- the format of the output (Any format constant defined in JPhyloIOFormatIDs
can
be passed here.)parameters
- the reader parameters for the JPhyloIO reader that is used internallyjava.io.IOException
- if the underlying JPhyloIO writer thrown an exception during writing to the
streampublic static <T> void writeSingleAlignment(AlignmentModel<T> model, java.lang.String alignmentLabel, java.io.File file, java.lang.String format) throws java.io.IOException
Note that this method is a convenience method, which cannot be used if more than one alignment should be written to a single file or if additional data or metadata should be included.
model
- the alignment model providing the content to be writtenalignmentLabel
- the label of the alignment to be written (Maybe null
.)file
- the file to write the output toformat
- the format of the output (Any format constant defined in JPhyloIOFormatIDs
can
be passed here.)java.io.IOException
- if the underlying JPhyloIO writer thrown an exception during writing to the
filepublic static <T> void writeSingleAlignment(AlignmentModel<T> model, java.lang.String alignmentLabel, java.io.File file, java.lang.String format, info.bioinfweb.jphyloio.ReadWriteParameterMap parameters) throws java.io.IOException
Note that this method is a convenience method, which cannot be used if more than one alignment should be written to a single file or if additional data or metadata should be included.
model
- the alignment model providing the content to be writtenfile
- the file to write the output toformat
- the format of the output (Any format constant defined in JPhyloIOFormatIDs
can
be passed here.)parameters
- the reader parameters for the JPhyloIO reader that is used internallyjava.io.IOException
- if the underlying JPhyloIO writer thrown an exception during writing to the
file