T
- the type of sequence elements (tokens) used by the underlying alignment model objectpublic class AlignmentModelDataAdapter<T> extends info.bioinfweb.jphyloio.dataadapters.implementations.NoCharDefsNoSetsMatrixDataAdapter implements info.bioinfweb.jphyloio.dataadapters.MatrixDataAdapter
AlignmentModel
to an implementation of JPhyloIOEventWriter
.
Whether the sequence start events links an associated OTU or not can be defined by the constructor parameter
linkOTUs
. If OTUs shall be linked, it will be assumed that such an OTU will have an ID consisting of the
concatenation of ReadWriteConstants.DEFAULT_OTU_ID_PREFIX
and the sequence ID used in the underlying
AlignmentModel
. If a more complex OTU linking is necessary, the method #getLinkedOTUID(int)
can
be overwritten accordingly.
This implementation does not write any metadata associated with sequences or the alignment as a whole. If such data
shall be written the methods #writeMetadata(JPhyloIOEventReceiver)
or
writeSequenceMetadata(JPhyloIOEventReceiver, String)
should be overwritten accordingly. If character
definitions or sets shall be written, the according methods need to be overwritten as well.
Constructor and Description |
---|
AlignmentModelDataAdapter(String idPrefix,
info.bioinfweb.jphyloio.events.LinkedLabeledIDEvent startEvent,
AlignmentModel<T> model,
boolean linkOTUs)
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsLongTokens(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters) |
long |
getColumnCount(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters)
Returns the number of columns in the underlying
AlignmentModel instance if all sequences have an equal length. |
String |
getIDPrefix() |
protected String |
getLinkedOTUID(String sequenceID)
Returns the ID of the JPhyloIO OTU that shall be linked with the specified sequence.
|
long |
getSequenceCount(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters) |
Iterator<String> |
getSequenceIDIterator(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters) |
long |
getSequenceLength(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters,
String sequenceID) |
info.bioinfweb.jphyloio.events.LinkedLabeledIDEvent |
getSequenceStartEvent(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters,
String sequenceID) |
info.bioinfweb.jphyloio.events.LinkedLabeledIDEvent |
getStartEvent(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters) |
info.bioinfweb.jphyloio.dataadapters.ObjectListDataAdapter<info.bioinfweb.jphyloio.events.TokenSetDefinitionEvent> |
getTokenSets(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters) |
boolean |
isLinkOTUs() |
protected String |
jPhyloIOByModelSequenceID(String modelSequenceID)
Returns the JPhyloIO sequence ID to be used for the specified sequence ID used in the underlying model.
|
protected String |
modelByJPhyloIOSequenceID(String jPhyloIOsequenceID)
Returns the LibrAlign model sequence ID associated with the specified JPhyloIO sequence ID.
|
protected void |
writeSequenceMetadata(info.bioinfweb.jphyloio.dataadapters.JPhyloIOEventReceiver receiver,
String sequenceID)
Can be used to write metadata associated with a sequence.
|
void |
writeSequencePartContentData(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters,
info.bioinfweb.jphyloio.dataadapters.JPhyloIOEventReceiver receiver,
String sequenceID,
long startColumn,
long endColumn) |
getCharacterDefinitions, getCharacterSets, getSequenceSets
writeMetadata
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public AlignmentModelDataAdapter(String idPrefix, info.bioinfweb.jphyloio.events.LinkedLabeledIDEvent startEvent, AlignmentModel<T> model, boolean linkOTUs)
idPrefix
- the ID prefix to be used for all generated JPhyloIO IDs of sequences and token sets.
(Must be a valid NCName.)startEvent
- the JPhyloIO alignment start event to be usedmodel
- the LibrAlign alignment model which shall be the source for this adapterlinkOTUs
- Specify true
here, if each sequence shall link an OTU or false
otherwise.
(See #getLinkedOTUID(int)
for details on how OTU IDs are generated.)public String getIDPrefix()
public boolean isLinkOTUs()
public info.bioinfweb.jphyloio.events.LinkedLabeledIDEvent getStartEvent(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters)
getStartEvent
in interface info.bioinfweb.jphyloio.dataadapters.ElementDataAdapter<info.bioinfweb.jphyloio.events.LinkedLabeledIDEvent>
public long getSequenceCount(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters)
getSequenceCount
in interface info.bioinfweb.jphyloio.dataadapters.MatrixDataAdapter
public long getColumnCount(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters)
AlignmentModel
instance if all sequences have an equal length.
If at least two of these sequences differ in their length, -1 is returned.getColumnCount
in interface info.bioinfweb.jphyloio.dataadapters.MatrixDataAdapter
MatrixDataAdapter.getColumnCount(info.bioinfweb.jphyloio.ReadWriteParameterMap)
public boolean containsLongTokens(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters)
containsLongTokens
in interface info.bioinfweb.jphyloio.dataadapters.MatrixDataAdapter
public info.bioinfweb.jphyloio.dataadapters.ObjectListDataAdapter<info.bioinfweb.jphyloio.events.TokenSetDefinitionEvent> getTokenSets(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters)
getTokenSets
in interface info.bioinfweb.jphyloio.dataadapters.MatrixDataAdapter
getTokenSets
in class info.bioinfweb.jphyloio.dataadapters.implementations.NoCharDefsNoSetsMatrixDataAdapter
protected String jPhyloIOByModelSequenceID(String modelSequenceID)
This default implementation returns the concatenation of getIDPrefix()
and sequenceID
. It can be
overwritten to use a different pattern.
modelSequenceID
- the ID of the sequence used in the underlying AlignmentModel
instanceprotected String modelByJPhyloIOSequenceID(String jPhyloIOsequenceID) throws IllegalArgumentException
This default implementation extracts the integer ID that was used to create such an ID using
#jPhyloIOByModelSequenceID(int)
. If #jPhyloIOByModelSequenceID(int)
was overwritten this method
must be overwritten accordingly.
Note that this method does not test, if the extracted ID actually exists in the underlying LibrAlign alignment model.
jPhyloIOsequenceID
- the sequence ID used by JPhyloIOIllegalArgumentException
- if no integer ID can be extracted from the specified IDprotected String getLinkedOTUID(String sequenceID)
This default implementation returns the concatenation of ReadWriteConstants.DEFAULT_OTU_ID_PREFIX
and
sequenceID
if isLinkOTUs()
returns true
or null
if isLinkOTUs()
returns
false
.
Note that the ID prefix for sequences and token sets, which can be specified in the constructor will not be used for IDs creates by this method.
This method can be overwritten to use a different pattern of OTU linking.
sequenceID
- the ID of the sequence used in the underlying AlignmentModel
instancenull
if no OTU shall be linked.public Iterator<String> getSequenceIDIterator(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters)
getSequenceIDIterator
in interface info.bioinfweb.jphyloio.dataadapters.MatrixDataAdapter
public info.bioinfweb.jphyloio.events.LinkedLabeledIDEvent getSequenceStartEvent(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters, String sequenceID)
getSequenceStartEvent
in interface info.bioinfweb.jphyloio.dataadapters.MatrixDataAdapter
public long getSequenceLength(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters, String sequenceID) throws IllegalArgumentException
getSequenceLength
in interface info.bioinfweb.jphyloio.dataadapters.MatrixDataAdapter
IllegalArgumentException
protected void writeSequenceMetadata(info.bioinfweb.jphyloio.dataadapters.JPhyloIOEventReceiver receiver, String sequenceID) throws IOException, IllegalArgumentException
This default implementation is empty, but can be overwritten by inherited classes.
receiver
- the receiver to write the events tosequenceID
- the ID of the sequence carrying the metadataIOException
- if an I/O error occurs while receiver
is trying to write the dataIllegalArgumentException
- if not sequence with the specified ID existspublic void writeSequencePartContentData(info.bioinfweb.jphyloio.ReadWriteParameterMap parameters, info.bioinfweb.jphyloio.dataadapters.JPhyloIOEventReceiver receiver, String sequenceID, long startColumn, long endColumn) throws IOException, IllegalArgumentException
writeSequencePartContentData
in interface info.bioinfweb.jphyloio.dataadapters.MatrixDataAdapter
IOException
IllegalArgumentException