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 *cr Portions contributed and copyright (C) 1998 by Andrew Dalke and 00008 *cr Bioreason, Inc. 00009 *cr 00010 *cr Some information comes from the Daylight Information Systems' 00011 *cr contrib program "mol2smi" which was placed into the public domain. 00012 *cr 00013 ***************************************************************************/ 00014 00015 /*************************************************************************** 00016 * RCS INFORMATION: 00017 * 00018 * $RCSfile: ReadMDLMol.h,v $ 00019 * $Author: johns $ $Locker: $ $State: Exp $ 00020 * $Revision: 1.7 $ $Date: 2003/12/31 20:14:01 $ 00021 * 00022 *************************************************************************** 00023 * DESCRIPTION: 00024 * 00025 * Read and write MDL ".mol" files 00026 * 00027 ***************************************************************************/ 00028 #ifndef READ_MDL_MOL_H 00029 #define READ_MDL_MOL_H 00030 00031 // Yeah, I know, I should use streams instead of FILE*s 00032 #include <stdio.h> 00033 00034 typedef struct mdl_atom { 00035 mdl_atom(void) { 00036 x = 0.0; y = 0.0; z = 0.0; symbol[0] = 0; 00037 mass_difference = 0; charge = 0; stereo_parity = 0; hcount = 0; 00038 stereo_care_box = 0; 00039 valence = 0; 00040 } 00041 00042 float x, y, z; 00043 char symbol[4]; 00044 int mass_difference; 00045 int charge; // actually, 4 - charge! 00046 int stereo_parity; 00047 int hcount; // actually, hcount + 1 ! 00048 00049 // terms past here exist in some Mol files (according to the Daylight 00050 // code) but I didn't find examples of use. These terms are 00051 // placeholders for future use. 00052 int stereo_care_box; 00053 int valence; 00054 } mdl_atom_struct; 00055 00056 typedef struct mdl_bond { 00057 mdl_bond(void) { 00058 bond_from = 0; bond_to = 0; bond_type = 0; bond_stereo = 0; 00059 } 00060 int bond_from; // uses base 1 00061 int bond_to; // uses base 1 00062 int bond_type; // eg, 1, 2, 3, 4 00063 int bond_stereo; 00064 } mdl_bond_struct; 00065 00066 int read_mdl_header(FILE *infile, int *natoms, int *nbonds); 00067 00068 int read_mdl_atom(FILE *infile, mdl_atom *atom); 00069 int write_mdl_atom(FILE *outfile, const mdl_atom& atom); 00070 00071 int read_mdl_bond(FILE *infile, mdl_bond *bond); 00072 int write_mdl_bond(FILE *outfile, const mdl_bond& bond); 00073 00074 int write_mdl_trailer(FILE *outfile); 00075 00076 #endif 00077