⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 residue.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* * =========================================================================== * PRODUCTION $Log: residue.cpp,v $ * PRODUCTION Revision 1000.2  2004/06/01 18:29:02  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.34 * PRODUCTION * =========================================================================== *//*  $Id: residue.cpp,v 1000.2 2004/06/01 18:29:02 gouriano Exp $* ===========================================================================**                            PUBLIC DOMAIN NOTICE*               National Center for Biotechnology Information**  This software/database is a "United States Government Work" under the*  terms of the United States Copyright Act.  It was written as part of*  the author's official duties as a United States Government employee and*  thus cannot be copyrighted.  This software/database is freely available*  to the public for use. The National Library of Medicine and the U.S.*  Government have not placed any restriction on its use or reproduction.**  Although all reasonable efforts have been taken to ensure the accuracy*  and reliability of the software and data, the NLM and the U.S.*  Government do not and cannot warrant the performance or results that*  may be obtained by using this software or data. The NLM and the U.S.*  Government disclaim all warranties, express or implied, including*  warranties of performance, merchantability or fitness for any particular*  purpose.**  Please cite the author in any work or product based on this material.** ===========================================================================** Authors:  Paul Thiessen** File Description:*      Classes to hold residues** ===========================================================================*/#ifdef _MSC_VER#pragma warning(disable:4018)   // disable signed/unsigned mismatch warning in MSVC#endif#include <ncbi_pch.hpp>#include <corelib/ncbistd.hpp>#include <objects/mmdb1/Residue_graph_pntr.hpp>#include <objects/mmdb1/Biost_resid_graph_set_pntr.hpp>#include <objects/general/Dbtag.hpp>#include <objects/mmdb1/Biomol_descr.hpp>#include <objects/mmdb1/Intra_residue_bond.hpp>#include <objects/mmdb1/Atom.hpp>#include <objects/mmdb1/Biostruc_id.hpp>#include <objects/mmdb1/Residue_id.hpp>#include <objects/general/Object_id.hpp>#include <objects/mmdb1/Residue_graph_id.hpp>#include <objects/mmdb1/Atom_id.hpp>#include "residue.hpp"#include "bond.hpp"#include "structure_set.hpp"#include "coord_set.hpp"#include "atom_set.hpp"#include "molecule.hpp"#include "periodic_table.hpp"#include "opengl_renderer.hpp"#include "style_manager.hpp"#include "cn3d_colors.hpp"#include "show_hide_manager.hpp"#include "cn3d_tools.hpp"#include "messenger.hpp"USING_NCBI_SCOPE;USING_SCOPE(objects);BEGIN_SCOPE(Cn3D)const char Residue::NO_CODE = '?';const int Residue::NO_ALPHA_ID = -1;static Residue::eAtomClassification ClassifyAtom(const Residue *residue, const CAtom& atom){    if (!atom.IsSetIupac_code()) return Residue::eUnknownAtom;    string code = atom.GetIupac_code().front();    CAtom::EElement element = atom.GetElement();    if (residue->IsAminoAcid()) {        // amino acid C-alpha        if (element==CAtom::eElement_c && code==" CA ")            return Residue::eAlphaBackboneAtom;        // amino acid partial backbone        if (            (element==CAtom::eElement_c && code==" C  ") ||            (element==CAtom::eElement_n && code==" N  ")           )            return Residue::ePartialBackboneAtom;        // amino acid complete backbone (all backbone that's not part of "partial")        // including both GLY alpha hydrogens and terminal COOH and NH3+        if (            (element==CAtom::eElement_o &&                (code==" O  " || code==" OXT")) ||            (element==CAtom::eElement_h &&                (code==" H  " || code==" HA " || code=="1HA " || code=="2HA " ||                 code==" HXT" || code=="1H  " || code=="2H  " || code=="3H  "))            )            return Residue::eCompleteBackboneAtom;        // anything else is side chain        return Residue::eSideChainAtom;    } else if (residue->IsNucleotide()) {        // nucleic acid Phosphorus        if (element==CAtom::eElement_p && code==" P  ")            return Residue::eAlphaBackboneAtom;        // nucleic acid partial backbone        if (            (element==CAtom::eElement_c && (code==" C5*" || code==" C4*" || code==" C3*")) ||            (element==CAtom::eElement_o && (code==" O5*" || code==" O3*")) ||            (element==CAtom::eElement_h && (code==" H3T" || code==" H5T"))           )            return Residue::ePartialBackboneAtom;        // nucleic acid complete backbone (all backbone that's not part of "partial")        if (            (element==CAtom::eElement_o &&                (code==" O1P" || code==" O2P" || code==" O4*" || code==" O2*")) ||            (element==CAtom::eElement_c && (code==" C2*" || code==" C1*")) ||            (element==CAtom::eElement_h &&                (code=="1H5*" || code=="2H5*" || code==" H4*" || code==" H3*" ||                 code==" H2*" || code==" H1*" || code==" H1P" || code==" H2P" ||                 code==" HO2" || code=="1H2*" || code=="2H2*"))           )            return Residue::eCompleteBackboneAtom;        // anything else is side chain        return Residue::eSideChainAtom;    }    return Residue::eUnknownAtom;}Residue::Residue(StructureBase *parent,    const CResidue& residue, int moleculeID,    const ResidueGraphList& standardDictionary,    const ResidueGraphList& localDictionary) :    StructureBase(parent), code(NO_CODE), alphaID(NO_ALPHA_ID), type(eOther){    // get ID    id = residue.GetId().Get();    // get Residue name    if (residue.IsSetName()) namePDB = residue.GetName();    // get CResidue_graph*    // standard (of correct type) or local dictionary?    const ResidueGraphList *dictionary;    int graphID;    if (residue.GetResidue_graph().IsStandard() &&        residue.GetResidue_graph().GetStandard().GetBiostruc_residue_graph_set_id().IsOther_database() &&        residue.GetResidue_graph().GetStandard().GetBiostruc_residue_graph_set_id().GetOther_database().GetDb() == "Standard residue dictionary" &&        residue.GetResidue_graph().GetStandard().GetBiostruc_residue_graph_set_id().GetOther_database().GetTag().IsId() &&        residue.GetResidue_graph().GetStandard().GetBiostruc_residue_graph_set_id().GetOther_database().GetTag().GetId() == 1) {        dictionary = &standardDictionary;        graphID = residue.GetResidue_graph().GetStandard().GetResidue_graph_id().Get();    } else if (residue.GetResidue_graph().IsLocal()) {        dictionary = &localDictionary;        graphID = residue.GetResidue_graph().GetLocal().Get();    } else        ERRORMSG("confused by Molecule #?, Residue #" << id << "; can't find appropriate dictionary");    // look up appropriate Residue_graph    const CResidue_graph *residueGraph = NULL;    ResidueGraphList::const_iterator i, ie=dictionary->end();    for (i=dictionary->begin(); i!=ie; ++i) {        if (i->GetObject().GetId().Get() == graphID) {            residueGraph = i->GetPointer();            break;        }    }    if (!residueGraph)        ERRORMSG("confused by Molecule #?, Residue #" << id << "; can't find Residue-graph ID #" << graphID);    // get iupac-code if present - assume it's the first character of the first VisibleString    if (residueGraph->IsSetIupac_code())        code = residueGraph->GetIupac_code().front()[0];    // get residue-graph name if present    if (residueGraph->IsSetDescr()) {        CResidue_graph::TDescr::const_iterator j, je = residueGraph->GetDescr().end();        for (j=residueGraph->GetDescr().begin(); j!=je; ++j) {            if (j->GetObject().IsName()) {                nameGraph = j->GetObject().GetName();                break;            }        }    }    // get type    if (residueGraph->IsSetResidue_type())        type = static_cast<eType>(residueGraph->GetResidue_type());    // get StructureObject* parent    const StructureObject *object;    if (!GetParentOfType(&object) || object->coordSets.size() == 0) {        ERRORMSG("Residue()::Residue() : parent doesn't have any CoordSets");        return;    }    // get atom info    nAtomsWithAnyCoords = 0;    CResidue_graph::TAtoms::const_iterator a, ae = residueGraph->GetAtoms().end();    for (a=residueGraph->GetAtoms().begin(); a!=ae; ++a) {        const CAtom& atom = a->GetObject();        int atomID = atom.GetId().Get();        AtomInfo *info = new AtomInfo;        AtomPntr ap(moleculeID, id, atomID);        // see if this atom is present in any CoordSet        StructureObject::CoordSetList::const_iterator c, ce=object->coordSets.end();        for (c=object->coordSets.begin(); c!=ce; ++c) {            if (((*c)->atomSet->GetAtom(ap, true, true))) {                ++nAtomsWithAnyCoords;                break;            }        }        info->residue = this;        // get name if present        if (atom.IsSetName()) info->name = atom.GetName();        // get code if present - just use first one of the SEQUENCE        if (atom.IsSetIupac_code())            info->code = atom.GetIupac_code().front();        // get atomic number, assuming it's the integer value of the enumerated type        CAtom_Base::EElement atomicNumber = atom.GetElement();        info->atomicNumber = static_cast<int>(atomicNumber);        // get ionizable status        if (atom.IsSetIonizable_proton() &&            atom.GetIonizable_proton() == CAtom::eIonizable_proton_true)            info->isIonizableProton = true;        else            info->isIonizableProton = false;        // assign (unique) name        info->glName = parentSet->CreateName(this, atomID);        // classify atom        info->classification = ClassifyAtom(this, atom);        // store alphaID in residue        if (info->classification == eAlphaBackboneAtom) alphaID = atomID;        // add info to map        if (atomInfos.find(atom.GetId().Get()) != atomInfos.end())            ERRORMSG("Residue #" << id << ": confused by multiple atom IDs " << atom.GetId().Get());        atomInfos[atomID] = info;    }    // get bonds    CResidue_graph::TBonds::const_iterator b, be = residueGraph->GetBonds().end();    for (b=residueGraph->GetBonds().begin(); b!=be; ++b) {        int order = b->GetObject().IsSetBond_order() ?                b->GetObject().GetBond_order() : Bond::eUnknown;        const Bond *bond = MakeBond(this,            moleculeID, id, b->GetObject().GetAtom_id_1().Get(),            moleculeID, id, b->GetObject().GetAtom_id_2().Get(),            order);        if (bond) bonds.push_back(bond);    }}Residue::~Residue(void){    AtomInfoMap::iterator a, ae = atomInfos.end();    for (a=atomInfos.begin(); a!=ae; ++a) delete a->second;}// draw atom spheres and residue labels herebool Residue::Draw(const AtomSet *atomSet) const{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -