00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef BASEMOLECULE_H
00026 #define BASEMOLECULE_H
00027
00028 #ifndef NAMELIST_TEMPLATE_H
00029 #include "NameList.h"
00030 #endif
00031 #ifndef RESIZEARRAY_TEMPLATE_H
00032 #include "ResizeArray.h"
00033 #endif
00034 #include "Atom.h"
00035 #include "Residue.h"
00036 #include "Timestep.h"
00037 #include "Fragment.h"
00038 #include "intstack.h"
00039
00040 #ifdef VMDWITHCARBS
00041 #include <vector>
00042 #include "SmallRing.h"
00043 #include "SmallRingLinkages.h"
00044 #include "inthash.h"
00045 #endif
00046
00047 #if 0
00048 #define VMDFASTRIBBONS
00049 #endif
00050
00051 class VolumetricData;
00052
00057 class BaseMolecule {
00058 public:
00059
00060
00061
00062 int nAtoms;
00063 int nResidues;
00064 int nWaters;
00065 int nSegments;
00066 int nFragments;
00067 int nProteinFragments;
00068 int nNucleicFragments;
00069
00070 NameList<int> atomNames;
00071 NameList<int> atomTypes;
00072 NameList<int> resNames;
00073 NameList<int> chainNames;
00074 NameList<int> segNames;
00075 NameList<int> altlocNames;
00076
00077 ResizeArray<Residue *> residueList;
00078 ResizeArray<Fragment *> fragList;
00079
00080 ResizeArray<Fragment *> pfragList;
00081
00082 ResizeArray<int> pfragCyclic;
00083 #if defined(VMDFASTRIBBONS)
00084 ResizeArray<int *> pfragCPList;
00085
00086 #endif
00087
00088
00089 ResizeArray<Fragment *> nfragList;
00090 ResizeArray<int> nfragCyclic;
00091 #if defined(VMDFASTRIBBONS)
00092 ResizeArray<int *> nfragCPList;
00093
00094 #endif
00095
00096 #ifdef VMDWITHCARBS
00097 ResizeArray<SmallRing *> smallringList;
00098
00099 SmallRingLinkages smallringLinkages;
00100 int currentMaxRingSize;
00101 int currentMaxPathLength;
00102 #endif
00103
00104
00105
00106
00107 NameList<float *> extra;
00108
00109
00110
00111 float *radius() { return extra.data("radius"); }
00112 float *mass() { return extra.data("mass"); }
00113 float *charge() { return extra.data("charge"); }
00114 float *beta() { return extra.data("beta"); }
00115 float *occupancy() { return extra.data("occupancy"); }
00116
00118 float *bondorders() { return extra.data("bondorders"); }
00119 void setbondorder(int atom, int bond, float order);
00120 float getbondorder(int atom, int bond);
00121
00123 int has_structure() const { return cur_atom > 0; }
00124
00126 void clear_bonds(void);
00127
00129 int count_bonds(void);
00130
00131 #ifdef VMDWITHCARBS
00132
00133 void find_small_rings_and_links(int maxpathlength, int maxringsize);
00134 #endif
00135
00136 private:
00137 const int ID;
00138
00139
00140
00141
00142 int cur_atom;
00143 MolAtom *atomList;
00144 int lastbonderratomid;
00145 int bonderrorcount;
00146
00147
00148
00149
00150
00158 int find_backbone(void);
00159
00160
00161
00162
00163
00164 int find_connected_backbone(IntStackHandle, int, int, int, int, int *);
00165 void clean_up_connection(IntStackHandle, int, int, int *);
00166 void find_connected_atoms_in_resid(IntStackHandle, int, int,
00167 int, int, int *);
00168 void find_and_mark(int, int, int,
00169 int *, int *);
00170 int make_uniq_resids(int *flgs);
00171
00178 int find_residues(void);
00179
00181
00182
00183 void find_connected_waters(int i, char *tmp);
00184 int find_connected_waters2(void);
00185
00190 int find_waters(void);
00191
00197 void find_connected_residues(int num_residues);
00198
00200 int find_segments(void) { return segNames.num(); }
00201
00203 int find_connected_fragments();
00204
00211 int find_fragments(void);
00212
00213 void find_subfragments_cyclic(ResizeArray<Fragment *> *subfragList, int restype);
00214 void find_cyclic_subfragments(ResizeArray<Fragment *> *subfragList, ResizeArray<int> *subfragCyclic);
00215
00217 void find_connected_subfragment(int resnum, int fragnum, char *flgs,
00218 int endatom, int altendatom, int alt2endatom, int alt3endatom,
00219 int restype,
00220 ResizeArray<Fragment *> *subfragList);
00221
00222 void find_subfragments(int startatom, int altstartatom, int alt2startatom,
00223 int endatom, int altendatom, int alt2endatom, int alt3endatom,
00224 int restype, ResizeArray<Fragment *> *subfragList);
00225
00226 void find_subfragments_topologically(int restype, ResizeArray<Fragment *> *subfragList, int endatom, int altendatom, int alt2endatom, int alt3endatom);
00227
00228 #if defined(VMDFASTRIBBONS)
00231 void calculate_ribbon_controlpoints();
00232 #endif
00233
00234 #ifdef VMDWITHCARBS
00235
00236 int find_small_rings(int maxringsize);
00237 int find_back_edges(ResizeArray<int> &back_edge_src, ResizeArray<int> &back_edge_dest);
00238 int find_connected_subgraph_back_edges(int atomid, ResizeArray<int> &back_edge_src, ResizeArray<int> &back_edge_dest,
00239 int *intree_parents);
00240 int find_small_rings_from_back_edges(int maxringsize, ResizeArray<int> &back_edge_src, ResizeArray<int> &back_edge_dest);
00241 int find_small_rings_from_partial(SmallRing *ring, int maxringsize, inthash_t *used_edges, inthash_t *used_atoms);
00242 int get_edge_key(int edge_src, int edge_dest);
00243
00244
00245 void orientate_small_rings(int maxringsize);
00246 void orientate_small_ring(SmallRing &ring,int maxringsize);
00247
00248
00249 int find_orientated_small_ring_linkages(int maxpathlength,int maxringsize);
00250 int find_linkages_for_ring_from_partial(LinkagePath &lp, int maxpathlength, inthash_t *atom_to_ring, inthash_t *multi_ring_atoms, inthash_t *used_atoms);
00251 #endif
00252
00253
00254 protected:
00255 char *moleculename;
00256 int need_find_bonds;
00257
00258 public:
00259
00260
00261
00262
00263
00264
00265
00266 BaseMolecule(int);
00267 virtual ~BaseMolecule(void);
00268
00269
00270
00271
00272
00275 int init_atoms(int n);
00276
00278 void find_bonds_from_timestep() { need_find_bonds = 1; }
00279 void find_unique_bonds_from_timestep() { need_find_bonds = 2; }
00280
00282 int add_atom(char *name, char *type, int atomicnumber,
00283 char *resname, int resid,
00284 const char *chainid,const char *segname,
00285 char *insertion = (char *) " ", const char *altloc = "");
00286
00288 int add_bond(int, int, float, int = ATOMNORMAL);
00289
00291 int add_bond_dupcheck(int, int, float);
00292
00294
00295 void analyze(void);
00296
00297
00298
00299
00300 int id(void) const { return ID; }
00301 const char *molname() const {return moleculename; }
00302
00303
00304
00305 MolAtom *atom(int n) { return atomList+n; }
00306 Residue *residue(int);
00307 Fragment *fragment(int);
00308
00309
00310 Residue *atom_residue(int);
00311 Fragment *atom_fragment(int);
00312
00314
00315 int find_atom_in_residue(int atomnameindex, int residue) {
00316 const ResizeArray<int> &atoms = residueList[residue]->atoms;
00317 int num = atoms.num();
00318 for (int i=0; i<num; i++) {
00319 if (atom(atoms[i])->nameindex == atomnameindex) return atoms[i];
00320 }
00321 return -3;
00322 }
00323
00324 int find_atom_in_residue(const char *atomname, int residue);
00326
00328
00329 float default_charge(char *);
00330 float default_mass(char *);
00331 float default_radius(char *);
00332 float default_occup(void) { return 1.0; }
00333 float default_beta(void) { return 0.0; }
00335
00337 void add_volume_data(const char *name, const float *o,
00338 const float *xa, const float *ya, const float *za, int x, int y, int z,
00339 float *voldata);
00340
00341 int num_volume_data();
00342 const VolumetricData *get_volume_data(int);
00343 void compute_volume_gradient(VolumetricData *);
00344
00345 protected:
00346 ResizeArray<VolumetricData *>volumeList;
00347 };
00348
00349
00350 #define IS_HYDROGEN(s) (s[0] == 'H' || (isdigit(s[0]) && s[1] == 'H' ))
00351
00352 #endif
00353