-
Notifications
You must be signed in to change notification settings - Fork 1
/
compute_rmsds.py
executable file
·29 lines (22 loc) · 905 Bytes
/
compute_rmsds.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
#!/usr/bin/env python3
'''Given an sdf file, UFF minimize all the conformations in it. Save the result
in the same order with an energy property on each conformation.
'''
import numpy as np
import os, argparse,glob, sys
from rdkit.Chem import AllChem as Chem
import gzip, re, subprocess
parser = argparse.ArgumentParser()
parser.add_argument("--sdf", type=str, required=True,help="sdf file")
args = parser.parse_args()
fname = args.sdf
m = re.search(r'(.*?(_ligand)?)_',fname)
refsdf = m.group(1)+'.sdf'
refsdf = refsdf.replace('_nosc','')
out = fname.replace('.sdf.gz','.rmsds.txt')
subprocess.check_output(f'obrms -f -m {refsdf} {fname} > {out}',shell=True)
#cross rmsds
out = fname.replace('sdf.gz','crms.npy')
text = subprocess.check_output(f'obrms -m -x {fname}',shell=True)
A = np.array([line.split(',')[1:] for line in text.decode().split('\n') if line],dtype=float)
np.save(out,A)