Class AtomContactSet
- All Implemented Interfaces:
Serializable,Iterable<AtomContact>
Contacts are keyed by the ordered pair of AtomIdentifiers of the 2 atoms, i.e. the
pair (a,b) and the pair (b,a) are 2 different keys. Thus look-ups (hasContact(Atom, Atom),
getContact(Atom, Atom)) must give the 2 atoms in the same order in which the contact was
calculated. The order produced by the calculation (Grid) is:
- for contacts within a single set of atoms (e.g. the intra-chain contacts of
StructureTools.getAtomsInContact(Chain, double)), the atom that comes first in the atom array is the first member of the pair - for contacts between 2 sets of atoms (e.g. the inter-chain contacts of
StructureTools.getAtomsInContact(Chain, Chain, double, boolean), or aStructureInterface), the atom belonging to the first set is the first member of the pair
Note that the order is not the order of PDB serials or of any other property of the atoms themselves: it is only the order in which the atoms were given to the calculation.
- Author:
- duarte_j
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAtomContactSet(double cutoff) AtomContactSet(double cutoff, int expectedSize) Creates an AtomContactSet sized to hold the given number of contacts, so that the underlying map doesn't have to be repeatedly resized and rehashed as contacts are added. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(AtomContact contact) Adds the given contact to this set, keyed by the ordered pair of its 2 atoms.voidaddAll(Collection<AtomContact> list) Adds all given contacts to this set, seeadd(AtomContact).getContact(Atom atom1, Atom atom2) Returns the contact between the 2 given atoms in the given order, or null if there is no such contact in this set.getContactsWithinDistance(double distance) Returns the list of contacts from this set that are within the given distance.booleanhasContact(Atom atom1, Atom atom2) Tells whether a contact exists between the 2 given atoms, in the given order.booleanhasContact(AtomIdentifier atomId1, AtomIdentifier atomId2) Tells whether a contact exists between the 2 given atom identifiers, in the given order, seehasContact(Atom, Atom).booleanhasContactsWithinDistance(double distance) Returns true if at least 1 contact from this set is within the given distance.iterator()intsize()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
AtomContactSet
public AtomContactSet(double cutoff) -
AtomContactSet
public AtomContactSet(double cutoff, int expectedSize) Creates an AtomContactSet sized to hold the given number of contacts, so that the underlying map doesn't have to be repeatedly resized and rehashed as contacts are added. Contact calculations produce hundreds of thousands of contacts for a large structure, where the repeated rehashing that growing from the default capacity entails is a significant part of the cost.- Parameters:
cutoff- the distance cutoffexpectedSize- the number of contacts expected to be added. Only affects performance: an over-estimate merely leaves the map larger than it needs to be.
-
-
Method Details
-
add
Adds the given contact to this set, keyed by the ordered pair of its 2 atoms. If a contact with the same ordered pair of atoms is already present it is replaced.- Parameters:
contact- the contact to add
-
addAll
Adds all given contacts to this set, seeadd(AtomContact).- Parameters:
list- the contacts to add
-
hasContact
Tells whether a contact exists between the 2 given atoms, in the given order.The 2 atoms have to be passed in the same order in which the contacts of this set were calculated, otherwise this returns false even if the 2 atoms are within the distance cutoff. See the class documentation for the ordering convention. If the order is not known, both orders have to be queried.
- Parameters:
atom1- the first atom of the pairatom2- the second atom of the pair- Returns:
- true if the 2 atoms are in contact in the given order, false otherwise
- See Also:
-
hasContact
Tells whether a contact exists between the 2 given atom identifiers, in the given order, seehasContact(Atom, Atom).- Parameters:
atomId1- the identifier of the first atom of the pairatomId2- the identifier of the second atom of the pair- Returns:
- true if the 2 atoms are in contact in the given order, false otherwise
-
getContact
Returns the contact between the 2 given atoms in the given order, or null if there is no such contact in this set.As in
hasContact(Atom, Atom)the order of the 2 atoms matters: they have to be passed in the same order in which the contacts of this set were calculated, otherwise null is returned even if the 2 atoms are within the distance cutoff. See the class documentation for the ordering convention.- Parameters:
atom1- the first atom of the pairatom2- the second atom of the pair- Returns:
- the contact between the 2 atoms in the given order, or null if there is none
-
size
public int size() -
iterator
- Specified by:
iteratorin interfaceIterable<AtomContact>
-
hasContactsWithinDistance
public boolean hasContactsWithinDistance(double distance) Returns true if at least 1 contact from this set is within the given distance. Note that if the distance given is larger than the distance cutoff used to calculate the contacts then nothing will be found.- Parameters:
distance-- Returns:
- Throws:
IllegalArgumentException- if given distance is larger than distance cutoff used for calculation of contacts
-
getContactsWithinDistance
Returns the list of contacts from this set that are within the given distance.- Parameters:
distance-- Returns:
- Throws:
IllegalArgumentException- if given distance is larger than distance cutoff used for calculation of contacts
-