-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathalignTwoPdb.py
More file actions
executable file
·53 lines (46 loc) · 1.58 KB
/
alignTwoPdb.py
File metadata and controls
executable file
·53 lines (46 loc) · 1.58 KB
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
#!/usr/bin/env python3
import os
import argparse
import sys
from time import sleep
import subprocess
import myPersonalFunctions
parser = argparse.ArgumentParser(description="take two pdb, align them, and show them")
parser.add_argument("p1", help="first pdb")
parser.add_argument("p2", help="second pdb")
parser.add_argument("-p", "--plot", action="store_true", default=False, help="Plot the result")
args = parser.parse_args()
try:
protein1_name,_ = args.p1.split('.')
except:
try:
protein1_name,_ = args.p1.split('/')
except:
protein1_name = args.p1
print("ATTENSION! protein1 name {}\n Correct?".format(protein1_name))
try:
protein2_name,_ = args.p2.split('.')
except:
try:
protein2_name,_ = args.p2.split('/')
except:
protein2_name = args.p2
print("ATTENSION! protein2 name {}\n Correct?".format(protein2_name))
do = os.system
cd = os.chdir
do(f"~/opt/TMalign/TMalign {protein1_name}.pdb {protein2_name}.pdb -o result")
do("cp result_all_atm result_all_atm.pdb")
do("grep 'TM-score=' result > tmscore.dat")
# Seq_ID=n_identical/n_aligned
do("cat tmscore.dat")
with open("tmscore.dat", "r") as f:
for line in f:
aligned_length,rmsd,tmscore,seqid = line.split(",")
aligned_length = int(aligned_length.split("=")[1])
rmsd = float(rmsd.split("=")[1])
tmscore = float(tmscore.split("=")[1])
seqid = float(seqid.split("=")[1])
print("aligned_length, rmsd, tmscore, seqid")
print(aligned_length, rmsd, tmscore, seqid)
if(args.plot):
do("pymol ~/opt/plot_scripts/tmalign_all.pml")