def import_organism_from_csv(csv_file, add_Hs=True):
     with open(csv_file) as csv_handle:
         dict_reader = csv.DictReader(csv_handle, delimiter=',')
         compound_list = []
         for row in dict_reader:
             name = row["name"]
             inchi = row["inchi"]
             if inchi is None or inchi == "None" or inchi == "":
                 pass
             else:
                 try:
                     if name.startswith("InChI"):
                         compound = Compound(InChI=inchi,
                                             heavy_standardisation=True,
                                             force_add_H=add_Hs)
                     else:
                         compound = Compound(InChI=inchi,
                                             name=name,
                                             heavy_standardisation=True,
                                             force_add_H=add_Hs)
                     if not compound.in_list(compound_list,
                                             main_layer=False):
                         compound_list.append(compound)
                 except ChemConversionError as e:
                     logging.error(
                         "For compound {} with inchi {}: error ChemConversionError"
                         .format(name, inchi))
     organism = ChemicalCompoundState(compound_list, main_layer=False)
     return (organism)
 def test_expand_821(self):
     csmile_821 = "[H][C](=[O])[C]([H])([H])[C]([H])([H])[H]"
     csmile_90191 = "[H][O][C]([H])([H])[C]([H])([O][H])[C]([H])([H])[H]"
     compound = Compound(csmile_821, "821")
     compound_1 = Compound("[H+]", name="1")
     compound_6 = Compound(
         "[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][P](=[O])([O][H])[O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]",
         name='6')
     compound_2345 = Compound("[H][C](=[O])[C]([H])=[C]([H])[H]",
                              name="2345")
     compound_90191 = Compound(csmile_90191, "90191")
     resulting_state_94682 = ChemicalCompoundState([compound_90191],
                                                   organism=Test_organism_H)
     resulting_state_117465 = ChemicalCompoundState(
         [compound_1, compound_6, compound_2345], organism=Test_organism_H)
     root_state = ChemicalCompoundState(compound, organism=Test_organism_H)
     root_node = MCTS_node(root_state, chemical_score=True)
     root_node.expand()
     for child in root_node.children:
         if child.move.rid == "MNXR94682_MNXM821":
             i_94682 = root_node.children.index(child)
         if child.move.rid == "MNXR117465_MNXM821":
             i_117465 = root_node.children.index(child)
     result_94682 = (
         root_node.children[i_94682].state == resulting_state_94682)
     result_117465 = (
         root_node.children[i_117465].state == resulting_state_117465)
     assert (result_94682 and result_117465)
Exemple #3
0
 def test_add_compound_to_state_no(self):
     csmile = "[H][C](=[O])[C]([H])([H])[C]([H])([H])[H]"
     compound = Compound(csmile)
     compound_2 = Compound(csmile)
     state = ChemicalCompoundState(compound, organism=Test_organism_H)
     state._add_compound_to_state(compound_2)
     assert len(state) == 1
Exemple #4
0
    def test_GetMoves_state_and_compound(self):
        compound_10 = Compound(
            "[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]"
        )
        state_test_10 = ChemicalCompoundState(
            compound_10,
            organism=Test_organism_H,
            available_rules=applicable_rules_mixed_dict)
        moves_compound = compound_10.obtain_applicable_transformation_with_move(
            available_rules=applicable_rules_mixed_dict)
        print("moves_compound: {}".format(moves_compound))
        del compound_10
        compound_10 = Compound(
            "[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]"
        )
        state_test_10 = ChemicalCompoundState(
            compound_10,
            organism=Test_organism_H,
            available_rules=applicable_rules_mixed_dict)

        moves_state = state_test_10.GetMoves(top_x=10)
        print("moves_state: {}".format(moves_state))
        identicial_moves = len(moves_state) == len(moves_compound)
        for move in moves_state:
            identicial_moves = identicial_moves and move.in_list(
                moves_compound, main_layer=False)
        assert identicial_moves
    def test_expand_90191(self):
        csmile_90191 = "[H][O][C]([H])([H])[C]([H])([O][H])[C]([H])([H])[H]"
        compound_1 = Compound("[H+]", name="1")
        compound_6 = Compound(
            "[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][P](=[O])([O][H])[O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]",
            name='6')
        compound_10 = Compound(
            "[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]",
            name="10")
        compound_909 = Compound("[H][O][C]([H])([C]([H])=[O])[C]([H])([H])[H]",
                                name=909)
        # compound_2345 = Compound("[H][C](=[O])[C]([H])=[C]([H])[H]", name = "2345")
        compound_90191 = Compound(csmile_90191)
        resulting_state_95713 = ChemicalCompoundState(
            [compound_1, compound_10, compound_909], organism=Test_organism_H)
        resulting_state_903108 = ChemicalCompoundState(
            [compound_1, compound_6, compound_909], organism=Test_organism_H)
        root_state = ChemicalCompoundState(compound_90191,
                                           organism=Test_organism_H)
        root_node = MCTS_node(root_state)
        root_node.expand()

        result_95713 = (root_node.children[0].state == resulting_state_95713 or
                        root_node.children[0].state == resulting_state_903108)
        result_903108 = (root_node.children[1].state == resulting_state_903108
                         or root_node.children[1].state
                         == resulting_state_95713)
        assert (result_95713 and result_903108)
