FileParsers.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (C) 2002-2007 Greg Landrum and Rational Discovery LLC
00003 //
00004 //   @@ All Rights Reserved  @@
00005 //
00006 #ifndef _RD_FILEPARSERS_H
00007 #define _RD_FILEPARSERS_H
00008 
00009 #include <RDGeneral/types.h>
00010 #include <GraphMol/RDKitBase.h>
00011 
00012 #include <string>
00013 #include <iostream>
00014 #include <vector>
00015 #include <exception>
00016 
00017 #include <boost/shared_ptr.hpp>
00018 
00019 namespace RDKit{
00020   const int MOLFILE_MAXLINE=256;
00021   std::string strip(const std::string &orig);
00022 
00023   //-----
00024   // mol files
00025   //-----
00026   typedef std::vector< RWMOL_SPTR > RWMOL_SPTR_VECT;
00027   // \brief construct a molecule from MDL mol data in a stream
00028   /*! 
00029    *   \param inStream - stream containing the data
00030    *   \param line     - current line number (used for error reporting)
00031    *   \param sanitize - toggles sanitization of the molecule
00032    *   \param removeHs - toggles removal of Hs from the molecule. H removal
00033    *                     is only done if the molecule is sanitized
00034    */
00035   RWMol *MolDataStreamToMol(std::istream *inStream, unsigned int &line,
00036                             bool sanitize=true,bool removeHs=true);
00037   // \overload
00038   RWMol *MolDataStreamToMol(std::istream &inStream, unsigned int &line,
00039                             bool sanitize=true,bool removeHs=true);
00040   // \brief construct a molecule from an MDL mol block
00041   /*! 
00042    *   \param molBlock - string containing the mol block
00043    *   \param sanitize - toggles sanitization of the molecule
00044    *   \param removeHs - toggles removal of Hs from the molecule. H removal
00045    *                     is only done if the molecule is sanitized
00046    */
00047   RWMol *MolBlockToMol(const std::string &molBlock, bool sanitize=true,bool removeHs=true);
00048   
00049   // \brief construct a molecule from an MDL mol file
00050   /*! 
00051    *   \param fName    - string containing the file name
00052    *   \param sanitize - toggles sanitization of the molecule
00053    *   \param removeHs - toggles removal of Hs from the molecule. H removal
00054    *                     is only done if the molecule is sanitized
00055    */
00056   RWMol *MolFileToMol(std::string fName, bool sanitize=true,bool removeHs=true);
00057 
00058   // \brief generates an MDL mol block for a molecule
00059   /*! 
00060    *   \param mol           - the molecule in question
00061    *   \param includeStereo - toggles inclusion of stereochemistry information
00062    *   \param confId        - selects the conformer to be used
00063    */
00064   std::string MolToMolBlock(const ROMol &mol,bool includeStereo=true, int confId=-1);
00065   // \brief construct a molecule from an MDL mol file
00066   /*! 
00067    *   \param mol           - the molecule in question
00068    *   \param fName         - the name of the file to use
00069    *   \param includeStereo - toggles inclusion of stereochemistry information
00070    *   \param confId        - selects the conformer to be used
00071    */
00072   void MolToMolFile(const ROMol &mol,std::string fName,bool includeStereo=true, int confId=-1);
00073 
00074 
00075   //-----
00076   //  TPL handling:
00077   //-----
00078 
00079   //! \brief translate TPL data (BioCad format) into a multi-conf molecule
00080   /*!
00081     \param inStream:      the stream from which to read
00082     \param line:          used to track the line number of errors
00083     \param sanitize:      toggles sanitization of the molecule
00084     \param skipFirstConf: according to the TPL format description, the atomic
00085                           coords in the atom-information block describe the first
00086                           conformation and the first conf block describes second 
00087                           conformation. The CombiCode, on the other hand, writes
00088                           the first conformation data both to the atom-information 
00089                           block and to the first conf block. We want to be able to
00090                           read CombiCode-style tpls, so we'll allow this mis-feature
00091                           to be parsed when this flag is set.
00092   */
00093   RWMol *TPLDataStreamToMol(std::istream *inStream, unsigned int &line,
00094                             bool sanitize=true,
00095                             bool skipFirstConf=false);
00096 
00097   //! \brief construct a multi-conf molecule from a TPL (BioCad format) file
00098   /*!
00099     \param fName:         the name of the file from which to read
00100     \param sanitize:      toggles sanitization of the molecule
00101     \param skipFirstConf: according to the TPL format description, the atomic
00102                           coords in the atom-information block describe the first
00103                           conformation and the first conf block describes second 
00104                           conformation. The CombiCode, on the other hand, writes
00105                           the first conformation data both to the atom-information 
00106                           block and to the first conf block. We want to be able to
00107                           read CombiCode-style tpls, so we'll allow this mis-feature
00108                           to be parsed when this flag is set.
00109   */
00110   RWMol *TPLFileToMol(std::string fName,bool sanitize=true,
00111                       bool skipFirstConf=false);
00112 
00113   std::string MolToTPLText(const ROMol &mol,
00114                            std::string partialChargeProp="_GasteigerCharge",
00115                            bool writeFirstConfTwice=false);
00116   void MolToTPLFile(const ROMol &mol,std::string fName,
00117                     std::string partialChargeProp="_GasteigerCharge",
00118                     bool writeFirstConfTwice=false);
00119 
00120 
00121 
00122 }
00123 
00124 #endif

Generated on Sat May 24 08:36:32 2008 for RDCode by  doxygen 1.5.3