Skip to content

IterateOverAllResiduesOfASystem

jleclaire edited this page Apr 25, 2017 · 3 revisions

How can I iterate over all residues of a system?

Iterate over all residues of a system using the ResidueIterator:

C++

#include <BALL/KERNEL/residueIterator.h>

BALL::System S;
...
BALL::ResidueIterator resit = S.beginResidue();
for (; +resit ; ++resit)
{
  std::cout << "Current residue: " << resit->getFullName() << std::endl;
}

Note that +resit equals resit != S.endResidue() !

python

import sys
from BALL import *

# read the PDB-file into a BALL::System
f = PDBFile(sys.argv[1])
S = System()
f.read(S)

for residue in residues(S):
  print "Current residue: " , residue.getFullName()
Clone this wiki locally