ccp4srs  Version 1.0.0
ccp4srs_monomer.h
Go to the documentation of this file.
1 // $Id: ccp4srs_monomer.h $
2 // =================================================================
3 //
4 // CCP4 SRS Library: Storage, Retrieval and Search support for
5 // CCP4 ligand data.
6 //
7 // Copyright (C) Eugene Krissinel 2010-2013.
8 //
9 // This library is free software: you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License version 3, modified in accordance with the provisions
12 // of the license to address the requirements of UK law.
13 //
14 // You should have received a copy of the modified GNU Lesser
15 // General Public License along with this library. If not, copies
16 // may be downloaded from http://www.ccp4.ac.uk/ccp4license.php
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU Lesser General Public License for more details.
22 //
23 // =================================================================
24 //
25 // 03.02.14 <-- Date of Last Modification.
26 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 // -----------------------------------------------------------------
28 //
29 // **** Module : ccp4srs_monomer <interface>
30 // ~~~~~~~~~
31 // **** Classes : ccp4srs::Monomer - monomer structure
32 // ~~~~~~~~~
33 //
34 // (C) E. Krissinel 2010-2014
35 //
36 // =================================================================
37 //
38 
39 #ifndef CCP4SRS_MONOMER_H
40 #define CCP4SRS_MONOMER_H
41 
42 #include "mmdb2/mmdb_mmcif_.h"
43 #include "mmdb2/mmdb_math_graph.h"
44 
45 #include "ccp4srs_entry.h"
46 #include "ccp4srs_bond.h"
47 #include "ccp4srs_angle.h"
48 #include "ccp4srs_torsion.h"
49 #include "ccp4srs_chicenter.h"
50 #include "ccp4srs_plane.h"
51 #include "ccp4srs_tree.h"
52 #include "ccp4srs_smiles.h"
53 #include "ccp4srs_types.h"
54 
55 namespace ccp4srs {
56 
57  DefineClass(Monomer);
58 
59  class Monomer : public Entry {
60 
61  public:
62  Monomer();
63  ~Monomer();
64 
65  virtual int type() { return Entry::Monomer; }
66 
67  void reset(); // deletes all data
68 
69  inline mmdb::cpstr ID () { return monID; }
70  inline mmdb::cpstr oldID() { return oldMonID; }
71  void setOldID ( mmdb::cpstr oldID );
72 
73  mmdb::cpstr chem_name ();
74  mmdb::cpstr chem_type ();
75  mmdb::cpstr chem_formula();
76 
77  inline int n_atoms () { return atoms .numberOf(); }
78  inline int n_bonds () { return bonds .numberOf(); }
79  inline int n_angles () { return angles .numberOf(); }
80  inline int n_torsions () { return torsions .numberOf(); }
81  inline int n_chicenters() { return chicenters.numberOf(); }
82  inline int n_planes () { return planes .numberOf(); }
83 
84  inline PAtom atom ( int n ) { return atoms .at(n); }
85  inline PBond bond ( int n ) { return bonds .at(n); }
86  inline PAngle angle ( int n ) { return angles .at(n); }
87  inline PPlane plane ( int n ) { return planes .at(n); }
88  inline PTree tree () { return &struct_tree; }
89  inline PTorsion torsion ( int n )
90  { return torsions.at(n); }
91  inline PChiCenter chicenter ( int n )
92  { return chicenters.at(n); }
93 
94  inline void add ( PAtom atom ) { atoms .add(atom ); }
95  inline void add ( PBond bond ) { bonds .add(bond ); }
96  inline void add ( PAngle angle ) { angles.add(angle); }
97  inline void add ( PPlane plane ) { planes.add(plane); }
98  inline void add ( PTree stree ) { struct_tree.copy(stree); }
99  inline void add ( PTorsion torsion )
100  { torsions.add(torsion); }
101  inline void add ( PChiCenter chicenter )
102  { chicenters.add(chicenter); }
103 
104  inline Container<Atom> *get_atoms () { return &atoms; }
105  inline Container<Bond> *get_bonds () { return &bonds; }
106  inline Container<Angle> *get_angles () { return &angles; }
107  inline Container<Torsion> *get_torsions() { return &torsions; }
109  inline Container<Plane> *get_planes () { return &planes; }
110  inline Tree *get_tree() { return &struct_tree; }
111 
112  inline Smiles *getACDLabs() { return &ACDLabs; }
113  inline Smiles *getCACTVS () { return &CACTVS; }
114  inline Smiles *getOpenEye() { return &OpenEye; }
115  inline Smiles *getInChI () { return &InChI; }
116 
117  int atom_no ( mmdb::cpstr aname );
118  int get_bound ( int atomNo, mmdb::cpstr elem, int serNo );
119  int get_bound ( int atomNo, int n );
120  int get_bound ( mmdb::cpstr aname, int n );
121 
122  CCP4SRS_RC addHydrogens ( mmdb::PResidue R );
123 
124  // getAtomNameMatch(..) returns anmatch[i], i=0..nAtoms-1, equal
125  // to j such that name(Atom[i])==name(A[j]). Note that atom names
126  // are similarly aligned and space-padded in MMDB, but not in SRS.
127  // However, the proper alignment is done on fly. If ith atom in
128  // the structue is not found in A, anmatch[i] is set -1.
129  // If array A contains atoms in different alternative
130  // conformations, the the value of altLoc is interpreted as
131  // follows:
132  // NULL - the highest occupancy atom will be taken
133  // if all occupancies are equal then atom with
134  // first altLoc taken
135  // other - atoms with given altLoc are taken. If such
136  // altLoc is not found, the function does as if
137  // NULL value for altLoc is given.
138  // A clean PDB file is anticipated, so that atoms with
139  // alternative conformations are grouped together.
140  // It is Ok to have NULL pointers in A.
141  void getAtomNameMatch ( mmdb::PPAtom A, int nat, mmdb::pstr altLoc,
142  mmdb::ivector anmatch );
143 
153  void getAtomNameMatch ( Container<Atom> *A, mmdb::ivector anmatch );
154 
155  mmdb::math::PGraph getGraph ( int *retCode );
156 
157  void getLeavingAtoms ( int & nLeavingAtoms,
158  mmdb::ivector & leavingAtom,
159  mmdb::ivector & bondedAtom );
160 
161  // Return code:
162  // CCP4SRS_Ok success
163  int readFromCIF ( mmdb::mmcif::PData mmCIFData,
164  mmdb::pstr error_desc = NULL );
165 
166  mmdb::mmcif::PData makeCIF(); // return to be deleted by application
167 
168  // service functions
169  void merge ( PMonomer monomer );
170  void check_ccp4_coordinates();
171 
172  protected:
173  mmdb::ResName monID;
174  mmdb::ResName oldMonID;
175  mmdb::pstr monName;
176  mmdb::pstr monType;
177  mmdb::pstr monFormula;
189 
190  void Init();
191 
192  void readMonIDFromCIF ( mmdb::mmcif::PLoop loop );
193  void readMonIDFromCIF ( mmdb::mmcif::PStruct mmCIFStruct );
194  int readFromCIF_ccp4 ( mmdb::mmcif::PData mmCIFData,
195  mmdb::pstr error_desc );
196  int readFromCIF_rcsb ( mmdb::mmcif::PData mmCIFData,
197  mmdb::pstr error_desc );
198 
199  virtual void write_mem ( PMemIO memIO, int version );
200  virtual bool read_mem ( PMemIO memIO, int version,
201  bool * Ok = NULL );
202 
203  };
204 
205 } // namespace ccp4srs
206 
207 #endif // CCP4SRS_MONOMER_H
Container< Angle > angles
Definition: ccp4srs_monomer.h:180
void add(PChiCenter chicenter)
Definition: ccp4srs_monomer.h:101
void getLeavingAtoms(int &nLeavingAtoms, mmdb::ivector &leavingAtom, mmdb::ivector &bondedAtom)
Definition: ccp4srs_monomer.cpp:102
int readFromCIF(mmdb::mmcif::PData mmCIFData, mmdb::pstr error_desc=NULL)
Definition: ccp4srs_monomer.cpp:544
Smiles * getACDLabs()
Definition: ccp4srs_monomer.h:112
mmdb::cpstr chem_name()
Definition: ccp4srs_monomer.cpp:87
DefineClass(Angle)
Container< Torsion > torsions
Definition: ccp4srs_monomer.h:181
PAtom atom(int n)
Definition: ccp4srs_monomer.h:84
mmdb::ResName oldMonID
Definition: ccp4srs_monomer.h:174
void readMonIDFromCIF(mmdb::mmcif::PLoop loop)
Definition: ccp4srs_monomer.cpp:524
void add(PTree stree)
Definition: ccp4srs_monomer.h:98
Definition: ccp4srs_entry.h:48
Definition: ccp4srs_entry.h:53
Definition: ccp4srs_tree.h:48
PChiCenter chicenter(int n)
Definition: ccp4srs_monomer.h:91
mmdb::cpstr ID()
Definition: ccp4srs_monomer.h:69
mmdb::pstr monFormula
Definition: ccp4srs_monomer.h:177
PPlane plane(int n)
Definition: ccp4srs_monomer.h:87
int get_bound(int atomNo, mmdb::cpstr elem, int serNo)
Definition: ccp4srs_monomer.cpp:237
virtual int type()
Definition: ccp4srs_monomer.h:65
CCP4SRS_RC addHydrogens(mmdb::PResidue R)
Definition: ccp4srs_monomer.cpp:310
Definition: ccp4srs_monomer.h:59
Smiles ACDLabs
Definition: ccp4srs_monomer.h:185
void merge(PMonomer monomer)
Definition: ccp4srs_monomer.cpp:1068
void getAtomNameMatch(mmdb::PPAtom A, int nat, mmdb::pstr altLoc, mmdb::ivector anmatch)
Definition: ccp4srs_monomer.cpp:464
mmdb::cpstr chem_type()
Definition: ccp4srs_monomer.cpp:92
int n_angles()
Definition: ccp4srs_monomer.h:79
Container< Bond > bonds
Definition: ccp4srs_monomer.h:179
CCP4SRS_RC
Definition: ccp4srs_types.h:55
void check_ccp4_coordinates()
Definition: ccp4srs_monomer.cpp:1167
void add(PTorsion torsion)
Definition: ccp4srs_monomer.h:99
mmdb::math::PGraph getGraph(int *retCode)
Definition: ccp4srs_monomer.cpp:1001
Definition: ccp4srs_smiles.h:51
void add(PPlane plane)
Definition: ccp4srs_monomer.h:97
virtual void write_mem(PMemIO memIO, int version)
Definition: ccp4srs_monomer.cpp:949
Container< Angle > * get_angles()
Definition: ccp4srs_monomer.h:106
mmdb::pstr monType
Definition: ccp4srs_monomer.h:176
Smiles * getInChI()
Definition: ccp4srs_monomer.h:115
mmdb::cpstr chem_formula()
Definition: ccp4srs_monomer.cpp:97
PBond bond(int n)
Definition: ccp4srs_monomer.h:85
Container< Atom > atoms
Definition: ccp4srs_monomer.h:178
int n_torsions()
Definition: ccp4srs_monomer.h:80
int n_planes()
Definition: ccp4srs_monomer.h:82
Container< ChiCenter > * get_chicenters()
Definition: ccp4srs_monomer.h:108
int n_bonds()
Definition: ccp4srs_monomer.h:78
mmdb::ResName monID
Definition: ccp4srs_monomer.h:173
void setOldID(mmdb::cpstr oldID)
Definition: ccp4srs_monomer.cpp:83
int atom_no(mmdb::cpstr aname)
Definition: ccp4srs_monomer.cpp:223
void copy(PTree tree, mmdb::ivector anmatch=NULL)
Definition: ccp4srs_tree.cpp:172
int n_atoms()
Definition: ccp4srs_monomer.h:77
void add(PAngle angle)
Definition: ccp4srs_monomer.h:96
Container< Plane > planes
Definition: ccp4srs_monomer.h:183
int readFromCIF_ccp4(mmdb::mmcif::PData mmCIFData, mmdb::pstr error_desc)
Definition: ccp4srs_monomer.cpp:693
Container< Bond > * get_bonds()
Definition: ccp4srs_monomer.h:105
void Init()
Definition: ccp4srs_monomer.cpp:57
void reset()
Definition: ccp4srs_monomer.cpp:65
Container< Torsion > * get_torsions()
Definition: ccp4srs_monomer.h:107
int readFromCIF_rcsb(mmdb::mmcif::PData mmCIFData, mmdb::pstr error_desc)
Definition: ccp4srs_monomer.cpp:552
Smiles * getCACTVS()
Definition: ccp4srs_monomer.h:113
Definition: ccp4srs_angle.cpp:42
Tree * get_tree()
Definition: ccp4srs_monomer.h:110
Tree struct_tree
Definition: ccp4srs_monomer.h:184
Definition: ccp4srs_container.h:48
mmdb::cpstr oldID()
Definition: ccp4srs_monomer.h:70
int n_chicenters()
Definition: ccp4srs_monomer.h:81
Smiles CACTVS
Definition: ccp4srs_monomer.h:186
void add(PAtom atom)
Definition: ccp4srs_monomer.h:94
void add(PBond bond)
Definition: ccp4srs_monomer.h:95
~Monomer()
Definition: ccp4srs_monomer.cpp:53
mmdb::mmcif::PData makeCIF()
Definition: ccp4srs_monomer.cpp:903
Container< Atom > * get_atoms()
Definition: ccp4srs_monomer.h:104
PTorsion torsion(int n)
Definition: ccp4srs_monomer.h:89
mmdb::pstr monName
Definition: ccp4srs_monomer.h:175
virtual bool read_mem(PMemIO memIO, int version, bool *Ok=NULL)
Definition: ccp4srs_monomer.cpp:968
PTree tree()
Definition: ccp4srs_monomer.h:88
Container< ChiCenter > chicenters
Definition: ccp4srs_monomer.h:182
Container< Plane > * get_planes()
Definition: ccp4srs_monomer.h:109
Smiles * getOpenEye()
Definition: ccp4srs_monomer.h:114
PAngle angle(int n)
Definition: ccp4srs_monomer.h:86
Monomer()
Definition: ccp4srs_monomer.cpp:49
Smiles InChI
Definition: ccp4srs_monomer.h:188
Smiles OpenEye
Definition: ccp4srs_monomer.h:187