当前位置: 首页>>代码示例>>C++>>正文


C++ ContactList::addContact方法代码示例

本文整理汇总了C++中ContactList::addContact方法的典型用法代码示例。如果您正苦于以下问题:C++ ContactList::addContact方法的具体用法?C++ ContactList::addContact怎么用?C++ ContactList::addContact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContactList的用法示例。


在下文中一共展示了ContactList::addContact方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getContacts

/**
 * 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;
}
开发者ID:Eigenstate,项目名称:vmd-python,代码行数:67,代码来源:ContactTools.cpp

示例2: getFormedNativeContacts

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;
}
开发者ID:Eigenstate,项目名称:vmd-python,代码行数:28,代码来源:ContactTools.cpp

示例3: getSubsetExcluding

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;
}
开发者ID:Eigenstate,项目名称:vmd-python,代码行数:26,代码来源:ContactList.cpp


注:本文中的ContactList::addContact方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。