-
Notifications
You must be signed in to change notification settings - Fork 0
/
pdb_match_chn.py
executable file
·57 lines (46 loc) · 1.33 KB
/
pdb_match_chn.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
"""
Map each chain ID in ref.pdb with another pdb file.
The best match is kept. Therefore, one chain can be matched to multiple chains.
Minimum sequence identity: 70 %
Usage:
pdb_match_chn.py <refe PDB file> <match PDB file>
Example:
pdb_match_chn.py example/ref.pdb example/model1.pdb
OUTPUT:
ref, modelpdb, score
A, A, 98.56
C, C, 100.0
D, D, 90.86
E, E, 84.01
"""
import sys, os
import pdb
import subprocess
import pdb
from myfun import *
def check_input(args):
if not len(args):
sys.stderr.write(__doc__)
sys.exit(1)
check_input(sys.argv[1:])
min_identity = 70
pdbFL1 = sys.argv[1]
pdbFL2 = sys.argv[2]
chainsA = get_chain_list(pdbFL1) #chain IDs in pdbFL1
chainsB = get_chain_list(pdbFL2) #chain IDs in pdbFL2
print("ref, modelpdb, score")
for chainA in chainsA:
match_nr = -1
match_chain = "None"
minscore = min_identity
for chainBnr in range(0, len(chainsB)):
chainB = chainsB[chainBnr]
result = subprocess.check_output(f"pdb-pdbalignscore {pdbFL1} {chainA} {pdbFL2} {chainB}", shell=True)
result = float(result)
if result > minscore:
minscore = result
match_nr = chainBnr
match_chain = chainsB[match_nr]
matchScore = result
print (f"{chainA}, {match_chain}, {matchScore}")