ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/openbabel/amberformat.cpp
Revision: 2445
Committed: Wed Nov 16 21:22:51 2005 UTC (18 years, 8 months ago) by tim
File size: 2577 byte(s)
Log Message:
adding more readers/writers

File Contents

# Content
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 "amberformat.hpp"
17
18 using namespace std;
19 namespace OpenBabel
20 {
21
22 bool AmberPrepFormat::ReadMolecule(OBBase* pOb, OBConversion* pConv)
23 {
24
25 OBMol* pmol = dynamic_cast<OBMol*>(pOb);
26 if(pmol==NULL)
27 return false;
28
29 //Define some references so we can use the old parameter names
30 istream &ifs = *pConv->GetInStream();
31 OBMol &mol = *pmol;
32 const char* title = pConv->GetTitle();
33
34 char buffer[BUFF_SIZE];
35 string str,str1;
36 OBAtom *atom;
37 OBInternalCoord *coord;
38 vector<string> vs;
39 vector<OBInternalCoord*> internals;
40
41 mol.BeginModify();
42
43 while (ifs.getline(buffer,BUFF_SIZE))
44 {
45 tokenize(vs,buffer);
46 if (vs.size() == 10)
47 {
48 atom = mol.NewAtom();
49 coord = new OBInternalCoord();
50 if (mol.NumAtoms() > 1)
51 coord->_a = mol.GetAtom(atoi(vs[4].c_str()));
52 if (mol.NumAtoms() > 2)
53 coord->_b = mol.GetAtom(atoi(vs[5].c_str()));
54 if (mol.NumAtoms() > 3)
55 coord->_c = mol.GetAtom(atoi(vs[6].c_str()));
56 coord->_dst = atof(vs[7].c_str());
57 coord->_ang = atof(vs[8].c_str());
58 coord->_tor = atof(vs[9].c_str());
59 internals.push_back(coord);
60
61 atom->SetAtomicNum(etab.GetAtomicNum(vs[1].c_str()));
62
63 if (!ifs.getline(buffer,BUFF_SIZE))
64 break;
65 tokenize(vs,buffer);
66 }
67 }
68
69 if (internals.size() > 0)
70 InternalToCartesian(internals,mol);
71
72 if (!pConv->IsOption("b",OBConversion::INOPTIONS))
73 mol.ConnectTheDots();
74 if (!pConv->IsOption("s",OBConversion::INOPTIONS) && !pConv->IsOption("b",OBConversion::INOPTIONS))
75 mol.PerceiveBondOrders();
76
77 mol.EndModify();
78 mol.SetTitle(title);
79 return(true);
80 }
81
82 } //namespace OpenBabel