Commit 46afd6de authored by Martino Bertoni's avatar Martino Bertoni 🌋
Browse files

bugfix from Pau, changed GLOBAL signature logic, corrected the baseurl

parent af5e4de2
......@@ -43,7 +43,7 @@ pip install git+http://gitlabsbnb.irbbarcelona.org/packages/signaturizer.git
```python
from signaturizer import Signaturizer
# load the predictor for B1 space (representing the Mode of Action)
sign = Signaturizer('/aloy/web_checker/exported_smilespreds/B1')
sign = Signaturizer('B1')
# prepare a list of SMILES strings
smiles = ['C', 'CCC']
# run prediction
......@@ -64,8 +64,7 @@ results = sign.predict(smiles, 'destination.h5')
```python
from signaturizer import Signaturizer
# load the bioactivity space predictor for all space
models = ['/aloy/web_checker/exported_smilespreds/%s%s' % (y,x) for y in 'ABCDE' for x in '12345']
sign = Signaturizer(models)
sign = Signaturizer('GLOBAL')
# prepare a list of SMILES strings
smiles = ['C', 'CCC']
# run prediction
......
import os
import shutil
import tempfile
import tensorflow as tf
import tensorflow.compat.v1 as tf
import tensorflow_hub as hub
......
......@@ -18,7 +18,7 @@ class Signaturizer():
"""Class loading TF-hub module and performing predictions."""
def __init__(self, model_name, verbose=True,
base_url="https://chemicalchecker.org/signaturizer/"):
base_url="file:///aloy/web_checker/exported_smilespreds/"):
"""Initialize the Signaturizer.
Args:
......@@ -31,13 +31,13 @@ class Signaturizer():
base_url(str): The ChemicalChecker getModel API URL.
"""
self.verbose = verbose
if isinstance(model_name, list):
models = model_name
else:
if not isinstance(model_name, list):
if model_name.upper() == 'GLOBAL':
models = list(itertools.product("ABCDE", "12345"))
models = [y + x for y in 'ABCDE' for x in '12345']
else:
models = [model_name]
else:
models = model_name
# load modules
self.modules = list()
self.graph = tf.Graph()
......
......@@ -81,3 +81,9 @@ class TestSignaturizer(unittest.TestCase):
self.assertTrue(math.isnan(comp))
for comp in res.signature[2]:
self.assertFalse(math.isnan(comp))
def test_predict_global(self):
module = Signaturizer('GLOBAL')
res = module.predict(self.test_smiles)
self.assertEqual(res.signature.shape[0], 2)
self.assertEqual(res.signature.shape[1], 128 * 25)
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