public final class SequenceAnnotationInterval extends Object
isBetweenBases())
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.| Modifier and Type | Class and Description |
|---|---|
static class |
SequenceAnnotationInterval.Direction
The direction of a sequence annotation interval.
|
| Constructor and Description |
|---|
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(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(SequenceAnnotationInterval interval)
Construct a SequenceAnnotationInterval that is identical to the given parameter.
|
SequenceAnnotationInterval(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 (see
SequenceAnnotationInterval.Direction.toArrowString()). |
| Modifier and Type | Method and Description |
|---|---|
SequenceAnnotationInterval |
adjustIntervalForGapInsertion(SequenceGapInformation sequenceGapInformation)
Creates a new interval adjusted to compensate for inserting gaps into the sequence covered by this interval.
|
SequenceAnnotationInterval |
adjustIntervalForGapRemoval(SequenceGapInformation sequenceGapInformation)
Creates a new interval adjusted to compensate for removing gaps from the sequence covered by this interval.
|
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
|
static SequenceAnnotationInterval |
between(int min,
int max)
Creates a zero-length SequenceAnnotationInterval between the given bases/residues with direction
SequenceAnnotationInterval.Direction.none |
boolean |
contains(int index)
Checks whether this interval includes the residue at the specified index.
|
boolean |
contains(SequenceAnnotationInterval anotherInterval)
Determines if this interval entirely covers another interval.
|
boolean |
containsOnPotentiallyCircularSequence(int index,
int sequenceLengthIfCircular)
Checks whether this interval includes the residue at the specified index in a potentially circular sequence.
|
boolean |
equals(Object obj) |
SequenceAnnotationInterval.Direction |
getDirection()
The direction in which this annotation interval is oriented.
|
int |
getFrom()
Start position of annotation.
|
int |
getLength()
The length (number of residues and gaps) of this interval.
|
int |
getMaximumIndex()
The largest sequence index covered by this interval, equivalent to Math.max(getFrom(), getTo()).
|
int |
getMinimumIndex()
The smallest sequence index covered by this interval, equivalent to Math.min(getFrom(), getTo()).
|
CharSequence |
getResidues(CharSequence residues,
int maximumResiduesToReturn,
boolean isNucleotideSequence)
Gets the residues covered by this interval for displaying to a user.
|
SequenceAnnotationInterval |
getReverse()
Returns the reverse of this interval, covering the same sequence residues but having
the opposite direction (as defined by
SequenceAnnotationInterval.Direction.reverse()). |
int |
getTo()
End position of annotation, usually (but not always) in the range 1 to the length of the sequence inclusive.
|
int |
hashCode() |
boolean |
intersectsWith(int minimumIndexOfOtherInterval,
int maximumIndexOfOtherIntervalInclusive)
|
boolean |
intersectsWith(SequenceAnnotationInterval anotherInterval)
Determines if this interval intersects with another interval.
|
boolean |
intersectsWithInCircularSequence(int minimumIndexOfOtherInterval,
int maximumIndexOfOtherIntervalInclusive,
int circularSequenceLength)
|
boolean |
intersectsWithInCircularSequence(SequenceAnnotationInterval anotherInterval,
int circularSequenceLength)
Determines if this interval intersects with another interval in a circular sequence.
|
boolean |
isBetweenBases()
Returns true if this interval represents a position between 2 bases, which is represented by the special case where
getMaximumIndex()==getMinimumIndex()-1. |
boolean |
isTruncatedAtMaximumIndex()
Checks whether the interval is incomplete and really finishes after the maximum index.
|
boolean |
isTruncatedAtMinimumIndex()
Checks whether the interval is incomplete and really beings before the minimum index.
|
static List<SequenceAnnotationInterval> |
merge(List<SequenceAnnotationInterval> _intervals)
Deprecated.
equivalent to calling
merge(intervals, true) |
static List<SequenceAnnotationInterval> |
merge(List<SequenceAnnotationInterval> _intervals,
boolean mergeIntervalsWithDifferentDirections)
Merges a list of intervals, i.e.
|
SequenceAnnotationInterval |
offsetBy(int offsetDistance)
Returns a new interval offset to the right by the given distance from this interval
|
SequenceAnnotationInterval |
reverse()
Deprecated.
use
getReverse() instead. |
String |
toString() |
String |
toString(boolean showDigitSeparator) |
String |
toString(boolean showDigitSeparator,
boolean formatNicely) |
SequenceAnnotationInterval |
truncate(int minIndex,
int maxIndex)
Truncates this interval to not extend below minIndex or above maxIndex.
|
public SequenceAnnotationInterval(String text) throws NumberFormatException
SequenceAnnotationInterval.Direction.toArrowString()).
This is the format returned from toString()text - A value of the format returned by toString()NumberFormatException - if the value isn't formatted correctly. This should only happen
if text is not a value of the format returned by toString().public SequenceAnnotationInterval(Interval interval)
interval - the interval to create an equivalent SequenceAnnotationInterval to.public SequenceAnnotationInterval(int from,
int to)
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.public SequenceAnnotationInterval(int minIndex,
int maxIndex,
SequenceAnnotationInterval.Direction direction)
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 intervalIllegalArgumentException - 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.NullPointerException - if direction is nullSequenceAnnotationInterval.Directionpublic SequenceAnnotationInterval(int minIndex,
int maxIndex,
SequenceAnnotationInterval.Direction direction,
boolean isTruncatedAtMinimumIndex,
boolean isTruncatedAtMaximumIndex)
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.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.NullPointerException - if direction is nullSequenceAnnotationInterval.Directionpublic SequenceAnnotationInterval(SequenceAnnotationInterval interval)
interval - interval to create a copy frompublic String toString()
toString in class ObjectisBetweenBases()) then the returned string will be of the form "Between 55 and 56".public String toString(boolean showDigitSeparator)
showDigitSeparator - true to separate every 3rd digit with commasisBetweenBases()) then the returned string will be of the form "Between 55 and 56".public String toString(boolean showDigitSeparator, boolean formatNicely)
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 by SequenceAnnotationInterval(String) because formats such as "2->1" could be interpreted as an annotation between bases 1 and 2 in older versions of Geneious.isBetweenBases()) then the returned string will be of the form "Between 55 and 56".public Interval asInterval()
public static SequenceAnnotationInterval between(int min, int max)
SequenceAnnotationInterval.Direction.nonemin - base/residue this interval comes directly aftermax - base/residue this interval comes directly beforeIllegalArgumentException - if max!=min+1 or min!=max+1isBetweenBases()@Deprecated public SequenceAnnotationInterval reverse()
getReverse() instead.SequenceAnnotationInterval.Direction.reverse()).public SequenceAnnotationInterval getReverse()
SequenceAnnotationInterval.Direction.reverse()).public int getFrom()
SequenceDocument.isCircular()),
any multiple of the sequence length may be added (or subtracted) from the position,
as long as at least one of getMinimumIndex(), 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 where getMinimumIndex() 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.public int getTo()
getFrom() for how circular sequences are handledpublic int getMinimumIndex()
public int getMaximumIndex()
public SequenceAnnotationInterval.Direction getDirection()
SequenceAnnotationInterval.Directionpublic boolean isTruncatedAtMinimumIndex()
public boolean isTruncatedAtMaximumIndex()
public boolean contains(int index)
SequenceDocument.isCircular())
then containsOnPotentiallyCircularSequence(int, int) should be used instead.index - An index in a sequence (In range 1 to sequence length.)public boolean containsOnPotentiallyCircularSequence(int index,
int sequenceLengthIfCircular)
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 sequencepublic boolean contains(SequenceAnnotationInterval anotherInterval)
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)
anotherInterval - another interval to check containment ofpublic boolean intersectsWith(SequenceAnnotationInterval anotherInterval)
anotherInterval - another interval to check intersection withpublic boolean intersectsWithInCircularSequence(SequenceAnnotationInterval anotherInterval, int circularSequenceLength)
anotherInterval - another interval to check intersection withcircularSequenceLength - the length of the circular sequence on which both intervals are present.public boolean intersectsWith(int minimumIndexOfOtherInterval,
int maximumIndexOfOtherIntervalInclusive)
intersectsWith(new SequenceAnnotationInterval(minimumIndexOfOtherInterval, maximumIndexOfOtherIntervalInclusive))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 withpublic boolean intersectsWithInCircularSequence(int minimumIndexOfOtherInterval,
int maximumIndexOfOtherIntervalInclusive,
int circularSequenceLength)
intersectsWithInCircularSequence(new SequenceAnnotationInterval(minimumIndexOfOtherInterval, maximumIndexOfOtherIntervalInclusive),circularSequenceLength)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.public boolean isBetweenBases()
getMaximumIndex()==getMinimumIndex()-1. The bases it is between are getMaximumIndex() (lower of the two) and getMinimumIndex() (upper of the two), both 1-basedgetMaximumIndex()==getMinimumIndex()-1. The bases it is between are getMaximumIndex() (lower of the two) and getMinimumIndex() (upper of the two), both 1-basedbetween(int, int)public int getLength()
getMaximumIndex() - getMinimumIndex()@Deprecated public static List<SequenceAnnotationInterval> merge(List<SequenceAnnotationInterval> _intervals)
merge(intervals, true)public static List<SequenceAnnotationInterval> merge(List<SequenceAnnotationInterval> _intervals, boolean mergeIntervalsWithDifferentDirections)
isTruncatedAtMinimumIndex() or isTruncatedAtMaximumIndex() even
if the original intervals were flagged in this way._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.public CharSequence getResidues(CharSequence residues, int maximumResiduesToReturn, boolean isNucleotideSequence)
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.public SequenceAnnotationInterval offsetBy(int offsetDistance)
offsetDistance - the distance fo offset to the rightpublic SequenceAnnotationInterval adjustIntervalForGapInsertion(SequenceGapInformation sequenceGapInformation)
adjustIntervalForGapRemoval(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.sequenceGapInformation - the gap information about the inserted gapsadjustIntervalForGapRemoval(com.biomatters.geneious.publicapi.implementations.SequenceGapInformation),
SequenceExtractionUtilities.adjustAnnotationsForGaps(CharSequence, java.util.List)public SequenceAnnotationInterval adjustIntervalForGapRemoval(SequenceGapInformation sequenceGapInformation)
adjustIntervalForGapInsertion(com.biomatters.geneious.publicapi.implementations.SequenceGapInformation).sequenceGapInformation - the gap information about the removed gapsadjustIntervalForGapInsertion(com.biomatters.geneious.publicapi.implementations.SequenceGapInformation),
SequenceExtractionUtilities.adjustAnnotationsForGapRemoval(CharSequence, java.util.List)public SequenceAnnotationInterval truncate(int minIndex, int maxIndex)
minIndex - the 1-based minimum indexmaxIndex - the 1-base maximum index