-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackuprec
38 lines (29 loc) · 894 Bytes
/
backuprec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import chimera
import os
from chimera import runCommand
inputfile = os.environ.get("IF")
outputfile = os.environ.get("OF")
chains = os.environ.get("CHAINS")
# MODULE
def prot_only(receptor):
for r in receptor.residues:
if r.isHet:
receptor.deleteResidue(r)
def chain_only(receptor, chain_names):
chains = receptor.sequences(asDict=True)
for chain in chains:
if chain not in chain_names:
for r in receptor.sequence(chain).residues:
if r is not None:
receptor.deleteResidue(r)
# MAIN
model = chimera.openModels.open(inputfile)
receptor = model[0]
if chains:
chain_names = chains.split(",")
else:
chain_names = receptor.sequences(asDict=True) # use all chains
chain_only(receptor, chain_names)
prot_only(receptor)
write_output = "write format pdb 0 %s" % outputfile
runCommand(write_output)