Skip to content

Commit 6e6d520

Browse files
committed
Bug fix on tmap plotter
1 parent eb39739 commit 6e6d520

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

sampledock/SnD/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .docking import dock, sort_pose, save_pose
22
from .pocket_prepare import prep_prm
33
from .sampler_util import hyperparam_loader, create_wd, smiles_to_sdfile
4-
from .post_process import mkdf, combine_designs
4+
from .post_process import mkdf, combine_designs
5+
from .tmap_plotter import LSH_Convert, tree_coords, df_to_faerun

sampledock/SnD/tmap_plotter.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,18 @@
66
# NON-COMMERCIAL LICENSE: https://github.com/atfrank/SampleDock/blob/master/LICENSE_NON-COMMERICAL
77
# Frank Lab 2020-2021
88

9+
import os
910
import pickle
1011
import tmap as tm
1112
from mhfp.encoder import MHFPEncoder
1213
from faerun import Faerun
1314
from matplotlib import pyplot as plt
1415
import pandas as pd
16+
from .post_process import df_from_molProps
1517

1618
from tqdm.contrib.concurrent import process_map
17-
18-
def df_from_molProps(mols):
19-
# declare a named tuple
20-
Prop = namedtuple('Prop',['SMILES','Score','MolWeight','LogP','QED','SAS'])
21-
props = [(mol.GetProp('SMILES'),
22-
float(mol.GetProp('SCORE.INTER')),
23-
float(mol.GetProp('MolWeight')),
24-
float(mol.GetProp('LogP')),
25-
float(mol.GetProp('QED')),
26-
float(mol.GetProp('SAS'))) for mol in mols]
27-
# Make it a named tuple
28-
props = [Prop._make(p) for p in props]
29-
return pd.DataFrame(props)
3019

31-
def LSH_Convert(mols, num_workers):
20+
def LSH_Convert(mols, outpath, num_workers):
3221
# MinHash fingerprints (mhfp) encoder for molecular fingerprinting
3322
enc = MHFPEncoder(1024)
3423
# Locality Sensitive Hashing Forest Instance
@@ -68,7 +57,7 @@ def tree_coords(lf, node_size = 1/20, k = 20, mmm_rps = 2):
6857
x, y, s, t, _ = tm.layout_from_lsh_forest(lf, cfg)
6958
return list(x), list(y), list(s), list(t)
7059

71-
def df_to_faerun(df):
60+
def df_to_faerun(df,x,y,s,t):
7261
print('Making Faerun plot')
7362
f = Faerun(view="front", coords=False)
7463
f.add_scatter(
@@ -105,8 +94,8 @@ def df_to_faerun(df):
10594
)
10695
# The first character of the name has to be a letter!
10796
f.add_tree("SnD_Tree", {"from": s, "to": t}, point_helper="SampleDock")
108-
10997
print('Plotting finished')
98+
return f
11099

111100
if __name__ == '__main__':
112101
import argparse

0 commit comments

Comments
 (0)