Package org.biojava.nbio.structure
Class AtomPositionMap
- java.lang.Object
 - 
- org.biojava.nbio.structure.AtomPositionMap
 
 
- 
public class AtomPositionMap extends Object
A map fromResidueNumbersto ATOM record positions in a PDB file.To use:
Atom[] atoms = new AtomCache().getAtoms("1w0p"); AtomPositionMap map = new AtomPositionMap(atoms); ResidueNumber start = new ResidueNumber("A", 100, null); ResidueNumber end = map.getEnd("A"); int pos = map.getPosition(start); int length = map.calcLength(start, end);Note: The getLength() methods were introduced in BioJava 4.0.0 to replace the calcLength methods. The new method returns the number of residues between two residues, inclusive, whereas the previous method returned 1 less than that.
- Author:
 - Douglas Myers-Turnbull
 
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAtomPositionMap.GroupMatcherUsed as a Predicate to indicate whether a particular Atom should be mapped 
- 
Field Summary
Fields Modifier and Type Field Description static AtomPositionMap.GroupMatcherAMINO_ACID_MATCHERMatches CA atoms of protein groupsstatic AtomPositionMap.GroupMatcherANYTHING_MATCHERMatches all atoms 
- 
Constructor Summary
Constructors Constructor Description AtomPositionMap(Atom[] atoms)Creates a new AtomPositionMap containing peptide alpha-carbon atomsAtomPositionMap(Atom[] atoms, AtomPositionMap.GroupMatcher matcher)Creates a new AtomPositionMap containing only atoms matched bymatcher.AtomPositionMap(Structure s)Creates a new AtomPositionMap containing representative atoms from a structure. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResidueNumbergetFirst()ResidueNumbergetFirst(String chainId)ResidueNumbergetLast()ResidueNumbergetLast(String chainId)intgetLength(int positionA, int positionB, String startingChain)Calculates the number of residues of the specified chain in a given range, inclusive.intgetLength(ResidueNumber start, ResidueNumber end)Calculates the number of atoms between two ResidueNumbers, inclusive.intgetLengthDirectional(int positionStart, int positionEnd, String startingChain)Calculates the number of residues of the specified chain in a given range.intgetLengthDirectional(ResidueNumber start, ResidueNumber end)Calculates the number of atoms between two ResidueNumbers, inclusive.NavigableMap<ResidueNumber,Integer>getNavMap()IntegergetPosition(ResidueNumber residueNumber)Gets the 0-based index of residueNumber to the matched atomsList<ResidueRangeAndLength>getRanges()Returns a list ofResidueRangescorresponding to this entire AtomPositionMap.ResidueRangeAndLengthtrimToValidResidues(ResidueRange rr)Trims a residue range so that both endpoints are contained in this map. 
 - 
 
- 
- 
Field Detail
- 
AMINO_ACID_MATCHER
public static final AtomPositionMap.GroupMatcher AMINO_ACID_MATCHER
Matches CA atoms of protein groups 
- 
ANYTHING_MATCHER
public static final AtomPositionMap.GroupMatcher ANYTHING_MATCHER
Matches all atoms 
 - 
 
- 
Constructor Detail
- 
AtomPositionMap
public AtomPositionMap(Atom[] atoms)
Creates a new AtomPositionMap containing peptide alpha-carbon atoms- Parameters:
 atoms-
 
- 
AtomPositionMap
public AtomPositionMap(Atom[] atoms, AtomPositionMap.GroupMatcher matcher)
Creates a new AtomPositionMap containing only atoms matched bymatcher. If multiple atoms are present from a group, the first atom encountered will be used.- Parameters:
 atoms-
 
- 
AtomPositionMap
public AtomPositionMap(Structure s)
Creates a new AtomPositionMap containing representative atoms from a structure.- Parameters:
 s-
 
 - 
 
- 
Method Detail
- 
getLength
public int getLength(int positionA, int positionB, String startingChain)
Calculates the number of residues of the specified chain in a given range, inclusive.- Parameters:
 positionA- index of the first atom to countpositionB- index of the last atom to countstartingChain- Case-sensitive chain- Returns:
 - The number of atoms between A and B inclusive belonging to the given chain
 
 
- 
getLengthDirectional
public int getLengthDirectional(int positionStart, int positionEnd, String startingChain)
Calculates the number of residues of the specified chain in a given range. Will return a negative value if the start is past the end.- Parameters:
 positionStart- index of the first atom to countpositionEnd- index of the last atom to countstartingChain- Case-sensitive chain- Returns:
 - The number of atoms from A to B inclusive belonging to the given chain
 
 
- 
getLength
public int getLength(ResidueNumber start, ResidueNumber end)
Calculates the number of atoms between two ResidueNumbers, inclusive. Both residues must belong to the same chain.- Parameters:
 start- First residueend- Last residue- Returns:
 - The number of atoms from A to B inclusive
 - Throws:
 IllegalArgumentException- if start and end are on different chains, or if either of the residues doesn't exist
 
- 
getLengthDirectional
public int getLengthDirectional(ResidueNumber start, ResidueNumber end)
Calculates the number of atoms between two ResidueNumbers, inclusive. Both residues must belong to the same chain. Will return a negative value if the start is past the end.- Parameters:
 start- First residueend- Last residue- Returns:
 - The number of atoms from A to B inclusive
 - Throws:
 IllegalArgumentException- if start and end are on different chains, or if either of the residues doesn't exist
 
- 
getNavMap
public NavigableMap<ResidueNumber,Integer> getNavMap()
 
- 
getPosition
public Integer getPosition(ResidueNumber residueNumber)
Gets the 0-based index of residueNumber to the matched atoms- Parameters:
 residueNumber-- Returns:
 - The position of the ATOM record in the PDB file corresponding to
 the 
residueNumber, or null if the residueNumber was not found 
 
- 
getFirst
public ResidueNumber getFirst(String chainId)
- Parameters:
 chainId-- Returns:
 - The first 
ResidueNumberof the specified chain (the one highest down in the PDB file) 
 
- 
getLast
public ResidueNumber getLast(String chainId)
- Parameters:
 chainId-- Returns:
 - The last 
ResidueNumberof the specified chain (the one farthest down in the PDB file) 
 
- 
getFirst
public ResidueNumber getFirst()
- Returns:
 - The first 
ResidueNumberof any chain (the one farthest down in the PDB file) 
 
- 
getLast
public ResidueNumber getLast()
- Returns:
 - The last 
ResidueNumberof any chain (the one farthest down in the PDB file) 
 
- 
getRanges
public List<ResidueRangeAndLength> getRanges()
Returns a list ofResidueRangescorresponding to this entire AtomPositionMap. 
- 
trimToValidResidues
public ResidueRangeAndLength trimToValidResidues(ResidueRange rr)
Trims a residue range so that both endpoints are contained in this map.- Parameters:
 rr- residue range- Returns:
 - residue range and length
 
 
 - 
 
 -