Exemple #6
0
 def test_compound_in_state_yes(self):
     csmile = "[H][C](=[O])[C]([H])([H])[C]([H])([H])[H]"
     unstandardised = "C(=O)CC"
     compound = Compound(csmile)
     compound_ns = Compound(unstandardised)
     state = ChemicalCompoundState(
         [compound], organism=Test_organism_H)  # state is not sanitised
     assert state.compound_in_state(compound_ns)
Exemple #7
0
 def test_compound_in_state_no(self):
     csmile = "[H][C](=[O])[C]([H])([H])[C]([H])([H])[H]"
     csmile_2 = "[H][O][C]([H])([H])[C]([H])([O][H])[C]([H])([H])[H]"
     compound = Compound(csmile)
     compound_2 = Compound(csmile_2)
     state = ChemicalCompoundState(
         [compound], organism=Test_organism_H)  # state is not sanitised
     assert not state.compound_in_state(compound_2)
Exemple #8
0
 def test_check_sanitized_state_not(self):
     csmile = "[H][C](=[O])[C]([H])([H])[C]([H])([H])[H]"
     unstandardised = "C(=O)CC"
     compound = Compound(csmile)
     compound_ns = Compound(unstandardised)
     state = ChemicalCompoundState(
         [compound, compound_ns], main_layer=True)  # state is not sanitised
     assert state._check_sanitized_state()
Exemple #9
0
 def test_check_sanitized_state_yes(self):
     csmile = "[H][C](=[O])[C]([H])([H])[C]([H])([H])[H]"
     csmile_2 = "[H][O][C]([H])([H])[C]([H])([O][H])[C]([H])([H])[H]"
     compound = Compound(csmile)
     compound_2 = Compound(csmile_2)
     state = ChemicalCompoundState([compound,
                                    compound_2])  # state is not sanitised
     assert state._check_sanitized_state()
Exemple #10
0
 def test_GetResults_from_InChI_Key_fraction(self):
     csmile = "[H][C](=[O])[C]([H])([H])[C]([H])([H])[H]"
     chassis_2_smile = "[H][O][C](=[O])[C](=[O])[C]([H])([H])[C]([H])([O][H])[C]([H])([O][H])[C]([H])([H])[H]"
     outside_compound = Compound(csmile)
     chassis_2 = Compound(chassis_2_smile)
     state_chassis = ChemicalCompoundState([chassis_2, outside_compound],
                                           organism=Test_organism_H)
     assert state_chassis.GetResults_from_InChI_Keys(
         rewarding=Basic_Rollout_Reward) == 1 / 2
Exemple #11
0
 def test_equal_two_from_addition(self):
     csmile = "[H][C](=[O])[C]([H])([H])[C]([H])([H])[H]"
     csmile_2 = "[H][O][C]([H])([H])[C]([H])([O][H])[C]([H])([H])[H]"
     compound = Compound(csmile)
     compound_2 = Compound(csmile_2)
     state = ChemicalCompoundState(compound, organism=Test_organism_H)
     state_2 = ChemicalCompoundState(compound_2, organism=Test_organism_H)
     state._add_compound_to_state(compound_2)
     state_2._add_compound_to_state(compound)
     assert state == state_2
