def setUp(self):
        # create a scaffold filter and fill it with a few entries
        smiles = [
            "O=S(=O)(c3ccc(n1nc(cc1c2ccc(cc2)C)C(F)(F)F)cc3)N", "CCC", "CCCCC"
        ]
        scores = np.array([0.7, 0.5, 0.])
        valid_idx = [0, 1, 2]
        component_parameters = ComponentParameters(
            component_type=self.sf_enum.TANIMOTO_SIMILARITY,
            name="tanimoto_similarity",
            weight=1.,
            smiles=smiles,
            model_path="",
            specific_parameters={})
        component_score_summary = ComponentSummary(scores,
                                                   component_parameters)

        final_summary = FinalSummary(scores, smiles, valid_idx,
                                     [component_score_summary],
                                     [component_score_summary])

        sf_parameters = ScaffoldParameters(
            name=self.scaffold_enum.IDENTICAL_MURCKO_SCAFFOLD,
            minscore=0.5,
            minsimilarity=0.4,
            nbmax=1)
        scaffold_filter_factory = ScaffoldFilterFactory()
        self.scaffold_filter = scaffold_filter_factory.load_scaffold_filter(
            sf_parameters)
        self.scaffold_filter.score(final_summary)
 def calculate_score(self, molecules: List) -> ComponentSummary:
     score, offtarget_score = self._calculate_offtarget_activity(
         molecules, self._activity_params, self._off_target_params,
         self._delta_params)
     score_summary = ComponentSummary(total_score=score,
                                      parameters=self._off_target_params)
     return score_summary
예제 #3
0
    def setUp(self):
        self.scaffold_enum = ScaffoldFilterEnum()
        self.sf_enum = ScoringFunctionComponentNameEnum()
        self.workfolders = [MAIN_TEST_PATH]
        # create a scaffold filter and fill it with a few entries
        smiles = [
            "O=S(=O)(c3ccc(n1nc(cc1c2ccc(cc2)C)C(F)(F)F)cc3)N", "CCC", "CCCCC",
            "CC"
        ]
        scores = np.array([1.0, 0.5, 0.4, 0.3])
        valid_idx = [0, 1, 2, 3]
        component_parameters = ComponentParameters(
            component_type=self.sf_enum.TANIMOTO_SIMILARITY,
            name="tanimoto_similarity",
            weight=1.,
            smiles=smiles,
            model_path="",
            specific_parameters={})
        component_score_summary = ComponentSummary(scores,
                                                   component_parameters)

        final_summary = FinalSummary(scores, smiles, valid_idx,
                                     [component_score_summary],
                                     [component_score_summary])

        sf_parameters = ScaffoldParameters(name=self.scaffold_enum.NO_FILTER,
                                           minscore=0.5,
                                           minsimilarity=0.4,
                                           nbmax=1)
        scaffold_filter_factory = ScaffoldFilterFactory()
        self.scaffold_filter = scaffold_filter_factory.load_scaffold_filter(
            sf_parameters)
        self.scaffold_filter.score(final_summary)
예제 #4
0
def _update_total_score(summary: ComponentSummary, query_length: int,
                        valid_indices: List[int]) -> ComponentSummary:
    total_score = np.full(query_length, 0, dtype=np.float32)
    assert len(valid_indices) == len(summary.total_score)
    for idx, value in zip(valid_indices, summary.total_score):
        total_score[idx] = value
    summary.total_score = total_score
    return summary
 def test_invalid_addition(self):
     # try to add a smile already present
     smiles = ["CCC"]
     scores = np.array([1.0])
     valid_idx = [0]
     component_parameters = ComponentParameters(
         component_type=self.sf_enum.TANIMOTO_SIMILARITY,
         name="tanimoto_similarity",
         weight=1.,
         smiles=smiles,
         model_path="",
         specific_parameters={})
     component_score_summary = ComponentSummary(scores,
                                                component_parameters)
     final_summary = FinalSummary(scores, smiles, valid_idx,
                                  [component_score_summary],
                                  [component_score_summary])
     self.scaffold_filter.score(final_summary)
     self.assertEqual(2, len(self.scaffold_filter.scaffolds))
예제 #6
0
 def calculate_score(self, molecules: List) -> ComponentSummary:
     score = self._substructure_match(molecules, self.custom_alerts)
     score_summary = ComponentSummary(total_score=score,
                                      parameters=self.parameters)
     return score_summary
 def calculate_score(self, molecules: List) -> ComponentSummary:
     score = self.activity_model.predict_from_mols(molecules, self.parameters.specific_parameters)
     score_summary = ComponentSummary(total_score=score, parameters=self.parameters)
     return score_summary
예제 #8
0
 def calculate_score(self, molecules: List) -> ComponentSummary:
     query_fps = self._mols_to_fingerprints(molecules)
     score = self._calculate_tanimoto(query_fps, self._fingerprints)
     score_summary = ComponentSummary(total_score=score,
                                      parameters=self.parameters)
     return score_summary
 def calculate_score(self, molecules: List) -> ComponentSummary:
     score = self._calculate_score(molecules)
     score_summary = ComponentSummary(total_score=score,
                                      parameters=self.parameters)
     return score_summary