1 /* $Id: residue.hpp 103491 2007-05-04 17:18:18Z kazimird $ 2 * =========================================================================== 3 * 4 * PUBLIC DOMAIN NOTICE 5 * National Center for Biotechnology Information 6 * 7 * This software/database is a "United States Government Work" under the 8 * terms of the United States Copyright Act. It was written as part of 9 * the author's official duties as a United States Government employee and 10 * thus cannot be copyrighted. This software/database is freely available 11 * to the public for use. The National Library of Medicine and the U.S. 12 * Government have not placed any restriction on its use or reproduction. 13 * 14 * Although all reasonable efforts have been taken to ensure the accuracy 15 * and reliability of the software and data, the NLM and the U.S. 16 * Government do not and cannot warrant the performance or results that 17 * may be obtained by using this software or data. The NLM and the U.S. 18 * Government disclaim all warranties, express or implied, including 19 * warranties of performance, merchantability or fitness for any particular 20 * purpose. 21 * 22 * Please cite the author in any work or product based on this material. 23 * 24 * =========================================================================== 25 * 26 * Authors: Paul Thiessen 27 * 28 * File Description: 29 * Classes to hold residues 30 * 31 * =========================================================================== 32 */ 33 34 #ifndef CN3D_RESIDUE__HPP 35 #define CN3D_RESIDUE__HPP 36 37 #include <corelib/ncbistl.hpp> 38 39 #include <map> 40 #include <string> 41 42 #include <objects/mmdb1/Residue_graph.hpp> 43 #include <objects/mmdb1/Residue.hpp> 44 45 #include "structure_base.hpp" 46 47 BEGIN_SCOPE(Cn3D) 48 49 typedef std::list< ncbi::CRef< ncbi::objects::CResidue_graph > > ResidueGraphList; 50 51 // a Residue is a set of bonds that connect one residue of a larger Molecule. 52 // Its constructor is where most of the work of decoding the ASN1 graph is done, 53 // based on the standard and local residue dictionaries. Each Residue also holds 54 // information (AtomInfo) about the nature of the atoms it contains. 55 56 class Bond; 57 58 class Residue : public StructureBase 59 { 60 public: 61 Residue(StructureBase *parent, 62 const ncbi::objects::CResidue& residue, int moleculeID, 63 const ResidueGraphList& standardDictionary, 64 const ResidueGraphList& localDictionary, 65 int nResidues, int moleculeType); 66 ~Residue(void); 67 68 // public data 69 int id; 70 static const char NO_CODE; 71 char code; 72 std::string 73 nameGraph, // 'name' field from residue-graph dictionary 74 namePDB; // 'name' in Residue, supposed to correspond to PDB-assigned residue number 75 static const int NO_ALPHA_ID; 76 int alphaID; // ID of "alpha" atom (C-alpha or P) 77 78 // residue type 79 enum eType { 80 eDNA = ncbi::objects::CResidue_graph::eResidue_type_deoxyribonucleotide, 81 eRNA = ncbi::objects::CResidue_graph::eResidue_type_ribonucleotide, 82 eAminoAcid = ncbi::objects::CResidue_graph::eResidue_type_amino_acid, 83 eOther = ncbi::objects::CResidue_graph::eResidue_type_other 84 }; 85 eType type; 86 87 // atom type 88 enum eAtomClassification { 89 eSideChainAtom, 90 eAlphaBackboneAtom, // C-alpha or P 91 ePartialBackboneAtom, // for unbranched backbone trace 92 eCompleteBackboneAtom, // all backbone atoms 93 eUnknownAtom // anything that's not known to be of an amino acid or nucleotide 94 }; 95 96 typedef struct { 97 std::string name, code; 98 int atomicNumber; 99 eAtomClassification classification; 100 unsigned int glName; 101 const Residue *residue; // convenient way to go from atom->residue 102 bool isIonizableProton; 103 } AtomInfo; 104 105 typedef std::list < const Bond * > BondList; 106 BondList bonds; 107 108 // public methods HasCode(void) const109 bool HasCode(void) const { return (code != NO_CODE); } HasName(void) const110 bool HasName(void) const { return (!nameGraph.empty()); } IsNucleotide(void) const111 bool IsNucleotide(void) const { return (type == eDNA || type == eRNA); } IsAminoAcid(void) const112 bool IsAminoAcid(void) const { return (type == eAminoAcid); } 113 bool Draw(const AtomSet *atomSet) const; 114 115 typedef std::map < int , const AtomInfo * > AtomInfoMap; 116 117 private: 118 AtomInfoMap atomInfos; // mapped by Atom-id 119 int nAtomsWithAnyCoords; 120 121 public: 122 // # atoms in the graph for this residue NAtomsInGraph(void) const123 int NAtomsInGraph(void) const { return atomInfos.size(); } 124 // # atoms in this residue with real coordinates in any model NAtomsWithAnyCoords(void) const125 int NAtomsWithAnyCoords(void) const { return nAtomsWithAnyCoords; } 126 GetAtomInfos(void) const127 const AtomInfoMap& GetAtomInfos(void) const { return atomInfos; } GetAtomInfo(int aID) const128 const AtomInfo * GetAtomInfo(int aID) const 129 { 130 AtomInfoMap::const_iterator info=atomInfos.find(aID); 131 if (info != atomInfos.end()) return (*info).second; 132 ERR_POST(ncbi::Warning << "Residue #" << id << ": can't find atom #" << aID); 133 return NULL; 134 } 135 }; 136 137 END_SCOPE(Cn3D) 138 139 #endif // CN3D_RESIDUE__HPP 140