Class SequencePropertiesStorage
- java.lang.Object
-
- com.biomatters.geneious.publicapi.implementations.sequence.SequencePropertiesStorage
-
- All Implemented Interfaces:
NucleotideGraph
,XMLSerializable
,XMLSerializable.OldVersionCompatible
,SequenceTrack.Manager.Provider
public class SequencePropertiesStorage extends java.lang.Object implements NucleotideGraph, XMLSerializable, XMLSerializable.OldVersionCompatible, SequenceTrack.Manager.Provider
Provides supporting functionality for sequence classes that need to store various sequence properties and serialise those to XML. As at 2008-01-22, this class implements EditableSequenceDocument, EditableNucleotideGraphSequenceDocument EXCEPT thatgetSequenceString()
andgetCharSequence()
may return null. For consistency the methods should remain named the same way as those in the SequenceDocuments, however because of the above difference an object of this class should never be passed anywhere as a SequenceDocument.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.biomatters.geneious.publicapi.documents.sequence.NucleotideGraph
NucleotideGraph.ImmutableGraphProvider
-
Nested classes/interfaces inherited from interface com.biomatters.geneious.publicapi.documents.XMLSerializable
XMLSerializable.OldVersionCompatible, XMLSerializable.VersionSupportType
-
-
Field Summary
-
Fields inherited from interface com.biomatters.geneious.publicapi.documents.XMLSerializable
ROOT_ELEMENT_NAME
-
-
Constructor Summary
Constructors Constructor Description SequencePropertiesStorage()
Default constructor with no arguments.SequencePropertiesStorage(org.jdom.Element element)
Constructs a SequencePropertiesStorage object from a JDOM XML Element.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static byte[]
byteArrayFromXML(org.jdom.Element element)
Converts some xml created from a preious call tobyteArrayToXML(String, byte[])
(String, int[])} back to a byte array.static org.jdom.Element
byteArrayToXML(java.lang.String elementName, byte[] values)
Converts a byte array to xml, storing them in a compact way if possible.void
fromXML(org.jdom.Element root)
Restore the object from the JDOM Element returned byXMLSerializable.toXML()
.void
fromXML(org.jdom.Element root, NucleotideGraph overriddenGraph)
Deprecated.SequenceCharSequence
getCharSequence()
int
getChromatogramLength()
The number of points for which this graph has values, which is typically larger than the length of the nucleotide sequence because a base isn't called at every position in the graph.int
getChromatogramPositionForResidue(int residueIndex)
The graph position (can be used as an argument toNucleotideGraph.getChromatogramValue(int, int)
) where the nucleotide at the specified residue index has been called.int
getChromatogramValue(int nucleotideStateNumber, int residuePosition)
Returns the graph value for the specified nucleotide and at the specified position.java.util.Date
getCreationDate()
This method is not implemented.java.lang.String
getDescription()
java.util.List<DocumentField>
getDisplayableFields()
This method is not implemented.java.lang.Object
getFieldValue(java.lang.String fieldCodeName)
This method is not implemented.NucleotideGraph
getGraph()
java.lang.String
getName()
java.lang.String
getProperty(java.lang.String propertyKey)
Returns a value from the internal properties object.java.util.List<SequenceAnnotation>
getSequenceAnnotations()
int
getSequenceLength()
Thelength
of the nucleotide sequence that can be annotated with this graph.int
getSequenceQuality(int residueIndex)
Returns a measurement of confidence in the residue reported at the specified residueIndex in the sequence.java.lang.String
getSequenceString()
SequenceTrack.Manager
getTrackManager(boolean mayReturnNullIfNoTracks)
Gets aSequenceTrack.Manager
associated with this sequence for providing sequence tracks.URN
getURN()
This method is not implemented.Geneious.MajorVersion
getVersionSupport(XMLSerializable.VersionSupportType versionType)
Gets either the latest version this class can serialize to viaXMLSerializable.OldVersionCompatible.toXML(Geneious.MajorVersion, ProgressListener)
or the most recent version in which the XML returned fromXMLSerializable.OldVersionCompatible.toXML(Geneious.MajorVersion, ProgressListener)
last changed.boolean
hasChromatogramPositionsForResidues()
Tests whether this NucleotideGraph contains information about the position of the base calls, i.e.boolean
hasChromatogramValues(int nucleotideStateNumber)
Specifies whether it is legal to callNucleotideGraph.getChromatogramValue(int, int)
for the specified nucleotide.boolean
hasGraph()
boolean
hasSequenceQualities()
Tests whether this graph contains information about the confidence in the associated sequence's residues, i.e.boolean
hasSetCircular()
Returns true ifsetCircular(boolean)
has ever been called on this storage propertiesstatic int[]
integerArrayFromXML(org.jdom.Element element)
Converts some xml created from a preious call tointegerArrayToXML(String, int[])
back to an integer array.static org.jdom.Element
integerArrayToXML(Geneious.MajorVersion version, java.lang.String elementName, int[] values)
Converts an integer array to xml, storing them in a compact way if possible.static org.jdom.Element
integerArrayToXML(java.lang.String elementName, int[] values)
Converts an integer array to xml, storing them in a compact way if possible.boolean
isCircular()
void
setAnnotations(java.util.List<SequenceAnnotation> annotations)
void
setCircular(boolean circular)
void
setDescription(java.lang.String description)
Set the human-readable graph description.void
setName(java.lang.String name)
Set the name of the graph.void
setProperty(java.lang.String propertyKey, java.lang.String value)
Sets a value on the internal properties object.void
setSequenceAndAnnotations(java.lang.CharSequence sequence, java.util.List<SequenceAnnotation> annotations)
void
setSequenceAndAnnotationsAndGraph(java.lang.CharSequence sequence, java.util.List<SequenceAnnotation> annotations, NucleotideGraph graph)
java.lang.String
toHTML()
This method is not implemented.org.jdom.Element
toXML()
Convert object to a JDOM element.org.jdom.Element
toXML(Geneious.MajorVersion majorVersion, jebl.util.ProgressListener progressListener)
Serializes this class to XML format, potentially to a format readable by an earlier version of Geneious.org.jdom.Element
toXML(java.lang.String elementName)
Convert object to a JDOM Element with the given name as the name of the root element.
-
-
-
Constructor Detail
-
SequencePropertiesStorage
public SequencePropertiesStorage()
Default constructor with no arguments.
-
SequencePropertiesStorage
public SequencePropertiesStorage(org.jdom.Element element) throws XMLSerializationException
Constructs a SequencePropertiesStorage object from a JDOM XML Element.- Parameters:
element
- a JDOM XML Element representing a SequencePropertiesStorage object- Throws:
XMLSerializationException
- if the SequencePropertiesStorage can't be reconstructed from the specified element for some reason
-
-
Method Detail
-
setSequenceAndAnnotations
public void setSequenceAndAnnotations(java.lang.CharSequence sequence, java.util.List<SequenceAnnotation> annotations)
Equivalent toEditableSequenceDocument.setSequenceAndAnnotations(CharSequence,java.util.List)
. except that null sequences or a null list of annotations are allowed.
-
setAnnotations
public void setAnnotations(java.util.List<SequenceAnnotation> annotations)
-
setName
public void setName(java.lang.String name)
Set the name of the graph.- Parameters:
name
- the name of the graph
-
setDescription
public void setDescription(java.lang.String description)
Set the human-readable graph description.- Parameters:
description
- the human-readable graph description
-
getName
public java.lang.String getName()
-
getProperty
public java.lang.String getProperty(java.lang.String propertyKey)
Returns a value from the internal properties object.- Parameters:
propertyKey
- key whose associated value is to be returned- Returns:
- the value to which this map maps the specified key, or null if the map contains no mapping for this key
- See Also:
Map.get(Object)
-
setProperty
public void setProperty(java.lang.String propertyKey, java.lang.String value)
Sets a value on the internal properties object.- Parameters:
propertyKey
- key with which the specified value is to be associatedvalue
- value to be associated with the specified key
-
getDescription
public java.lang.String getDescription()
-
getSequenceString
public final java.lang.String getSequenceString()
-
getCharSequence
public SequenceCharSequence getCharSequence()
-
getSequenceAnnotations
public java.util.List<SequenceAnnotation> getSequenceAnnotations()
- Returns:
- the annotations stored by this class using
setAnnotations(java.util.List)
or null ifsetAnnotations(java.util.List)
has not been called.
-
getVersionSupport
public Geneious.MajorVersion getVersionSupport(XMLSerializable.VersionSupportType versionType)
Description copied from interface:XMLSerializable.OldVersionCompatible
Gets either the latest version this class can serialize to viaXMLSerializable.OldVersionCompatible.toXML(Geneious.MajorVersion, ProgressListener)
or the most recent version in which the XML returned fromXMLSerializable.OldVersionCompatible.toXML(Geneious.MajorVersion, ProgressListener)
last changed. Example implementation:switch (versionType) { case FormatLastExtended: //added a new tag to xml in 10.0 that can be safely ignored by older versions return Geneious.MajorVersion.Version10_0; case FormatLastChanged: //renamed a tag in 9.1 meaning that older versions can no longer read the xml from 9.1 return Geneious.MajorVersion.Version9_1; case OldestVersionSerializableTo: //this document class can export xml that is compatible with 9.0 return Geneious.MajorVersion.Version9_0; default: throw new IllegalArgumentException("Unrecognized VersionSupportType"); }
- Specified by:
getVersionSupport
in interfaceXMLSerializable.OldVersionCompatible
- Parameters:
versionType
- specifies which version property to return- Returns:
- the major version of Geneious corresponding to the versionType for this classes toXML method.
-
toXML
public org.jdom.Element toXML(java.lang.String elementName)
Convert object to a JDOM Element with the given name as the name of the root element.- Parameters:
elementName
- the name of the root element- Returns:
- object encoded as a JDOM XML element or possibly null if there is no data to store.
- See Also:
XMLSerializable.toXML()
-
toXML
public org.jdom.Element toXML(Geneious.MajorVersion majorVersion, jebl.util.ProgressListener progressListener)
Description copied from interface:XMLSerializable.OldVersionCompatible
Serializes this class to XML format, potentially to a format readable by an earlier version of Geneious. It is acceptable for the XML to include unnecessary tags that will be ignored by the earlier version. For example if the implementation has only extended the XML since the earlier version, then the XML returned may be identical to the XML returned for the current version. SeeXMLSerializable.toXML()
for a more detailed description of what it means to serialize to XML. All classes that implement this method must also implement XMLSerializable.toXML() and should delegate back to this method using Geneious.getMajorVersion() and ProgressListener.EMPTY as parameters.- Specified by:
toXML
in interfaceXMLSerializable.OldVersionCompatible
- Parameters:
majorVersion
- the major version of Geneious to serialize to XML for. For example "6.0" but not "6.0.0". This must be a version returned greater or equal to a version returned fromgetVersionSupport
(VersionSupportType.OldestVersionSerializableTo
) and must never be greater than the current version (Geneious.getMajorVersion())progressListener
- for reporting progress and cancelling- Returns:
- object encoded as a JDOM element
-
integerArrayToXML
public static org.jdom.Element integerArrayToXML(java.lang.String elementName, int[] values)
Converts an integer array to xml, storing them in a compact way if possible.- Parameters:
elementName
- the name of the element to return.values
- the values to serialize to xml. Must not be null.- Returns:
- an element that can be converted back to an integer array using
integerArrayArrayFromXML(org.jdom.Element)
. - Since:
- API 4.11 (Geneious 5.0)
-
integerArrayToXML
public static org.jdom.Element integerArrayToXML(Geneious.MajorVersion version, java.lang.String elementName, int[] values)
Converts an integer array to xml, storing them in a compact way if possible.- Parameters:
version
- the version number of Geneious that must be able to deserialize this. All versions of Geneious from 6.0 onwards are and always will be supported.elementName
- the name of the element to return.values
- the values to serialize to xml. Must not be null.- Returns:
- an element that can be converted back to an integer array using
integerArrayArrayFromXML(org.jdom.Element)
. - Since:
- API 4.600 (Geneious 6.0.0)
-
byteArrayToXML
public static org.jdom.Element byteArrayToXML(java.lang.String elementName, byte[] values)
Converts a byte array to xml, storing them in a compact way if possible.- Parameters:
elementName
- the name of the element to return.values
- the values to serialize to xml. Must not be null.- Returns:
- an element that can be converted back to an integer array using
byteArrayFromXML(org.jdom.Element)
- Since:
- API 4.11 (Geneious 5.0)
-
integerArrayFromXML
public static int[] integerArrayFromXML(org.jdom.Element element)
Converts some xml created from a preious call tointegerArrayToXML(String, int[])
back to an integer array.- Parameters:
element
- the element to convert to an array. May be null, in which case this method returns null.- Returns:
- an integer array or null if element was null.
- Since:
- API 4.11 (Geneious 5.0)
-
byteArrayFromXML
public static byte[] byteArrayFromXML(org.jdom.Element element)
Converts some xml created from a preious call tobyteArrayToXML(String, byte[])
(String, int[])} back to a byte array.- Parameters:
element
- the element to convert to an array. May be null, in which case this method returns null.- Returns:
- a byte array or null if element was null.
- Since:
- API 4.11 (Geneious 5.0)
-
fromXML
@Deprecated public void fromXML(org.jdom.Element root, NucleotideGraph overriddenGraph) throws XMLSerializationException
Deprecated.Backwards compatibility XML deserialization of SequencePropertiesStorage which overrides another NucleotideGraph and which was stored by Geneious 3.5.x or earlier. In these versions, it was possible to override only certain aspects of a NucleotideGraph, so that when those aspects are missing in the XML File they must be read from the overriden chromatogram instead. New code introduced for Geneious 3.6 or later (which will only encounter XMLserialized
by version 3.6 or later) should never need to call this method, and should instead just callfromXML(org.jdom.Element)
.- Parameters:
root
- Element from which to XML deserialize (same as infromXML(org.jdom.Element)
overriddenGraph
- The graph from which to takechromatogram
andsequence
lengths if they are not specified in the XML. May be null if these properties override no other graph and root must contain specification of a legal graph by itself.- Throws:
XMLSerializationException
- If the Element passed in (plus optionally overriddenGraph) is not a valid serialization of a NucleotideGraph
-
fromXML
public void fromXML(org.jdom.Element root) throws XMLSerializationException
Description copied from interface:XMLSerializable
Restore the object from the JDOM Element returned byXMLSerializable.toXML()
. This method generally should not be called directly. Instead, you should usually callXMLSerializer.classFromXML(org.jdom.Element)
orXMLSerializer.classFromXML(org.jdom.Element, Class)
which calls this method internally. It is optional to implement this method. Instead of implementing an empty constructor and implementing this method properly, the implementation may instead throw an UnsupportedOperationException and implement a constructor that takes a singleElement
as a parameter. This allows for cleaner code such as support for final fields in the XMLSerializable class. The element parameter should not be modified since it may be reused. If you need a modified version of it, take a copy withElement.clone()
.- Specified by:
fromXML
in interfaceXMLSerializable
- Parameters:
root
- representation from a previous call toXMLSerializable.toXML()
- Throws:
XMLSerializationException
- if the Element can't be converted into this type of object
-
hasChromatogramPositionsForResidues
public boolean hasChromatogramPositionsForResidues()
Description copied from interface:NucleotideGraph
Tests whether this NucleotideGraph contains information about the position of the base calls, i.e. whether it is legal to callNucleotideGraph.getChromatogramPositionForResidue(int)
.- Specified by:
hasChromatogramPositionsForResidues
in interfaceNucleotideGraph
- Returns:
- true if this NucleotideGraph contains information about the position of the base calls.
-
getChromatogramPositionForResidue
public int getChromatogramPositionForResidue(int residueIndex)
Description copied from interface:NucleotideGraph
The graph position (can be used as an argument toNucleotideGraph.getChromatogramValue(int, int)
) where the nucleotide at the specified residue index has been called. This method may only be called ifNucleotideGraph.hasChromatogramPositionsForResidues()
returns true. The graph sites are guaranteed to have the same order as the sequence nucleotides. Therefore, any implementation must ensure that ifi < j
, thengetChromatogramPositionForResidue(i) <= getChromatogramPositionForResidue(j)
.- Specified by:
getChromatogramPositionForResidue
in interfaceNucleotideGraph
- Parameters:
residueIndex
- A value0 <= residueIndex <
specifying the index in the nucleotide sequence for which to calculate the corresponding position in the graph.NucleotideGraph.getSequenceLength()
- Returns:
- A value in the range 0 <= value <
NucleotideGraph.getChromatogramLength()
, specifiying the graph position where the nucleotide that is at positionresidueIndex
has been called. For positionsresidueIndex
where thesequence
length
consisting of values between 0 and getChromatogramLength()-1 inclusive. For a residueIndex where the sequenceholds
a '-', the returned site position must always beInteger.MIN_VALUE
.
-
getSequenceLength
public int getSequenceLength()
Description copied from interface:NucleotideGraph
Thelength
of the nucleotide sequence that can be annotated with this graph. If a class implements both this interface andSequenceDocument
, then the return value of this method must be equal togetCharSequence()
.length()
Also ifNucleotideGraph.hasChromatogramPositionsForResidues()
orNucleotideGraph.hasSequenceQualities()
is true, the return value indicates the range of legal values to pass toNucleotideGraph.getChromatogramPositionForResidue(int)
andNucleotideGraph.getSequenceQuality(int)
.- Specified by:
getSequenceLength
in interfaceNucleotideGraph
- Returns:
- length of the nucleotide sequence belonging to this graph.
-
hasSequenceQualities
public boolean hasSequenceQualities()
Description copied from interface:NucleotideGraph
Tests whether this graph contains information about the confidence in the associated sequence's residues, i.e. whether it is legal to callNucleotideGraph.getSequenceQuality(int)
.- Specified by:
hasSequenceQualities
in interfaceNucleotideGraph
- Returns:
- true if it is legal to call
NucleotideGraph.getSequenceQuality(int)
on this graph.
-
getSequenceQuality
public int getSequenceQuality(int residueIndex)
Description copied from interface:NucleotideGraph
Returns a measurement of confidence in the residue reported at the specified residueIndex in the sequence. The measure is on a logaritmic scale: P(call correct) = 1 - 10^(-v/10) where v is the quality returned from this method. If the sequence contains a gap at the specified position, this method should returnInteger.MIN_VALUE
if it is an end gap. If it is an internal gap, it should return the average quality of the non-gap positions on either side of the gap. This method may only be called ifNucleotideGraph.hasSequenceQualities()
returns true.- Specified by:
getSequenceQuality
in interfaceNucleotideGraph
- Parameters:
residueIndex
- A value0 <= residueIndex <
specifying the index in the nucleotide sequence for which to calculate the quality of the graph.NucleotideGraph.getSequenceLength()
- Returns:
- The quality score v for the residue at the specified index in the nucleotide sequence, which indicates the reliability of the nucleotide on a logarithmic scale as described above.
-
getChromatogramLength
public int getChromatogramLength()
Description copied from interface:NucleotideGraph
The number of points for which this graph has values, which is typically larger than the length of the nucleotide sequence because a base isn't called at every position in the graph.- Specified by:
getChromatogramLength
in interfaceNucleotideGraph
- Returns:
- the length of this graph, or 0 if this graph has no graph values for any nucleotide (i.e. 0 if
NucleotideGraph.hasChromatogramPositionsForResidues()
is false).
-
hasChromatogramValues
public boolean hasChromatogramValues(int nucleotideStateNumber)
Description copied from interface:NucleotideGraph
Specifies whether it is legal to callNucleotideGraph.getChromatogramValue(int, int)
for the specified nucleotide.- Specified by:
hasChromatogramValues
in interfaceNucleotideGraph
- Parameters:
nucleotideStateNumber
- A nucleotide state number encoded in the same way as forNucleotideGraph.getChromatogramValue(int, int)
, i.e. 0 = A, 1 = C, 2 = G, 3 = T- Returns:
- true if is legal to call
NucleotideGraph.getChromatogramValue(int, int)
for the specified nucleotide
-
getChromatogramValue
public int getChromatogramValue(int nucleotideStateNumber, int residuePosition)
Description copied from interface:NucleotideGraph
Returns the graph value for the specified nucleotide and at the specified position. If the graph is a chromatogram, this is a measure of the support for the specified nucleotide at this position. May only be called ifNucleotideGraph.hasChromatogramValues(int)
returns true for the specified nucleotide.- Specified by:
getChromatogramValue
in interfaceNucleotideGraph
- Parameters:
nucleotideStateNumber
- The nucleotide for which to retrieve the graph value, encoded as 0 = A, 1 = C, 2 = G, 3 = T (alphabetic order, same as inNucleotides
)residuePosition
- The position in the sequence for which to query the graph value, with 0 <= graphPosition <graph length
- Returns:
- the graph value for the specified nucleotide and at the specified position.
-
getGraph
public NucleotideGraph getGraph()
-
setSequenceAndAnnotationsAndGraph
public void setSequenceAndAnnotationsAndGraph(java.lang.CharSequence sequence, java.util.List<SequenceAnnotation> annotations, NucleotideGraph graph)
-
getDisplayableFields
public java.util.List<DocumentField> getDisplayableFields()
This method is not implemented. It always throws anUnsupportedOperationException
.- Returns:
- never returns. Always throws
UnsupportedOperationException
. - Throws:
java.lang.UnsupportedOperationException
- always
-
getFieldValue
public java.lang.Object getFieldValue(java.lang.String fieldCodeName)
This method is not implemented. It always throws anUnsupportedOperationException
.- Parameters:
fieldCodeName
- ignored- Returns:
- never returns. Always throws
UnsupportedOperationException
. - Throws:
java.lang.UnsupportedOperationException
- always
-
getURN
public URN getURN()
This method is not implemented. It always throws anUnsupportedOperationException
.- Returns:
- never returns. Always throws
UnsupportedOperationException
. - Throws:
java.lang.UnsupportedOperationException
- always
-
getCreationDate
public java.util.Date getCreationDate()
This method is not implemented. It always throws anUnsupportedOperationException
.- Returns:
- never returns. Always throws
UnsupportedOperationException
. - Throws:
java.lang.UnsupportedOperationException
- always
-
toHTML
public java.lang.String toHTML()
This method is not implemented. It always throws anUnsupportedOperationException
.- Returns:
- never returns. Always throws
UnsupportedOperationException
. - Throws:
java.lang.UnsupportedOperationException
- always
-
toXML
public org.jdom.Element toXML()
Description copied from interface:XMLSerializable
Convert object to a JDOM element. The representation should be complete so thatXMLSerializable.fromXML(org.jdom.Element)
can completely restore the object's representation. It is recommended that the returned element useXMLSerializable.ROOT_ELEMENT_NAME
as its name, in which case it must not define an attribute called "type". In this case, fromXML, will be called with an element whose name may differ from the element return from this function. This recommendation allows a more compact representation of the XML can be stored. This method generally should not be called directly. Instead, you should usually callXMLSerializer.classToXML(String, XMLSerializable)
which calls this method internally. PluginDocument implementations of this method may choose to throw anXMLSerializationException
, enclosed in aRuntimeException
.- Specified by:
toXML
in interfaceXMLSerializable
- Returns:
- object encoded as a JDOM element
-
setCircular
public void setCircular(boolean circular)
-
isCircular
public boolean isCircular()
-
hasSetCircular
public boolean hasSetCircular()
Returns true ifsetCircular(boolean)
has ever been called on this storage properties- Returns:
- true if
setCircular(boolean)
has ever been called on this storage properties.
-
hasGraph
public boolean hasGraph()
-
getTrackManager
public SequenceTrack.Manager getTrackManager(boolean mayReturnNullIfNoTracks)
Description copied from interface:SequenceTrack.Manager.Provider
Gets aSequenceTrack.Manager
associated with this sequence for providing sequence tracks. For detailed information on sequence tracks, seeSequenceTrack
. If this method is called on an alignment, the track manager is for the consensus sequence. Individual sequences in the alignment may also implementSequenceTrack.Manager.Provider
if they provide tracks.- Specified by:
getTrackManager
in interfaceSequenceTrack.Manager.Provider
- Parameters:
mayReturnNullIfNoTracks
- to save on memory usage when dealing with lots of small sequences, some implementations may not wish to construct a TrackManager unless necessary. If this parameter is true the implementation may return null rather than an empty track manager if is has no tracks- Returns:
- a track manager or possibly null if mayReturnNullIfNoTracks is true
- Since:
- API 4.900 (Geneious 9.0.0)
-
-