MolecularAI / reinvent-scoring

Apache License 2.0
10 stars 14 forks source link

DockStream absent from score_component_factory #1

Closed j3mdamas closed 2 years ago

j3mdamas commented 2 years ago

Hi,

@patronov, I'm tagging you as this is a breaking feature for DockStream.

In the latest release on pip and on the source code on master, the reinvent_scoring does not allow the usage of dockstream as a component on Reinvent 3.0 as the class is not imported and enumerated. When adding such a component to a Reinvent 3.0 run, this is the traceback:

Traceback (most recent call last):
  File "/progs/all/opensource/reinvent/3.0/source/input.py", line 21, in <module>
    manager.run()
  File "/cluster/import/master/progs/all/opensource/reinvent/3.0/source/running_modes/manager.py", line 16, in run
    runner = RunningMode(self.configuration)
  File "/cluster/import/master/progs/all/opensource/reinvent/3.0/source/running_modes/constructors/running_mode.py", line 22, in __new__
    return ReinforcementLearningModeConstructor(configuration)
  File "/cluster/import/master/progs/all/opensource/reinvent/3.0/source/running_modes/constructors/reinforcement_learning_mode_constructor.py", line 20, in __new__
    scoring_function = ScoringFunctionFactory(config.scoring_function)
  File "/progs/all/opensource/reinvent/3.0/miniconda3/lib/python3.7/site-packages/reinvent_scoring/scoring/scoring_function_factory.py", line 16, in __new__
    return cls.create_scoring_function_instance(sf_parameters, scoring_function_registry)
  File "/progs/all/opensource/reinvent/3.0/miniconda3/lib/python3.7/site-packages/reinvent_scoring/scoring/scoring_function_factory.py", line 25, in create_scoring_function_instance
    return scoring_function(parameters, sf_parameters.parallel)
  File "/progs/all/opensource/reinvent/3.0/miniconda3/lib/python3.7/site-packages/reinvent_scoring/scoring/function/custom_product.py", line 14, in __init__
    super().__init__(parameters, parallel)
  File "/progs/all/opensource/reinvent/3.0/miniconda3/lib/python3.7/site-packages/reinvent_scoring/scoring/function/base_scoring_function.py", line 62, in __init__
    self.scoring_components = factory.create_score_components()
  File "/progs/all/opensource/reinvent/3.0/miniconda3/lib/python3.7/site-packages/reinvent_scoring/scoring/score_components/score_component_factory.py", line 69, in create_score_components
    return [self._current_components.get(p.component_type)(p) for p in self._parameters]
  File "/progs/all/opensource/reinvent/3.0/miniconda3/lib/python3.7/site-packages/reinvent_scoring/scoring/score_components/score_component_factory.py", line 69, in <listcomp>
    return [self._current_components.get(p.component_type)(p) for p in self._parameters]
TypeError: 'NoneType' object is not callable

This is quickly fixed with this patch:

@@ -7,7 +7,7 @@ from reinvent_scoring.scoring.score_components import TanimotoSimilarity, \
     SASComponent, MolWeight, PSA, RotatableBonds, HBD_Lipinski, HBA_Lipinski, \
     NumRings, AZlogD74, HLMClint, SlogP, \
     RHClint, HHClint, SolubilityDD, HERG, CACO2Intrinsic, CACO2Efflux, AZdock, RatPKPiP, Top20, GraphLength, \
-    NumberOfStereoCenters
+    NumberOfStereoCenters, DockStream
 from reinvent_scoring.scoring.score_components import BaseScoreComponent
 from reinvent_scoring.scoring.enums import ScoringFunctionComponentNameEnum
 from reinvent_scoring.scoring.score_components.pip.pip_log_prediction_component import PiPLogPredictionComponent
@@ -61,7 +61,8 @@ class ScoreComponentFactory:
             enum.RAT_PK_PIP: RatPKPiP,
             enum.CLAB_TOP_20: Top20,
             enum.RA_SCORE: PiPPredictionComponent,
-            enum.KPUU_PIP: PiPLogPredictionComponent
+            enum.KPUU_PIP: PiPLogPredictionComponent,
+            enum.DOCKSTREAM: DockStream
         }
         return component_map

I can fix it on my deployment, but it's quite cumbersome to start having too many hacks on it. Do you think it is possible to fix it and release a new version of the package?

Thanks in advance, João

patronov commented 2 years ago

Hi João,

Thanks for pointing this out. Will, aim to include this in the next version.

Should also mention that the latest versions (0.0.50) also include changes in ComponentParameters. The fields model_path and smiles are no longer relevant as they are moved to reside within specific_parameters. Didnt update the public git repo but you can get it from pip install reinvent-scoring.

Best,

Atanas

j3mdamas commented 2 years ago

Thanks! So it will be on 0.0.51? Could you let me know so I can update my env file to pick up that version instead when it's available?

patronov commented 2 years ago

Should be there now. Please, also note that the transformation is now in specific_parameters under the keyword: transformation thats where all the transformation related parameters are held.

j3mdamas commented 2 years ago

@patronov thanks a lot! I'll be out of the office, I'll check it when I'm back

j3mdamas commented 2 years ago

I'm currently using 0.0.57 and this is solved. Thanks.