Class SequenceAnnotationInterval
- java.lang.Object
-
- com.biomatters.geneious.publicapi.documents.sequence.SequenceAnnotationInterval
-
public final class SequenceAnnotationInterval extends java.lang.ObjectImmutable pair of integers with a direction, representing a directed range in the sequence annotation. Both ends are included in the range except in the special case of a 0 length interval between 2 bases (seeisBetweenBases()) Values are usually in range from 1 to n (sequence length) but may extend outside the sequence range in cases where the partial sequence it is on doesn't cover the full length of the annotation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSequenceAnnotationInterval.DirectionThe direction of a sequence annotation interval.
-
Constructor Summary
Constructors Constructor Description SequenceAnnotationInterval(int from, int to)Backwards compatibility constructor for an interval that starts at index from (inclusive) and ends at index to (inclusive).SequenceAnnotationInterval(int minIndex, int maxIndex, SequenceAnnotationInterval.Direction direction)SequenceAnnotationInterval(int minIndex, int maxIndex, SequenceAnnotationInterval.Direction direction, boolean isTruncatedAtMinimumIndex, boolean isTruncatedAtMaximumIndex)Main constructor.SequenceAnnotationInterval(int minIndex, int maxIndex, SequenceAnnotationInterval.Direction direction, boolean isTruncatedAtMinimumIndex, boolean isTruncatedAtMaximumIndex, int minAdjustmentWhenRestoringGaps, boolean truncatedAtMinimumIndexWhenRestoringGaps, int maxAdjustmentWhenRestoringGaps, boolean truncatedAtMaximumIndexWhenRestoringGaps)Main constructor.SequenceAnnotationInterval(SequenceAnnotationInterval interval)Construct a SequenceAnnotationInterval that is identical to the given parameter.SequenceAnnotationInterval(Interval interval)Creates a SequenceAnnotationInterval (which uses 1-based inclusive max co-ordinates) from an interval (which uses 0-based exclusive max co-ordinates)SequenceAnnotationInterval(java.lang.String text)constructs interval from the string representation of the form "[...]n,nnn D m,mmm[...]" where "n,nnn" is an integer with commas every three digits and "D" is a valid direction (seeSequenceAnnotationInterval.Direction.toArrowString()).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SequenceAnnotationIntervaladjustIntervalForGapInsertion(SequenceGapInformation sequenceGapInformation)Creates a new interval adjusted to compensate for inserting gaps into the sequence covered by this interval.SequenceAnnotationIntervaladjustIntervalForGapRemoval(SequenceGapInformation sequenceGapInformation)Creates a new interval adjusted to compensate for removing gaps from the sequence covered by this interval.IntervalasInterval()Returns this SequenceAnnotationInterval as an Interval, which uses 0-based exclusive max co-ordinates rather than 1-based inclusive max co-ordinates used by SequenceAnnotationIntervalstatic SequenceAnnotationIntervalbetween(int min, int max)Creates a zero-length SequenceAnnotationInterval between the given bases/residues with directionSequenceAnnotationInterval.Direction.nonestatic SequenceAnnotationIntervalbetween(int min, int max, int gapLengthToExpandToFill)Creates a zero-length SequenceAnnotationInterval between the given bases/residues with directionSequenceAnnotationInterval.Direction.nonesuch that if it appears in an alignment with a gap in this region of the given size, will expand to fill that gap.booleancontains(int index)Checks whether this interval includes the residue at the specified index.booleancontains(SequenceAnnotationInterval anotherInterval)Determines if this interval entirely covers another interval.booleancontainsOnPotentiallyCircularSequence(int index, int sequenceLengthIfCircular)Checks whether this interval includes the residue at the specified index in a potentially circular sequence.booleanequals(java.lang.Object obj)SequenceAnnotationInterval.DirectiongetDirection()The direction in which this annotation interval is oriented.intgetFrom()Start position of annotation.intgetLength()The length (number of residues and gaps) of this interval.intgetMaximumIndex()The largest sequence index covered by this interval, equivalent to Math.max(getFrom(), getTo()).intgetMinimumIndex()The smallest sequence index covered by this interval, equivalent to Math.min(getFrom(), getTo()).java.lang.CharSequencegetResidues(java.lang.CharSequence residues, int maximumResiduesToReturn, boolean isNucleotideSequence)Deprecated.New code should usegetResidues(CharSequence, int, boolean, boolean, boolean)java.lang.CharSequencegetResidues(java.lang.CharSequence residues, int maximumResiduesToReturn, boolean isNucleotideSequence, boolean isRna, boolean includeDots)Gets the residues covered by this interval for displaying to a user,SequenceAnnotationIntervalgetReverse()Returns the reverse of this interval, covering the same sequence residues but having the opposite direction (as defined bySequenceAnnotationInterval.Direction.reverse()).SequenceAnnotationIntervalgetReverseComplement(int sequenceLength)Returns the reverse complement of this interval, suitable for adding to a sequence that is the reverse complement of the sequence this interval is on.intgetTo()End position of annotation.inthashCode()booleanintersectsWith(int minimumIndexOfOtherInterval, int maximumIndexOfOtherIntervalInclusive)booleanintersectsWith(SequenceAnnotationInterval anotherInterval)Determines if this interval intersects with another interval.booleanintersectsWithInCircularSequence(int minimumIndexOfOtherInterval, int maximumIndexOfOtherIntervalInclusive, int circularSequenceLength)booleanintersectsWithInCircularSequence(SequenceAnnotationInterval anotherInterval, int circularSequenceLength)Determines if this interval intersects with another interval in a circular sequence.booleanisBetweenBases()Returns true if this interval represents a position between 2 bases, which is represented by the special case wheregetMaximumIndex()==getMinimumIndex()-1.booleanisTruncatedAtFinishIndex()booleanisTruncatedAtMaximumIndex()Checks whether the interval is incomplete and really finishes after the maximum index.booleanisTruncatedAtMinimumIndex()Checks whether the interval is incomplete and really beings before the minimum index.booleanisTruncatedAtStartIndex()static java.util.List<SequenceAnnotationInterval>merge(java.util.List<SequenceAnnotationInterval> _intervals)Deprecated.equivalent to callingmerge(intervals, true)static java.util.List<SequenceAnnotationInterval>merge(java.util.List<SequenceAnnotationInterval> _intervals, boolean mergeIntervalsWithDifferentDirections)Merges a list of intervals, i.e.SequenceAnnotationIntervaloffsetBy(int offsetDistance)Returns a new interval offset to the right by the given distance from this intervalSequenceAnnotationIntervalreverse()Deprecated.usegetReverse()instead.java.lang.StringtoString()java.lang.StringtoString(boolean showDigitSeparator)java.lang.StringtoString(boolean showDigitSeparator, boolean formatNicely)SequenceAnnotationIntervaltruncate(int minIndex, int maxIndex)Truncates (clips) this interval to not extend below minIndex or above maxIndex.SequenceAnnotationIntervalwithDirection(SequenceAnnotationInterval.Direction direction)
-
-
-
Constructor Detail
-
SequenceAnnotationInterval
public SequenceAnnotationInterval(java.lang.String text) throws java.lang.NumberFormatExceptionconstructs interval from the string representation of the form "[...]n,nnn D m,mmm[...]" where "n,nnn" is an integer with commas every three digits and "D" is a valid direction (seeSequenceAnnotationInterval.Direction.toArrowString()). This is the format returned fromtoString()- Parameters:
text- A value of the format returned bytoString()- Throws:
java.lang.NumberFormatException- if the value isn't formatted correctly. This should only happen if text is not a value of the format returned bytoString().
-
SequenceAnnotationInterval
public SequenceAnnotationInterval(Interval interval)
Creates a SequenceAnnotationInterval (which uses 1-based inclusive max co-ordinates) from an interval (which uses 0-based exclusive max co-ordinates)- Parameters:
interval- the interval to create an equivalent SequenceAnnotationInterval to.
-
SequenceAnnotationInterval
public SequenceAnnotationInterval(int from, int to)Backwards compatibility constructor for an interval that starts at index from (inclusive) and ends at index to (inclusive). The direction is leftToRight if from < end, and rightToLeft if from > end. For from==end, no guarantee is made what the direction of the resulting interval will be.- Parameters:
from- The start of the interval (inclusive), usually in range 1 to sequence length inclusive but it may extend outside this range in cases where the partial sequence it is on doesn't cover the full length of the annotation.to- The end of the interval (inclusive), usually in range 1 to sequence length inclusive but it may extend outside this range in cases where the partial sequence it is on doesn't cover the full length of the annotation.
-
SequenceAnnotationInterval
public SequenceAnnotationInterval(int minIndex, int maxIndex, SequenceAnnotationInterval.Direction direction)- Parameters:
minIndex- The minimum index (inclusive) spanned by this interval, usually in range 1 to sequence length inclusive but it may extend outside this range in cases where the partial sequence it is on doesn't cover the full length of the annotation.maxIndex- The maximum index (inclusive) spanned by this interval, usually in range 1 to sequence length inclusive but it may extend outside this range in cases where the partial sequence it is on doesn't cover the full length of the annotation.direction- The direction of the interval- Throws:
java.lang.IllegalArgumentException- if maxIndex < minIndex - 1. The special case of maxIndex==minIndex-1 represents an annotation the sits between the bases maxIndex and minIndex. As of 2008-2-29, Geneious has not been checked to see if all modules handle this situation correctly, so it is generally not a good idea to use these special annotations yet.java.lang.NullPointerException- if direction is null- See Also:
SequenceAnnotationInterval.Direction
-
SequenceAnnotationInterval
public SequenceAnnotationInterval(int minIndex, int maxIndex, SequenceAnnotationInterval.Direction direction, boolean isTruncatedAtMinimumIndex, boolean isTruncatedAtMaximumIndex)Main constructor.- Parameters:
minIndex- The minimum index (inclusive) spanned by this interval, indexed from 1maxIndex- The maximum index (inclusive) spanned by this interval, indexed from 1direction- The direction of the intervalisTruncatedAtMinimumIndex- true to indicate that the interval is incomplete and really begins before minIndex.isTruncatedAtMaximumIndex- true to indicate that the interval is incomplete and really finishes after maxIndex.- Throws:
java.lang.IllegalArgumentException- if maxIndex < minIndex - 1. The special case of maxIndex==minIndex-1 represents an annotation the sits between the bases maxIndex and minIndex. As of 2008-2-29, Geneious has not been checked to see if all modules handle this situation correctly, so it is generally not a good idea to use these special annotations yet.java.lang.NullPointerException- if direction is null- See Also:
SequenceAnnotationInterval.Direction
-
SequenceAnnotationInterval
public SequenceAnnotationInterval(int minIndex, int maxIndex, SequenceAnnotationInterval.Direction direction, boolean isTruncatedAtMinimumIndex, boolean isTruncatedAtMaximumIndex, int minAdjustmentWhenRestoringGaps, boolean truncatedAtMinimumIndexWhenRestoringGaps, int maxAdjustmentWhenRestoringGaps, boolean truncatedAtMaximumIndexWhenRestoringGaps)Main constructor.- Parameters:
minIndex- The minimum index (inclusive) spanned by this interval, indexed from 1maxIndex- The maximum index (inclusive) spanned by this interval, indexed from 1direction- The direction of the intervalisTruncatedAtMinimumIndex- true to indicate that the interval is incomplete and really begins before minIndex.isTruncatedAtMaximumIndex- true to indicate that the interval is incomplete and really finishes after maxIndex.minAdjustmentWhenRestoringGaps- the amount to add to minIndex when restoring gaps on this interval. used byadjustIntervalForGapInsertion(com.biomatters.geneious.publicapi.implementations.SequenceGapInformation)truncatedAtMinimumIndexWhenRestoringGaps- true if isTruncatedAtMinimumIndex should be set to true when restoring gaps on this interval. used byadjustIntervalForGapInsertion(com.biomatters.geneious.publicapi.implementations.SequenceGapInformation)maxAdjustmentWhenRestoringGaps- the amount to add to maxIndex when restoring gaps on this interval. used byadjustIntervalForGapInsertion(com.biomatters.geneious.publicapi.implementations.SequenceGapInformation)truncatedAtMaximumIndexWhenRestoringGaps- true if isTruncatedAtMaximumIndex should be set to true when restoring gaps on this interval. used byadjustIntervalForGapInsertion(com.biomatters.geneious.publicapi.implementations.SequenceGapInformation)- Throws:
java.lang.IllegalArgumentException- if maxIndex < minIndex - 1. The special case of maxIndex==minIndex-1 represents an annotation the sits between the bases maxIndex and minIndex. As of 2008-2-29, Geneious has not been checked to see if all modules handle this situation correctly, so it is generally not a good idea to use these special annotations yet.java.lang.NullPointerException- if direction is null- Since:
- API 4.1000 (Geneious 10.0.0)
- See Also:
SequenceAnnotationInterval.Direction
-
SequenceAnnotationInterval
public SequenceAnnotationInterval(SequenceAnnotationInterval interval)
Construct a SequenceAnnotationInterval that is identical to the given parameter. Because SequenceAnnotationInterval is an immutable class, it can be shared safely and it is never necessary to construct a copy of the same value. Therefore, use of this constructor is discouraged.- Parameters:
interval- interval to create a copy from
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of the form "[...]n,nnn D m,mmm[...]" where "n,nnn" is an integer with commas every three digits
and '...' is prepended or appended if the interval beings before the minimum index or ends after the maximum index
and D is an arrow in the format returned by Direction.toArrowString(). If this interval is between bases (see
isBetweenBases()) then the returned string will be of the form "Between 55 and 56".
-
toString
public java.lang.String toString(boolean showDigitSeparator)
- Parameters:
showDigitSeparator- true to separate every 3rd digit with commas- Returns:
- a string representation of the form "[...]n,nnn D m,mmm[...]" where "n,nnn" is an integer with commas every three digits
(if showDigitSeparator is true)
and '...' is prepended or appended if the interval beings before the minimum index or ends after the maximum index
and D is an arrow in the format returned by Direction.toArrowString(). If this interval is between bases (see
isBetweenBases()) then the returned string will be of the form "Between 55 and 56".
-
toString
public java.lang.String toString(boolean showDigitSeparator, boolean formatNicely)- Parameters:
showDigitSeparator- true to separate every 3rd digit with commasformatNicely- to display intervals in the reverse direction more nicely when the maximum and minimum indices are not identical. For example it would return "5->1" instead of the alternative format of "1 -< 5". Note that this nicer format is not guaranteed to be parsable bySequenceAnnotationInterval(String)because formats such as "2->1" could be interpreted as an annotation between bases 1 and 2 in older versions of Geneious.- Returns:
- a string representation of the form "[...]n,nnn D m,mmm[...]" where "n,nnn" is an integer with commas every three digits
(if showDigitSeparator is true)
and '...' is prepended or appended if the interval beings before the minimum index or ends after the maximum index
and D is an arrow in the format returned by Direction.toArrowString(). If this interval is between bases (see
isBetweenBases()) then the returned string will be of the form "Between 55 and 56".
-
asInterval
public Interval asInterval()
Returns this SequenceAnnotationInterval as an Interval, which uses 0-based exclusive max co-ordinates rather than 1-based inclusive max co-ordinates used by SequenceAnnotationInterval- Returns:
- this SequenceAnnotationInterval as an Interval
-
between
public static SequenceAnnotationInterval between(int min, int max)
Creates a zero-length SequenceAnnotationInterval between the given bases/residues with directionSequenceAnnotationInterval.Direction.none- Parameters:
min- base/residue this interval comes directly aftermax- base/residue this interval comes directly before- Returns:
- a zero-length SequenceAnnotationInterval between the given bases/residues
- Throws:
java.lang.IllegalArgumentException- if max!=min+1 or min!=max+1- Since:
- API 4.51 (Geneious 5.5.1)
- See Also:
isBetweenBases()
-
between
public static SequenceAnnotationInterval between(int min, int max, int gapLengthToExpandToFill)
Creates a zero-length SequenceAnnotationInterval between the given bases/residues with directionSequenceAnnotationInterval.Direction.nonesuch that if it appears in an alignment with a gap in this region of the given size, will expand to fill that gap.- Parameters:
min- base/residue this interval comes directly aftermax- base/residue this interval comes directly beforegapLengthToExpandToFill- if this annotation appears in an alignment with a gap in this region of the given size, will expand to fill that gap.- Returns:
- a zero-length SequenceAnnotationInterval between the given bases/residues
- Throws:
java.lang.IllegalArgumentException- if max!=min+1 or min!=max+1- Since:
- API 4.910 (Geneious 9.1.0)
- See Also:
isBetweenBases()
-
reverse
@Deprecated public SequenceAnnotationInterval reverse()
Deprecated.usegetReverse()instead.Returns the reverse of this interval, covering the same sequence residues but having the opposite direction (as defined bySequenceAnnotationInterval.Direction.reverse()).- Returns:
- the reverse of this interval
-
getReverse
public SequenceAnnotationInterval getReverse()
Returns the reverse of this interval, covering the same sequence residues but having the opposite direction (as defined bySequenceAnnotationInterval.Direction.reverse()). Truncation status of the interval ends are not changed. For example if this interval is truncated at its maximum index, the returned interval is also truncated at its maximum index.- Returns:
- the reverse of this interval
- Since:
- API 4.50 (Geneious 5.5.0)
- See Also:
getReverseComplement(int)
-
getReverseComplement
public SequenceAnnotationInterval getReverseComplement(int sequenceLength)
Returns the reverse complement of this interval, suitable for adding to a sequence that is the reverse complement of the sequence this interval is on. Truncation status of the maximum and minimum indices are swapped. For example if this interval is truncated at its maximum index, the returned interval is truncated at its minimum index.- Parameters:
sequenceLength- the length of the sequence this interval is on- Returns:
- the reverse complement of this interval
- Since:
- API 4.201900 (Geneious 2019.0.0)
- See Also:
getReverse()
-
getFrom
public int getFrom()
Start position of annotation. The start position will be greater thangetTo()for reverse directed annotations. See alsogetMinimumIndex()andgetMaximumIndex(). The start position is usually (but not always) in the range 1 to the length of the sequence inclusive. If the value is outside this range, the annotation is considered to start before (or after) the end of the sequence. In the case of circular sequences (seeSequenceDocument.isCircular()), any multiple of the sequence length may be added (or subtracted) from the position, as long as at least one ofgetMinimumIndex(),getMaximumIndex()is in the range [1, sequenceLength]. As this can still allow two different encodings of the range when it spans the end of the sequence, the recommended encoding is the one wheregetMinimumIndex()is in the range [1, sequenceLength]. For example, if the sequence length of a circular sequence is 10, an annotation from 5 to 13 goes from residue 5 to residue 3. An annotation from 7 to 22 goes around the sequence 1.5 times starting on residue 7 and finishing on residue 2.- Returns:
- start position of the annotation
- See Also:
getTo(),getMinimumIndex(),getMaximumIndex()
-
getTo
public int getTo()
End position of annotation. This position will be less thangetFrom()position for reverse directed annotations. See alsogetMinimumIndex()andgetMaximumIndex(). The to position is usually (but not always) in the range 1 to the length of the sequence inclusive. If the value is outside this range, the annotation is considered to start before (or after) the end of the sequence. SeegetFrom()for how circular sequences are handled- Returns:
- end position of the annotation
- See Also:
getFrom(),getMinimumIndex(),getMaximumIndex()
-
getMinimumIndex
public int getMinimumIndex()
The smallest sequence index covered by this interval, equivalent to Math.min(getFrom(), getTo()). Usually in range 1 to sequence length. If the value is outside this range, the annotation is considered to start before (or after) the end of the sequence.- Returns:
- The smallest sequence index covered by this interval, equivalent to Math.min(getFrom(), getTo()).
-
getMaximumIndex
public int getMaximumIndex()
The largest sequence index covered by this interval, equivalent to Math.max(getFrom(), getTo()). Usually in the range 1 to sequence length. If the value is outside this range, the annotation is considered to start before (or after) the end of the sequence.- Returns:
- The largest sequence index covered by this interval, equivalent to Math.max(getFrom(), getTo()).
-
getDirection
public SequenceAnnotationInterval.Direction getDirection()
The direction in which this annotation interval is oriented.- Returns:
- The direction in which this annotation interval is oriented.
- See Also:
SequenceAnnotationInterval.Direction
-
isTruncatedAtMinimumIndex
public boolean isTruncatedAtMinimumIndex()
Checks whether the interval is incomplete and really beings before the minimum index.- Returns:
- true to indicate that the interval is incomplete and really beings before the minimum index.
-
isTruncatedAtStartIndex
public boolean isTruncatedAtStartIndex()
- Returns:
- true if this annotations is truncated at the index returned from
getFrom() - Since:
- API 4.1110 (Geneious 11.1.0)
- See Also:
isTruncatedAtFinishIndex(),isTruncatedAtMinimumIndex(),isTruncatedAtMaximumIndex()
-
isTruncatedAtFinishIndex
public boolean isTruncatedAtFinishIndex()
- Returns:
- true if this annotations is truncated at the index returned from
getTo() - Since:
- API 4.1110 (Geneious 11.1.0)
- See Also:
isTruncatedAtStartIndex(),isTruncatedAtMinimumIndex(),isTruncatedAtMaximumIndex()
-
isTruncatedAtMaximumIndex
public boolean isTruncatedAtMaximumIndex()
Checks whether the interval is incomplete and really finishes after the maximum index.- Returns:
- true to indicate that the interval is incomplete and really finishes after the maximum index.
-
contains
public boolean contains(int index)
Checks whether this interval includes the residue at the specified index. If the sequence in question may potentially be a ciruclar sequence (seeSequenceDocument.isCircular()) thencontainsOnPotentiallyCircularSequence(int, int)should be used instead.- Parameters:
index- An index in a sequence (In range 1 to sequence length.)- Returns:
- true if this interval contains the specified index. i.e. minIndex <= index && index <= maxIndex
-
containsOnPotentiallyCircularSequence
public boolean containsOnPotentiallyCircularSequence(int index, int sequenceLengthIfCircular)Checks whether this interval includes the residue at the specified index in a potentially circular sequence.- Parameters:
index- An index in a sequence (In range 1 to sequence length.)sequenceLengthIfCircular- if the sequence this annotation corresponds to is circular, then this should be >0 to indicate the length of a circular sequence- Returns:
- true if this interval contains the specified index. i.e. minIndex <= index && index <= maxIndex
- Since:
- API 4.700 (Geneious 7.0.0)
-
contains
public boolean contains(SequenceAnnotationInterval anotherInterval)
Determines if this interval entirely covers another interval. Two intervals with the same boundaries are considered to contain each other.Intervals between two bases (the special case where
getMaximumIndex()==getMinimumIndex()-1) can only contain an identical interval. They are contained by an interval if they are within or on the edge of it.This method does not handle annotations on a circular sequence (where Intervals that extend outside the range "1->sequence length" inclusive are considered to wrap around to the other end of the sequence)
- Parameters:
anotherInterval- another interval to check containment of- Returns:
- true if this interval entirely contains the other interval.
- Since:
- Geneious API 4.40 (Geneious 5.4.0)
-
intersectsWith
public boolean intersectsWith(SequenceAnnotationInterval anotherInterval)
Determines if this interval intersects with another interval. i.e. they have at least 1 residue in common. Two intervals are also considered to intersect if one interval entirely covers the other interval.- Parameters:
anotherInterval- another interval to check intersection with- Returns:
- true if this interval intersects with the other interval.
-
intersectsWithInCircularSequence
public boolean intersectsWithInCircularSequence(SequenceAnnotationInterval anotherInterval, int circularSequenceLength)
Determines if this interval intersects with another interval in a circular sequence. i.e. they have at least 1 residue in common. Intervals that extend outside the range "1->sequence length" inclusive are considered to wrap around to the other end of the sequence. . Two intervals are also considered to intersect if one interval entirely covers the other interval.- Parameters:
anotherInterval- another interval to check intersection withcircularSequenceLength- the length of the circular sequence on which both intervals are present.- Returns:
- true if this interval intersects with the other interval.
-
intersectsWith
public boolean intersectsWith(int minimumIndexOfOtherInterval, int maximumIndexOfOtherIntervalInclusive)Equivalent to callingintersectsWith(new SequenceAnnotationInterval(minimumIndexOfOtherInterval, maximumIndexOfOtherIntervalInclusive))- Parameters:
minimumIndexOfOtherInterval- the 1-based minimum index of another interval to test for intersection withmaximumIndexOfOtherIntervalInclusive- the 1-based maximum index (inclusive) of another interval to test for intersection with- Returns:
- true if this interval intersects with the other interval.
-
intersectsWithInCircularSequence
public boolean intersectsWithInCircularSequence(int minimumIndexOfOtherInterval, int maximumIndexOfOtherIntervalInclusive, int circularSequenceLength)Equivalent to callingintersectsWithInCircularSequence(new SequenceAnnotationInterval(minimumIndexOfOtherInterval, maximumIndexOfOtherIntervalInclusive),circularSequenceLength)- Parameters:
minimumIndexOfOtherInterval- the 1-based minimum index of another interval to test for intersection withmaximumIndexOfOtherIntervalInclusive- the 1-based maximum index (inclusive) of another interval to test for intersection withcircularSequenceLength- the length of the circular sequence on which both intervals are present.- Returns:
- true if this interval intersects with the other interval.
-
isBetweenBases
public boolean isBetweenBases()
Returns true if this interval represents a position between 2 bases, which is represented by the special case wheregetMaximumIndex()==getMinimumIndex()-1. The bases it is between are getMaximumIndex() (lower of the two) and getMinimumIndex() (upper of the two), both 1-based- Returns:
- true if this interval represents a position between 2 bases, which is represented by the special case where
getMaximumIndex()==getMinimumIndex()-1. The bases it is between are getMaximumIndex() (lower of the two) and getMinimumIndex() (upper of the two), both 1-based - See Also:
between(int, int)
-
getLength
public int getLength()
The length (number of residues and gaps) of this interval.- Returns:
- The length of this interval, 1 +
getMaximumIndex()-getMinimumIndex()
-
merge
@Deprecated public static java.util.List<SequenceAnnotationInterval> merge(java.util.List<SequenceAnnotationInterval> _intervals)
Deprecated.equivalent to callingmerge(intervals, true)
-
merge
public static java.util.List<SequenceAnnotationInterval> merge(java.util.List<SequenceAnnotationInterval> _intervals, boolean mergeIntervalsWithDifferentDirections)
Merges a list of intervals, i.e. replaces sets of overlapping or (conditionally) directly adjacent intervals with a single interval. If merging intervals with different directions, to determine the direction of the resulting interval, the directions occurring in the overlapping set are considered in the order that they have been defined in the enum Direction. The first direction to have occurred is taken. This implies: - If all intervals in the overlapping set have the same direction, this direction is taken. - If there is a disagreement, preference is given to the direction that is the smallest according to Direction's natural order. The exact number of intervals for each direction does not matter; i.e. 10x right-to-left and 1x left-to-right yields left-to-right. Empty intervals are preserved (unless they are contained within other intervals). The returned merged intervals will not be flagged as eitherisTruncatedAtMinimumIndex()orisTruncatedAtMaximumIndex()even if the original intervals were flagged in this way.- Parameters:
_intervals- the intervals to mergemergeIntervalsWithDifferentDirections- true to allow merging of intervals in different directions. False to merge them anyway and use one of the directions as described above.- Returns:
- Merged set of intervals, ordered from left to right (increasing coordinates)
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getResidues
@Deprecated public java.lang.CharSequence getResidues(java.lang.CharSequence residues, int maximumResiduesToReturn, boolean isNucleotideSequence)Deprecated.New code should usegetResidues(CharSequence, int, boolean, boolean, boolean)Gets the residues covered by this interval for displaying to a user, truncating it with "..." on the ends if it is too long or if the interval extends outside the sequence bounds.- Parameters:
residues- the residues for the entire sequence.maximumResiduesToReturn- the maximum number of residue characters to include. Does not include the possible "..."sisNucleotideSequence- true if this is a nucleotide sequence. Used for deciding whether to reverse complement residues when a reverse annotation is encountered. For protein sequences, the residues displayed will always be in the forwards direction no matter what direction this interval has.- Returns:
- the residues covered by this interval, possibly truncated and with "..." appended or prepended
-
getResidues
public java.lang.CharSequence getResidues(java.lang.CharSequence residues, int maximumResiduesToReturn, boolean isNucleotideSequence, boolean isRna, boolean includeDots)Gets the residues covered by this interval for displaying to a user,- Parameters:
residues- the residues for the entire sequence.maximumResiduesToReturn- the maximum number of residue characters to include. Does not include the possible "..."sisNucleotideSequence- true if this is a nucleotide sequence. Used for deciding whether to reverse complement residues when a reverse annotation is encountered. For protein sequences, the residues displayed will always be in the forwards direction no matter what direction this interval has.isRna- Whether this sequence is RNA. This parameter will be ignored if isNucleotideSequence is false.SequenceUtilities.isRna(CharSequence, int)can be used to provide a value for this parameter.includeDots- Whether to append/prepend "..." on the result ends if it is too long or if the interval extends outside the sequence bounds.- Returns:
- the residues covered by this interval.
- Since:
- API 4.202200 (Geneious 2022.0.0)
-
offsetBy
public SequenceAnnotationInterval offsetBy(int offsetDistance)
Returns a new interval offset to the right by the given distance from this interval- Parameters:
offsetDistance- the distance fo offset to the right- Returns:
- a new interval offset to the right by the given distance from this interval
-
adjustIntervalForGapInsertion
public SequenceAnnotationInterval adjustIntervalForGapInsertion(SequenceGapInformation sequenceGapInformation)
Creates a new interval adjusted to compensate for inserting gaps into the sequence covered by this interval. Note, if this interval was created from a previous call toadjustIntervalForGapRemoval(com.biomatters.geneious.publicapi.implementations.SequenceGapInformation)then the original interval will be restored assuming the gaps around the ends of the interval are similar enough.- Parameters:
sequenceGapInformation- the gap information about the inserted gaps- Returns:
- a new interval adjusted to compensate for inserting gaps into the sequence covered by this interval.
- See Also:
adjustIntervalForGapRemoval(com.biomatters.geneious.publicapi.implementations.SequenceGapInformation),SequenceExtractionUtilities.adjustAnnotationsForGaps(CharSequence, java.util.List)
-
adjustIntervalForGapRemoval
public SequenceAnnotationInterval adjustIntervalForGapRemoval(SequenceGapInformation sequenceGapInformation)
Creates a new interval adjusted to compensate for removing gaps from the sequence covered by this interval. If the end points of the interval are on or adjacent to gapped regions of the sequence, then the returned interval will appear to have lost information about the original position. However, this original position information is stored internally such that it can be recovered from a call toadjustIntervalForGapInsertion(com.biomatters.geneious.publicapi.implementations.SequenceGapInformation).- Parameters:
sequenceGapInformation- the gap information about the removed gaps- Returns:
- a new interval adjusted to compensate for removing gaps from the sequence covered by this interval.
- See Also:
adjustIntervalForGapInsertion(com.biomatters.geneious.publicapi.implementations.SequenceGapInformation),SequenceExtractionUtilities.adjustAnnotationsForGapRemoval(CharSequence, java.util.List)
-
truncate
public SequenceAnnotationInterval truncate(int minIndex, int maxIndex)
Truncates (clips) this interval to not extend below minIndex or above maxIndex. If this interval lies entirely outside that range null is returned.- Parameters:
minIndex- the 1-based minimum indexmaxIndex- the 1-base maximum index- Returns:
- either this interval (if no truncation is necessary), a truncated interval, or null if this interval lies entirely outside the range.
- Since:
- Geneious API 4.14 (Geneious 5.1)
-
withDirection
public SequenceAnnotationInterval withDirection(SequenceAnnotationInterval.Direction direction)
- Returns:
- a new interval identical to this one, except with a potentially different direction
- Since:
- API 4.1000 (Geneious 10.0.0)
-
-