コード例 #1
0
/**
 * Calculates thecontacts in a structure.
 *
 * @param structure The structure.
 * @param distanceCutoff The maximum distance between two residues from them to be considered in contact.
 * @param minSequenceDistance The minimum separation in the sequence for two residues to be considered contacts.
 * @param maxSequenceDistance The maximum separation in the sequence for two residues to be considered contacts.
 * @return The contacts present in the structure.
 */
ContactList* ContactTools::getContacts(Structure* structure, double distanceCutoff, int minSequenceDistance, int maxSequenceDistance)
{
    // Find all of the contacts within the cutoff distance.
    ContactList* contacts = new ContactList;
    int length = structure->getSize();
    int i, j, k, l;
    for (i=0; i<length-minSequenceDistance; i++)
    {
        int maxJ = length;
        if (maxSequenceDistance >= 0)
        {
            maxJ = i+maxSequenceDistance+1;
            if (maxJ > length) maxJ = length;
        }
            
        for (j=i+minSequenceDistance; j<maxJ; j++)
        {
            Residue* residue1 = structure->getResidue(i);
            Residue* residue2 = structure->getResidue(j);
            
            // If this is the same residue, process each atom pair only once.
            if (i == j)
            {
                for (k=0; k<residue1->getNumberAtoms()-1; k++)
                {
                    Atom* atom1 = residue1->getAtom(k);
                    for (l=k+1; l<residue2->getNumberAtoms(); l++)
                    {
                        Atom* atom2 = residue2->getAtom(l);
                        if (atom1->getDistanceTo(*atom2) <= distanceCutoff)
                        {
                            contacts->addContact(new Contact(structure, i, k, j, l));
                        }
                    }
                }
            }
            
            // Otherwise, process each atom pair.
            else
            {
                for (k=0; k<residue1->getNumberAtoms(); k++)
                {
                    Atom* atom1 = residue1->getAtom(k);
                    for (l=0; l<residue2->getNumberAtoms(); l++)
                    {
                        Atom* atom2 = residue2->getAtom(l);
                        if (atom1->getDistanceTo(*atom2) <= distanceCutoff)
                        {
                            contacts->addContact(new Contact(structure, i, k, j, l));
                        }
                    }
                }
            }
        }
    }
    
    return contacts;
}
コード例 #2
0
ContactList* ContactTools::getFormedNativeContacts(ContactList* nativeContacts, Structure* comparisonStructure, double maxDistanceDeviation)
{
    // Get the sequence distance for each formed native contact.
    ContactList* formedNativeContacts = new ContactList;
    int i;
    for (i=0; i<nativeContacts->getNumberContacts(); i++)
    {
        Contact* nativeContact = nativeContacts->getContact(i);
        double nativeDistance = nativeContact->getContactDistance();
        
        // Find the contact in the comparison structure.
        Contact* comparisonContact = new Contact(comparisonStructure, nativeContact->getResidue1Index(), nativeContact->getAtom1Index(), nativeContact->getResidue2Index(), nativeContact->getAtom2Index());
        double comparisonDistance = comparisonContact->getContactDistance();
        
        if (nativeDistance-maxDistanceDeviation <= comparisonDistance && comparisonDistance <= nativeDistance+maxDistanceDeviation)
        {
            formedNativeContacts->addContact(comparisonContact);
        }
        else
        {
            // Otherwise delete the contact.
            delete comparisonContact;
            comparisonContact = NULL;
        }
    }
    
    return formedNativeContacts;
}
コード例 #3
0
ファイル: ContactList.cpp プロジェクト: Eigenstate/vmd-python
ContactList* ContactList::getSubsetExcluding(ContactList* excludeList)
{
   int i, j;
    ContactList* newList = new ContactList();
    for (i=0; i<getNumberContacts(); i++)
    {
        bool include = true;
        Contact* contact = getContact(i);
        for (j=0; j<excludeList->getNumberContacts(); j++)
        {
            if (*contact == *excludeList->getContact(j))
            {
                include = false;
                break;
            }
        }
        
        // If this contact should be included, add it to the list.
        if (include)
        {
            newList->addContact(new Contact(*contact));
        }
    }
    
    return newList;
}