Class ResidueRange

java.lang.Object
org.biojava.nbio.structure.ResidueRange
Direct Known Subclasses:
ResidueRangeAndLength

public class ResidueRange extends Object
A chain, a start residue, and an end residue. Chain may be null when referencing a single-chain structure; for multi-chain structures omitting the chain is an error. Start and/or end may also be null, which is interpreted as the first and last residues in the chain, respectively.
Author:
dmyerstu
See Also:
  • Field Details

    • RANGE_REGEX

      public static final Pattern RANGE_REGEX
    • CHAIN_REGEX

      public static final Pattern CHAIN_REGEX
  • Constructor Details

  • Method Details

    • parse

      public static ResidueRange parse(String s)
      Parse the residue range from a string. Several formats are accepted:
      • chain.start-end
      • chain.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
      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:
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getChainId

      public String getChainId()
    • getEnd

      public ResidueNumber getEnd()
    • getStart

      public ResidueNumber getStart()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getResidue

      public ResidueNumber getResidue(int positionInRange, AtomPositionMap map)
      Returns the ResidueNumber that is at position positionInRange 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 every ResidueNumber in this ResidueRange. Stores the contents of map until the iterator is finished, so calling code should set the iterator to null if it did not finish.
    • multiIterator

      public static Iterator<ResidueNumber> multiIterator(AtomPositionMap map, ResidueRange... rrs)
      Returns a new Iterator over every ResidueNumber in the list of ResidueRanges. Stores the contents of map until the iterator is finished, so calling code should set the iterator to null if it did not finish.
    • multiIterator

      public static Iterator<ResidueNumber> multiIterator(AtomPositionMap map, List<? extends ResidueRange> rrs)
      Returns a new Iterator over every ResidueNumber in the list of ResidueRanges. Stores the contents of map until the iterator is finished, so calling code should set the iterator to null 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)