示例#1
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
示例#2
0
 def test_node_rollout_possible(self):
     csmile_821 = "[H][C](=[O])[C]([H])([H])[C]([H])([H])[H]"
     compound_821 = Compound(csmile_821, "821")
     state_1 = ChemicalCompoundState([compound_821],
                                     organism=Test_organism_H)
     node_1 = MCTS_node(state_1)
     moves = state_1.GetMoves(top_x=2, chemical_score=False)
     rolled_state = node_1.rollout()
     assert (node_1.state != rolled_state)
示例#3
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'])
示例#4
0
 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'])
示例#5
0
 def test_ApplyMoves(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)
     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)
     # move = moves[list(moves.keys())[0]]
     for move in moves:
         if move.rid == "MNXR94682_MNXM821":
             i = moves.index(move)
     move = moves[i]
     state_apply_move.ApplyMove(move)
     assert state_apply_move == known_result_state
示例#6
0
 def test_proper_child_addition_821_rule_94682_moves_state(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)
     for move in moves:
         print(move.rid)
         if move.rid == "MNXR94682_MNXM821":
             i = moves.index(move)
     # print(moves)
     move_94682 = moves[i]
     state_apply_move.ApplyMove(move_94682)
     assert state_apply_move == known_result_state
示例#7
0
 def test_proper_child_addition_821_rule_117465_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_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")
     known_result_state = ChemicalCompoundState(
         [compound_1, compound_6, compound_2345], organism=Test_organism_H)
     state_apply_move = ChemicalCompoundState(compound,
                                              organism=Test_organism_H)
     moves = state_apply_move.GetMoves(top_x=2)
     for move in moves:
         print(move.rid)
         if move.rid == "MNXR117465_MNXM821":
             i = moves.index(move)
     move_117465 = moves[i]
     state_apply_move.ApplyMove(move_117465)
     assert state_apply_move == known_result_state