NCBI C++ ToolKit
molecule_identifier.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: molecule_identifier.hpp 97253 2022-06-29 17:35:29Z dzhang $
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 * Class to hold, and factory to generate, general
30 * (instance-independent) identifier for any molecule
31 *
32 * ===========================================================================
33 */
34 
35 #ifndef CN3D_MOLECULE_IDENTIFIER__HPP
36 #define CN3D_MOLECULE_IDENTIFIER__HPP
37 
38 #include <corelib/ncbistl.hpp>
39 #include <corelib/ncbistd.hpp>
40 #include <corelib/ncbimisc.hpp>
41 
43 
44 #include <list>
45 #include <string>
46 
48 
49 BEGIN_SCOPE(Cn3D)
50 
51 class Molecule;
52 class Sequence;
53 
55 {
56 public:
57  static const int VALUE_NOT_SET;
58  static const TGi GI_NOT_SET;
59 
60  // store all Seq-ids, and also mmdb info
61  typedef std::list < ncbi::CRef < ncbi::objects::CSeq_id > > SeqIdList;
65 
68 
69  // # residues (1 for non-biopolymers - hets, solvents)
70  unsigned int nResidues;
71 
72  // get title string based on identifiers present
73  std::string ToString(void) const;
74 
75  // create, or retrieve if known, an identifier for an entity
76  static const MoleculeIdentifier * GetIdentifier(const Molecule *molecule, const SeqIdList& ids);
77  static const MoleculeIdentifier * GetIdentifier(const Sequence *sequence, int mmdbID, const SeqIdList& ids);
78 
79  // get identifier for MMDB ID + molecule (NULL if not found)
80  static const MoleculeIdentifier * FindIdentifier(int mmdbID, int moleculeID);
81 
82  // test for Seq-id match
83  bool MatchesSeqId(const ncbi::objects::CSeq_id& sid) const;
84 
85  // clear identifier store (e.g. when a new file is loaded)
86  static void ClearIdentifiers(void);
87 
88  // does this molecule have structure?
89  bool HasStructure(void) const
90  {
91  return (
93  (pdbID.size() > 0 && !pdbChain.empty()));
94  }
95 
96  // comparison of identifiers (e.g. for sorting) - floats PDB's to top, then gi's in numerical order
97  static bool CompareIdentifiers(const MoleculeIdentifier *a, const MoleculeIdentifier *b);
98 
99  // get general label (e.g. an accession)
100  std::string GetLabel(void) const
101  {
103  if (seqIDs.size() > 0)
104  seqIDs.front()->GetLabel(&label, ncbi::objects::CSeq_id::eContent, 0);
105  return label;
106  }
107 
108 private:
109  // can't create one of these directly - must use GetIdentifier()
112  { }
113 
114  // get identifier based on Seq-id match
115  static MoleculeIdentifier * GetIdentifier(const SeqIdList& ids);
116 
117  // get identifier based on MMDB ID + molecule, for stuff like ligands that don't have Seq-id
119 
120  // save and fill out special id fields from Seq-ids
121  void AddFields(const SeqIdList& ids);
122 };
123 
124 END_SCOPE(Cn3D)
125 
126 #endif // CN3D_MOLECULE_IDENTIFIER__HPP
vector< CRef< CSeq_id > > SeqIdList
void AddFields(const SeqIdList &ids)
std::string GetLabel(void) const
static bool CompareIdentifiers(const MoleculeIdentifier *a, const MoleculeIdentifier *b)
bool MatchesSeqId(const ncbi::objects::CSeq_id &sid) const
static void ClearIdentifiers(void)
static const int VALUE_NOT_SET
bool HasStructure(void) const
std::string ToString(void) const
std::list< ncbi::CRef< ncbi::objects::CSeq_id > > SeqIdList
static const MoleculeIdentifier * GetIdentifier(const Molecule *molecule, const SeqIdList &ids)
static const TGi GI_NOT_SET
static const MoleculeIdentifier * FindIdentifier(int mmdbID, int moleculeID)
Include a standard set of the NCBI C++ Toolkit most basic headers.
string
Definition: cgiapp.hpp:690
@ eContent
Definition: feature.hpp:87
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
static const char label[]
USING_NCBI_SCOPE
unsigned int a
Definition: ncbi_localip.c:102
Miscellaneous common-use basic types and functionality.
The NCBI C++/STL use hints.
Modified on Fri Sep 20 14:58:25 2024 by modify_doxy.py rev. 669887