You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dstoeckel edited this page Mar 16, 2015
·
2 revisions
How can I iterate over all Proteins of a System?
Iterate over all Proteins in a System using BALL's MoleculeIterator:
C++
#include<BALL/FORMAT/PDBFile.h>
#include<BALL/KERNEL/system.h>
#include<BALL/KERNEL/protein.h>
...
usingnamespaceBALL;usingnamespacestd;
...
// 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!
Python
importsysfromBALLimport*# read the PDB-file into a BALL::Systemf=PDBFile(sys.argv[1])
S=System()
f.read(S)
forproteininproteins(S):
# get the protein's sequenceprintPeptides.GetSequence(protein)