11
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
12
GNU General Public License for more details.
13
13
***********************************************************************/
14
#include <openbabel/babelconfig.h>
16
#include "obconversion.h"
17
#include "obmolecformat.h"
16
#include <openbabel/obmolecformat.h>
19
18
using namespace std;
20
19
namespace OpenBabel
23
class NWChemOutputFormat : public OBMoleculeFormat
22
class NWChemOutputFormat : public OBMoleculeFormat
26
25
//Register this format type ID
27
26
NWChemOutputFormat()
29
OBConversion::RegisterFormat("nwo",this);
28
OBConversion::RegisterFormat("nwo",this);
32
virtual const char* Description() //required
35
"NWChem output format\n \
31
virtual const char* Description() //required
34
"NWChem output format\n \
36
35
Read Options e.g. -as\n\
37
36
s Output single bonds only\n\
38
37
b Disable bonding entirely\n\n";
41
virtual const char* SpecificationURL()
42
{return "http://www.emsl.pnl.gov/docs/nwchem/";}; //optional
40
virtual const char* SpecificationURL()
41
{return "http://www.emsl.pnl.gov/docs/nwchem/";}; //optional
44
43
//Flags() can return be any the following combined by | or be omitted if none apply
45
44
// NOTREADABLE READONEONLY NOTWRITABLE WRITEONEONLY
46
45
virtual unsigned int Flags()
48
return READONEONLY | NOTWRITABLE;
47
return READONEONLY | NOTWRITABLE;
51
50
////////////////////////////////////////////////////
52
51
/// The "API" interface functions
53
52
virtual bool ReadMolecule(OBBase* pOb, OBConversion* pConv);
56
//Make an instance of the format class
57
NWChemOutputFormat theNWChemOutputFormat;
59
class NWChemInputFormat : public OBFormat
55
//Make an instance of the format class
56
NWChemOutputFormat theNWChemOutputFormat;
58
class NWChemInputFormat : public OBMoleculeFormat
62
61
//Register this format type ID
63
62
NWChemInputFormat()
65
OBConversion::RegisterFormat("nw",this);
64
OBConversion::RegisterFormat("nw",this);
68
67
virtual const char* Description() //required
71
"NWChem input format\n \
70
"NWChem input format\n \
72
71
No comments yet\n";
75
virtual const char* SpecificationURL()
76
{return "http://www.emsl.pnl.gov/docs/nwchem/";}; //optional
74
virtual const char* SpecificationURL()
75
{return "http://www.emsl.pnl.gov/docs/nwchem/";}; //optional
78
77
//Flags() can return be any the following combined by | or be omitted if none apply
79
78
// NOTREADABLE READONEONLY NOTWRITABLE WRITEONEONLY
86
85
/// The "API" interface functions
87
86
virtual bool WriteMolecule(OBBase* pOb, OBConversion* pConv);
89
////////////////////////////////////////////////////
90
/// The "Convert" interface functions
91
virtual bool WriteChemObject(OBConversion* pConv)
93
//Retrieve the target OBMol
94
OBBase* pOb = pConv->GetChemObject();
95
OBMol* pmol = dynamic_cast<OBMol*> (pOb);
98
ret=WriteMolecule(pmol,pConv);
104
//Make an instance of the format class
105
NWChemInputFormat theNWChemInputFormat;
108
/////////////////////////////////////////////////////////////////
109
bool NWChemOutputFormat::ReadMolecule(OBBase* pOb, OBConversion* pConv)
112
OBMol* pmol = dynamic_cast<OBMol*>(pOb);
90
//Make an instance of the format class
91
NWChemInputFormat theNWChemInputFormat;
94
/////////////////////////////////////////////////////////////////
95
bool NWChemOutputFormat::ReadMolecule(OBBase* pOb, OBConversion* pConv)
98
OBMol* pmol = pOb->CastAndClear<OBMol>();
116
102
//Define some references so we can use the old parameter names
117
103
istream &ifs = *pConv->GetInStream();
149
135
atom->SetAtomicNum(etab.GetAtomicNum(vs[1].c_str()));
151
137
if (!ifs.getline(buffer,BUFF_SIZE))
153
139
tokenize(vs,buffer);
155
} // if "output coordinates"
141
} // if "output coordinates"
144
if (mol.NumAtoms() == 0) { // e.g., if we're at the end of a file PR#1737209
158
149
if (!pConv->IsOption("b",OBConversion::INOPTIONS))
159
150
mol.ConnectTheDots();
164
155
mol.SetTitle(title);
168
////////////////////////////////////////////////////////////////
170
bool NWChemInputFormat::WriteMolecule(OBBase* pOb, OBConversion* pConv)
159
////////////////////////////////////////////////////////////////
161
bool NWChemInputFormat::WriteMolecule(OBBase* pOb, OBConversion* pConv)
172
163
OBMol* pmol = dynamic_cast<OBMol*>(pOb);
176
167
//Define some references so we can use the old parameter names
177
168
ostream &ofs = *pConv->GetOutStream();