Commit db86fb65 authored by David M. Rogers's avatar David M. Rogers
Browse files

Refactored Jens' rescoring and added.

parent e4704b17
#!/usr/bin/env python3
from helpers import *
import os
import pandas as pd
import oddt
from oddt.scoring import descriptors
def main(argv):
assert len(argv) == 3, "Usage: %s <receptor.pdbqt> <ligs.pq>"
# set up descriptors
receptor = next(oddt.toolkit.readfile('pdbqt', argv[1]))
df = pd.read_parquet(argv[2])
os.remove(argv[2]) # signal job start
cutoff = 12
ligand_atomic_nums = [6, 7, 8, 9, 15, 16, 17, 35, 53]
protein_atomic_nums = [6, 7, 8, 16]
cc = oddt.scoring.descriptors.close_contacts_descriptor(
receptor,
cutoff=cutoff,
protein_types=protein_atomic_nums,
ligand_types=ligand_atomic_nums)
vina_scores = ['vina_gauss1',
'vina_gauss2',
'vina_repulsion',
'vina_hydrophobic',
'vina_hydrogen',
'vina_num_rotors']
vina = oddt.scoring.descriptors.oddt_vina_descriptor(receptor, vina_scores=vina_scores)
descriptors_v1 = cc
descriptors_v2 = oddt.scoring.descriptors.close_contacts_descriptor(
receptor,
cutoff=np.array([0, 2, 4, 6, 8, 10, 12]),
protein_types=protein_atomic_nums,
ligand_types=ligand_atomic_nums)
descriptors_v3 = oddt.scoring.ensemble_descriptor((vina, cc))
# calculate descriptors individually
desc_rfscore1 = []
desc_rfscore2 = []
desc_rfscore3 = []
for x in df['conf']:
if pd.isnan(x):
desc_rfscore1.append(None)
desc_rfscore2.append(None)
desc_rfscore3.append(None)
continue
try:
c = oddt.toolkit.readstring('pdbqt', x)
desc_rfscore1.append(descriptors_v1.build(c))
desc_rfscore2.append(descriptors_v2.build(c))
desc_rfscore3.append(descriptors_v3.build(c))
except Exception:
desc_rfscore1.append(None)
desc_rfscore2.append(None)
desc_rfscore3.append(None)
result = pd.DataFrame({'name': df['name'].astype(str),
'desc_rfscore1': desc_rfscore1,
'desc_rfscore2': desc_rfscore2,
'desc_rfscore3': desc_rfscore3,
})
result.set_index('name')
result.to_parquet(argv[2], compression='snappy', engine='pyarrow')
if __name__=="__main__":
import sys
main(sys.argv)
......@@ -29,5 +29,5 @@ rescore:
- targets/{r}.tgz # note: untarring is automatic
- {r}_docked/{n}.pq
script:
/apps/scoring/rescore.py {r}.pdbqt {n}.pq
/apps/scoring/rescore.py *{r}*.pdbqt {n}.pq
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment