File: amber.cpp

package info (click to toggle)
ghemical 0.82-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 9,448 kB
  • ctags: 18,571
  • sloc: ansic: 68,828; cpp: 51,774; fortran: 35,324; sh: 2,505; makefile: 475; perl: 70
file content (63 lines) | stat: -rw-r--r-- 1,744 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**********************************************************************
Copyright (C) 2000 by OpenEye Scientific Software, Inc.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
***********************************************************************/

#include "mol.h"

namespace OpenBabel {


bool ReadAmberPrep(istream &ifs,OBMol &mol,char *title)
{
  char buffer[BUFF_SIZE];
  string str,str1;
  OBAtom *atom;
  OBInternalCoord *coord;
  vector<string> vs;
  vector<OBInternalCoord*> internals;

  mol.BeginModify();

  while	(ifs.getline(buffer,BUFF_SIZE))
    {
      tokenize(vs,buffer);
      if (vs.size() > 8)
	{
	  atom = mol.NewAtom();
	  coord = new OBInternalCoord();
	  if (mol.NumAtoms() > 1)
	    coord->_a = mol.GetAtom(atoi(vs[4].c_str()));
	  if (mol.NumAtoms() > 2)
	    coord->_b = mol.GetAtom(atoi(vs[5].c_str()));
	  if (mol.NumAtoms() > 3)
	    coord->_c = mol.GetAtom(atoi(vs[6].c_str()));
	  coord->_dst = atof(vs[7].c_str());
	  coord->_ang = atof(vs[8].c_str());
	  coord->_tor = atof(vs[9].c_str());
	  internals.push_back(coord);

	  atom->SetAtomicNum(etab.GetAtomicNum(vs[1].c_str()));

	  if (!ifs.getline(buffer,BUFF_SIZE)) break;
	  tokenize(vs,buffer);
	}
    }
  InternalToCartesian(internals,mol);
  mol.EndModify();

  mol.ConnectTheDots();
  mol.PerceiveBondOrders();
  mol.SetTitle(title);
  return(true);
}

} // namespace