add dude processing scripts
Browse files- dude.py +74 -0
- dude.slurm +9 -0
- dude_combine.py +10 -0
dude.py
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from mpi4py import MPI
|
2 |
+
from mpi4py.futures import MPICommExecutor
|
3 |
+
|
4 |
+
from Bio.PDB import PDBParser, PPBuilder
|
5 |
+
import warnings
|
6 |
+
|
7 |
+
import gzip
|
8 |
+
import tempfile
|
9 |
+
import os
|
10 |
+
from rdkit import Chem
|
11 |
+
|
12 |
+
import pandas as pd
|
13 |
+
|
14 |
+
def open_ligands(fn):
|
15 |
+
with tempfile.NamedTemporaryFile(mode='w+b',delete=False) as f:
|
16 |
+
with gzip.open(fn,'rb') as g:
|
17 |
+
f.write(g.read())
|
18 |
+
name = f.name
|
19 |
+
|
20 |
+
suppl = Chem.SDMolSupplier(name)
|
21 |
+
os.unlink(name)
|
22 |
+
return suppl
|
23 |
+
|
24 |
+
def get_ligands(path):
|
25 |
+
try:
|
26 |
+
parser = PDBParser()
|
27 |
+
with warnings.catch_warnings():
|
28 |
+
warnings.simplefilter("ignore")
|
29 |
+
structure = parser.get_structure('protein',path+'/receptor.pdb')
|
30 |
+
ppb = PPBuilder()
|
31 |
+
seq = []
|
32 |
+
for pp in ppb.build_peptides(structure):
|
33 |
+
seq.append(str(pp.get_sequence()))
|
34 |
+
seq = ''.join(seq)
|
35 |
+
|
36 |
+
name = os.path.basename(path)
|
37 |
+
|
38 |
+
decoys = open_ligands(path+'/decoys_final.sdf.gz')
|
39 |
+
actives = open_ligands(path+'/actives_final.sdf.gz')
|
40 |
+
|
41 |
+
actives_smiles = []
|
42 |
+
for m in actives:
|
43 |
+
try:
|
44 |
+
actives_smiles.append(Chem.MolToSmiles(m))
|
45 |
+
except:
|
46 |
+
pass
|
47 |
+
|
48 |
+
decoys_smiles = []
|
49 |
+
for m in decoys:
|
50 |
+
try:
|
51 |
+
decoys_smiles.append(Chem.MolToSmiles(m))
|
52 |
+
except:
|
53 |
+
pass
|
54 |
+
|
55 |
+
all_smiles = actives_smiles + decoys_smiles
|
56 |
+
all_active = [True]*len(actives_smiles) + [False]*len(decoys_smiles)
|
57 |
+
names = [name]*len(all_active)
|
58 |
+
seqs = [seq]*len(all_active)
|
59 |
+
df = pd.DataFrame({'name': names, 'seq': seqs, 'smiles': all_smiles, 'active': all_active})
|
60 |
+
|
61 |
+
df.to_parquet(path+'/ligands.parquet')
|
62 |
+
except Exception as e:
|
63 |
+
print(e)
|
64 |
+
pass
|
65 |
+
|
66 |
+
|
67 |
+
if __name__ == '__main__':
|
68 |
+
import glob
|
69 |
+
|
70 |
+
filenames = glob.glob('DUDE/all/*')
|
71 |
+
comm = MPI.COMM_WORLD
|
72 |
+
with MPICommExecutor(comm, root=0) as executor:
|
73 |
+
if executor is not None:
|
74 |
+
executor.map(get_ligands, filenames)
|
dude.slurm
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
#SBATCH -J preprocess_dude
|
3 |
+
#SBATCH -p gpu
|
4 |
+
#SBATCH -A STF006
|
5 |
+
#SBATCH -t 3:00:00
|
6 |
+
#SBATCH -N 8
|
7 |
+
#SBATCH --ntasks-per-node=16
|
8 |
+
|
9 |
+
srun python dude.py
|
dude_combine.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import dask.dataframe as dd
|
2 |
+
|
3 |
+
if __name__ == '__main__':
|
4 |
+
import glob
|
5 |
+
|
6 |
+
filenames = glob.glob('DUDE/all/*/ligands.parquet')
|
7 |
+
|
8 |
+
ddf = dd.read_parquet(filenames)
|
9 |
+
df = ddf.compute()
|
10 |
+
df.to_parquet('data/dude.parquet')
|