|
6 | 6 | # NON-COMMERCIAL LICENSE: https://github.com/atfrank/SampleDock/blob/master/LICENSE_NON-COMMERICAL
|
7 | 7 | # Frank Lab 2020-2021
|
8 | 8 |
|
| 9 | +import os |
9 | 10 | import pickle
|
10 | 11 | import tmap as tm
|
11 | 12 | from mhfp.encoder import MHFPEncoder
|
12 | 13 | from faerun import Faerun
|
13 | 14 | from matplotlib import pyplot as plt
|
14 | 15 | import pandas as pd
|
| 16 | +from .post_process import df_from_molProps |
15 | 17 |
|
16 | 18 | 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) |
30 | 19 |
|
31 |
| -def LSH_Convert(mols, num_workers): |
| 20 | +def LSH_Convert(mols, outpath, num_workers): |
32 | 21 | # MinHash fingerprints (mhfp) encoder for molecular fingerprinting
|
33 | 22 | enc = MHFPEncoder(1024)
|
34 | 23 | # Locality Sensitive Hashing Forest Instance
|
@@ -68,7 +57,7 @@ def tree_coords(lf, node_size = 1/20, k = 20, mmm_rps = 2):
|
68 | 57 | x, y, s, t, _ = tm.layout_from_lsh_forest(lf, cfg)
|
69 | 58 | return list(x), list(y), list(s), list(t)
|
70 | 59 |
|
71 |
| -def df_to_faerun(df): |
| 60 | +def df_to_faerun(df,x,y,s,t): |
72 | 61 | print('Making Faerun plot')
|
73 | 62 | f = Faerun(view="front", coords=False)
|
74 | 63 | f.add_scatter(
|
@@ -105,8 +94,8 @@ def df_to_faerun(df):
|
105 | 94 | )
|
106 | 95 | # The first character of the name has to be a letter!
|
107 | 96 | f.add_tree("SnD_Tree", {"from": s, "to": t}, point_helper="SampleDock")
|
108 |
| - |
109 | 97 | print('Plotting finished')
|
| 98 | + return f |
110 | 99 |
|
111 | 100 | if __name__ == '__main__':
|
112 | 101 | import argparse
|
|
0 commit comments