Exemple #12
0
 def test_GetResults_from_InChI_Key_reward(self):
     chassis_1_smile = "[H+]"
     chassis_2_smile = "[H][O][C](=[O])[C](=[O])[C]([H])([H])[C]([H])([O][H])[C]([H])([O][H])[C]([H])([H])[H]"
     chassis_1 = Compound(chassis_1_smile)
     chassis_2 = Compound(chassis_2_smile)
     state_chassis = ChemicalCompoundState([chassis_1, chassis_2],
                                           organism=Test_organism_H)
     assert state_chassis.GetResults_from_InChI_Keys(
         rewarding=Basic_Rollout_Reward
     ) == Basic_Rollout_Reward.full_state_reward
Exemple #13
0
 def test_equal_two(slef):
     csmile = "[H][C](=[O])[C]([H])([H])[C]([H])([H])[H]"
     csmile_2 = "[H][O][C]([H])([H])[C]([H])([O][H])[C]([H])([H])[H]"
     compound = Compound(csmile)
     compound_2 = Compound(csmile_2)
     state = ChemicalCompoundState([compound, compound_2],
                                   organism=Test_organism_H)
     state_2 = ChemicalCompoundState([compound, compound_2],
                                     organism=Test_organism_H)
     assert state == state_2
Exemple #14
0
 def test_compound_in_chassis_state(self):
     compound_1 = Compound("[H+]")
     compound_6 = Compound(
         "[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][P](=[O])([O][H])[O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]"
     )
     compound_3459 = Compound(
         "[H][O][C](=[O])[C](=[O])[C]([H])([H])[C]([H])([O][H])[C]([H])([O][H])[C]([H])([H])[H]"
     )
     chassis_metabolites = ChemicalCompoundState(
         [compound_1, compound_6, compound_3459], organism=Test_organism_H)
     assert chassis_metabolites.compound_in_state(compound_1)
Exemple #15
0
 def test_remove_cmps(self):
     chassis_1_smile = "[H+]"
     chassis_2_smile = "[H][O][C](=[O])[C](=[O])[C]([H])([H])[C]([H])([O][H])[C]([H])([O][H])[C]([H])([H])[H]"
     chassis_1 = Compound(chassis_1_smile)
     chassis_2 = Compound(chassis_2_smile)
     state_chassis = ChemicalCompoundState([chassis_1, chassis_2],
                                           organism=Test_organism_H)
     present_in_state = state_chassis.compound_in_state(chassis_1)
     state_chassis.remove_cmpd_from_state(chassis_1)
     present_in_state_after = state_chassis.compound_in_state(chassis_1)
     assert present_in_state and not present_in_state_after
Exemple #16
0
    def test_rave_update(self):
        compound_1 = Compound("[H+]")
        compound_6 = Compound("[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][P](=[O])([O][H])[O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]")
        move = Move(rsmart = "rsmart",
                    rid = "rid",
                    compound_id= "compound_id",
                    product_list = [compound_1, compound_6])

        move.update(5, visit_number = 10)
        move.update(0.2, 10)
        assert move.RAVE_total_score == 52
        assert move.RAVE_visits == 20
 def test_node_rollout_terminal(self):
     compound_10 = Compound(
         "[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]"
     )
     compound_6 = Compound(
         "[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][P](=[O])([O][H])[O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]",
         name='6')
     state_1 = ChemicalCompoundState([compound_10, compound_6],
                                     organism=Test_organism_H)
     node_1 = MCTS_node(state_1)
     rolled_state = node_1.rollout()
     assert (rolled_state == node_1.state)
 def test_terminal_state_true_unavailable_moves(self):
     compound_1 = Compound("[H+]", name="1")
     compound_6 = Compound(
         "[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][P](=[O])([O][H])[O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]",
         name='6')
     compound_2345 = Compound("[H][C](=[O])[C]([H])=[C]([H])[H]",
                              name="2345")
     state = ChemicalCompoundState(
         [compound_1, compound_6, compound_2345],
         organism=Test_organism_H)  # state is not sanitised
     node = MCTS_node(state)
     assert node.moves == []
