OSDN Git Service

initial import
[molby/Molby.git] / MolLib / Molecule.h
1 /*
2  *  Molecule.h
3  *
4  *  Created by Toshi Nagata on 06/03/11.
5  *  Copyright 2006-2008 Toshi Nagata. All rights reserved.
6  *
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation version 2 of the License.
10  
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15 */
16
17 #ifndef __Molecule_h__
18 #define __Molecule_h__
19
20 #include "Types.h"
21 #include "Object.h"
22 #include "IntGroup.h"
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27         
28 #define ATOMS_MAX_CONNECTS 12
29 #define ATOMS_MAX_SYMMETRY 12
30 #define ATOMS_MAX_NUMBER 100000000  /*  Sufficiently large value  */
31
32 /*  Conversion between kcal/mol and internal energy unit (am*ang^2/fs^2, am = atomic mass) */
33 #define KCAL2INTERNAL (4.184e-4)
34 #define INTERNAL2KCAL (1.0/KCAL2INTERNAL)
35 #define J2INTERNAL (1e-4)
36 #define INTERNAL2J (1.0/J2INTERNAL)
37         
38 #define BOLTZMANN (8.31441e-3*J2INTERNAL)
39 #define PI 3.14159265358979
40                 
41 /*  Anisotropic thermal parameter  */
42 typedef struct Aniso {
43         Double  bij[6];    /*  b11, b22, b33, b12, b23, b31 (ORTEP type 0) */
44         Mat33  pmat;      /*  A 3x3 matrix whose three row vectors are the principal axes of the ellipsoid. Note: If the B matrix is not positive definite, the axis length corresponding to the negative eigenvalue is replaced with 0.001.  */
45 } Aniso;
46
47 /*  Symmetry operation  */
48 /*  If periodic box is defined, dx/dy/dz denote multiples of the axes of the periodic box.
49     Otherwise, dx/dy/dz denote offset to the x/y/z coordinates of the atoms.  */
50 typedef struct Symop {
51         signed int dx : 4;
52         signed int dy : 4;
53         signed int dz : 4;
54         unsigned int sym : 8;
55         unsigned int alive: 1;
56 } Symop;
57
58 /*  Exflags  */
59 enum {
60         kAtomHiddenFlag = 1
61 };
62
63 /*  Atom record  */
64 typedef struct Atom {
65         Int    segSeq;
66         char   segName[4];
67         Int    resSeq;
68         char   resName[4];
69         char   aname[4];
70         UInt   type;
71         Double  charge;
72         Double  weight;
73         char   element[4];
74         Int    atomicNumber;
75         Int    nconnects;   /*  Number of connections (= bonds)  */
76         Int    connects[ATOMS_MAX_CONNECTS];
77         Vector r;  /*  position  */
78         Vector v;  /*  velocity  */
79         Vector f;  /*  force  */
80         Double  occupancy;
81         Double  tempFactor;
82         Aniso  *aniso;
83         Int    intCharge;
84         Int    exflags;
85         Int    nframes;  /*  Multiple frames  */
86         Vector *frames;
87         Symop  symop;    /*  For symmetry-expanded atom  */
88         Int    symbase;  /*  The index of original atom for symmetry-expansion  */
89         Int    labelid;  /*  The label ID; 0 for no label  */
90         short  wrap_dx, wrap_dy, wrap_dz; /*  Calculated by md_wrap_coordinates; used only in wrapped output.  */
91         Double fix_force; /*  0: no fix, >0: fix at fix_pos with harmonic potential, <0: fix at fix_pos without force  */
92         Vector fix_pos;
93         Byte   periodic_exclude;  /*  If nonzero, then this atom is excluded from periodic calculations  */
94 } Atom;
95
96 extern Int gSizeOfAtomRecord;
97
98 #define ATOM_AT_INDEX(p, i)  ((Atom *)((char *)(p) + (i) * gSizeOfAtomRecord))
99 #define ATOM_NEXT(p)         ((Atom *)((char *)(p) + gSizeOfAtomRecord))
100 #define ATOM_PREV(p)         ((Atom *)((char *)(p) - gSizeOfAtomRecord))
101
102 #define SYMOP_ALIVE(s) (s.dx || s.dy || s.dz || s.sym)
103 #define SYMOP_EQUAL(s1, s2) (s1.dx == s2.dx && s1.dy == s2.dy && s1.dz == s2.dz && s1.sym == s2.sym)
104
105 /*  Duplicate an atom. If dst is non-NULL, *src is copied to *dst and dst is returned. If dst is NULL, a new atom is allocated by malloc() and that atom is returned. It is the called's responsibility to release the returned memory. */
106 extern Atom *AtomDuplicate(Atom *dst, const Atom *src);
107 /*  Clean the content of an atom record  */
108 extern void AtomClean(Atom *ap);
109
110 /*  MolEnumerable type code  */
111 enum {
112         kAtomKind = 0,
113         kBondKind = 1,
114         kAngleKind = 2,
115         kDihedralKind = 3,
116         kImproperKind = 4,
117         kResidueKind = 5,
118         kEndKind
119 };
120
121 /*  Enumerable class to access to atoms, bonds, etc.  */
122 typedef struct MolEnumerable {
123         struct Molecule *mol;
124         int    kind;
125 } MolEnumerable;
126
127 /*  Atom reference  */
128 typedef struct AtomRef {
129         struct Molecule *mol;
130         int idx;
131 } AtomRef;
132
133 /*  Crystallographic cell parameter (also used as periodic box in MD) */
134 typedef struct XtalCell {
135         Double  cell[6];     /*  a, b, c, alpha, beta, gamma (in degree)  */
136         Double  rcell[6];    /*  Reciprocal cell  */
137         Vector  axes[3];     /*  Cartesian unit vectors along the three axis  */
138         Vector  origin;      /*  Cartesian origin of the periodic box  */
139         char    flags[3];    /*  1 for periodic, 0 for non-periodic  */
140         Transform tr;        /*  Crystal coord -> cartesian  */
141         Transform rtr;       /*  Cartesian -> crystal coord  */
142 } XtalCell;
143
144 /*  Periodic box parameter  */
145 #if 0
146 typedef struct PeriodicBox {
147         Vector  axes[3];     /*  Unit vectors along the three axis  */
148         Vector  origin;      /*  Origin of the periodic box  */
149         char    flags[3];    /*  1 for periodic, 0 for non-periodic  */
150         Transform tr;        /*  Internal coord -> cartesian  */
151         Transform rtr;       /*  Cartesian -> internal coord  */        
152 } PeriodicBox;
153 #endif
154
155 /*  Expanded atoms  */
156 typedef struct ExAtom {
157         Int    index;        /*  Base atom index  */
158         Vector dr;           /*  Translational offset  */
159         Int    symop;        /*  Symmetry operation  */
160         Int    labelid;      /*  Label ID; 0 for no label  */
161 } ExAtom;
162
163 /*  3-Dimensional distribution  */
164 typedef struct Cube {
165         Int idn;             /*  Integer identifier (such as MO number)  */
166         Vector origin;
167         Vector dx, dy, dz;
168         Int nx, ny, nz;
169         Double *dp;          /*  Value for point (ix, iy, iz) is in dp[(ix*ny+iy)*nz+iz]  */
170 } Cube;
171
172 /*  Gaussian orbital symmetry types  */
173 enum {
174         kGTOType_S,
175         kGTOType_SP,
176         kGTOType_P,
177         kGTOType_D,
178         kGTOType_D5,
179         kGTOtype_F,
180         kGTOType_F7,
181         kGTOType_UU
182 };
183
184 /*  Exponent/coefficient info for a single gaussian primitive  */
185 typedef struct PrimInfo {
186         Double A;            /*  Exponent  */
187         Double C;            /*  Contraction coefficient  */
188         Double Csp;          /*  P(S=P) contraction coefficient  */
189 } PrimInfo;
190
191 /*  Gaussian orbital shell information  */
192 typedef struct ShellInfo {
193         signed char sym;     /*  Symmetry of the basis; S, P, ... */
194         signed char ncomp;   /*  Number of components (S: 1, P: 3, SP: 4, etc.)  */
195         signed char nprim;   /*  Number of primitives for this shell  */
196         Int p_idx;           /*  Index to the PrimInfo (exponent/coefficient) table  */
197         Int cn_idx;          /*  Index to the normalized (cached) contraction coefficient table  */
198         Int a_idx;           /*  Index to the atom which this primitive belongs to */
199         Int m_idx;           /*  Index to the MO matrix  */
200 } ShellInfo;
201
202 /*  Basis set and MO information  */
203 typedef struct BasisSet {
204         Int nshells;         /*  Number of gaussian orbital shells  */
205         ShellInfo *shells;   /*  Gaussian orbital shells  */
206         Int npriminfos;      /*  Size of primitive information table  */
207         PrimInfo *priminfos; /*  Primitive information table  */
208         Int ncns;            /*  Number of normalized (cached) contraction coefficient values  */
209         Double *cns;         /*  Normalized (cached) contraction coefficients; (up to 10 values for each primitive)  */
210         Int natoms;          /*  Number of atoms; separately cached here because MO info should be invariant during editing */
211         Vector *pos;         /*  Positions of atoms; the unit is bohr, not angstrom  */
212         Double *nuccharges;  /*  Nuclear charges (for ECP atoms)  */
213         Int nelectrons;      /*  Number of electrons  */
214         Int nmos;            /*  Number of MOs */
215         Double *mo;          /*  MO matrix (mo[i][j] represents the j-th AO coefficient for the i-th MO)  */
216         Double *moenergies;  /*  MO energies  */
217         Double *scfdensities; /*  SCF densities; lower triangle of a symmetric matrix (size nmos*(nmos+1)/2)  */
218         Int ncubes;          /*  Number of calculated MOs  */
219         Cube **cubes;        /*  Calculated MOs (an array of pointers to Cubes)  */
220 } BasisSet;
221
222 /*  Electrostatic potential  */
223 typedef struct Elpot {
224         Vector pos;
225         Double esp;
226 } Elpot;
227
228 /*  Molecule record  */
229 typedef struct Molecule {
230         Object base;
231         Int    natoms;
232         Atom   *atoms;
233         Int    nbonds;
234         Int    *bonds;       /*  The size of array is 2*nbonds  */
235         Int    nangles;
236         Int    *angles;      /*  The size of array is 3*nangles  */
237         Int    ndihedrals;
238         Int    *dihedrals;   /*  The size of array is 4*ndihedrals  */
239         Int    nimpropers;
240         Int    *impropers;   /*  The size of array is 4*nimpropers  */
241         Int    nresidues;    /*  Number of residues; maximum residue number + 1 (because residue 0 is 'undefined residue')  */
242         char   (*residues)[4];
243         XtalCell   *cell;
244 /*      char   is_xtal_coord; *//*  True if the coordinates are measured in crystallographic units  */
245         Int    nsyms;        /*  Symmetry operations; syms are always described in crystallographic units (even when is_xtal_coord is false)  */
246         Transform *syms;
247 /*      PeriodicBox *box;    *//*  Periodic box  */
248         IntGroup *selection;
249         Int    nexatoms;
250         ExAtom *exatoms;
251         Int    nexbonds;
252         Int    *exbonds;     /*  The size of array is 2*nbonds; Atom index >= 0 : base atoms, < 0 : expanded atoms at index -exbonds[n]-1  */
253         Int    nframes;      /*  The number of frames. This is a cached value, and should be
254                                                          recalculated from the atoms if it is -1  */
255         Int    cframe;       /*  The current frame number  */
256         struct MainView *mview;  /*  Reference to the MainView object if present (no retain)  */
257         Int    modifyCount;  /*  Internal counter for modification. This value is not to be modified
258                                  manually; instead, call MoleculeIncrementModifyCount() whenever
259                                                      modification is done, which also takes care necessary notification
260                                                          to the other part of the application (system dependent)  */
261
262         struct MDArena *arena;  /*  Reference to the MDArena record during MM/MD run (no retain)  */
263
264         /*  Information from the dcd files  */
265         Int    startStep;     /*  the timestep for frame 0  */
266         Int    stepsPerFrame; /*  the number of timesteps between neighboring frames  */
267         Double psPerStep;     /*  picosecond per step  */
268
269         /*  Information for basis sets and MOs  */
270         BasisSet *bset;
271         
272         /*  Electrostatic potential  */
273         Int    nelpots;
274         Elpot  *elpots;
275
276         /*  Parameters specific for this molecule  */
277         struct Parameter *par;
278         
279         /*  Flag to request rebuilding MD internal information  */
280         Byte   needsMDRebuild;
281         
282         /*  Prohibit modification of the topology (to avoid interfering MD) */
283         Byte   noModifyTopology;
284         
285         /*  Flag to request aborting a subthread  */
286         Byte   requestAbortThread;
287
288         /*  Flag to signal that a subthread is terminated  */
289         Byte   threadTerminated;
290
291         /*  Mutex object. If non-NULL, it should be locked before modifying molecule  */
292         void *mutex;
293
294 } Molecule;
295
296 int strlen_limit(const char *s, int limit);
297
298 Molecule *MoleculeNew(void);
299 int MoleculeLoadFile(Molecule *mp, const char *fname, const char *ftype, char *errbuf, int errbufsize);
300 int MoleculeLoadPsfFile(Molecule *mp, const char *fname, char *errbuf, int errbufsize);
301 int MoleculeLoadTepFile(Molecule *mp, const char *fname, char *errbuf, int errbufsize);
302 int MoleculeLoadShelxFile(Molecule *mp, const char *fname, char *errbuf, int errbufsize);
303 int MoleculeLoadGaussianFchkFile(Molecule *mp, const char *fname, char *errbuf, int errbufsize);
304 Molecule *MoleculeNewWithName(const char *name);
305 Molecule *MoleculeInitWithAtoms(Molecule *mp, const Atom *atoms, int natoms);
306 Molecule *MoleculeInitWithMolecule(Molecule *mp2, const Molecule *mp);
307 void MoleculeSetName(Molecule *par, const char *name);
308 const char *MoleculeGetName(Molecule *mp);
309 Molecule *MoleculeWithName(const char *name);
310 Molecule *MoleculeRetain(Molecule *mp);
311 void MoleculeRelease(Molecule *mp);
312 void MoleculeExchange(Molecule *mp1, Molecule *mp2);
313
314 void MoleculeIncrementModifyCount(Molecule *mp);
315 void MoleculeClearModifyCount(Molecule *mp);
316
317 MolEnumerable *MolEnumerableNew(Molecule *mol, int kind);
318 void MolEnumerableRelease(MolEnumerable *mseq);
319 AtomRef *AtomRefNew(Molecule *mol, int idx);
320 void AtomRefRelease(AtomRef *aref);
321
322 void MoleculeSetCell(Molecule *mp, Double a, Double b, Double c, Double alpha, Double beta, Double gamma, int convertCoordinates);
323 void MoleculeSetAniso(Molecule *mp, int n1, int type, Double x11, Double x22, Double x33, Double x12, Double x23, Double x31);
324 int MoleculeSetPeriodicBox(Molecule *mp, const Vector *ax, const Vector *ay, const Vector *az, const Vector *ao, const char *periodic);
325
326 int MoleculeReadCoordinatesFromFile(Molecule *mp, const char *fname, const char *ftype, char *errbuf, int errbufsize);
327 int MoleculeReadCoordinatesFromPdbFile(Molecule *mp, const char *fname, char *errbuf, int errbufsize);
328 int MoleculeReadCoordinatesFromDcdFile(Molecule *mp, const char *fname, char *errbuf, int errbufsize);
329
330 int MoleculeReadExtendedInfo(Molecule *mp, const char *fname, char *errbuf, int errbufsize);
331 int MoleculeWriteExtendedInfo(Molecule *mp, const char *fname, char *errbuf, int errbufsize);
332
333 int MoleculeWriteToFile(Molecule *mp, const char *fname, const char *ftype, char *errbuf, int errbufsize);
334 int MoleculeWriteToPsfFile(Molecule *mp, const char *fname, char *errbuf, int errbufsize);
335 int MoleculeWriteToPdbFile(Molecule *mp, const char *fname, char *errbuf, int errbufsize);
336 int MoleculeWriteToDcdFile(Molecule *mp, const char *fname, char *errbuf, int errbufsize);
337 int MoleculeWriteToTepFile(Molecule *mp, const char *fname, char *errbuf, int errbufsize);
338 void MoleculeDump(Molecule *mol);
339
340 char *MoleculeSerialize(Molecule *mp, Int *outLength, Int *timep);
341 Molecule *MoleculeDeserialize(const char *data, Int length, Int *timep);
342
343 void MoleculeCleanUpResidueTable(Molecule *mp);
344 int MoleculeChangeNumberOfResidues(Molecule *mp, int nresidues);
345 int MoleculeChangeResidueNumberWithArray(Molecule *mp, IntGroup *group, Int *resSeqs);
346 int MoleculeChangeResidueNumber(Molecule *mp, IntGroup *group, int resSeq);
347 int MoleculeOffsetResidueNumbers(Molecule *mp, IntGroup *group, int offset, int nresidues);
348 int MoleculeChangeResidueNames(Molecule *mp, int argc, Int *resSeqs, char *names);
349 int MoleculeMaximumResidueNumber(Molecule *mp, IntGroup *group);
350 int MoleculeMinimumResidueNumber(Molecule *mp, IntGroup *group);
351
352 int MoleculeCreateAnAtom(Molecule *mp, const Atom *ap, int pos);
353 int MoleculeMerge(Molecule *dst, Molecule *src, IntGroup *where, int resSeqOffset);
354 int MoleculeUnmerge(Molecule *src, Molecule **dstp, IntGroup *where, int resSeqOffset);
355 int MoleculeExtract(Molecule *src, Molecule **dstp, IntGroup *where, int dummyFlag);
356 int MoleculeAddBonds(Molecule *mp, Int nbonds, const Int *bonds);
357 int MoleculeDeleteBonds(Molecule *mp, Int nbonds, const Int *bonds);
358 int MoleculeAddAngles(Molecule *mp, const Int *angles, IntGroup *where);
359 int MoleculeDeleteAngles(Molecule *mp, Int *angles, IntGroup *where);
360 int MoleculeAddDihedrals(Molecule *mp, const Int *dihedrals, IntGroup *where);
361 int MoleculeDeleteDihedrals(Molecule *mp, Int *dihedrals, IntGroup *where);
362 int MoleculeAddImpropers(Molecule *mp, const Int *impropers, IntGroup *where);
363 int MoleculeDeleteImpropers(Molecule *mp, Int *impropers, IntGroup *where);
364 int MoleculeLookupBond(Molecule *mp, Int n1, Int n2);
365 int MoleculeLookupAngle(Molecule *mp, Int n1, Int n2, Int n3);
366 int MoleculeLookupDihedral(Molecule *mp, Int n1, Int n2, Int n3, Int n4);
367 int MoleculeLookupImproper(Molecule *mp, Int n1, Int n2, Int n3, Int n4);
368
369 /*
370 Int     MoleculeReplaceAllAngles(Molecule *mol, Int nangles, const Int *angles, Int **outAngles);
371 Int MoleculeReplaceAllDihedrals(Molecule *mol, Int ndihedrals, const Int *dihedrals, Int **outDihedrals);
372 Int MoleculeReplaceAllImpropers(Molecule *mol, Int nimpropers, const Int *impropers, Int **outImpropers);
373
374 Int MoleculeFindAllAngles(Molecule *mol, Int **outAngles);
375 Int MoleculeFindAllDihedrals(Molecule *mol, Int **outDihedrals);
376 Int MoleculeFindAllImpropers(Molecule *mol, Int **outImpropers);
377 */
378
379 Int MoleculeFindMissingAngles(Molecule *mol, Int **outAngles);
380 Int MoleculeFindMissingDihedrals(Molecule *mol, Int **outDihedrals);
381 Int MoleculeFindMissingImpropers(Molecule *mol, Int **outImpropers);
382         
383 IntGroup *MoleculeSearchBondsIncludingAtoms(Molecule *mp, IntGroup *atomgroup);
384 IntGroup *MoleculeSearchAnglesIncludingAtoms(Molecule *mp, IntGroup *atomgroup);
385 IntGroup *MoleculeSearchDihedralsIncludingAtoms(Molecule *mp, IntGroup *atomgroup);
386 IntGroup *MoleculeSearchImpropersIncludingAtoms(Molecule *mp, IntGroup *atomgroup);
387
388 IntGroup *MoleculeSearchBondsAcrossAtomGroup(Molecule *mp, IntGroup *atomgroup);
389
390 IntGroup *MoleculeSearchAnglesIncludingBond(Molecule *mp, int n1, int n2);
391 IntGroup *MoleculeSearchDihedralsIncludingBond(Molecule *mp, int n1, int n2);
392 IntGroup *MoleculeSearchImpropersIncludingBond(Molecule *mp, int n1, int n2);
393
394 int MoleculeLookupAtomInResidue(Molecule *mp, int n1, int resno);
395 int MoleculeAnalyzeAtomName(const char *s, char *resName, int *resSeq, char *atomName);
396 int MoleculeAtomIndexFromString(Molecule *mp, const char *s);
397
398 int MoleculeGuessBonds(Molecule *mp, Double limit, Int *outNbonds, Int **outBonds);
399 int MoleculeAreAtomsConnected(Molecule *mp, int n1, int n2);
400 int MoleculeRebuildTablesFromConnects(Molecule *mp);
401
402 void MoleculeGetAtomName(Molecule *mp, int index, char *buf, int bufsize);
403
404 void MoleculeSetSelection(Molecule *mp, IntGroup *select);
405 IntGroup *MoleculeGetSelection(Molecule *mp);
406 void MoleculeSelectAtom(Molecule *mp, int n1, int extending);
407 void MoleculeUnselectAtom(Molecule *mp, int n1);
408 void MoleculeToggleSelectionOfAtom(Molecule *mp, int n1);
409 int MoleculeIsAtomSelected(Molecule *mp, int n1);
410 int MoleculeIsBondSelected(Molecule *mp, int n1, int n2);
411 IntGroup *MoleculeModifySelectionByRemovingAtoms(Molecule *mp, IntGroup *selection, IntGroup *remove);
412
413 int MoleculeTransformBySymop(Molecule *mp, const Vector *vpin, Vector *vpout, Symop symop);
414 int MoleculeAddExpandedAtoms(Molecule *mp, Symop symop, IntGroup *group);
415 int MoleculeAmendBySymmetry(Molecule *mp, IntGroup *group, IntGroup **groupout, Vector **vpout);
416
417 int MoleculeShowAllAtoms(Molecule *mp);
418 int MoleculeShowReverse(Molecule *mp);
419 int MoleculeHideAtoms(Molecule *mp, IntGroup *ig);
420
421 int MoleculeReorderAtoms(Molecule *mp, const Int *new2old, Int *old2new_out, Int isize);
422
423 void MoleculeTransform(Molecule *mp, Transform tr, IntGroup *group);
424 void MoleculeMove(Molecule *mp, Transform tr, IntGroup *group);
425 void MoleculeTranslate(Molecule *mp, const Vector *vp, IntGroup *group);
426 void MoleculeRotate(Molecule *mp, const Vector *axis, Double angle, const Vector *center, IntGroup *group);
427 void MoleculeReaxis(Molecule *mp, const Vector *xaxis, const Vector *yaxis, const Vector *zaxis, IntGroup *group);
428 int MoleculeCenterOfMass(Molecule *mp, Vector *center, IntGroup *group);
429 int MoleculeBounds(Molecule *mp, Vector *min, Vector *max, IntGroup *group);
430         
431 Int *MoleculeSearchEquivalentAtoms(Molecule *mol, IntGroup *ig);
432         
433 void MoleculeAddExpansion(Molecule *mp, Vector dr, Int symop, IntGroup *group, Double limit);
434 void MoleculeClearExpansion(Molecule *mp, IntGroup *group);
435 void MoleculeRemoveExpansion(Molecule *mp, Vector dr, Int symop, IntGroup *group);
436 void MoleculeAutoExpansion(Molecule *mp, const float *boxstart, const float *boxend, IntGroup *group, Double limit);
437
438 void MoleculeXtalToCartesian(Molecule *mp, Vector *dst, const Vector *src);
439 void MoleculeCartesianToXtal(Molecule *mp, Vector *dst, const Vector *src);
440 Double MoleculeMeasureBond(Molecule *mp, const Vector *vp1, const Vector *vp2);
441 Double MoleculeMeasureAngle(Molecule *mp, const Vector *vp1, const Vector *vp2, const Vector *vp3);
442 Double MoleculeMeasureDihedral(Molecule *mp, const Vector *vp1, const Vector *vp2, const Vector *vp3, const Vector *vp4);
443
444 IntGroup *MoleculeFragmentExcludingAtomGroup(Molecule *mp, int n1, IntGroup *exatoms);
445 IntGroup *MoleculeFragmentExcludingAtoms(Molecule *mp, int n1, int argc, int *argv);
446 IntGroup *MoleculeFragmentWithAtomGroups(Molecule *mp, IntGroup *inatoms, IntGroup *exatoms);
447 int MoleculeIsFragmentDetachable(Molecule *mp, IntGroup *group, int *n1, int *n2);
448 int MoleculeIsFragmentRotatable(Molecule *mp, IntGroup *group, int *n1, int *n2, IntGroup **rotGroup);
449
450 int MoleculeGetNumberOfFrames(Molecule *mp);
451 int MoleculeInsertFrames(Molecule *mp, IntGroup *group, const Vector *inFrame);
452 int MoleculeRemoveFrames(Molecule *mp, IntGroup *group, Vector *outFrame);
453 int MoleculeInsertFrame(Molecule *mp, int index, const Vector *inFrame);
454 int MoleculeRemoveFrame(Molecule *mp, int frame, Vector *outFrame);
455 int MoleculeSelectFrame(Molecule *mp, int frame, int copyback);
456
457 int MoleculeCalcMO(Molecule *mp, Int mono, const Vector *op, const Vector *dxp, const Vector *dyp, const Vector *dzp, Int nx, Int ny, Int nz, int (*callback)(double progress, void *ref), void *ref);
458 int MoleculeGetDefaultMOGrid(Molecule *mp, Int npoints, Vector *op, Vector *xp, Vector *yp, Vector *zp, Int *nx, Int *ny, Int *nz);
459 const Cube *MoleculeGetCubeAtIndex(Molecule *mp, Int index);
460 int MoleculeLookUpCubeWithMONumber(Molecule *mp, Int mono);
461 int MoleculeClearCubeAtIndex(Molecule *mp, Int index);
462 int MoleculeOutputCube(Molecule *mp, Int index, const char *fname, const char *comment);
463
464 #define kMoleculePasteboardType "Molecule"
465 #define kParameterPasteboardType "Parameter"
466
467 STUB int MoleculeCallback_writeToPasteboard(const char *type, const void *data, int length);
468 STUB int MoleculeCallback_readFromPasteboard(const char *type, void **dptr, int *length);
469 STUB int MoleculeCallback_isDataInPasteboard(const char *type);
470
471 STUB Molecule *MoleculeCallback_openNewMolecule(const char *fname);
472 STUB void MoleculeCallback_notifyModification(Molecule *mp, int now_flag);
473 STUB Molecule *MoleculeCallback_currentMolecule(void);
474 STUB Molecule *MoleculeCallback_moleculeAtIndex(int idx);
475 STUB Molecule *MoleculeCallback_moleculeAtOrderedIndex(int idx);
476 STUB void MoleculeCallback_displayName(Molecule *mol, char *buf, int bufsize);
477 STUB void MoleculeCallback_pathName(Molecule *mol, char *buf, int bufsize);
478
479 STUB void MoleculeCallback_lockMutex(void *mutex);
480 STUB void MoleculeCallback_unlockMutex(void *mutex);
481 STUB void MoleculeCallback_cannotModifyMoleculeDuringMDError(Molecule *mol);
482
483 void MoleculeLock(Molecule *mol);
484 void MoleculeUnlock(Molecule *mol);
485
486 #if 0
487 #define __MoleculeLock(mol) MoleculeLock(mol)
488 #define __MoleculeUnlock(mol) MoleculeUnlock(mol)
489 #else
490 #define __MoleculeLock(mol)
491 #define __MoleculeUnlock(mol)
492 #endif
493         
494 #ifdef __cplusplus
495 }
496 #endif
497                 
498 #endif /* __Molecule_h__ */