-
Notifications
You must be signed in to change notification settings - Fork 36
IterateOverAllProteinsOfASystem
dstoeckel edited this page Mar 16, 2015
·
2 revisions
Iterate over all Proteins in a System using BALL's MoleculeIterator:
#include <BALL/FORMAT/PDBFile.h>
#include <BALL/KERNEL/system.h>
#include <BALL/KERNEL/protein.h>
...
using namespace BALL;
using namespace std;
...
// read the PDB-file into a BALL::System
PDBFile f("myProtein.pdb");
System S;
f >> S;
for (MoleculeIterator m_it = S.beginMolecule(); +m_it; ++m_it)
{
if (RTTI::isKindOf<Protein>(*(m_it)))
{
// cast to BALL::Protein
Protein* protein = RTTI::castTo<Protein>(*(m_it));
// get the protein's sequence
cout << Peptides::GetSequence(*protein) << endl;
}
}Note that _+m_it _ equals m_it != S.endMolecule() !
Note also: Never try to add or remove Molecules from the System while iterating over it! Your program will crash!
import sys
from BALL import *
# read the PDB-file into a BALL::System
f = PDBFile(sys.argv[1])
S = System()
f.read(S)
for protein in proteins(S):
# get the protein's sequence
print Peptides.GetSequence(protein)