Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

molfile_plugin.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr
00003  *cr            (C) Copyright 1995-2006 The Board of Trustees of the
00004  *cr                        University of Illinois
00005  *cr                         All Rights Reserved
00006  *cr
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: molfile_plugin.h,v $
00013  *      $Author: johns $       $Locker:  $             $State: Exp $
00014  *      $Revision: 1.112 $       $Date: 2019/10/17 06:12:24 $
00015  *
00016  ***************************************************************************/
00017 
00023 #ifndef MOL_FILE_PLUGIN_H
00024 #define MOL_FILE_PLUGIN_H
00025 
00026 #include "vmdplugin.h"
00027 
00028 #if defined(DESRES_READ_TIMESTEP2)
00029 /* includes needed for large integer types used for frame counts */
00030 #include <sys/types.h>
00031 typedef ssize_t molfile_ssize_t;      
00032 #endif
00033 
00037 #define MOLFILE_PLUGIN_TYPE "mol file reader"
00038 
00043 #define MOLFILE_CONVERTER_PLUGIN_TYPE "mol file converter"
00044 
00045 /* File plugin symbolic constants for better code readability */
00046 #define MOLFILE_SUCCESS           0   
00047 #define MOLFILE_EOF              -1   
00048 #define MOLFILE_ERROR            -1   
00049 #define MOLFILE_NOSTRUCTUREDATA  -2   
00051 #define MOLFILE_NUMATOMS_UNKNOWN -1   
00052 #define MOLFILE_NUMATOMS_NONE     0   
00057 #define MOLFILE_BUFSIZ           81   
00058 #define MOLFILE_BIGBUFSIZ        4096 
00060 #define MOLFILE_MAXWAVEPERTS     25   
00075 #define MOLFILE_DIRECTIO_MIN_BLOCK_SIZE 4096
00076 #define MOLFILE_DIRECTIO_MAX_BLOCK_SIZE 4096
00077 
00078 
00082 typedef struct {
00083   char database[81];   
00084   char accession[81];  
00085   char date[81];       
00086   char title[81];      
00087   int remarklen;       
00088   char *remarks;       
00089 } molfile_metadata_t;
00090 
00091 
00092 /* 
00093  * Struct for specifying atoms in a molecular structure.  The first 
00094  * six components are required, the rest are optional and their presence is 
00095  * indicating by setting the corresponding bit in optsflag.  When omitted,
00096  * the application (for read_structure) or plugin (for write_structure) 
00097  * must be able to supply default values if the missing parameters are 
00098  * part of its internal data structure.
00099  * Note that it is not possible to specify coordinates with this structure.
00100  * This is intentional; all coordinate I/O is done with the read_timestep and 
00101  * write_timestep functions. 
00102  */
00103 
00107 typedef struct {
00108   /* these fields absolutely must be set or initialized to empty */
00109   char name[16];      
00110   char type[16];      
00111   char resname[8];    
00112   int resid;          
00113   char segid[8];      
00114 #if 0 && vmdplugin_ABIVERSION > 10000
00115   /* The new PDB file formats allows for much larger structures, */
00116   /* which can therefore require longer chain ID strings.  The   */
00117   /* new PDBx/mmCIF file formats do not have length limits on    */
00118   /* fields, so PDB chains could be arbitrarily long strings     */
00119   /* in such files.  At present, we know we need at least 3-char */
00120   /* chains for existing PDBx/mmCIF files.                       */
00121   char chain[4];      
00122 #else
00123   char chain[2];      
00124 #endif
00125   /* rest are optional; use optflags to specify what's present   */
00126   char altloc[2];     
00127   char insertion[2];  
00128   float occupancy;    
00129   float bfactor;      
00130   float mass;         
00131   float charge;       
00132   float radius;       
00133   int atomicnumber;   
00135 #if 0
00136   char complex[16];
00137   char assembly[16];
00138   int qmregion;
00139   int qmregionlink;
00140   int qmlayer;
00141   int qmlayerlink;
00142   int qmfrag;
00143   int qmfraglink;
00144   string qmecp;
00145   int qmadapt;
00146   int qmect;          
00147   int qmparam;
00148   int autoparam;
00149 #endif
00150 
00151 #if defined(DESRES_CTNUMBER)
00152   int ctnumber;       
00153 #endif
00154 } molfile_atom_t;
00155 
00158 #define MOLFILE_NOOPTIONS     0x0000 
00159 #define MOLFILE_INSERTION     0x0001 
00160 #define MOLFILE_OCCUPANCY     0x0002 
00161 #define MOLFILE_BFACTOR       0x0004 
00162 #define MOLFILE_MASS          0x0008 
00163 #define MOLFILE_CHARGE        0x0010 
00164 #define MOLFILE_RADIUS        0x0020 
00165 #define MOLFILE_ALTLOC        0x0040 
00166 #define MOLFILE_ATOMICNUMBER  0x0080 
00167 #define MOLFILE_BONDSSPECIAL  0x0100 
00168 #if defined(DESRES_CTNUMBER)
00169 #define MOLFILE_CTNUMBER      0x0200 
00170 #endif
00171 #define MOLFILE_BADOPTIONS    0xFFFFFFFF 
00174 
00175 
00179 #define MOLFILE_QMTS_NOOPTIONS     0x0000 
00180 #define MOLFILE_QMTS_GRADIENT      0x0001 
00181 #define MOLFILE_QMTS_SCFITER       0x0002
00182 
00184 typedef struct molfile_timestep_metadata {
00185   unsigned int count;                  
00186   unsigned int avg_bytes_per_timestep; 
00187   int has_velocities;                  
00188 } molfile_timestep_metadata_t;
00189 
00190 
00191 /* 
00192  *
00193  * Per-timestep atom coordinates, velocities, forces, energies,
00194  * and periodic cell information
00195  *
00196  */ 
00197 
00198 #if 0
00199 
00202 typedef struct {
00203   int energyflags;         // XXX indicate use and semantics of data fields
00204 
00205   double total_energy;     // XXX these copied from DESRES_READ_TIMESTEP2 case
00206   double potential_energy;
00207   double kinetic_energy;
00208   double extended_energy;
00209   double force_energy;
00210   double total_pressure;
00211 
00212   // Alchemical free energy methods need to store individual energy samples.
00213   // We don't really want pre-averaged quantities, they lead to problems later.
00214   double lambda;       // data gen sim parm: + aux scheduling + soft core parm
00215   double temperature;  // temp set by thermostat
00216   // either we use deltaU, or we store U and Uprime... 
00217   double deltaU;       // Ulambda - Ulambdaprime
00218   double Ulambda;      // U for lambda
00219   double Ulambdaprime; // U for lambdaprime
00220 
00221   // IDWS methods
00222   // XXX both values of lambdaprime and required de-interleaving information
00223 
00224   // Replica exchange methods
00225   // XXX rectangle sample params?
00226   
00227   // REST2 method
00228   // XXX 
00229 
00230 } molfile_energies_t;
00231 #endif
00232 
00233 
00238 typedef struct {
00239   float *coords;        
00240   float *velocities;    
00251   float A, B, C, alpha, beta, gamma; 
00254   double physical_time; 
00256 #if defined(DESRES_READ_TIMESTEP2)
00257   /* HACK to support generic trajectory information */
00258   double total_energy;
00259   double potential_energy;
00260   double kinetic_energy;
00261   double extended_energy;
00262   double force_energy;
00263   double total_pressure;
00264 #endif
00265 
00266 } molfile_timestep_t;
00267 
00268 
00273 typedef struct {
00274   char dataname[256];   
00275   float origin[3];      
00277   /*
00278    * x/y/z axis:
00279    * These the three cell sides, providing both direction and length
00280    * (not unit vectors) for the x, y, and z axes.  In the simplest
00281    * case, these would be <size,0,0> <0,size,0> and <0,0,size) for 
00282    * an orthogonal cubic volume set.  For other cell shapes these
00283    * axes can be oriented non-orthogonally, and the parallelpiped
00284    * may have different side lengths, not just a cube/rhombus.
00285    */
00286   float xaxis[3];       
00287   float yaxis[3];       
00288   float zaxis[3];       
00290   /*
00291    * x/y/z size: 
00292    * Number of grid cells along each axis.  This is _not_ the
00293    * physical size of the box, this is the number of voxels in each
00294    * direction, independent of the shape of the volume set. 
00295    */
00296   int xsize;            
00297   int ysize;            
00298   int zsize;            
00300 #if vmdplugin_ABIVERSION > 16
00301   int has_scalar;       
00302   int has_gradient;     
00303   int has_variance;     
00304 #endif
00305   int has_color;        
00306 } molfile_volumetric_t;
00307 
00308 
00309 #if vmdplugin_ABIVERSION > 16
00310 
00314 typedef struct {
00315   int setidx;           
00316   float *scalar;        
00317   float *gradient;      
00318   float *variance;      
00319   float *rgb3f;         
00320   unsigned char *rgb3u; 
00321 } molfile_volumetric_readwrite_t;
00322 #endif
00323 
00324 
00325 /**************************************************************
00326  **************************************************************
00327  ****                                                      ****
00328  ****          Data structures for QM files                ****
00329  ****                                                      ****
00330  **************************************************************
00331  **************************************************************/
00332 
00333 /* macros for the convergence status of a QM calculation. */
00334 #define MOLFILE_QMSTATUS_UNKNOWN       -1 /* don't know yet */
00335 #define MOLFILE_QMSTATUS_OPT_CONV       0 /* optimization converged */
00336 #define MOLFILE_QMSTATUS_SCF_NOT_CONV   1 /* SCF convergence failed */
00337 #define MOLFILE_QMSTATUS_OPT_NOT_CONV   2 /* optimization not converged */
00338 #define MOLFILE_QMSTATUS_FILE_TRUNCATED 3 /* file was truncated */
00339 
00340 /* macros describing the SCF method (SCFTYP in GAMESS) */
00341 #define MOLFILE_SCFTYPE_UNKNOWN -1 /* no info about the method  */
00342 #define MOLFILE_SCFTYPE_NONE     0 /* calculation didn't make use of SCF */
00343 #define MOLFILE_SCFTYPE_RHF      1 /* restricted Hartree-Fock   */
00344 #define MOLFILE_SCFTYPE_UHF      2 /* unrestricted Hartree-Fock */
00345 #define MOLFILE_SCFTYPE_ROHF     3 /* restricted open-shell Hartree-Fock */
00346 #define MOLFILE_SCFTYPE_GVB      4 /* generalized valence bond orbitals  */
00347 #define MOLFILE_SCFTYPE_MCSCF    5 /* multi-configuration SCF   */
00348 #define MOLFILE_SCFTYPE_FF       6 /* classical force-field based sim.   */
00349 
00350 /* macros describing the type of calculation (RUNTYP in GAMESS) */
00351 #define MOLFILE_RUNTYPE_UNKNOWN    0  /* single point run */
00352 #define MOLFILE_RUNTYPE_ENERGY     1  /* single point run */
00353 #define MOLFILE_RUNTYPE_OPTIMIZE   2  /* geometry optimization */
00354 #define MOLFILE_RUNTYPE_SADPOINT   3  /* saddle point search */
00355 #define MOLFILE_RUNTYPE_HESSIAN    4  /* Hessian/frequency calculation */
00356 #define MOLFILE_RUNTYPE_SURFACE    5  /* potential surface scan */
00357 #define MOLFILE_RUNTYPE_GRADIENT   6  /* energy gradient calculation */
00358 #define MOLFILE_RUNTYPE_MEX        7  /* minimum energy crossing */
00359 #define MOLFILE_RUNTYPE_DYNAMICS   8  /* Any type of molecular dynamics
00360                                        * e.g. Born-Oppenheimer, Car-Parinello,
00361                                        * or classical MD */
00362 #define MOLFILE_RUNTYPE_PROPERTIES 9  /* Properties were calculated from a
00363                                        * wavefunction that was read from file */
00364 
00365 
00371 typedef struct {
00372   /* hessian data */
00373   int nimag;                    
00374   int nintcoords;               
00375   int ncart;                    
00377   /* orbital/basisset data */
00378   int num_basis_funcs;          
00379   int num_basis_atoms;          
00380   int num_shells;               
00381   int wavef_size;               
00386   /* everything else */
00387   int have_sysinfo;
00388   int have_carthessian;         
00389   int have_inthessian;          
00390   int have_normalmodes;         
00391 } molfile_qm_metadata_t;
00392 
00393 
00397 typedef struct {
00398   int nproc;             
00399   int memory;            
00400   int runtype;           
00401   int scftype;           
00402   int status;            
00404   int num_electrons;     
00405   int totalcharge;       
00406   int num_occupied_A;    
00407   int num_occupied_B;    
00409   double *nuc_charge;    
00411   char basis_string[MOLFILE_BUFSIZ];    
00412   char runtitle[MOLFILE_BIGBUFSIZ];     
00413   char geometry[MOLFILE_BUFSIZ];        
00415   char version_string[MOLFILE_BUFSIZ];  
00416 } molfile_qm_sysinfo_t;
00417 
00418 
00422 typedef struct {
00423   int *num_shells_per_atom; 
00424   int *num_prim_per_shell;  
00426   float *basis;             
00431   int *atomic_number;       
00432   int *angular_momentum;    
00436   int *shell_types;         
00437 } molfile_qm_basis_t;
00438 
00439 
00452 typedef struct {
00453   double *carthessian;  
00455   int    *imag_modes;   
00456   double *inthessian;   
00459   float *wavenumbers;   
00460   float *intensities;   
00461   float *normalmodes;   
00462 } molfile_qm_hessian_t;
00463 
00464 
00468 typedef struct {
00469   molfile_qm_sysinfo_t run;             /* system info  */
00470   molfile_qm_basis_t   basis;           /* basis set info */
00471   molfile_qm_hessian_t hess;            /* hessian info */
00472 } molfile_qm_t;
00473 
00474 
00475 
00503 enum molfile_qm_wavefunc_type {
00504   MOLFILE_WAVE_CANON,    MOLFILE_WAVE_GEMINAL,
00505   MOLFILE_WAVE_MCSCFNAT, MOLFILE_WAVE_MCSCFOPT,
00506   MOLFILE_WAVE_CINATUR,
00507   MOLFILE_WAVE_PIPEK,  MOLFILE_WAVE_BOYS, MOLFILE_WAVE_RUEDEN,
00508   MOLFILE_WAVE_NAO,    MOLFILE_WAVE_PNAO, MOLFILE_WAVE_NHO, 
00509   MOLFILE_WAVE_PNHO,   MOLFILE_WAVE_NBO,  MOLFILE_WAVE_PNBO, 
00510   MOLFILE_WAVE_PNLMO,  MOLFILE_WAVE_NLMO, MOLFILE_WAVE_MOAO, 
00511   MOLFILE_WAVE_NATO,   MOLFILE_WAVE_UNKNOWN
00512 };
00513 
00514 
00519 enum molfile_qm_charge_type {
00520   MOLFILE_QMCHARGE_UNKNOWN,
00521   MOLFILE_QMCHARGE_MULLIKEN, MOLFILE_QMCHARGE_LOWDIN,
00522   MOLFILE_QMCHARGE_ESP, MOLFILE_QMCHARGE_NPA
00523 };
00524 
00525 
00526 
00532 typedef struct molfile_qm_timestep_metadata {
00533   unsigned int count;                  
00534   unsigned int avg_bytes_per_timestep; 
00535   int has_gradient;                    
00536   int num_scfiter;                     
00537   int num_orbitals_per_wavef[MOLFILE_MAXWAVEPERTS]; 
00538   int has_orben_per_wavef[MOLFILE_MAXWAVEPERTS]; 
00539   int has_occup_per_wavef[MOLFILE_MAXWAVEPERTS]; 
00540   int num_wavef ;                      
00541   int wavef_size;                      
00543   int num_charge_sets;                 
00544 } molfile_qm_timestep_metadata_t;
00545 
00546 
00550 typedef struct {
00551   int   type;               
00552   int   spin;               
00553   int   excitation;         
00554   int   multiplicity;       
00555   char info[MOLFILE_BUFSIZ]; 
00557   double energy;            
00561   float *wave_coeffs;       
00563   float *orbital_energies;  
00564   float *occupancies;       
00565   int   *orbital_ids;       
00567 } molfile_qm_wavefunction_t;
00568 
00569 
00574 typedef struct {
00575   molfile_qm_wavefunction_t *wave; 
00576   float  *gradient;         
00578   double *scfenergies;      
00579   double *charges;          
00580   int    *charge_types;     
00581 } molfile_qm_timestep_t;
00582 
00583 
00584 /**************************************************************
00585  **************************************************************/
00586 
00587 
00588 
00589 
00594 enum molfile_graphics_type {
00595   MOLFILE_POINT,  MOLFILE_TRIANGLE, MOLFILE_TRINORM, MOLFILE_NORMS, 
00596   MOLFILE_LINE,   MOLFILE_CYLINDER, MOLFILE_CAPCYL,  MOLFILE_CONE,    
00597   MOLFILE_SPHERE, MOLFILE_TEXT,     MOLFILE_COLOR,   MOLFILE_TRICOLOR
00598 };
00599 
00603 typedef struct {
00604   int type;             /* One of molfile_graphics_type */
00605   int style;            /* A general style parameter    */
00606   float size;           /* A general size parameter     */
00607   float data[9];        /* All data for the element     */
00608 } molfile_graphics_t;
00609 
00610 
00611 /*
00612  * Types for raw graphics elements stored in files.  Data for each type
00613  * should be stored by the plugin as follows:
00614 
00615 type        data                                     style       size
00616 ----        ----                                     -----       ----
00617 point       x, y, z                                              pixel size
00618 triangle    x1,y1,z1,x2,y2,z2,x3,y3,z3                 
00619 trinorm     x1,y1,z1,x2,y2,z2,x3,y3,z3                 
00620             the next array element must be NORMS
00621 tricolor    x1,y1,z1,x2,y2,z2,x3,y3,z3                 
00622             the next array elements must be NORMS
00623             the following element must be COLOR, with three RGB triples
00624 norms       x1,y1,z1,x2,y2,z2,x3,y3,z3                 
00625 line        x1,y1,z1,x2,y2,z2                        0=solid     pixel width
00626                                                      1=stippled
00627 cylinder    x1,y1,z1,x2,y2,z2                        resolution  radius
00628 capcyl      x1,y1,z1,x2,y2,z2                        resolution  radius
00629 sphere      x1,y1,z1                                 resolution  radius
00630 text        x, y, z, up to 24 bytes of text                      pixel size
00631 color       r, g, b
00632 */
00633 
00634 
00640 typedef struct {
00644   vmdplugin_HEAD
00645 
00656   const char *filename_extension;
00657 
00666   void *(* open_file_read)(const char *filepath, const char *filetype, 
00667       int *natoms);
00668   
00676   int (*read_structure)(void *, int *optflags, molfile_atom_t *atoms);
00677 
00706   int (*read_bonds)(void *, int *nbonds, int **from, int **to, float **bondorder, 
00707                     int **bondtype, int *nbondtypes, char ***bondtypename);
00708 
00723   int (* read_next_timestep)(void *, int natoms, molfile_timestep_t *);
00724 
00728   void (* close_file_read)(void *);
00729    
00736   void *(* open_file_write)(const char *filepath, const char *filetype, 
00737       int natoms);
00738   
00742   int (* write_structure)(void *, int optflags, const molfile_atom_t *atoms);
00743 
00750   int (* write_timestep)(void *, const molfile_timestep_t *);
00751   
00755   void (* close_file_write)(void *);
00756 
00764   int (* read_volumetric_metadata)(void *, int *nsets, 
00765         molfile_volumetric_t **metadata);
00766 
00775   int (* read_volumetric_data)(void *, int set, float *datablock, 
00776         float *colorblock);
00777 #if vmdplugin_ABIVERSION > 16
00778   int (* read_volumetric_data_ex)(void *, molfile_volumetric_readwrite_t *v);
00779 #endif
00780 
00787   int (* read_rawgraphics)(void *, int *nelem, const molfile_graphics_t **data);
00788 
00795   int (* read_molecule_metadata)(void *, molfile_metadata_t **metadata);
00796   
00819   int (* write_bonds)(void *, int nbonds, int *from, int *to, float *bondorder, 
00820                      int *bondtype, int nbondtypes, char **bondtypename);
00821 
00829   int (* write_volumetric_data)(void *, molfile_volumetric_t *metadata,
00830                                 float *datablock, float *colorblock);
00831 #if vmdplugin_ABIVERSION > 16
00832   int (* write_volumetric_data_ex)(void *, molfile_volumetric_t *metadata,
00833                                    molfile_volumetric_readwrite_t *v);
00834 #endif
00835 
00840   int (* read_angles)(void *handle, int *numangles, int **angles, int **angletypes,
00841                       int *numangletypes, char ***angletypenames, int *numdihedrals,
00842                       int **dihedrals, int **dihedraltypes, int *numdihedraltypes,
00843                       char ***dihedraltypenames, int *numimpropers, int **impropers,        
00844                       int **impropertypes, int *numimpropertypes, char ***impropertypenames,
00845                       int *numcterms, int **cterms, int *ctermcols, int *ctermrows);
00846 
00851   int (* write_angles)(void *handle, int numangles, const int *angles, const int *angletypes,
00852                        int numangletypes, const char **angletypenames, int numdihedrals,
00853                        const int *dihedrals, const int *dihedraltypes, int numdihedraltypes,
00854                        const char **dihedraltypenames, int numimpropers, 
00855                        const int *impropers, const int *impropertypes, int numimpropertypes,
00856                        const char **impropertypenames, int numcterms,  const int *cterms, 
00857                        int ctermcols, int ctermrows);
00858 
00859 
00871   int (* read_qm_metadata)(void *, molfile_qm_metadata_t *metadata);
00872 
00873 
00884   int (* read_qm_rundata)(void *, molfile_qm_t *qmdata);
00885 
00886 
00905 #if vmdplugin_ABIVERSION > 17
00906   int (* read_timestep_pagealign_size)(void *, int *pagealignsize);
00907 #endif
00908 
00909 
00927   int (* read_timestep)(void *, int natoms, molfile_timestep_t *,
00928                         molfile_qm_metadata_t *, molfile_qm_timestep_t *);
00929 
00930   int (* read_timestep_metadata)(void *, molfile_timestep_metadata_t *);
00931   int (* read_qm_timestep_metadata)(void *, molfile_qm_timestep_metadata_t *);
00932 
00933 
00934 #if defined(EXPERIMENTAL_DIRECTIO_APIS)
00935 
00941   int (* calc_fileoffsets_timestep)(void *, 
00942                                     molfile_ssize_t frameindex, 
00943                                     int firstatom, 
00944                                     int lastatom,
00945                                     int *firstatom, 
00946                                     int *pageoffset,
00947                                     molfile_ssize_t *startoffset,
00948                                     molfile_ssize_t *readlen);
00949 #endif
00950 
00951 
00952 #if defined(DESRES_READ_TIMESTEP2)
00953 
00956   int (* read_timestep2)(void *, molfile_ssize_t index, molfile_timestep_t *);
00957 
00962   molfile_ssize_t (* read_times)( void *,
00963                                   molfile_ssize_t start,
00964                                   molfile_ssize_t count,
00965                                   double * times );
00966 #endif
00967 
00985   int (* cons_fputs)(const int, const char*);
00986 
00987 } molfile_plugin_t;
00988 
00989 #endif
00990 

Generated on Mon Aug 10 03:06:06 2020 for VMD Plugins (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002