Ejemplo n.º 1
0
def test__backbone_isomorphism():
    """ test graph.backbone_isomorphism
    """
    cgr = C8H13O_CGR
    natms = len(graph.atoms(cgr))
    for _ in range(10):
        pmt_dct = dict(enumerate(numpy.random.permutation(natms)))
        cgr_pmt = graph.relabel(cgr, pmt_dct)
        assert graph.backbone_isomorphism(cgr, cgr_pmt) == pmt_dct
Ejemplo n.º 2
0
def test__atom_inchi_numbers():
    """ test graph.atom_inchi_numbers
    """
    cgr = C8H13O_CGR
    natms = len(graph.atoms(cgr))
    for _ in range(10):
        pmt_dct = dict(enumerate(numpy.random.permutation(natms)))
        cgr_pmt = graph.relabel(cgr, pmt_dct)
        inv_pmt_dct = dict(map(reversed, pmt_dct.items()))
        assert graph.atom_inchi_numbers(cgr_pmt) == inv_pmt_dct
Ejemplo n.º 3
0
def test__from_dictionaries():
    """ test graph.from_dictionaries
    """
    assert graph.from_dictionaries(
        graph.atom_symbols(CH2FH2H_CGR_EXP),
        graph.bond_keys(CH2FH2H_CGR_EXP)
    ) == CH2FH2H_CGR_EXP

    assert graph.from_dictionaries(
        graph.atom_symbols(C8H13O_RGRS[0]),
        graph.bond_keys(C8H13O_RGRS[0]),
        atm_imp_hyd_vlc_dct=graph.atom_implicit_hydrogen_valences(
            C8H13O_RGRS[0]),
        bnd_ord_dct=graph.bond_orders(C8H13O_RGRS[0])
    ) == C8H13O_RGRS[0]

    assert graph.from_dictionaries(
        graph.atom_symbols(C8H13O_SGRS[0]),
        graph.bond_keys(C8H13O_SGRS[0]),
        atm_imp_hyd_vlc_dct=graph.atom_implicit_hydrogen_valences(
            C8H13O_SGRS[0]),
        atm_ste_par_dct=graph.atom_stereo_parities(C8H13O_SGRS[0]),
        bnd_ste_par_dct=graph.bond_stereo_parities(C8H13O_SGRS[0])
    ) == C8H13O_SGRS[0]

    # a litte ridiculous, but make sure we get the keys right
    sgr_ref = C8H13O_SGRS[0]
    natms = len(graph.atoms(sgr_ref))
    for _ in range(10):
        pmt_dct = dict(enumerate(numpy.random.permutation(natms)))
        sgr = graph.relabel(sgr_ref, pmt_dct)
        assert graph.from_dictionaries(
            graph.atom_symbols(sgr),
            graph.bond_keys(sgr),
            atm_imp_hyd_vlc_dct=graph.atom_implicit_hydrogen_valences(sgr),
            atm_ste_par_dct=graph.atom_stereo_parities(sgr),
            bnd_ste_par_dct=graph.bond_stereo_parities(sgr)
        ) == sgr
Ejemplo n.º 4
0
def test__from_atoms_and_bonds():
    """ test graph.from_atoms_and_bonds
    """
    assert C8H13O_CGR == graph.from_atoms_and_bonds(
        atm_dct=graph.atoms(C8H13O_CGR), bnd_dct=graph.bonds(C8H13O_CGR))