Package org.biojava.nbio.structure
Class ResidueRangeAndLength
- java.lang.Object
-
- org.biojava.nbio.structure.ResidueRange
-
- org.biojava.nbio.structure.ResidueRangeAndLength
-
- Direct Known Subclasses:
AugmentedResidueRange
public class ResidueRangeAndLength extends ResidueRange
A chain, a start residue, and an end residue. Also stores a length. Because of insertion codes, this length is not necessarilyend − start
.
-
-
Field Summary
-
Fields inherited from class org.biojava.nbio.structure.ResidueRange
CHAIN_REGEX, RANGE_REGEX
-
-
Constructor Summary
Constructors Constructor Description ResidueRangeAndLength(String chain, String start, String end, int length)
ResidueRangeAndLength(String chain, ResidueNumber start, ResidueNumber end, int length)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
calcLength(List<ResidueRangeAndLength> rrs)
Calculates the combined number of residues of the ResidueRanges inrrs
.boolean
equals(Object o)
int
getLength()
int
hashCode()
Iterator<ResidueNumber>
iterator(AtomPositionMap map)
Returns a new Iterator over everyResidueNumber
in this ResidueRange.static ResidueRangeAndLength
parse(String s, AtomPositionMap map)
Parses a residue range.static List<ResidueRangeAndLength>
parseMultiple(String s, AtomPositionMap map)
static List<ResidueRangeAndLength>
parseMultiple(List<String> ranges, AtomPositionMap map)
-
Methods inherited from class org.biojava.nbio.structure.ResidueRange
contains, getChainName, getEnd, getResidue, getStart, multiIterator, multiIterator, parse, parseMultiple, parseMultiple, toString, toString, toStrings
-
-
-
-
Constructor Detail
-
ResidueRangeAndLength
public ResidueRangeAndLength(String chain, ResidueNumber start, ResidueNumber end, int length)
-
ResidueRangeAndLength
public ResidueRangeAndLength(String chain, String start, String end, int length)
-
-
Method Detail
-
iterator
public Iterator<ResidueNumber> iterator(AtomPositionMap map)
Returns a new Iterator over everyResidueNumber
in this ResidueRange. Stores the contents ofmap
until the iterator is finished, so calling code should set the iterator tonull
if it did not finish.- Overrides:
iterator
in classResidueRange
-
calcLength
public static int calcLength(List<ResidueRangeAndLength> rrs)
Calculates the combined number of residues of the ResidueRanges inrrs
. Assumes no overlap. If two or more ranges cover the same residues, will over-count the union of the residues.- Parameters:
rrs
- A list of ResidueRanges- Returns:
- The combined length
- Throws:
IllegalArgumentException
- If thelength
of one or more ResidueRange is null- See Also:
getLength()
-
parse
public static ResidueRangeAndLength parse(String s, AtomPositionMap map)
Parses a residue range. The AtomPositionMap is used to calculate the length and fill in missing information, such as for whole chains ('A:'). Supports the special chain name '_' for single-chain structures. If residues are specified outside of the range given in the map, attempts to decrease the input range to valid values. In extreme cases where this process fails fails to find any valid indices, returns null. For a function which more conservatively represents the input range, without chain inference and error fixes, useResidueRange.parse(String)
.- Parameters:
s
- A string of the form chain_start-end. For example:A.5-100
.- Returns:
- The unique ResidueRange corresponding to
s
.
-
parseMultiple
public static List<ResidueRangeAndLength> parseMultiple(List<String> ranges, AtomPositionMap map)
-
parseMultiple
public static List<ResidueRangeAndLength> parseMultiple(String s, AtomPositionMap map)
- Parameters:
s
- A string of the form chain_start-end,chain_start-end, ... For example:A.5-100,R_110-190,Z_200-250
.- Returns:
- The unique ResidueRange corresponding to
s
.
-
getLength
public int getLength()
- Returns:
- The number of residues in this ResidueRange
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classResidueRange
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classResidueRange
-
-