-
Notifications
You must be signed in to change notification settings - Fork 34
IterateOverAllChainsInASystem
jleclaire edited this page Apr 25, 2017
·
4 revisions
Iterate over all Chains in a System using BALL's ChainIterator:
#include <BALL/KERNEL/chainIterator.h>
...
BALL::System S;
...
BALL::ChainIterator ch_it = S.beginChain();
for (; +ch_it; ++ch_it)
{
std::cout << ch_it->countResidues() << std::endl;
}
Note, that +ch_it
equals ch_it != S.endChain()
!
Note also: Never try to add or remove atoms or chains 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)
print "Number of chains :" , len(chains(S))
for chain in chains(S):
print "Number of residues: ", chain.countResidues()