script for saving pdb chains in single file

This commit is contained in:
Tanushree Tunstall 2020-05-15 13:44:57 +01:00
parent bc2844dffb
commit f28b287c86
4 changed files with 103 additions and 17 deletions

26
scripts/chain_extract.py Normal file → Executable file
View file

@ -10,21 +10,15 @@
from Bio.PDB import PDBParser, PDBIO, Select
io = PDBIO()
pdb = PDBParser().get_structure("3byw", "3byw.pdb")
# Select() Method to return True for every chain in 'chains'
class ChainSelect(Select):
def accept_chain(self, chain):
#print dir(chain)
if chain.id in chains:
return 1
else:
return 0
if __name__ == '__main__':
chains = ['G', 'H'] # specify selected chains
io.set_structure(pdb)
io.save(pdb.get_id() + "_crop.pdb", ChainSelect())
class ChainExtract(Select):
def __init__(self, chain):
self.chain = chain
def accept_chain(self, chain):
#print(dir(chain))
if chain.id in self.chain:
return 1
else:
return 0