A contact is pair of atoms that are on a certain distance from each other. The Library offers a few functions for finding such pairs of contacting atoms.
Function | Purpose |
CMMDBManager::SeekContacts | Finding contacts between vector of atoms and one
atom from the same vector.
|
CMMDBManager::SeekContacts | Finding contacts between atom and vector of atoms.
|
CMMDBManager::SeekContacts | Finding contacts between two vectors of atoms.
|
SortContacts | Sorting contacts.
|
CMMDBManager::MakeBricks | Bricking the coordinate space and assigning atoms to
the bricks
|
CMMDBManager::GetBrickDimension | Retrieving the number of bricks in X, Y and Z - directions
|
CMMDBManager::GetBrick | Retrieving a brick
|
CMMDBManager::GetBrickCoor | Getting coordinates of a brick that contains given atom
|
CMMDBManager::GetBrickCoor | Getting coordinates of a brick that contains given
point of space
|
CMMDBManager::RemoveBricks | Removing bricking
|
void CMMDBManager::SeekContacts ( |
PPCAtom Atom, |
The function attempts to find atoms in vector Atom, which are within the distance dist1<=r<=dist2 from atom Atom[atomNum], and which belong to residues separated by at least seqDist inter-residue spaces. Indices of contacting atoms (i.e. their positions in input array Atom) are returned in dynamically-allocated or static array contact.
NOTE 1: The number of inter-residue spaces between given residues is calculated from the actual number of residues between them, and not from the residues' sequence numbers.
NOTE 2: A coordinate file may be missing some residues or even whole parts of a chain. If this is the case and if the missing residue(s) fall within the sequence distance of seqDist from one of the contacting atoms, the algorithm assumes that not less than seqDist residues are missed. A gap of missing residues is assumed if C-alpha atoms of neighbouring residues are separated by more than 4 angstroms.
Looking for 5-angstrom contacts between C-alpha of 33rd residue of
chain A (which is not a residue with sequence number 33, but
merely a residue in 33rd position in the chain counted as
0..nResidues-1) and C-alpha atoms of all other
residues of the same chain that are at more than one residue position
apart from each other:
CMMDBManager MMDB;
int RC,selHnd,alen,ncontacts,i;
PPCAtom Atom;
PSContact contact;
char S1[100];
char S2[100];
// read coordinate file
RC = MMDB.ReadCoorFile ( CoorFileName );
if (RC) {
.. checking for errors
exit(1);
}
// select C-alpha atoms of chain A:
SelHnd = MMDB.NewSelection();
MMDB.Select ( selHnd,STYPE_ATOM,1,"A",
ANY_RES,"*",ANY_RES,"*",
"*","CA","C",SKEY_NEW );
MMDB.GetSelIndex ( selHnd,Atom,alen );
// get contacts:
contact = NULL; // prepare for dynamical allocation
ncontacts = 0; // of vector contact
MMDB.SeekContacts ( Atom, // vector of selected atoms
alen, // number of selected atoms
33, // 1st contacting atom nr 33
0.0, // minimal contact distance
5.0, // maximal contact distance
2, // sequence distance
contact, // vector of contacts
ncontacts, // number of contacts
0, // allocate contact dynamically
0 // zero group ID
);
// print contacts
if (ncontacts>0) {
printf ( " Found %i contacts:\n",ncontacts );
for (i=0;i<ncontacts;i++)
printf ( " %s <-> %s %10.4f A\n",
Atom[contact[i].id1]->GetAtomID(S1),
Atom[contact[i].id2]->GetAtomID(S2),
contact[i].dist );
} else
printf ( " No contact found.\n" );
// dispose array contact:
if (contact) delete contact;
void CMMDBManager::SeekContacts ( |
PCAtom A, |
The function attempts to find atoms in vector Atom, which are within the distance dist1<=r<=dist2 from atom A, and which belong to residues separated by at least seqDist inter-residue spaces. Indices of contacting atoms (i.e. their positions in input array Atom) are returned in dynamically-allocated or static array contact.
NOTE 1: The number of inter-residue spaces between given residues is calculated from the actual number of residues between them, and not from the residues' sequence numbers.
NOTE 2: A coordinate file may be missing some residues or even whole parts of a chain. If this is the case and if the missing residue(s) fall within the sequence distance of seqDist from one of the contacting atoms, the algorithm assumes that not less than seqDist residues are missed. A gap of missing residues is assumed if C-alpha atoms of neighbouring residues are separated by more than 4 angstroms.
Looking for 5-angstrom contacts between C-alpha atom of residue with
sequence number 34 of chain A and C-alpha atoms of all other
residues of the same chain that are at more than two residue position
apart from each other:
CMMDBManager MMDB;
int RC,selHnd,alen,ncontacts,i;
PCAtom A;
PPCAtom Atom;
PSContact contact;
char S1[100];
char S2[100];
// read coordinate file
RC = MMDB.ReadCoorFile ( CoorFileName );
if (RC) {
.. checking for errors
exit(1);
}
// select C-alpha atoms of chain A:
SelHnd = MMDB.NewSelection();
MMDB.Select ( selHnd,STYPE_ATOM,1,"A",
ANY_RES,"*",ANY_RES,"*",
"*","CA","C",SKEY_NEW );
MMDB.GetSelIndex ( selHnd,Atom,alen );
// get 1st contacting atom:
strcpy ( S1,"/1/A/34/CA[C]" );
A = MMDB.GetAtom ( S1 );
if (!A) {
// atom not found, identify the reason:
printf ( " Atom '%s' not found: ",S1 );
switch (MMDB.AtomExtrCode) {
case AEXTR_NoModel : printf ( "no such model.\n" ); break;
case AEXTR_NoChain : printf ( "no such chain in model.\n" ); break;
case AEXTR_NoResidue : printf ( "no such residue in chain\n" ); break;
case AEXTR_NoAtom : printf ( "no such atom in residue\n" ); break;
case AEXTR_WrongPath : printf ( "wrong atom ID syntax\n" ); break;
default : printf ( "unknown error code\n" );
}
exit(2);
}
// get contacts:
contact = NULL; // prepare for dynamical allocation
ncontacts = 0; // of vector contact
MMDB.SeekContacts ( A, // 1st contacting atom
Atom, // vector of selected atoms
alen, // number of selected atoms
0.0, // minimal contact distance
5.0, // maximal contact distance
2, // sequence distance
contact, // vector of contacts
ncontacts, // number of contacts
0, // allocate contact dynamically
0 // zero group ID
);
// print contacts
if (ncontacts>0) {
printf ( " Found %i contacts:\n",ncontacts );
for (i=0;i<ncontacts;i++)
printf ( " %s <-> %s %10.4f A\n",
S1,Atom[contact[i].id2]->GetAtomID(S2),
contact[i].dist );
} else
printf ( " No contact found.\n" );
// dispose array contact:
if (contact) delete contact;
void CMMDBManager::SeekContacts ( |
PPCAtom Atom1, |
The function attempts to find all such pairs of atoms {Atom1[i],Atom2[j]} that are within the distance dist1<=r<=dist2 from each other and belong to residues separated by at least seqDist inter-residue spaces. Indices of contacting atoms (i.e. their positions in input arrays Atom1 and Atom2) are returned in dynamically-allocated or static array contact.
The function employs the bricking algorithm and therefore considerably outperforms a trivial scheme of applying the atom-to-vector version of CMMDBManager::SeekContacts to all atoms of vector Atom1, if its length is greater than alen2=2.NOTE 1: The number of inter-residue spaces between given residues is calculated from the actual number of residues between them, and not from the residues' sequence numbers.
NOTE 2: A coordinate file may be missing some residues or even whole parts of a chain. If this is the case and if the missing residue(s) fall within the sequence distance of seqDist from one of the contacting atoms, the algorithm assumes that not less than seqDist residues are missed. A gap of missing residues is assumed if C-alpha atoms of neighbouring residues are separated by more than 4 angstroms.
Looking for 5-angstrom contacts between C-alpha atoms of chain A with
all sulphur atoms. Only contacts between not-the-same residues should
be considered.
CMMDBManager MMDB;
int RC,selHnd1,selHnd2,alen1,alen2,ncontacts,i;
PPCAtom Atom1,Atom2
PSContact contact;
char S1[100];
char S2[100];
// read coordinate file
RC = MMDB.ReadCoorFile ( CoorFileName );
if (RC) {
.. checking for errors
exit(1);
}
// select C-alpha atoms of chain A:
SelHnd1 = MMDB.NewSelection();
MMDB.Select ( selHnd1,STYPE_ATOM,1,"A",
ANY_RES,"*",ANY_RES,"*",
"*","CA","C",SKEY_NEW );
MMDB.GetSelIndex ( selHnd1,Atom1,alen1 );
// select all sulphurs:
SelHnd2 = MMDB.NewSelection();
MMDB.Select ( selHnd2,STYPE_ATOM,1,"*",
ANY_RES,"*",ANY_RES,"*",
"*","*","S",SKEY_NEW );
MMDB.GetSelIndex ( selHnd2,Atom2,alen2 );
// get contacts:
contact = NULL; // prepare for dynamical allocation
ncontacts = 0; // of vector contact
MMDB.SeekContacts ( Atom1, // 1st vector of atoms
alen1, // length of 1st vector
Atom2, // 2nd vector of atoms
alen2, // length of 2nd vector
0.0, // minimal contact distance
5.0, // maximal contact distance
2, // sequence distance
contact, // vector of contacts
ncontacts, // number of contacts
0, // allocate contact dynamically
NULL, // no transformation matrix
0 // zero group ID
);
// print contacts
if (ncontacts>0) {
printf ( " Found %i contacts:\n",ncontacts );
for (i=0;i<ncontacts;i++)
printf ( " %s <-> %s %10.4f A\n",
Atom1[contact[i].id1]->GetAtomID(S1),
Atom2[contact[i].id2]->GetAtomID(S2),
contact[i].dist );
} else
printf ( " No contact found.\n" );
// dispose array contact:
if (contact) delete contact;
void SortContacts ( |
PSContact contact, |
Value | Description | |
CNSORT_1INC | sorting by increasing index of 1st contacting atom contact[i].id1. | |
CNSORT_1DEC | sorting by decreasing index of 1st contacting atom contact[i].id1. | |
CNSORT_2INC | sorting by increasing index of 2nd contacting atom contact[i].id2. | |
CNSORT_2DEC | sorting by decreasing index of 2nd contacting atom contact[i].id2. | |
CNSORT_DINC | sorting by increasing contact distance contact[i].dist. | |
CNSORT_DDEC | sorting by decreasing contact distance contact[i].dist. |
The function sorts contacts found in the vector contact according to the sort mode specified by sortmode.
NOTE : This function is a standalone procedure rather than a member of CMMDBManager or any other class of the Library.
void CMMDBManager::MakeBricks ( |
PPCAtom atmvec, |
The function cuts the volume occupied by atoms given in vector atmvec into cubical bricks and for each brick it makes a list of atoms contained in the brick. The bricked volume is approximated as a minimal bar that contains all atoms covered by layer of width not less than Margin angstroms from all sides such that integer number of bricks of size BrickSize would fit on each face of it.
NOTE 1: The function removes previously existing bricking, if there was any.
NOTE 2: The contact-seeking function CMMDBManager::SeekContacts removes previously existing bricking.
Make bricking of all C-alphas and print atoms found in the brick of
33rd residue's C-alpha:
CMMDBManager MMDB;
int RC,selHnd,alen, nx,ny,nz, i;
PPCAtom Atom;
PCBrick Brick;
char S[100];
// read coordinate file
RC = MMDB.ReadCoorFile ( CoorFileName );
if (RC) {
.. checking for errors
exit(1);
}
// select C-alpha atoms of chain A:
SelHnd = MMDB.NewSelection();
MMDB.Select ( selHnd,STYPE_ATOM,1,"A",
ANY_RES,"*",ANY_RES,"*",
"*","CA","C",SKEY_NEW );
MMDB.GetSelIndex ( selHnd,Atom,alen );
MMDB.MakeBricks ( Atom,alen,6.0,6.0 );
MMDB.GetBrickCoor ( Atom[32], nx,ny,nz );
Brick = MMDB.GetBrick ( nx,ny,nz );
MMDB.GetBrickDimension ( nx,ny,nz );
printf ( " total bricks:\n"
" %5i on X\n"
" %5i on Y\n"
" %5i on Z\n",nx,ny,nz );
if (!Brick) {
printf ( " ***** no brick found: mmdb misfunction\n" );
} else {
printf ( " atoms found in brick (%i,%i,%i):\n\n"
" sel.No. Coordinate ID\n",nx,ny,nz );
for (i=0;i<Brick->nAtoms;i++)
printf ( " %4i %s\n",Brick->id[i],
Brick->Atom[i]->GetAtomID(S1) );
}
MMDB.RemoveBricks ();
MMDB.DeleteSelection ( selHnd );
void CMMDBManager::GetBrickDimension ( |
int & nxmax, |
The function returns number of bricks in X, Y and Z - directions created by function CMMDBManager::MakeBricks. The bricks are indexed like [0..nxmax-1, 0..nymax-1,0..nzmax-1]. The function returns zeros if bricks were not created.
PCBrick CMMDBManager::GetBrick ( |
int nx, |
The function returns pointer to the brick having indices of nx, ny,nz in X, Y and Z - directions, respectively. If such a brick does not exists, if indices are wrong (beyond the valid range) or if bricking was not done, the function returns NULL.
NOTE : The application must not dispose or alterate the bricks.
void CMMDBManager::GetBrickCoor ( |
PCAtom A, |
The function returns indices nx, ny and nz of the brick that contains atom A. If such a brick does not exist, or if bricking was not done, the function returns a negative value for nx.
void CMMDBManager::GetBrickCoor ( |
realtype x, |
The function returns indices nx, ny and nz of the brick that contains point (x,y,z) (given in angstroms). If such a brick does not exist, or if bricking was not done, the function returns a negative value for nx.
void CMMDBManager::RemoveBricks ( |
) |
The function removes bricks created by function CMMDBManager::MakeBricks. There is no particular need in calling this function other than freeing RAM: the bricks are disposed automatically when necessary.