Open Babel  3.0
optransform.h
Go to the documentation of this file.
1 /**********************************************************************
2 optransform.h: makes option to transform molecule as specified in a datafile
3 Copyright (C) 2008 Chris Morley
4 
5 This file is part of the Open Babel project.
6 For more information, see <http://openbabel.org/>
7 
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation version 2 of the License.
11 
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 ***********************************************************************/
17 
18 #include <openbabel/babelconfig.h>
19 #include <openbabel/phmodel.h>
20 #include <openbabel/mol.h>
21 #include <openbabel/op.h>
22 #include <vector>
23 
24 namespace OpenBabel
25 {
26  class OBMol;
31 class OpTransform : public OBOp
32 {
33 public:
35  OpTransform(const char* ID, const char* filename, const char* descr)
36  : OBOp(ID, false), _filename(filename), _descr(descr), _dataLoaded(false){}
37 
39 
40  virtual const char* Description();
41 
43  virtual bool WorksWith(OBBase* pOb)const{ return dynamic_cast<OBMol*>(pOb)!=NULL; }
44 
46  virtual bool Do(OBBase* pOb, const char* OptionText=NULL, OpMap* pOptions=NULL, OBConversion* pConv=NULL);
47 
48  virtual OpTransform* MakeInstance(const std::vector<std::string>& textlines)
49 {
50  OpTransform* pTransform = new OpTransform(
51  textlines[1].c_str(),textlines[2].c_str(),textlines[3].c_str());
52  pTransform->_textlines = textlines;
53  return pTransform;
54 }
55 
56 private:
57  bool Initialize();
58  void ParseLine(const char *buffer);
59 
60 private:
61  const char* _filename;
62  const char* _descr;
63  std::vector<std::string> _textlines;
64 
65  bool _dataLoaded;
66  std::vector<OBChemTsfm> _transforms;
67 };
68 
69 }//namespace
70 
OpTransform(const char *ID, const char *filename, const char *descr)
constructor. Each instance provides an ID, a datafile and a description.
Definition: optransform.h:35
const std::map< std::string, std::string > OpMap
Definition: op.h:38
Class to convert from one format to another.
Definition: obconversion.h:59
virtual bool Do(OBBase *pOb, const char *OptionText=NULL, OpMap *pOptions=NULL, OBConversion *pConv=NULL)
Carries out the transform.
virtual bool WorksWith(OBBase *pOb) const
Checks that this op is being applied to the right kind of object(OBMol)
Definition: optransform.h:43
Molecule Class.
Definition: mol.h:118
Handle molecules. Declarations of OBMol, OBAtom, OBBond, OBResidue. (the main header for Open Babel) ...
Applies molecular reactions/transforms (OBChemTsfm class) read from a datafile.
Definition: optransform.h:31
virtual OpTransform * MakeInstance(const std::vector< std::string > &textlines)
Definition: optransform.h:48
Read pH rules and assign charges.
Base plugin class for operations on molecules.
virtual const char * Description()
Required description of a sub-type.
Operations to modify molecules before output.
Definition: op.h:33
~OpTransform()
Definition: optransform.h:38
Base Class.
Definition: base.h:239
Global namespace for all Open Babel code.
Definition: alias.h:22