1
/**********************************************************************
2
Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
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
***********************************************************************/
17
#include "molvector.h"
21
//Functions for dealing with groups of molecules. MolVec will read either all
22
//molecules from a file or a set of conformers.
24
OEMolVector::~OEMolVector()
26
for (unsigned int i = 0; i < _molvec.size(); i++)
32
// Read all molecules from a file into a OEMolVector. Input and output types
35
void OEMolVector::Read(ifstream &ifs, const io_type in_type, const io_type out_type, int nToRead)
41
if (nRead == nToRead) break;
44
(*mol).SetInputType(in_type);
45
(*mol).SetOutputType(out_type);
46
ff.ReadMolecule(ifs,*mol);
48
if (!(*mol).NumAtoms())
53
_molvec.push_back(mol);
57
// Write a OEMolVector to a file. Output type defaults to SDF
59
void OEMolVector::Write(ofstream &ofs)
61
vector<OEMol *>::iterator mol_i;
64
for (mol_i = _molvec.begin(); mol_i != _molvec.end(); mol_i++)
66
ff.WriteMolecule(ofs,(**mol_i));
70
// Get a specific molecule from a OEMolVector. Index starts at zero.
71
OEMol *OEMolVector::GetMol(int i)
73
if (i >= 0 && i < (signed)_molvec.size())
77
cerr << "Index " << i << " out of range in OEMolVector::GetMol " << endl;
82
// Read a set of conformers from an input file and put them into a MolVec.
83
// This function read the first molecule and sets the current title (held
84
// int the variable master) to be the current title. It continues to read
85
// molecules and push them into the vector util it reads a molecule with a
86
// different name. At this point it rewinds the file stream to the beginning
87
// of the current molecule and returns
88
bool OEMolVector::ReadConfs(ifstream &ifs, const io_type in_type, const io_type out_type)
100
(*mol).SetInputType(in_type);
101
(*mol).SetOutputType(out_type);
102
streampos sp = ifs.tellg();
103
ff.ReadMolecule(ifs,*mol);
104
if (mol->NumAtoms() == 0)
110
title = mol->GetTitle();
114
_molvec.push_back(mol);
119
_molvec.push_back(mol);
133
} // namespace OpenEye