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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
|
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: extractors.C,v 1.2.8.2 2007/03/27 21:16:34 amoll Exp $
//
// Author:
// Oliver Kohlbacher
//
#include <BALL/KERNEL/extractors.h>
#include <BALL/KERNEL/expression.h>
#include <BALL/KERNEL/atomContainer.h>
#include <BALL/KERNEL/residue.h>
#include <BALL/KERNEL/protein.h>
#include <BALL/KERNEL/nucleicAcid.h>
namespace BALL
{
AtomList atoms(const AtomContainer& fragment, const String& expression)
{
AtomList result;
// iterate over all atoms
AtomConstIterator it = fragment.beginAtom();
if (expression == "")
{
for (; +it; ++it)
{
// store the atom pointer in the list
result.push_back(const_cast<Atom*>(&*it));
}
}
else
{
Expression match(expression);
for (; +it; ++it)
{
if (match(*it))
{
// store the atom pointer in the list
result.push_back(const_cast<Atom*>(&*it));
}
}
}
return result;
}
AtomList atoms(const AtomList& atom_list, const String& expression)
{
AtomList result;
// iterate over all atoms
AtomList::const_iterator it = atom_list.begin();
Expression match(expression);
for (; it != atom_list.end(); ++it)
{
if (match(**it))
{
// store the atom pointer in the list
result.push_back(const_cast<Atom*>(*it));
}
}
return result;
}
PDBAtomList PDBAtoms(const AtomContainer& fragment, const String& expression)
{
PDBAtomList result;
// iterate over all atoms
AtomConstIterator it = fragment.beginAtom();
if (expression == "")
{
for (; +it; ++it)
{
const PDBAtom* pdb_atom = dynamic_cast<const PDBAtom*>(&*it);
if (pdb_atom != 0)
{
// store the pdb atom pointer in the list
result.push_back(const_cast<PDBAtom*>(pdb_atom));
}
}
}
else
{
Expression match(expression);
for (; +it; ++it)
{
const PDBAtom* pdb_atom = dynamic_cast<const PDBAtom*>(&*it);
if ((pdb_atom != 0) && match(*pdb_atom))
{
// store the pdb atom pointer in the list
result.push_back(const_cast<PDBAtom*>(pdb_atom));
}
}
}
return result;
}
BondList bonds(const AtomContainer& fragment, bool selected_only)
{
// iterate over all atoms
HashSet<Bond*> bond_set;
AtomConstIterator atom_it = fragment.beginAtom();
for (; +atom_it; ++atom_it)
{
if (atom_it->isSelected() || !selected_only)
{
// it the atom is selected or selection is irrelevant,
// insert all bonds into the bond_set
Atom::BondConstIterator bond_it = atom_it->beginBond();
for (; +bond_it; ++bond_it)
{
bond_set.insert(const_cast<Bond*>(&*bond_it));
}
}
}
// copy the results from the hash set to the list
BondList result;
for (HashSet<Bond*>::Iterator it = bond_set.begin(); +it; ++it)
{
result.push_back(*it);
}
return result;
}
BondList bonds(const Atom& atom)
{
BondList result;
Atom::BondConstIterator bond_it = atom.beginBond();
for (; +bond_it; ++bond_it)
{
result.push_back(const_cast<Bond*>(&*bond_it));
}
return result;
}
AtomContainerList atomContainers(const AtomContainer& fragment, bool selected_only)
{
AtomContainerList result;
// iterate over all base fragments
AtomContainerConstIterator it = fragment.beginAtomContainer();
for (; +it; ++it)
{
if (!selected_only || it->isSelected())
{
// store the base fragment pointer in the list
result.push_back(const_cast<AtomContainer*>(&*it));
}
}
return result;
}
FragmentList fragments(const AtomContainer& fragment, bool selected_only)
{
// iterate over all fragments
FragmentList result;
AtomContainerConstIterator it = fragment.beginAtomContainer();
for (; +it; ++it)
{
const Fragment* fragment = dynamic_cast<const Fragment*>(&*it);
if ((fragment != 0) && (it->isSelected() || !selected_only))
{
// store the fragment pointer in the list
result.push_back(const_cast<Fragment*>(fragment));
}
}
return result;
}
MoleculeList molecules(const AtomContainer& fragment, bool selected_only)
{
// iterate over all molecules
AtomContainerConstIterator it = fragment.beginAtomContainer();
MoleculeList result;
for (; +it; ++it)
{
const Molecule* molecule = dynamic_cast<const Molecule*>(&*it);
if ((molecule != 0) && (it->isSelected() || !selected_only))
{
// store the molecule pointer in the list
result.push_back(const_cast<Molecule*>(molecule));
}
}
return result;
}
ResidueList residues(const AtomContainer& fragment, bool selected_only)
{
// iterate over all residues
AtomContainerConstIterator it = fragment.beginAtomContainer();
ResidueList result;
for (; +it; ++it)
{
const Residue* residue = dynamic_cast<const Residue*>(&*it);
if ((residue != 0) && (it->isSelected() || !selected_only))
{
// store the residue pointer in the list
result.push_back(const_cast<Residue*>(residue));
}
}
return result;
}
SecondaryStructureList secondaryStructures(const AtomContainer& fragment, bool selected_only)
{
// iterate over all secondary structures
AtomContainerConstIterator it = fragment.beginAtomContainer();
SecondaryStructureList result;
for (; +it; ++it)
{
const SecondaryStructure* sec_struct = dynamic_cast<const SecondaryStructure*>(&*it);
if ((sec_struct != 0) && (it->isSelected() || !selected_only))
{
// store the sec_struct pointer in the list
result.push_back(const_cast<SecondaryStructure*>(sec_struct));
}
}
return result;
}
ChainList chains(const AtomContainer& fragment, bool selected_only)
{
// iterate over all chains
AtomContainerConstIterator it = fragment.beginAtomContainer();
ChainList result;
for (; +it; ++it)
{
const Chain* chain = dynamic_cast<const Chain*>(&*it);
if ((chain != 0) && (it->isSelected() || !selected_only))
{
// store the chain pointer in the list
result.push_back(const_cast<Chain*>(chain));
}
}
return result;
}
ProteinList proteins(const AtomContainer& fragment, bool selected_only)
{
// iterate over all proteins
AtomContainerConstIterator it = fragment.beginAtomContainer();
ProteinList result;
for (; +it; ++it)
{
const Protein* protein = dynamic_cast<const Protein*>(&*it);
if ((protein != 0) && (it->isSelected() || !selected_only))
{
// store the protein pointer in the list
result.push_back(const_cast<Protein*>(protein));
}
}
return result;
}
NucleotideList nucleotides(const AtomContainer& fragment, bool selected_only)
{
// iterate over all proteins
AtomContainerConstIterator it = fragment.beginAtomContainer();
NucleotideList result;
for (; +it; ++it)
{
const Nucleotide* nucleotide = dynamic_cast<const Nucleotide*>(&*it);
if ((nucleotide != 0) && (it->isSelected() || !selected_only))
{
// store the nucleotide pointer in the list
result.push_back(const_cast<Nucleotide*>(nucleotide));
}
}
return result;
}
NucleicAcidList nucleicAcids(const AtomContainer& fragment, bool selected_only)
{
// iterate over all proteins
AtomContainerConstIterator it = fragment.beginAtomContainer();
NucleicAcidList result;
for (; +it; ++it)
{
const NucleicAcid* nucleic_acid = dynamic_cast<const NucleicAcid*>(&*it);
if ((nucleic_acid != 0) && (it->isSelected() || !selected_only))
{
// store the nucleic acid pointer in the list
result.push_back(const_cast<NucleicAcid*>(nucleic_acid));
}
}
return result;
}
}
|