public final class SequenceGapInformation extends Object
SequenceAnnotations,
which can go beyond sequence ends.
Like all other sequence indices except for the ones in SequenceAnnotations,
indices used in this class are 0-based.
When the sequence actually contains internal gaps, this class uses memory about 0.5 bytes of memory per base in the gapped internal sequence for large sequences (over 10 million base pairs)
Some DefaultSequenceDocument instances
(usually only instances of reference sequences in a big contig) store a pre-built SequenceGapInformation which is available
DefaultSequenceDocument.getSequenceGapInformation()| Modifier and Type | Class and Description |
|---|---|
static interface |
SequenceGapInformation.Provider
An interface that
SequenceDocuments can optionally to implement to indicate they may provide a (potentially) pre-built SequenceGapInformation |
| Constructor and Description |
|---|
SequenceGapInformation(CharSequence gappedSequence)
Constructs SequenceGapInformation for the specified gapped sequence.
|
SequenceGapInformation(CharSequence gappedSequence,
ProgressListener progressListener)
Constructs SequenceGapInformation for the specified gapped sequence.
|
SequenceGapInformation(org.jdom.Element element,
SequenceCharSequence gappedCharSequence)
Deserializes a SequenceGapInformation from XML previously returned from
toXML(String). |
| Modifier and Type | Method and Description |
|---|---|
List<SequenceAnnotation> |
adjustAnnotationsForGapInsertion(List<SequenceAnnotation> annotations)
Creates a new list of annotations by adjusting their locations
to compensate for adding gaps into the sequence.
|
List<SequenceAnnotation> |
adjustAnnotationsForGapRemoval(List<SequenceAnnotation> annotations)
Creates a new list of annotations by adjusting their locations
to compensate for removing all the gaps in the sequence.
|
static SequenceGapInformation |
forSequenceDocument(SequenceDocument sequence)
Get SequenceGapInformation for the given sequence.
|
int |
getGappedIndex(int indexInUngappedSequence)
Translates an index in the ungapped sequence to the index of the corresponding nongap
character in the
gappedSequence passed to the constructor. |
int |
getGappedSequenceLength() |
int |
getLeadingGapsLength() |
int |
getTrailingGapsLength() |
int |
getTrailingGapsStartIndex() |
int |
getUngappedIndexOfThisOrNextResidue(int indexInGappedSequence)
Same as
getUngappedIndexOfThisOrPreviousResidue(int), but if the specified index is on a gap in the
gapped sequence, then the ungapped index of the next rather than the previous nongap
residue is returned. |
static int |
getUngappedIndexOfThisOrNextResidue(SequenceCharSequence sequence,
int indexInGappedSequence)
Gets the ungapped index corresponding to a gapped index.
|
int |
getUngappedIndexOfThisOrNextResidueTreatingEndGapsLikeInternalGaps(int indexInGappedSequence)
Same as
getUngappedIndexOfThisOrPreviousResidueTreatingEndGapsLikeInternalGaps(int), but if the specified index is on a gap in the
gapped sequence, then the ungapped index of the next rather than the previous nongap
residue is returned. |
int |
getUngappedIndexOfThisOrPreviousResidue(int indexInGappedSequence)
Calculates the index where the character gappedSequence.charAt(indexInGappedSequence)
would move if all gaps were stripped from gappedSequence.
|
static int |
getUngappedIndexOfThisOrPreviousResidue(SequenceCharSequence sequence,
int indexInGappedSequence)
Gets the ungapped index corresponding to a gapped index.
|
int |
getUngappedIndexOfThisOrPreviousResidueTreatingEndGapsLikeInternalGaps(int indexInGappedSequence)
Calculates the index where the character gappedSequence.charAt(indexInGappedSequence)
would move if all gaps were stripped from gappedSequence.
|
int |
getUngappedSequenceLength()
Returns the ungapped length of the sequence passed to the constructor
|
static Geneious.MajorVersion |
getVersionSupportStatic(XMLSerializable.VersionSupportType versionType)
Returns version support as defined by
XMLSerializable.OldVersionCompatible#getVersionSupport(com.biomatters.geneious.publicapi.documents.XMLSerializable.VersionSupportType). |
boolean |
isGap(int indexInGappedSequence)
Return true if the character at the specified gapped sequence index is an internal gap or end gap
Characters beyond the ends of the gapped sequence are assumed to be non-gaps
(for consistency with
getUngappedIndexOfThisOrPreviousResidue(int))
therefore isGap(x) where x<0 or x>=gappedSequenceLength will return false. |
boolean |
isInternalGap(int indexInGappedSequence)
Return true if the character at the specified gapped sequence index is an internal (non-end) gap.
|
org.jdom.Element |
toXML(Geneious.MajorVersion version,
String name)
Serializes this gap information (excluding the char sequence) to XML which may use
PluginDocument.FILE_DATA_ATTRIBUTE_NAME |
org.jdom.Element |
toXML(String name)
Serializes this gap information (excluding the char sequence) to XML which may use
PluginDocument.FILE_DATA_ATTRIBUTE_NAME |
public SequenceGapInformation(org.jdom.Element element,
SequenceCharSequence gappedCharSequence)
toXML(String).element - an element previously returned from toXML(String).gappedCharSequence - the gapped char sequence previously associated with the previously serialized SequenceGapInformation.public SequenceGapInformation(CharSequence gappedSequence)
gappedSequence - A CharSequence that contains gaps and for which we want to be able to translate between gapped and ungapped indices.public SequenceGapInformation(CharSequence gappedSequence, ProgressListener progressListener) throws DocumentOperationException.Canceled
gappedSequence - A CharSequence that contains gaps and for which we want to be able to translate between gapped and ungapped indices.progressListener - for reporting progress and cancellingDocumentOperationException.Canceled - if the progress listener requests we cancel.public static Geneious.MajorVersion getVersionSupportStatic(XMLSerializable.VersionSupportType versionType)
XMLSerializable.OldVersionCompatible#getVersionSupport(com.biomatters.geneious.publicapi.documents.XMLSerializable.VersionSupportType). All
SequenceGapInformation instances support version serialization in the same way, so this method is static.versionType - the type of version support to know about.XMLSerializable.OldVersionCompatible#getVersionSupport(com.biomatters.geneious.publicapi.documents.XMLSerializable.VersionSupportType)public org.jdom.Element toXML(String name) throws IOException
PluginDocument.FILE_DATA_ATTRIBUTE_NAMEname - the name of the element to retrnIOException - if it can't be serialized because we can't write to a local temporary filepublic org.jdom.Element toXML(Geneious.MajorVersion version, String name) throws IOException
PluginDocument.FILE_DATA_ATTRIBUTE_NAMEversion - the version of Geneious to serialize forname - the name of the element to retrnIOException - if it can't be serialized because we can't write to a local temporary filepublic static SequenceGapInformation forSequenceDocument(SequenceDocument sequence)
sequence - a SequenceDocument that contains gaps and for which we want to be able to translate between gapped and ungapped indices.public int getLeadingGapsLength()
SequenceCharSequence.getLeadingGapsLength()public int getTrailingGapsLength()
SequenceCharSequence.getTrailingGapsLength()public int getTrailingGapsStartIndex()
SequenceCharSequence.getTrailingGapsStartIndex()public int getUngappedIndexOfThisOrPreviousResidue(int indexInGappedSequence)
Example:
012345678901 old indices
-ABC--DE--f-
-101222344456 new indices
indexInGappedSequence - The 0-based index in the gapped sequence to convert to an index in the sequence without gapspublic int getUngappedIndexOfThisOrPreviousResidueTreatingEndGapsLikeInternalGaps(int indexInGappedSequence)
Example:
012345678901 old indices
-ABC--DE--f-
-101222344455 new indices
indexInGappedSequence - The 0-based index in the gapped sequence to convert to an index in the sequence without gapspublic boolean isGap(int indexInGappedSequence)
getUngappedIndexOfThisOrPreviousResidue(int))
therefore isGap(x) where x<0 or x>=gappedSequenceLength will return false.indexInGappedSequence - an index of a character in the gapped sequence.public boolean isInternalGap(int indexInGappedSequence)
getUngappedIndexOfThisOrPreviousResidue(int))
therefore isGap(x) where x<0 or x>=gappedSequenceLength will return false.indexInGappedSequence - an index of a character in the gapped sequence.public int getUngappedIndexOfThisOrNextResidueTreatingEndGapsLikeInternalGaps(int indexInGappedSequence)
getUngappedIndexOfThisOrPreviousResidueTreatingEndGapsLikeInternalGaps(int), but if the specified index is on a gap in the
gapped sequence, then the ungapped index of the next rather than the previous nongap
residue is returned.indexInGappedSequence - a 0-based index in the gapped sequencepublic int getUngappedIndexOfThisOrNextResidue(int indexInGappedSequence)
getUngappedIndexOfThisOrPreviousResidue(int), but if the specified index is on a gap in the
gapped sequence, then the ungapped index of the next rather than the previous nongap
residue is returned.indexInGappedSequence - a 0-based index in the gapped sequencepublic static int getUngappedIndexOfThisOrNextResidue(SequenceCharSequence sequence, int indexInGappedSequence)
getUngappedIndexOfThisOrNextResidue(int) that doesn't require the time and memory usage of constructing a reusable SequenceGapInformationsequence - the sequenceindexInGappedSequence - a 0-based index in the gapped sequencepublic static int getUngappedIndexOfThisOrPreviousResidue(SequenceCharSequence sequence, int indexInGappedSequence)
getUngappedIndexOfThisOrPreviousResidue(int) that doesn't require the time and memory usage of constructing a reusable SequenceGapInformationsequence - the sequenceindexInGappedSequence - a 0-based index in the gapped sequencepublic int getGappedIndex(int indexInUngappedSequence)
Translates an index in the ungapped sequence to the index of the corresponding nongap
character in the gappedSequence passed to the constructor.
It is permissible for indexInUngappedSequence to be < 0 or >= getUngappedSequenceLength().
For that case, it is assumed that gappedSequence is part of a larger sequence
that contains no gaps beyond gappedSequence's ends.
indexInUngappedSequence - An index in the ungapped sequence, i.e.SequenceUtilities.removeGaps(gappedSequence)indexInUngappedSequence'th nongap charcter in gappedSequence.public int getUngappedSequenceLength()
public int getGappedSequenceLength()
public List<SequenceAnnotation> adjustAnnotationsForGapRemoval(List<SequenceAnnotation> annotations)
adjustAnnotationsForGapInsertion(java.util.List)annotations - the original list of sequence annotationsadjustAnnotationsForGapInsertion(java.util.List)public List<SequenceAnnotation> adjustAnnotationsForGapInsertion(List<SequenceAnnotation> annotations)
adjustAnnotationsForGapRemoval(java.util.List)annotations - annotations to be adjusted for gap removaladjustAnnotationsForGapRemoval(java.util.List)