1
/**********************************************************************
2
Copyright (C) 2001 by Geoffrey Hutchison
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation version 2 of the License.
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
12
***********************************************************************/
18
bool ReadNWChem(istream &ifs,OBMol &mol,char *title)
20
char buffer[BUFF_SIZE];
26
ttab.SetFromType("XYZ");
28
while (ifs.getline(buffer,BUFF_SIZE))
30
if(strstr(buffer,"Output coordinates") != NULL)
35
ifs.getline(buffer,BUFF_SIZE); // blank
36
ifs.getline(buffer,BUFF_SIZE); // column headings
37
ifs.getline(buffer,BUFF_SIZE); // ---- ----- ----
38
ifs.getline(buffer,BUFF_SIZE);
40
while (vs.size() == 6)
43
x = atof((char*)vs[3].c_str());
44
y = atof((char*)vs[4].c_str());
45
z = atof((char*)vs[5].c_str());
46
atom->SetVector(x,y,z); //set coordinates
49
atom->SetAtomicNum(etab.GetAtomicNum(vs[1].c_str()));
51
ttab.SetToType("INT"); ttab.Translate(str,vs[1]);
54
if (!ifs.getline(buffer,BUFF_SIZE)) break;
57
} // if "output coordinates"
66
bool WriteNWChem(ostream &ofs,OBMol &mol)
69
char buffer[BUFF_SIZE];
71
ofs << "start molecule" << endl << endl;
72
ofs << "title " << endl << " " << mol.GetTitle() << endl << endl;
74
ofs << "geometry units angstroms print xyz autosym" << endl;
77
for(i = 1;i <= mol.NumAtoms(); i++)
79
atom = mol.GetAtom(i);
80
sprintf(buffer,"%3s%15.5f%15.5f%15.5f",
81
etab.GetSymbol(atom->GetAtomicNum()),
85
ofs << buffer << endl;