def test_run():
    tsf = Transformation.from_smiles("N1C=CC2=C1C=CC=C2",
                                     "OC1=CC2=C(NC=C2)C=C1")
    products = tsf.run("N1C=CC2=C1C=CC=C2")
    assert [p.smiles for p in products] == ["Oc1ccc2c(c1)C=CN2"]

    tsf = Transformation.from_smiles("N1C=CC2=C1C=CC=C2",
                                     "OC1=CC2=C(NC=C2)C=C1")
    products = tsf.run("N1C=CC2=C1C=CC=C2")
    assert [p.smiles for p in products] == ["Oc1ccc2c(c1)C=CN2"]

    tsf = Transformation.from_smiles("OC1=CC=CC=C1", "OC1=CC=CC=C1Br")
    products = tsf.run("CCC1=CC=CC=C1O")
    assert [p.smiles for p in products] == ["CCc1cccc(Br)c1O"]
    products = tsf.run("CCC1=CC=CC(CC)=C1O")
    assert not products
def test_preserve_explicit_H():
    tsf = Transformation.from_smiles("[H]C([H])([H])OC1=CC=CC=C1",
                                     "OC1=CC=CC=C1")
    assert (
        tsf.smarts ==
        "[#1]-[#6:3](-[#1])(-[#1])-[#8:1]-[#6:2]1:[#6:4]:[#6:6]:[#6:8]:[#6:7]:[#6:5]:1>>[#8:1](-[#6:2]1:[#6:4]:[#6:6]:[#6:8]:[#6:7]:[#6:5]:1)-[#1:3]"
    )
def test_simplify():
    tsf = Transformation.from_smiles(
        "OCC1OC(Oc2cc(O)c3c(occc3=O)c2O)C(O)C(O)C1O",
        "CC(=O)OCC1OC(Oc2cc(O)c3c(occc3=O)c2O)C(O)C(O)C1O",
    )
    assert (tsf.simplify()[0].smarts ==
            "[#8:1](-[#6:2])-[#1:3]>>[#6]-[#6:3](=[#8])-[#8:1]-[#6:2]")
Beispiel #4
0
async def transformations_from_smiles(
    smiles: List[str] = Body(..., example=["CCO", "CCOC"]),
    reverse: bool = Body(False, example=["CCO", "CCOC"]),
    params: SimplifierParams = Body(BaseModel(), example=SimplifierParams()),
):
    result = []
    transformation = Transformation.from_smiles(*smiles)
    simplified = transformation.simplify(**params.dict())
    idx = 0
    for tsf in simplified:
        result.append(gen_tsf_data(idx, tsf))
        idx += 1
        if reverse:
            tsf.reverse()
            result.append(gen_tsf_data(idx, tsf))
            idx += 1
    return result
def test_simplify_keep_conjugated(conjugated, smarts):
    smiles = [r"CC\C=C\C1=CC(O)=CC=C1", r"CC\C=C\C1=CC(OC)=CC=C1"]
    tsf = Transformation.from_smiles(*smiles)
    simp = tsf.simplify(conjugated=conjugated)[0]
    assert simp.smarts == smarts
def test_simplify_keep_hetero_atoms(hetero_atoms, smarts):
    smiles = [r"OCO", r"COCO"]
    tsf = Transformation.from_smiles(*smiles)
    simp = tsf.simplify(hetero_atoms=hetero_atoms)[0]
    assert simp.smarts == smarts
def test_simplify_to_many_transformations(smiles_set, smarts_simplified):
    tsf = Transformation.from_smiles(*smiles_set)
    assert set([simp.smarts
                for simp in tsf.simplify()]) == set(smarts_simplified)
def test_from_smiles():
    tsf = Transformation.from_smiles("OC1=CC=CC=C1", "OC1=CC=CC=C1Br")
    assert tsf.smarts == SMARTS
def test_simplify_keep_aromatization(smiles_set, smarts_simplified):
    tsf = Transformation.from_smiles(*smiles_set)
    assert tsf.simplify()[0].smarts == smarts_simplified