4 * Created by Toshi Nagata on 06/03/11.
5 * Copyright 2006-2008 Toshi Nagata. All rights reserved.
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.
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.
17 #ifndef __Molecule_h__
18 #define __Molecule_h__
30 #define ATOMS_MAX_SYMMETRY 12
31 #define ATOMS_MAX_NUMBER 100000000 /* Sufficiently large value */
33 /* Conversion between kcal/mol and internal energy unit (am*ang^2/fs^2, am = atomic mass) */
34 #define KCAL2INTERNAL (4.184e-4)
35 #define INTERNAL2KCAL (1.0/KCAL2INTERNAL)
36 #define J2INTERNAL (1e-4)
37 #define INTERNAL2J (1.0/J2INTERNAL)
39 #define BOLTZMANN (8.31441e-3*J2INTERNAL)
40 #define PI 3.14159265358979
41 #define PI2R 0.564189583547756 /* 1.0/sqrt(PI) */
43 /* Anisotropic thermal parameter */
44 typedef struct Aniso {
45 Double bij[6]; /* b11, b22, b33, b12, b13, b23 (ORTEP type 0) */
46 char has_bsig; /* Has sigma values? */
47 Double bsig[6]; /* sigma values */
48 Mat33 pmat; /* A 3x3 matrix whose three column 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. */
49 Double eigval[3]; /* Eigenvalues of the B matrix; this should be all non-negative */
52 /* Symmetry operation */
53 /* If periodic box is defined, dx/dy/dz denote multiples of the axes of the periodic box.
54 Otherwise, dx/dy/dz denote offset to the x/y/z coordinates of the atoms. */
55 typedef struct Symop {
60 unsigned int alive: 1;
68 /* Atom connection record */
69 /* If nconnects <= ATOM_CONNECT_LIMIT, data[] field is used. Otherwise,
70 memory is allocated by malloc(). */
71 #define ATOM_CONNECT_LIMIT 6
72 typedef struct AtomConnect {
73 Int count; /* Number of connections */
76 Int data[ATOM_CONNECT_LIMIT];
80 typedef struct PiAnchor {
99 Vector r; /* position */
100 Vector v; /* velocity */
101 Vector f; /* force */
102 Vector sigma; /* For crystallographic data only; sigma for each crystallographic coordinates */
103 /* (Unlike r, these are not converted to the cartesian system) */
109 Int nframes; /* Multiple frames */
111 Symop symop; /* For symmetry-expanded atom */
112 Int symbase; /* The index of original atom for symmetry-expansion */
113 PiAnchor *anchor; /* Non-NULL if this atom is a pi-anchor */
114 Int labelid; /* The label ID; 0 for no label */
115 short wrap_dx, wrap_dy, wrap_dz; /* Calculated by md_wrap_coordinates; used only in wrapped output. */
116 Double fix_force; /* 0: no fix, >0: fix at fix_pos with harmonic potential, <0: fix at fix_pos without force */
118 Byte mm_exclude; /* If nonzero, then this atom is excluded from MM/MD calculations */
119 Byte periodic_exclude; /* If nonzero, then this atom is excluded from periodic calculations */
120 char uff_type[6]; /* UFF type string */
123 extern Int gSizeOfAtomRecord;
125 #define ATOM_AT_INDEX(p, i) ((Atom *)((char *)(p) + (i) * gSizeOfAtomRecord))
126 #define ATOM_NEXT(p) ((Atom *)((char *)(p) + gSizeOfAtomRecord))
127 #define ATOM_PREV(p) ((Atom *)((char *)(p) - gSizeOfAtomRecord))
128 #define SYMOP_ALIVE(s) ((s.dx || s.dy || s.dz || s.sym) != 0)
129 #define SYMOP_EQUAL(s1, s2) (s1.dx == s2.dx && s1.dy == s2.dy && s1.dz == s2.dz && s1.sym == s2.sym)
130 #define SYMMETRY_AT_INDEX(p, i) (*((i) == 0 ? &gIdentityTransform : &p[i]))
132 /* atom.connects is a union entry, including direct data for nconnects <= ATOM_CONNECT_LIMIT
133 and malloc()'ed entry for nconnects > ATOM_CONNECT_LIMIT. The following functions
134 automatically take care of the memory allocation/deallocation. */
135 Int *AtomConnectData(AtomConnect *ac);
136 void AtomConnectResize(AtomConnect *ac, Int nconnects);
137 void AtomConnectInsertEntry(AtomConnect *ac, Int idx, Int connect);
138 void AtomConnectDeleteEntry(AtomConnect *ac, Int idx);
140 #define ATOM_CONNECT_PTR(ac) ((ac)->count > ATOM_CONNECT_LIMIT ? (ac)->u.ptr : (ac)->u.data)
142 /* 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. */
143 extern Atom *AtomDuplicate(Atom *dst, const Atom *src);
145 /* Duplicate an atom, except for the frame entry */
146 extern Atom *AtomDuplicateNoFrame(Atom *dst, const Atom *src);
148 /* Clean the content of an atom record */
149 extern void AtomClean(Atom *ap);
151 /* MolEnumerable type code */
162 /* Enumerable class to access to atoms, bonds, etc. */
163 typedef struct MolEnumerable {
164 struct Molecule *mol;
169 typedef struct AtomRef {
170 struct Molecule *mol;
174 /* Crystallographic cell parameter (also used as periodic box in MD) */
175 typedef struct XtalCell {
176 Double cell[6]; /* a, b, c, alpha, beta, gamma (in degree) */
177 Double rcell[6]; /* Reciprocal cell */
178 Vector axes[3]; /* Cartesian unit vectors along the three axis */
179 Vector origin; /* Cartesian origin of the periodic box */
180 char flags[3]; /* 1 for periodic, 0 for non-periodic */
181 char has_sigma; /* Has sigma? */
182 Transform tr; /* Crystal coord -> cartesian */
183 Transform rtr; /* Cartesian -> crystal coord */
184 Double cellsigma[6]; /* For crystallographic data; sigma for the cell parameters */
187 /* 3-Dimensional distribution */
188 typedef struct Cube {
189 Int idn; /* Integer identifier (such as MO number) */
193 Double *dp; /* Value for point (ix, iy, iz) is in dp[(ix*ny+iy)*nz+iz] */
196 /* Gaussian orbital symmetry types */
210 /* Exponent/coefficient info for a single gaussian primitive */
211 typedef struct PrimInfo {
212 Double A; /* Exponent */
213 Double C; /* Contraction coefficient */
214 Double Csp; /* P(S=P) contraction coefficient */
217 /* Gaussian orbital shell information */
218 typedef struct ShellInfo {
219 signed char sym; /* Symmetry of the basis; S, P, ... */
220 signed char ncomp; /* Number of components (S: 1, P: 3, SP: 4, etc.) */
221 signed char nprim; /* Number of primitives for this shell */
222 signed char add_exp; /* Additional exponent (for JANPA-Molden only) */
223 Int p_idx; /* Index to the PrimInfo (exponent/coefficient) table */
224 Int cn_idx; /* Index to the normalized (cached) contraction coefficient table */
225 Int a_idx; /* Index to the atom which this primitive belongs to */
226 Int m_idx; /* Index to the MO matrix */
229 /* Basis set and MO information */
230 typedef struct BasisSet {
231 Int nshells; /* Number of gaussian orbital shells */
232 ShellInfo *shells; /* Gaussian orbital shells */
233 Int npriminfos; /* Size of primitive information table */
234 PrimInfo *priminfos; /* Primitive information table */
235 Int ncns; /* Number of normalized (cached) contraction coefficient values */
236 Double *cns; /* Normalized (cached) contraction coefficients; (up to 10 values for each primitive) */
237 Int natoms_bs; /* Number of atoms; separately cached here because MO info should be invariant during editing */
238 Double *nuccharges; /* Nuclear charges (for ECP atoms) */
239 Int ne_alpha, ne_beta; /* Number of alpha/beta electrons */
240 Int rflag; /* 0: UHF, 1: RHF, 2:ROHF */
241 Int ncomps; /* Number of AO components; equal to sum of shells[i].ncomp */
242 Int nmos; /* Number of MOs; equal to ncomps if close shell, ncomps*2 if open shell */
243 Double *mo; /* MO matrix (mo[i][j] represents the j-th AO coefficient for the i-th MO) */
244 /* Memory are allocated for (2*nmos+1) entries; the last entry is for displaying arbitrary vector */
245 Double *moenergies; /* MO energies */
246 Double *scfdensities; /* SCF densities; lower triangle of a symmetric matrix (size nmos*(nmos+1)/2) */
247 Int ncubes; /* Number of calculated MOs */
248 Cube **cubes; /* Calculated MOs (an array of pointers to Cubes) */
251 /* Marching Cube (for drawing isosurface) */
252 typedef struct MCubePoint {
253 Int key; /* key = ((ix*ny+iy)*nz+iz)*3+ii, ii=0/1/2 for x/y/z direction, respectively */
254 float d; /* offset toward the direction; 0 <= d < 1 */
255 float pos[3]; /* cartesian coordinate of the point */
256 float grad[3]; /* gradient vector */
259 typedef struct MCube {
260 char hidden; /* If non-zero, then this MCube is not drawn */
261 Int idn; /* MO number */
262 Vector origin; /* Cube origin */
263 Double dx, dy, dz; /* Cube steps */
264 Int nx, ny, nz; /* Cube dimension (must be multiples of 8) */
265 Double thres; /* Threshold value */
266 Double *dp; /* Value for point (ix, iy, iz) is in dp[(ix*ny+iy)*nz+iz] */
268 Double *radii; /* Estimated radius (with margin) for each atom */
269 Double expand; /* Expand the estimated radius by this value (default: 1.0) */
271 /* Flags for cube (ix, iy, iz)-(ix+1, iy+1, iz+1). It is an 8-bit */
272 /* integer representing whether the values at the 8 corners are */
273 /* larger than the threshold value or not. As special cases, */
274 /* the values 0 and 255 (all corners are below or above the threshold) */
275 /* are represented as 255, and the value 0 is used to indicate "yet undefined". */
277 /* Cube points and triangles: for positive and negative surfaces */
279 MCubePoint *cubepoints;
281 Int *triangles; /* Triangles; indices to cubepoints[] */
282 float rgba[4]; /* Surface color */
286 /* Electrostatic potential */
287 typedef struct Elpot {
292 /* Properties (total energy etc.; specific for each frame) */
293 typedef struct MolProp {
298 /* Molecule record */
299 typedef struct Molecule {
304 Int *bonds; /* The size of array is 2*nbonds */
306 Int *angles; /* The size of array is 3*nangles */
308 Int *dihedrals; /* The size of array is 4*ndihedrals */
310 Int *impropers; /* The size of array is 4*nimpropers */
311 Int nresidues; /* Number of residues; maximum residue number + 1 (because residue 0 is 'undefined residue') */
314 Int nsyms; /* Symmetry operations; syms are always described in crystallographic units (even when the unit cell is not defined) */
318 Int nframes; /* The number of frames (>= 1). This is a cached value, and should be
319 recalculated from the atoms if it is -1 */
320 Int cframe; /* The current frame number */
323 Vector *frame_cells; /* The cell vectors for frames; (nframe_cells*4) array of Vectors */
325 struct MainView *mview; /* Reference to the MainView object if present (no retain) */
326 Int modifyCount; /* Internal counter for modification. This value is not to be modified
327 manually; instead, call MoleculeIncrementModifyCount() whenever
328 modification is done, which also takes care necessary notification
329 to the other part of the application (system dependent) */
331 struct MDArena *arena; /* Reference to the MDArena record during MM/MD run (no retain) */
333 const char *path; /* The full path of the molecule, when this molecule is last saved to/loaded from file. Only used in the command-line version. (In GUI version, the path is obtained by the Document mechanism) */
335 /* Information from the dcd files */
336 Int startStep; /* the timestep for frame 0 */
337 Int stepsPerFrame; /* the number of timesteps between neighboring frames */
338 Double psPerStep; /* picosecond per step */
340 /* Information for basis sets and MOs */
346 /* Electrostatic potential */
354 /* Parameters specific for this molecule */
355 struct Parameter *par;
357 /* Bond order (not to be used in MM/MD, but may be necessary to hold this info) */
361 /* Flag to request rebuilding MD internal information */
364 /* Flag to clear selection of the parameter table */
365 Byte parameterTableSelectionNeedsClear;
367 /* Flag to request copying coordinates to MD arena */
368 Byte needsMDCopyCoordinates;
370 /* Prohibit modification of the topology (to avoid interfering MD) */
371 Byte noModifyTopology;
373 /* Flag to request aborting a subthread */
374 Byte requestAbortThread;
376 /* Flag to signal that a subthread is terminated */
377 Byte threadTerminated;
379 /* Mutex object. If non-NULL, it should be locked before modifying molecule */
382 /* Flag to prohibit modification from user interface */
383 Byte dontModifyFromGUI;
385 /* Ruby pointer (see ruby_bind.c) */
387 Byte exmolobjProtected;
391 int strlen_limit(const char *s, int limit);
393 void BasisSetRelease(BasisSet *bset);
395 Molecule *MoleculeNew(void);
396 int MoleculeLoadFile(Molecule *mp, const char *fname, const char *ftype, char **errbuf);
397 int MoleculeLoadPsfFile(Molecule *mp, const char *fname, char **errbuf);
398 int MoleculeLoadTepFile(Molecule *mp, const char *fname, char **errbuf);
399 int MoleculeLoadShelxFile(Molecule *mp, const char *fname, char **errbuf);
400 int MoleculeLoadGaussianFchkFile(Molecule *mp, const char *fname, char **errbuf);
401 int MoleculeLoadMbsfFile(Molecule *mp, const char *fname, char **errbuf);
402 Molecule *MoleculeNewWithName(const char *name);
403 Molecule *MoleculeInitWithAtoms(Molecule *mp, const Atom *atoms, int natoms);
404 Molecule *MoleculeInitWithMolecule(Molecule *mp2, Molecule *mp);
405 void MoleculeSetName(Molecule *par, const char *name);
406 const char *MoleculeGetName(Molecule *mp);
407 void MoleculeSetPath(Molecule *mol, const char *fname);
408 const char *MoleculeGetPath(Molecule *mol);
409 Molecule *MoleculeWithName(const char *name);
410 Molecule *MoleculeRetain(Molecule *mp);
411 void MoleculeRelease(Molecule *mp);
412 void MoleculeExchange(Molecule *mp1, Molecule *mp2);
414 int MoleculeAddGaussianOrbitalShell(Molecule *mol, Int a_idx, Int sym, Int nprims, Int add_exp);
415 int MoleculeAddGaussianPrimitiveCoefficients(Molecule *mol, Double exponent, Double contraction, Double contraction_sp);
416 int MoleculeGetGaussianComponentInfo(Molecule *mol, Int comp_idx, Int *outAtomIdx, char *outLabel, Int *outShellIdx);
417 int MoleculeSetMOCoefficients(Molecule *mol, Int idx, Double energy, Int ncomps, Double *coeffs);
418 int MoleculeGetMOCoefficients(Molecule *mol, Int idx, Double *energy, Int *ncoeffs, Double **coeffs);
419 int MoleculeSetMOInfo(Molecule *mol, Int rflag, Int ne_alpha, Int ne_beta);
421 void MoleculeIncrementModifyCount(Molecule *mp);
422 void MoleculeClearModifyCount(Molecule *mp);
424 MolEnumerable *MolEnumerableNew(Molecule *mol, int kind);
425 void MolEnumerableRelease(MolEnumerable *mseq);
426 AtomRef *AtomRefNew(Molecule *mol, int idx);
427 void AtomRefRelease(AtomRef *aref);
429 void MoleculeSetCell(Molecule *mp, Double a, Double b, Double c, Double alpha, Double beta, Double gamma, int convertCoordinates);
430 void MoleculeSetAniso(Molecule *mp, int n1, int type, Double x11, Double x22, Double x33, Double x12, Double x13, Double x23, const Double *sigmap);
431 void MoleculeSetAnisoBySymop(Molecule *mp, int idx);
432 int MoleculeSetPeriodicBox(Molecule *mp, const Vector *ax, const Vector *ay, const Vector *az, const Vector *ao, const char *periodic, int convertCoordinates);
433 int MoleculeCalculateCellFromAxes(XtalCell *cp, int calc_abc);
435 int MoleculeReadCoordinatesFromFile(Molecule *mp, const char *fname, const char *ftype, char **errbuf);
436 int MoleculeReadCoordinatesFromPdbFile(Molecule *mp, const char *fname, char **errbuf);
437 int MoleculeReadCoordinatesFromDcdFile(Molecule *mp, const char *fname, char **errbuf);
439 int MoleculeLoadGamessDatFile(Molecule *mol, const char *fname, char **errbuf);
441 int MoleculeReadExtendedInfo(Molecule *mp, const char *fname, char **errbuf);
442 int MoleculeWriteExtendedInfo(Molecule *mp, const char *fname, char **errbuf);
444 int MoleculeWriteToFile(Molecule *mp, const char *fname, const char *ftype, char **errbuf);
445 int MoleculeWriteToPsfFile(Molecule *mp, const char *fname, char **errbuf);
446 int MoleculeWriteToPdbFile(Molecule *mp, const char *fname, char **errbuf);
447 int MoleculeWriteToDcdFile(Molecule *mp, const char *fname, char **errbuf);
448 int MoleculeWriteToTepFile(Molecule *mp, const char *fname, char **errbuf);
449 int MoleculeWriteToMbsfFile(Molecule *mp, const char *fname, char **errbuf);
450 void MoleculeDump(Molecule *mol);
452 int MoleculePrepareMDArena(Molecule *mol, int check_only, char **retmsg);
454 char *MoleculeSerialize(Molecule *mp, Int *outLength, Int *timep);
455 Molecule *MoleculeDeserialize(const char *data, Int length, Int *timep);
457 void MoleculeCleanUpResidueTable(Molecule *mp);
458 int MoleculeChangeNumberOfResidues(Molecule *mp, int nresidues);
459 int MoleculeChangeResidueNumberWithArray(Molecule *mp, IntGroup *group, Int *resSeqs);
460 int MoleculeChangeResidueNumber(Molecule *mp, IntGroup *group, int resSeq);
461 int MoleculeOffsetResidueNumbers(Molecule *mp, IntGroup *group, int offset, int nresidues);
462 int MoleculeChangeResidueNames(Molecule *mp, int argc, Int *resSeqs, char *names);
463 int MoleculeMaximumResidueNumber(Molecule *mp, IntGroup *group);
464 int MoleculeMinimumResidueNumber(Molecule *mp, IntGroup *group);
468 int MoleculeCheckSanity(Molecule *mp);
470 #define MoleculeCheckSanity(mp)
473 int MoleculeCreateAnAtom(Molecule *mp, const Atom *ap, int pos);
474 int MoleculeMerge(Molecule *dst, Molecule *src, IntGroup *where, int resSeqOffset, Int *nactions, struct MolAction ***actions, Int forUndo);
475 int MoleculeUnmerge(Molecule *src, Molecule **dstp, IntGroup *where, int resSeqOffset, Int *nactions, struct MolAction ***actions, Int forUndo);
476 int MoleculeExtract(Molecule *src, Molecule **dstp, IntGroup *where, int dummyFlag);
477 int MoleculeAddBonds(Molecule *mp, Int nbonds, const Int *bonds, IntGroup *where, Int autoGenerate);
478 int MoleculeDeleteBonds(Molecule *mp, Int *bonds, IntGroup *where, Int **outRemoved, IntGroup **outRemovedPos);
479 int MoleculeAssignBondOrders(Molecule *mp, const Double *orders, IntGroup *where);
480 int MoleculeGetBondOrders(Molecule *mp, Double *outOrders, IntGroup *where);
481 int MoleculeAddAngles(Molecule *mp, const Int *angles, IntGroup *where);
482 int MoleculeDeleteAngles(Molecule *mp, Int *angles, IntGroup *where);
483 int MoleculeAddDihedrals(Molecule *mp, const Int *dihedrals, IntGroup *where);
484 int MoleculeDeleteDihedrals(Molecule *mp, Int *dihedrals, IntGroup *where);
485 int MoleculeAddImpropers(Molecule *mp, const Int *impropers, IntGroup *where);
486 int MoleculeDeleteImpropers(Molecule *mp, Int *impropers, IntGroup *where);
487 int MoleculeLookupBond(Molecule *mp, Int n1, Int n2);
488 int MoleculeLookupAngle(Molecule *mp, Int n1, Int n2, Int n3);
489 int MoleculeLookupDihedral(Molecule *mp, Int n1, Int n2, Int n3, Int n4);
490 int MoleculeLookupImproper(Molecule *mp, Int n1, Int n2, Int n3, Int n4);
492 Int MoleculeFindMissingAngles(Molecule *mol, Int **outAngles);
493 Int MoleculeFindMissingDihedrals(Molecule *mol, Int **outDihedrals);
494 Int MoleculeFindMissingImpropers(Molecule *mol, Int **outImpropers);
496 IntGroup *MoleculeSearchBondsIncludingAtoms(Molecule *mp, IntGroup *atomgroup);
497 IntGroup *MoleculeSearchAnglesIncludingAtoms(Molecule *mp, IntGroup *atomgroup);
498 IntGroup *MoleculeSearchDihedralsIncludingAtoms(Molecule *mp, IntGroup *atomgroup);
499 IntGroup *MoleculeSearchImpropersIncludingAtoms(Molecule *mp, IntGroup *atomgroup);
501 IntGroup *MoleculeSearchBondsAcrossAtomGroup(Molecule *mp, IntGroup *atomgroup);
503 IntGroup *MoleculeSearchAnglesIncludingBond(Molecule *mp, int n1, int n2);
504 IntGroup *MoleculeSearchDihedralsIncludingBond(Molecule *mp, int n1, int n2);
505 IntGroup *MoleculeSearchImpropersIncludingBond(Molecule *mp, int n1, int n2);
507 int MoleculeLookupAtomInResidue(Molecule *mp, int n1, int resno);
508 int MoleculeAnalyzeAtomName(const char *s, char *resName, int *resSeq, char *atomName);
509 int MoleculeAtomIndexFromString(Molecule *mp, const char *s);
511 int MoleculeFindCloseAtoms(Molecule *mp, const Vector *vp, Double radius, Double limit, Int *outNbonds, Int **outBonds, Int triangle);
512 int MoleculeGuessBonds(Molecule *mp, Double limit, Int *outNbonds, Int **outBonds);
513 int MoleculeRebuildTablesFromConnects(Molecule *mp);
514 int MoleculeAreAtomsConnected(Molecule *mol, int idx1, int idx2);
516 void MoleculeGetAtomName(Molecule *mp, int index, char *buf, int bufsize);
518 void MoleculeSetSelection(Molecule *mp, IntGroup *select);
519 IntGroup *MoleculeGetSelection(Molecule *mp);
520 void MoleculeSelectAtom(Molecule *mp, int n1, int extending);
521 void MoleculeUnselectAtom(Molecule *mp, int n1);
522 void MoleculeToggleSelectionOfAtom(Molecule *mp, int n1);
523 int MoleculeIsAtomSelected(Molecule *mp, int n1);
524 int MoleculeIsBondSelected(Molecule *mp, int n1, int n2);
525 IntGroup *MoleculeModifySelectionByRemovingAtoms(Molecule *mp, IntGroup *selection, IntGroup *remove);
527 int MoleculeGetTransformForSymop(Molecule *mp, Symop symop, Transform *tf, int is_cartesian);
528 int MoleculeGetSymopForTransform(Molecule *mp, const Transform tf, Symop *symop, int is_cartesian);
530 int MoleculeTransformBySymop(Molecule *mp, const Vector *vpin, Vector *vpout, Symop symop);
531 int MoleculeAddExpandedAtoms(Molecule *mp, Symop symop, IntGroup *group, Int *indices, Int allowOverlap);
532 int MoleculeAmendBySymmetry(Molecule *mp, IntGroup *group, IntGroup **groupout, Vector **vpout);
534 int MoleculeShowAllAtoms(Molecule *mp);
535 int MoleculeShowReverse(Molecule *mp);
536 int MoleculeHideAtoms(Molecule *mp, IntGroup *ig);
538 int MoleculeRenumberAtoms(Molecule *mp, const Int *new2old, Int *old2new_out, Int isize);
540 void MoleculeTransform(Molecule *mp, Transform tr, IntGroup *group);
541 void MoleculeTranslate(Molecule *mp, const Vector *vp, IntGroup *group);
542 void MoleculeRotate(Molecule *mp, const Vector *axis, Double angle, const Vector *center, IntGroup *group);
543 int MoleculeCenterOfMass(Molecule *mp, Vector *center, IntGroup *group);
544 int MoleculeBounds(Molecule *mp, Vector *min, Vector *max, IntGroup *group);
546 Int *MoleculeSearchEquivalentAtoms(Molecule *mol, IntGroup *ig);
548 void MoleculeAddExpansion(Molecule *mp, Vector dr, Int symop, IntGroup *group, Double limit);
549 void MoleculeClearExpansion(Molecule *mp, IntGroup *group);
550 void MoleculeRemoveExpansion(Molecule *mp, Vector dr, Int symop, IntGroup *group);
551 void MoleculeAutoExpansion(Molecule *mp, const float *boxstart, const float *boxend, IntGroup *group, Double limit);
553 void MoleculeXtalToCartesian(Molecule *mp, Vector *dst, const Vector *src);
554 void MoleculeCartesianToXtal(Molecule *mp, Vector *dst, const Vector *src);
555 Double MoleculeMeasureBond(Molecule *mp, const Vector *vp1, const Vector *vp2);
556 Double MoleculeMeasureAngle(Molecule *mp, const Vector *vp1, const Vector *vp2, const Vector *vp3);
557 Double MoleculeMeasureDihedral(Molecule *mp, const Vector *vp1, const Vector *vp2, const Vector *vp3, const Vector *vp4);
559 IntGroup *MoleculeFragmentExcludingAtomGroup(Molecule *mp, int n1, IntGroup *exatoms);
560 IntGroup *MoleculeFragmentExcludingAtoms(Molecule *mp, int n1, int argc, int *argv);
561 IntGroup *MoleculeFragmentWithAtomGroups(Molecule *mp, IntGroup *inatoms, IntGroup *exatoms);
562 int MoleculeIsFragmentDetachable(Molecule *mp, IntGroup *group, int *n1, int *n2);
563 int MoleculeIsFragmentRotatable(Molecule *mp, IntGroup *group, int *n1, int *n2, IntGroup **rotGroup);
565 int MoleculeGetNumberOfFrames(Molecule *mp);
566 int MoleculeInsertFrames(Molecule *mp, IntGroup *group, const Vector *inFrame, const Vector *inFrameCell);
567 int MoleculeRemoveFrames(Molecule *mp, IntGroup *group, Vector *outFrame, Vector *outFrameCell);
568 int MoleculeSelectFrame(Molecule *mp, int frame, int copyback);
569 int MoleculeFlushFrames(Molecule *mp);
570 int MoleculeReorderFrames(Molecule *mp, const Int *old_idx);
572 int MoleculeCreateProperty(Molecule *mp, const char *name);
573 int MoleculeLookUpProperty(Molecule *mp, const char *name);
574 int MoleculeDeletePropertyAtIndex(Molecule *mp, int idx);
575 int MoleculeSetProperty(Molecule *mp, int idx, IntGroup *ig, const Double *values);
576 int MoleculeGetProperty(Molecule *mp, int idx, IntGroup *ig, Double *outValues);
578 void MoleculeUpdatePiAnchorPositions(Molecule *mol);
579 void MoleculeCalculatePiAnchorPosition(Molecule *mol, int idx);
580 int MoleculeSetPiAnchorList(Molecule *mol, Int idx, Int nentries, Int *entries, Double *weights, Int *nUndoActions, struct MolAction ***undoActions);
582 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);
583 int MoleculeGetDefaultMOGrid(Molecule *mp, Int npoints, Vector *op, Vector *xp, Vector *yp, Vector *zp, Int *nx, Int *ny, Int *nz);
584 const Cube *MoleculeGetCubeAtIndex(Molecule *mp, Int index);
585 int MoleculeLookUpCubeWithMONumber(Molecule *mp, Int mono);
586 int MoleculeClearCubeAtIndex(Molecule *mp, Int index);
587 int MoleculeOutputCube(Molecule *mp, Int index, const char *fname, const char *comment);
589 MCube *MoleculeClearMCube(Molecule *mol, Int nx, Int ny, Int nz, const Vector *origin, Double dx, Double dy, Double dz);
590 int MoleculeUpdateMCube(Molecule *mol, int idn);
591 void MoleculeDeallocateMCube(MCube *mcube);
593 extern char *gMoleculePasteboardType;
594 extern char *gParameterPasteboardType;
595 extern char *gLoadSaveErrorMessage;
597 STUB void MoleculeRetainExternalObj(Molecule *mol);
598 STUB void MoleculeReleaseExternalObj(Molecule *mol);
600 STUB int MoleculeCallback_writeToPasteboard(const char *type, const void *data, int length);
601 STUB int MoleculeCallback_readFromPasteboard(const char *type, void **dptr, int *length);
602 STUB int MoleculeCallback_isDataInPasteboard(const char *type);
604 STUB Molecule *MoleculeCallback_openNewMolecule(const char *fname);
605 STUB void MoleculeCallback_notifyModification(Molecule *mp, int now_flag);
606 STUB Molecule *MoleculeCallback_currentMolecule(void);
607 STUB Molecule *MoleculeCallback_moleculeAtIndex(int idx);
608 STUB Molecule *MoleculeCallback_moleculeAtOrderedIndex(int idx);
609 STUB void MoleculeCallback_displayName(Molecule *mol, char *buf, int bufsize);
610 STUB void MoleculeCallback_pathName(Molecule *mol, char *buf, int bufsize);
611 STUB int MoleculeCallback_setDisplayName(Molecule *mol, const char *name);
613 STUB void MoleculeCallback_lockMutex(void *mutex);
614 STUB void MoleculeCallback_unlockMutex(void *mutex);
615 STUB void MoleculeCallback_disableModificationFromGUI(Molecule *mol);
616 STUB void MoleculeCallback_enableModificationFromGUI(Molecule *mol);
618 STUB void MoleculeCallback_cannotModifyMoleculeDuringMDError(Molecule *mol);
620 STUB int MoleculeCallback_callSubProcessAsync(Molecule *mol, const char **argv, int (*callback)(Molecule *, int), int (*timerCallback)(Molecule *, int), FILE *output, FILE *errout);
622 /* This is also defined in Molby_extern.h, but it may be called from functions in Molecule.c */
623 STUB int MyAppCallback_checkInterrupt(void);
625 void MoleculeLock(Molecule *mol);
626 void MoleculeUnlock(Molecule *mol);
629 #define __MoleculeLock(mol) MoleculeLock(mol)
630 #define __MoleculeUnlock(mol) MoleculeUnlock(mol)
632 #define __MoleculeLock(mol)
633 #define __MoleculeUnlock(mol)
640 #endif /* __Molecule_h__ */