Class SequenceTrack.Manager
- java.lang.Object
-
- com.biomatters.geneious.publicapi.implementations.sequence.SequenceTrack.Manager
-
- All Implemented Interfaces:
XMLSerializable.OldVersionCompatible
- Enclosing class:
- SequenceTrack
public static class SequenceTrack.Manager extends java.lang.Object implements XMLSerializable.OldVersionCompatible
Manages all the tracks on a single sequence, including allowing tracks to added or removed. For detailed information on sequence tracks, seeSequenceTrack
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SequenceTrack.Manager.Provider
An interface implemented bySequenceDocuments
orSequenceAlignmentDocuments
to indicate they provide sequence tracks.
-
Constructor Summary
Constructors Constructor Description Manager(PluginDocument associatedPluginDocument)
Constructs a new empty manager with no tracks.Manager(PluginDocument associatedPluginDocument, org.jdom.Element element)
Recreates a manager from XML.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTrack(SequenceTrack track)
Adds a new track to this sequence.SequenceTrack.Manager
createGapInsertingManager(PluginDocument associatedPluginDocument, SequenceGapInformation sequenceGapInformation, boolean reverseToo, org.virion.jam.util.SimpleListener listenerToNotifyAboutDirectChangesToGappedManager)
Creates a new manager that inserts gaps into annotations relative to this manager.SequenceTrack.Manager
createGapRemovingManager(PluginDocument associatedPluginDocument, SequenceGapInformation sequenceGapInformation, boolean reverseToo, org.virion.jam.util.SimpleListener listenerToNotifyAboutDirectChangesToGappedManager)
Creates a new manager that removes gaps from annotations relative to this manager.java.util.List<SequenceTrack>
getTracks()
Gets all tracks on this sequence.java.lang.String
getUniqueTrackName(java.lang.String namePrefix)
Creates a name unique among all tracks in this manager.static java.lang.String
getUniqueTrackName(java.util.List<SequenceTrack.Manager> managers, java.lang.String namePrefix)
Creates a name unique among all tracks in all these managers.static java.lang.String
getUniqueTrackName(java.util.Set<java.lang.String> namesNotAllowed, java.lang.String namePrefix)
Creates a track name that isn't in a given set of names.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.static SequenceTrack.Manager
readObject(PluginDocument associatedPluginDocument, java.io.DataInput in)
Reads this object from a DataInput.void
removeTrack(SequenceTrack track)
Removes an existing track.org.jdom.Element
toXML()
Serializes this manager to XML, usingPluginDocument.FILE_DATA_ATTRIBUTE_NAME
where appropriate.org.jdom.Element
toXML(Geneious.MajorVersion majorVersion, jebl.util.ProgressListener progressListener)
Serializes this manager to XML, usingPluginDocument.FILE_DATA_ATTRIBUTE_NAME
where appropriate.void
writeObject(Geneious.MajorVersion majorVersion, java.io.DataOutput out, jebl.util.ProgressListener progressListener)
Writes this manager to a DataOutputvoid
writeObject(java.io.DataOutput out, jebl.util.ProgressListener progressListener)
Writes this manager to a DataOutput
-
-
-
Constructor Detail
-
Manager
public Manager(PluginDocument associatedPluginDocument)
Constructs a new empty manager with no tracks.- Parameters:
associatedPluginDocument
- the document (sequence or alignment) this track manager is associated with. This is used to prevent the document getting garbage collected while the track is being modified but not yet saved, and to set the modification status (if applicable). This may be null.
-
Manager
public Manager(PluginDocument associatedPluginDocument, org.jdom.Element element) throws XMLSerializationException
Recreates a manager from XML.- Parameters:
associatedPluginDocument
- the document (sequence or alignment) this track manager is associated with. This is used to prevent the document getting garbage collected while the track is being modified but not yet saved, and to set the modification status (if applicable). This may be null.element
- an element returned previously fromtoXML()
- Throws:
XMLSerializationException
- if there is a problem deserializing
-
-
Method Detail
-
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()
Serializes this manager to XML, usingPluginDocument.FILE_DATA_ATTRIBUTE_NAME
where appropriate.- Returns:
- this manager serialized to XML.
-
toXML
public org.jdom.Element toXML(Geneious.MajorVersion majorVersion, jebl.util.ProgressListener progressListener)
Serializes this manager to XML, usingPluginDocument.FILE_DATA_ATTRIBUTE_NAME
where appropriate.- Specified by:
toXML
in interfaceXMLSerializable.OldVersionCompatible
- Parameters:
majorVersion
- a Geneious version that must be able to deserialize this XMLprogressListener
- for reporting progress and cancelling- Returns:
- this manager serialized to XML.
-
writeObject
public void writeObject(java.io.DataOutput out, jebl.util.ProgressListener progressListener) throws java.io.IOException
Writes this manager to a DataOutput- Parameters:
out
- the output to write to.progressListener
- for reporting progress and cancelling- Throws:
java.io.IOException
- if there is a problem writing to the output.- See Also:
SequenceTrack.readObject(java.io.DataInput)
-
writeObject
public void writeObject(Geneious.MajorVersion majorVersion, java.io.DataOutput out, jebl.util.ProgressListener progressListener) throws java.io.IOException
Writes this manager to a DataOutput- Parameters:
majorVersion
- a Geneious version that must be able to deserialize this dataout
- the output to write to.progressListener
- for reporting progress and cancelling- Throws:
java.io.IOException
- if there is a problem writing to the output.- Since:
- API 4.600 (Geneious 6.0.0)
- See Also:
SequenceTrack.readObject(java.io.DataInput)
-
readObject
public static SequenceTrack.Manager readObject(PluginDocument associatedPluginDocument, java.io.DataInput in) throws java.io.IOException
Reads this object from a DataInput. This should only be data previously written to usingwriteObject(java.io.DataOutput, jebl.util.ProgressListener)
- Parameters:
associatedPluginDocument
- the document (sequence or alignment) this track manager is associated with. This is only used to prevent the document getting garbage collected while the track is being modified but not yet saved. This may be null.in
- the input to read from- Returns:
- the manager read from the input.
- Throws:
java.io.IOException
- if there is a problem reading from the input- See Also:
writeObject(java.io.DataOutput, jebl.util.ProgressListener)
-
getUniqueTrackName
public static java.lang.String getUniqueTrackName(java.util.Set<java.lang.String> namesNotAllowed, java.lang.String namePrefix)
Creates a track name that isn't in a given set of names.SequenceAnnotationGenerators
need not worry about generating unique track names. The sequence viewer and core Geneious will handle doing it by calling this method.- Parameters:
namesNotAllowed
- a set of track names which the returned name won't be.namePrefix
- a prefix for the newly created track name. If no track exists with this name, then the returned name will be equal to this prefix.- Returns:
- a name that starts with namePrefix and is not in the namesNotAllowed set.
- Since:
- API 4.51 (Geneious 5.5.1)
- See Also:
getUniqueTrackName(String)
-
getUniqueTrackName
public static java.lang.String getUniqueTrackName(java.util.List<SequenceTrack.Manager> managers, java.lang.String namePrefix)
Creates a name unique among all tracks in all these managers.SequenceAnnotationGenerators
need not worry about generating unique track names. The sequence viewer and core Geneious will handle doing it by calling this method.- Parameters:
managers
- a list of track managers to consider. This list itself must not be null (but may be empty). Individual entries in the list may be null.namePrefix
- a prefix for the newly created track name. If no track exists with this name, then the returned name will be equal to this prefix.- Returns:
- a name not used by any track in any of these managers
- See Also:
getUniqueTrackName(String)
-
getUniqueTrackName
public java.lang.String getUniqueTrackName(java.lang.String namePrefix)
Creates a name unique among all tracks in this manager.SequenceAnnotationGenerators
need not worry about generating unique track names. The sequence viewer and core Geneious will handle doing it by calling this method.- Parameters:
namePrefix
- a prefix for the newly created track name. If no track exists with this name, then the returned name will be equal to this prefix.- Returns:
- a name not used by any track in this manager
- See Also:
getUniqueTrackName(java.util.List, String)
-
getTracks
public java.util.List<SequenceTrack> getTracks()
Gets all tracks on this sequence. This list is not modifiable. To add or remove tracks useaddTrack(SequenceTrack)
orremoveTrack(SequenceTrack)
. To modify tracks, just use appropriate methods on one of the returned tracks and callAnnotatedPluginDocument.saveDocument()
afterwards. The returned tracks do not includeSequenceTrack.NO_TRACK
annotations for annotations on a sequence which are not in tracks. These are only available viaSequenceDocument.getSequenceAnnotations()
. The returned tracks only have a small amount of meta data loaded, so this method will be fast. Full track data is loaded on demand viaSequenceTrack.getSequenceAnnotations(jebl.util.ProgressListener)
.- Returns:
- all tracks on this sequence.
-
addTrack
public void addTrack(SequenceTrack track)
Adds a new track to this sequence.AnnotatedPluginDocument.saveDocument()
also needs to be called to make the changes permanent.- Parameters:
track
- the new track.
-
removeTrack
public void removeTrack(SequenceTrack track)
Removes an existing track.AnnotatedPluginDocument.saveDocument()
also needs to be called to make the changes permanent.- Parameters:
track
- the track to remove, which must be one of the tracks returned fromgetTracks()
- Throws:
java.lang.IllegalArgumentException
- if the track isn't one of the tracks returned fromgetTracks()
-
createGapInsertingManager
public SequenceTrack.Manager createGapInsertingManager(PluginDocument associatedPluginDocument, SequenceGapInformation sequenceGapInformation, boolean reverseToo, org.virion.jam.util.SimpleListener listenerToNotifyAboutDirectChangesToGappedManager)
Creates a new manager that inserts gaps into annotations relative to this manager. Changes to either this or the returned manager are automatically propagated to each other.- Parameters:
associatedPluginDocument
- the document (sequence or alignment) this track manager is associated with. This is only used to prevent the document getting garbage collected while the track is being modified but not yet saved. This may be null.sequenceGapInformation
- contains information about the gaps to be insertedreverseToo
- true to reverse all annotations toolistenerToNotifyAboutDirectChangesToGappedManager
- a listener to notify whenever the returned manager or any of its tracks are directly modified. May be null.- Returns:
- a new manager that inserts gaps into annotations relative to this manager.
-
createGapRemovingManager
public SequenceTrack.Manager createGapRemovingManager(PluginDocument associatedPluginDocument, SequenceGapInformation sequenceGapInformation, boolean reverseToo, org.virion.jam.util.SimpleListener listenerToNotifyAboutDirectChangesToGappedManager)
Creates a new manager that removes gaps from annotations relative to this manager. Changes to either this or the returned manager are automatically propagated to each other.- Parameters:
associatedPluginDocument
- the document (sequence or alignment) this track manager is associated with. This is only used to prevent the document getting garbage collected while the track is being modified but not yet saved. This may be null.sequenceGapInformation
- contains information about the gaps to be removereverseToo
- true to reverse all annotations toolistenerToNotifyAboutDirectChangesToGappedManager
- a listener to notify whenever the returned manager or any of its tracks are directly modified. May be null.- Returns:
- a new manager that removes gaps from annotations relative to this manager.
- Since:
- API 4.51 (Geneious 5.5.1)
-
-