Exemple #19
0
 def test_GetResultsForBiosensors_present(self):
     chassis_1_smile = "[H+]"
     chassis_1 = Compound(chassis_1_smile)
     benzoate = Compound(
         InChI="InChI=1S/C7H6O2/c8-7(9)6-4-2-1-3-5-6/h1-5H,(H,8,9)/p-1")
     benzoate_chassis = ChemicalCompoundState([benzoate, chassis_1],
                                              organism=detectable_cmpds_H)
     retrosynthesis = benzoate_chassis.GetResults_from_InChI_Keys(
         rewarding=Basic_Rollout_Reward)
     biosensor = benzoate_chassis.GetResultsForBiosensors(
         rewarding=Basic_Rollout_Reward)
     assert retrosynthesis == 0.5 and biosensor == 2
 def test_expand_1_6_2345_empty_children(self):
     compound_1 = Compound("[H+]", name="1")
     compound_6 = Compound(
         "[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][P](=[O])([O][H])[O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]",
         name='6')
     compound_2345 = Compound("[H][C](=[O])[C]([H])=[C]([H])[H]",
                              name="2345")
     state = ChemicalCompoundState(
         [compound_1, compound_6, compound_2345],
         organism=Test_organism_H)  # state is not sanitised
     node = MCTS_node(state)
     node.expand()
     assert node.children == []
 def test_node_unexpanded(self):
     csmile_821 = "[H][C](=[O])[C]([H])([H])[C]([H])([H])[H]"
     compound_821 = Compound(csmile_821, "821")
     compound_10 = Compound(
         "[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]",
         name="10")
     compound_909 = Compound("[H][O][C]([H])([C]([H])=[O])[C]([H])([H])[H]",
                             name="909")
     state_1 = ChemicalCompoundState(
         [compound_821, compound_10, compound_909],
         organism=Test_organism_H)
     node_1 = MCTS_node(state_1)
     assert (node_1.children == [])
 def test_terminal_state_true_chassis(self):
     compound_1 = Compound("[H+]", name="1")
     compound_6 = Compound(
         "[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][P](=[O])([O][H])[O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]",
         name='6')
     compound_3459 = Compound(
         "[H][O][C](=[O])[C](=[O])[C]([H])([H])[C]([H])([O][H])[C]([H])([O][H])[C]([H])([H])[H]",
         name='3459')
     state = ChemicalCompoundState(
         [compound_1, compound_6, compound_3459],
         organism=Test_organism_H)  # state is not sanitised
     node = MCTS_node(state)
     assert node.terminal == True
Exemple #23
0
    def setUp(self):

        self.tol = 1e-12
        test_string1 = 'Na Fe P O4'

        test_string2 = 'Na2 Fe O2'

        active_ion = 'Na'

        self.CC = CapacityCalculator(active_ion)

        self.cpd1 = Compound(test_string1)
        self.cpd2 = Compound(test_string2)
Exemple #24
0
 def test_saving_and_loading(self):
     compound_1 = Compound("[H+]")
     compound_10 = Compound(
         "[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]"
     )
     compound_909 = Compound("[H][O][C]([H])([C]([H])=[O])[C]([H])([H])[H]")
     chassis_1_10_909 = ChemicalCompoundState(
         [compound_1, compound_10, compound_909], organism=Test_organism_H)
     chassis_1_10_909.save(folder_address="tests/generated_jsons/pickles")
     chassis_load = unpickle("BOPG_BSAB_GPRL",
                             type="state",
                             folder_address="tests/data")
     assert chassis_1_10_909 == chassis_load
 def test_proper_child_addition_821_rule_94682_moves(self):
     # random.seed(42)
     csmile = "[H][C](=[O])[C]([H])([H])[C]([H])([H])[H]"
     csmile_2 = "[H][O][C]([H])([H])[C]([H])([O][H])[C]([H])([H])[H]"
     compound = Compound(csmile, "821")
     compound_2 = Compound(csmile_2, "90191")
     known_result_state = ChemicalCompoundState([compound_2],
                                                organism=Test_organism_H)
     state_apply_move = ChemicalCompoundState(compound,
                                              organism=Test_organism_H)
     moves = state_apply_move.GetMoves(top_x=2)
     # state_apply_move.ApplyMove(list(moves.keys())[0])
     assert set([move.rid for move in moves
                 ]) == set(['MNXR94682_MNXM821', 'MNXR117465_MNXM821'])
