jglaser commited on
Commit
0a05de5
·
1 Parent(s): d802ce7

add RF2 scoring for testing

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -0
  2. data/dcoid_rf2.parquet +3 -0
  3. dcoid_combine.py +4 -3
  4. dcoid_rf2.py +77 -0
  5. dcoid_rf2.slurm +10 -0
.gitattributes CHANGED
@@ -816,3 +816,4 @@ data/dude/part.713.parquet filter=lfs diff=lfs merge=lfs -text
816
  data/dude/part.82.parquet filter=lfs diff=lfs merge=lfs -text
817
  data/dude_predict.parquet filter=lfs diff=lfs merge=lfs -text
818
  data/dcoid.parquet filter=lfs diff=lfs merge=lfs -text
 
 
816
  data/dude/part.82.parquet filter=lfs diff=lfs merge=lfs -text
817
  data/dude_predict.parquet filter=lfs diff=lfs merge=lfs -text
818
  data/dcoid.parquet filter=lfs diff=lfs merge=lfs -text
819
+ data/dcoid_rf2.parquet filter=lfs diff=lfs merge=lfs -text
data/dcoid_rf2.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f22bcc4300a2c97a7346b9dfa8e072de088a3c6e5ac4d955c1ab2a89cc6d2ab
3
+ size 148055
dcoid_combine.py CHANGED
@@ -1,12 +1,13 @@
1
  import pandas as pd
 
2
 
3
  if __name__ == '__main__':
4
  import glob
5
 
6
- df_actives = pd.read_parquet('data/dcoid_actives.parquet')
7
- df_decoys = pd.read_parquet('data/dcoid_decoys.parquet')
8
 
9
  df_actives['active'] = pd.Series([True]*len(df_actives))
10
  df_decoys['active'] = pd.Series([False]*len(df_decoys))
11
 
12
- pd.concat([df_actives,df_decoys]).to_parquet('data/dcoid.parquet')
 
1
  import pandas as pd
2
+ import sys
3
 
4
  if __name__ == '__main__':
5
  import glob
6
 
7
+ df_actives = pd.read_parquet(sys.argv[1])
8
+ df_decoys = pd.read_parquet(sys.argv[2])
9
 
10
  df_actives['active'] = pd.Series([True]*len(df_actives))
11
  df_decoys['active'] = pd.Series([False]*len(df_decoys))
12
 
13
+ pd.concat([df_actives,df_decoys]).to_parquet(sys.argv[3])
dcoid_rf2.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from mpi4py import MPI
2
+ from mpi4py.futures import MPICommExecutor
3
+
4
+
5
+ from oddt.scoring.functions import RFScore
6
+ import oddt
7
+ from Bio.PDB import PDBParser, PDBIO, Select
8
+ import tempfile
9
+ import os
10
+ import sys
11
+
12
+ import pandas as pd
13
+
14
+ scorer = RFScore.rfscore.load(version=2)
15
+
16
+ def is_het(residue):
17
+ res = residue.id[0]
18
+ return res != " " and res != "W"
19
+
20
+ class ResidueSelect(Select):
21
+ def __init__(self, het):
22
+ self.het = het
23
+
24
+ def accept_residue(self, residue):
25
+ """ Recognition of heteroatoms - Remove water molecules """
26
+ return (self.het and is_het(residue) or not self.het and not is_het(residue))
27
+
28
+ def get_complex(fn):
29
+ try:
30
+ io = PDBIO()
31
+ parser = PDBParser()
32
+
33
+ structure = parser.get_structure('complex',fn)
34
+ io.set_structure(structure)
35
+
36
+ with tempfile.NamedTemporaryFile(mode='w',delete=False) as f:
37
+ name_receptor = f.name
38
+
39
+ with tempfile.NamedTemporaryFile(mode='w',delete=False) as f:
40
+ name_ligand = f.name
41
+
42
+ io.save(name_receptor,ResidueSelect(het=False))
43
+ io.save(name_ligand,ResidueSelect(het=True))
44
+
45
+ receptor = next(oddt.toolkit.readfile('pdb',name_receptor))
46
+ ligand = next(oddt.toolkit.readfile('pdb',name_ligand))
47
+
48
+ scorer.set_protein(receptor)
49
+ scorer.predict_ligand(ligand)
50
+
51
+ os.unlink(name_ligand)
52
+ os.unlink(name_receptor)
53
+ return float(ligand.data['rfscore_v2'])
54
+ except Exception as e:
55
+ print(e)
56
+ pass
57
+
58
+ if __name__ == '__main__':
59
+ import glob
60
+
61
+ filenames = glob.glob(sys.argv[2])
62
+ comm = MPI.COMM_WORLD
63
+ with MPICommExecutor(comm, root=0) as executor:
64
+ if executor is not None:
65
+ result = executor.map(get_complex, filenames)
66
+
67
+ names = []
68
+ scores = []
69
+ for n,r in zip(filenames,result):
70
+ try:
71
+ scores.append(r)
72
+ names.append(os.path.basename(n))
73
+ except:
74
+ pass
75
+ df = pd.DataFrame({'name': names, 'rf2': scores})
76
+ df.to_parquet(sys.argv[1])
77
+
dcoid_rf2.slurm ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ #SBATCH -J dcoid_rf2
3
+ #SBATCH -p batch
4
+ #SBATCH -A STF006
5
+ #SBATCH -t 1:00:00
6
+ #SBATCH -N 8
7
+ #SBATCH --ntasks-per-node=32
8
+
9
+ srun python dcoid_rf2.py data/dcoid_rf2_actives.parquet "/gpfs/alpine/world-shared/bip214/binding_affinity/dcoid/actives/*pdb"
10
+ srun python dcoid_rf2.py data/dcoid_rf2_decoys.parquet "/gpfs/alpine/world-shared/bip214/binding_affinity/dcoid/decoys/*pdb"