| 1 |
/********************************************************************** |
| 2 |
Copyright (C) 2000 by OpenEye Scientific Software, Inc. |
| 3 |
Some portions Copyright (C) 2001-2005 by Geoffrey R. Hutchison |
| 4 |
Some portions Copyright (C) 2004 by Chris Morley |
| 5 |
|
| 6 |
This program is free software; you can redistribute it and/or modify |
| 7 |
it under the terms of the GNU General Public License as published by |
| 8 |
the Free Software Foundation version 2 of the License. |
| 9 |
|
| 10 |
This program is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
GNU General Public License for more details. |
| 14 |
***********************************************************************/ |
| 15 |
|
| 16 |
#include "tinkerformat.hpp" |
| 17 |
|
| 18 |
using namespace std; |
| 19 |
namespace OpenBabel |
| 20 |
{ |
| 21 |
|
| 22 |
bool TinkerFormat::WriteMolecule(OBBase* pOb, OBConversion* pConv) |
| 23 |
{ |
| 24 |
OBMol* pmol = dynamic_cast<OBMol*>(pOb); |
| 25 |
if(pmol==NULL) |
| 26 |
return false; |
| 27 |
|
| 28 |
//Define some references so we can use the old parameter names |
| 29 |
ostream &ofs = *pConv->GetOutStream(); |
| 30 |
OBMol &mol = *pmol; |
| 31 |
|
| 32 |
unsigned int i; |
| 33 |
char buffer[BUFF_SIZE]; |
| 34 |
OBBond *bond; |
| 35 |
vector<OBEdgeBase*>::iterator j; |
| 36 |
|
| 37 |
sprintf(buffer,"%6d %-20s MM2 parameters",mol.NumAtoms(),mol.GetTitle()); |
| 38 |
ofs << buffer << endl; |
| 39 |
|
| 40 |
ttab.SetFromType("INT"); |
| 41 |
|
| 42 |
OBAtom *atom; |
| 43 |
string str,str1; |
| 44 |
for(i = 1;i <= mol.NumAtoms(); i++) |
| 45 |
{ |
| 46 |
atom = mol.GetAtom(i); |
| 47 |
str = atom->GetType(); |
| 48 |
ttab.SetToType("MM2"); |
| 49 |
ttab.Translate(str1,str); |
| 50 |
sprintf(buffer,"%6d %2s %12.6f%12.6f%12.6f %5d", |
| 51 |
i, |
| 52 |
etab.GetSymbol(atom->GetAtomicNum()), |
| 53 |
atom->GetX(), |
| 54 |
atom->GetY(), |
| 55 |
atom->GetZ(), |
| 56 |
atoi((char*)str1.c_str())); |
| 57 |
ofs << buffer; |
| 58 |
|
| 59 |
for (bond = atom->BeginBond(j); bond; bond = atom->NextBond(j)) |
| 60 |
{ |
| 61 |
sprintf(buffer,"%6d", (bond->GetNbrAtom(atom))->GetIdx()); |
| 62 |
ofs << buffer; |
| 63 |
} |
| 64 |
|
| 65 |
ofs << endl; |
| 66 |
} |
| 67 |
|
| 68 |
return(true); |
| 69 |
} |
| 70 |
|
| 71 |
} //namespace OpenBabel |