Exemple #26
0
 def test_GetMoves(self):
     # will have to be modified once we have proper scores
     # random.seed(42)
     csmile = "[H][C](=[O])[C]([H])([H])[C]([H])([H])[H]"
     csmile_2 = "[H][O][C]([H])([H])[C]([H])([O][H])[C]([H])([H])[H]"
     compound = Compound(csmile)
     compound_2 = Compound(csmile_2)
     state_2 = ChemicalCompoundState([compound, compound_2],
                                     organism=Test_organism_H)
     moves = state_2.GetMoves(top_x=2, chemical_score=False)
     for move in moves:
         print(move.rid)
     assert set([move.rid for move in moves
                 ]) == set(['MNXR103108_MNXM90191', 'MNXR95713_MNXM90191'])
Exemple #27
0
    def test_equality_true(self):
        compound_1 = Compound("[H+]")
        compound_6 = Compound("[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][P](=[O])([O][H])[O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]")
        compound_2345 = Compound("[H][C](=[O])[C]([H])=[C]([H])[H]")
        move = Move(rsmart = "rsmart",
                    rid = "rid",
                    compound_id= "compound_id",
                    product_list = [compound_1, compound_6],
                    set_number = 5)
        move_bis = Move(rsmart = "rsmart",
                    rid = "rid",
                    compound_id= "compound_id",
                    product_list = [compound_6, compound_1])

        assert move.eq_full_inchi_key(move_bis)
Exemple #28
0
 def test_differing_compound_not_in_other(self):
     compound_1 = Compound("[H+]")
     compound_6 = Compound(
         "[H][N]=[C]([O][H])[C]1=[C]([H])[N]([C]2([H])[O][C]([H])([C]([H])([H])[O][P](=[O])([O][H])[O][P](=[O])([O][H])[O][C]([H])([H])[C]3([H])[O][C]([H])([n]4[c]([H])[n][c]5[c]([N]([H])[H])[n][c]([H])[n][c]54)[C]([H])([O][P](=[O])([O][H])[O][H])[C]3([H])[O][H])[C]([H])([O][H])[C]2([H])[O][H])[C]([H])=[C]([H])[C]1([H])[H]"
     )
     compound_2345 = Compound("[H][C](=[O])[C]([H])=[C]([H])[H]",
                              name="2345")
     compound_3459 = Compound(
         "[H][O][C](=[O])[C](=[O])[C]([H])([H])[C]([H])([O][H])[C]([H])([O][H])[C]([H])([H])[H]"
     )
     state_1 = ChemicalCompoundState(
         [compound_1, compound_6, compound_2345])
     state_2 = ChemicalCompoundState(
         [compound_1, compound_6, compound_3459])
     assert state_1.not_in_other(state_2)[0] == compound_2345
 def test_name_morphine_given(self):
     InChI_key = "BQJCRHHNABKAKU-UHFFFAOYSA-N"
     # Remark: we are not generating standard InChI keys or InChIs.
     # It's okay as long as we're consistent
     canonical_smiles = "CN1CCC23C4C1CC5=C2C(=C(C=C5)O)OC3C(C=C4)O"
     morphine = Compound(canonical_smiles, name = "morphine")
     assert morphine.name == 'morphine'
 def test_name_none_given(self):
     InChI_key = "BQJCRHHNABKAKU"
     # Remark: we are not generating standard InChI keys or InChIs.
     # It's okay as long as we're consistent
     canonical_smiles = "CN1CCC23C4C1CC5=C2C(=C(C=C5)O)OC3C(C=C4)O"
     morphine = Compound(canonical_smiles)
     assert morphine.name.split("-")[0] == InChI_key