Package org.biojava.nbio.structure
Class ResidueRange
- java.lang.Object
-
- org.biojava.nbio.structure.ResidueRange
-
- Direct Known Subclasses:
ResidueRangeAndLength
public class ResidueRange extends Object
A chainName, a start residue, and an end residue. The chainName is matched toChain.getName()
, so for mmCIF files it indicates the authorId rather than the asymId. Chain may be null when referencing a single-chainName structure; for multi-chainName structures omitting the chainName is an error. Start and/or end may also be null, which is interpreted as the first and last residues in the chainName, respectively.- Author:
- dmyerstu
- See Also:
ResidueNumber
,ResidueRangeAndLength
-
-
Field Summary
Fields Modifier and Type Field Description static Pattern
CHAIN_REGEX
static Pattern
RANGE_REGEX
-
Constructor Summary
Constructors Constructor Description ResidueRange(String chainName, String start, String end)
ResidueRange(String chainName, ResidueNumber start, ResidueNumber end)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(ResidueNumber residueNumber, AtomPositionMap map)
boolean
equals(Object obj)
String
getChainName()
ResidueNumber
getEnd()
ResidueNumber
getResidue(int positionInRange, AtomPositionMap map)
Returns the ResidueNumber that is at positionpositionInRange
in this ResidueRange.ResidueNumber
getStart()
int
hashCode()
Iterator<ResidueNumber>
iterator(AtomPositionMap map)
Returns a new Iterator over everyResidueNumber
in this ResidueRange.static Iterator<ResidueNumber>
multiIterator(AtomPositionMap map, List<? extends ResidueRange> rrs)
Returns a new Iterator over everyResidueNumber
in the list of ResidueRanges.static Iterator<ResidueNumber>
multiIterator(AtomPositionMap map, ResidueRange... rrs)
Returns a new Iterator over everyResidueNumber
in the list of ResidueRanges.static ResidueRange
parse(String s)
Parse the residue range from a string.static List<ResidueRange>
parseMultiple(String s)
static List<ResidueRange>
parseMultiple(List<String> ranges)
String
toString()
static String
toString(List<? extends ResidueRange> ranges)
static List<String>
toStrings(List<? extends ResidueRange> ranges)
-
-
-
Field Detail
-
RANGE_REGEX
public static final Pattern RANGE_REGEX
-
CHAIN_REGEX
public static final Pattern CHAIN_REGEX
-
-
Constructor Detail
-
ResidueRange
public ResidueRange(String chainName, String start, String end)
-
ResidueRange
public ResidueRange(String chainName, ResidueNumber start, ResidueNumber end)
-
-
Method Detail
-
parse
public static ResidueRange parse(String s)
Parse the residue range from a string. Several formats are accepted:- chainName.start-end
- chainName.residue
- chain_start-end (for better filename compatibility)
Residues can be positive or negative and may include insertion codes. See
ResidueNumber.fromString(String)
.Examples:
A:5-100
A_5-100
A_-5
A:-12I-+12I
A:^-$
- Parameters:
s
- residue string to parse- Returns:
- The unique ResidueRange corresponding to
s
-
parseMultiple
public static List<ResidueRange> parseMultiple(String s)
- 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
. - See Also:
parse(String)
-
getChainName
public String getChainName()
-
getEnd
public ResidueNumber getEnd()
-
getStart
public ResidueNumber getStart()
-
getResidue
public ResidueNumber getResidue(int positionInRange, AtomPositionMap map)
Returns the ResidueNumber that is at positionpositionInRange
in this ResidueRange.- Returns:
- The ResidueNumber, or false if it does not exist or is not within this ResidueRange
-
contains
public boolean contains(ResidueNumber residueNumber, AtomPositionMap map)
- Returns:
- True if and only if
residueNumber
is within this ResidueRange
-
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.
-
multiIterator
public static Iterator<ResidueNumber> multiIterator(AtomPositionMap map, ResidueRange... rrs)
Returns a new Iterator over everyResidueNumber
in the list of ResidueRanges. Stores the contents ofmap
until the iterator is finished, so calling code should set the iterator tonull
if it did not finish.
-
multiIterator
public static Iterator<ResidueNumber> multiIterator(AtomPositionMap map, List<? extends ResidueRange> rrs)
Returns a new Iterator over everyResidueNumber
in the list of ResidueRanges. Stores the contents ofmap
until the iterator is finished, so calling code should set the iterator tonull
if it did not finish.
-
parseMultiple
public static List<ResidueRange> parseMultiple(List<String> ranges)
-
toStrings
public static List<String> toStrings(List<? extends ResidueRange> ranges)
-
toString
public static String toString(List<? extends ResidueRange> ranges)
-
-