Skip to content
dstoeckel edited this page Mar 16, 2015 · 2 revisions

How can I pick one single chain out of a system containing several chains?

Separate e.g. a docked structure into ligand and receptor or extract one chain of a multimere.

#include <BALL/KERNEL/system.h>
#include <BALL/KERNEL/protein.h>
#include <BALL/KERNEL/chain.h>

using namespace BALL;

//first a system is needed, e.g from a .pdb file
PDBFile infile("system.pdb");
System S;
infile >> S;
infile.close();

//prepare protein containers for the different proteins/chains of the system
//this intermediate step is needed because a chain is just part of a larger complex and by this can not be directly written into a file
Protein first;
Protein second;

//iterate over all chains in the system
Chain C;
ChainIterator chain_it;
for(chain_it = S.beginChain(); chain_it != S.endChain(); ++chain_it)
{
  //in between a selection criteria is needed to find the specific chain
  C = *chain_it;
  firstChain.insert(C);
}
//now C contains the selected chain and can be used further, e.g. it can be written in a separate file firstChain.pdb
PDBFile outfile("firstChain.pdb", File::MODE_OUT);
outfile << first;
outfile.close();  
Clone this wiki locally