Exemplo n.º 1
0
def ether_groups(gra, filterlst=()):
    """ Determine the location of ether groups

        Returns a lsts of idxs of C-O-C groups
    """

    ether_grps = tuple()

    # Determing the indices of all rings in the molecule

    _ring_idxs = ring_idxs(rings(gra))

    coc_grps = two_bond_idxs(gra, asymb1='C', cent='O', asymb2='C')
    for coc_grp in coc_grps:
        c1_idx, o_idx, c2_idx = coc_grp
        if not _ring_idxs:
            ether_grps += ((c1_idx, o_idx, c2_idx),)
        else:
            for idxs in _ring_idxs:
                if not set(coc_grp) <= set(idxs):
                    ether_grps += ((c1_idx, o_idx, c2_idx),)

    ether_grps = filter_idxs(ether_grps, filterlst=filterlst)

    return ether_grps
Exemplo n.º 2
0
def ether_groups(gra, filterlst=()):
    """ Determine the location of ether groups. The locations are
        specified as tuple of idxs indicating the C-O-C atoms
        of the group: (C-idx, O-idx, C-idx).

        :param gra: molecular graph
        :type gra: molecular graph data structure
        :rtype: tuple(int)
    """

    ether_grps = tuple()

    # Determing the indices of all rings in the molecule

    _ring_idxs = ring_idxs(rings(gra))

    coc_grps = two_bond_idxs(gra, symb1='C', cent='O', symb2='C')
    for coc_grp in coc_grps:
        c1_idx, o_idx, c2_idx = coc_grp
        if not _ring_idxs:
            ether_grps += ((c1_idx, o_idx, c2_idx), )
        else:
            for idxs in _ring_idxs:
                if not set(coc_grp) <= set(idxs):
                    ether_grps += ((c1_idx, o_idx, c2_idx), )

    ether_grps = filter_idxs(ether_grps, filterlst=filterlst)

    return ether_grps
Exemplo n.º 3
0
def epoxide_groups(gra):
    """ Determine the location of epoxide groups

        Return C-O-C ring: only good for a 1,2-epoxide
    """

    epox_grps = tuple()

    # Determing the indices of all rings in the molecule
    _ring_idxs = ring_idxs(rings(gra))

    coc_grps = two_bond_idxs(gra, asymb1='C', cent='O', asymb2='C')
    for coc_grp in coc_grps:
        c1_idx, o_idx, c2_idx = coc_grp
        if _ring_idxs:
            for idxs in _ring_idxs:
                if set(coc_grp) <= set(idxs):
                    epox_grps += ((c1_idx, o_idx, c2_idx),)

    return epox_grps
Exemplo n.º 4
0
def epoxy_groups(gra):
    """ Determine the location of 1,2-epoxy groups. The locations are
        specified as tuple-of-tuple of idxs indicating the C-O-C atoms
        of the group: (C-idx, O-idx, C-idx).

        :param gra: molecular graph
        :type gra: molecular graph data structure
        :rtype: tuple(int)
    """

    epox_grps = tuple()

    # Determing the indices of all rings in the molecule
    _ring_idxs = ring_idxs(rings(gra))

    coc_grps = two_bond_idxs(gra, symb1='C', cent='O', symb2='C')
    for coc_grp in coc_grps:
        c1_idx, o_idx, c2_idx = coc_grp
        if _ring_idxs:
            for idxs in _ring_idxs:
                if set(coc_grp) <= set(idxs):
                    epox_grps += ((c1_idx, o_idx, c2_idx), )

    return epox_grps
Exemplo n.º 5
0
def _rotor_counts(gra, symbs):
    """ Count up various types of bonds for a structure.

        :param gra: molecular graph of species
        :type gra: automol graph data structure
        :param symbs: atomic symbols of species
        :type symbs: tuple(str)
        :rtype: tuple(float)
    """

    # Initialize the rotor counts
    n_pp, n_ps, n_pt, n_pq = 0, 0, 0, 0
    n_ss, n_st, n_sq = 0, 0, 0
    n_tt, n_tq = 0, 0
    n_qq = 0
    n_co, n_oo = 0, 0
    n_ss_ring, n_rings = 0, 0

    # Get the rings  and the number
    rings = _rings(gra)
    ring_keys = set(ring_idxs(_rings(gra)))
    n_rings = len(rings)

    # Loop over the bonds and count the number of atoms
    neighbors = atoms_neighbor_atom_keys(gra)
    for bnd in bond_keys(gra):
        key1, key2 = bnd
        spair = (symbs[key1], symbs[key2])
        if spair == ('C', 'C'):
            # Figure out which neighbors are not hydrogen and count the number
            atom1_neighbors = neighbors[key1]
            numc1 = 0
            for neighbor1 in atom1_neighbors:
                if symbs[neighbor1] != 'H':
                    numc1 += 1
            atom2_neighbors = neighbors[key2]
            numc2 = 0
            for neighbor2 in atom2_neighbors:
                if symbs[neighbor2] != 'H':
                    numc2 += 1
            # Determine appropriate term to increment
            npair = (numc1, numc2)
            if npair == (1, 1):
                n_pp += 1
            elif npair in ((1, 2), (2, 1)):
                n_ps += 1
            elif npair in ((1, 3), (3, 1)):
                n_pt += 1
            elif npair in ((1, 4), (4, 1)):
                n_pq += 1
            elif npair == (2, 2):
                if {key1, key2} <= ring_keys:
                    n_ss_ring += 1
                else:
                    n_ss += 1
            elif npair in ((2, 3), (3, 2)):
                n_st += 1
            elif npair in ((2, 4), (4, 2)):
                n_sq += 1
            elif npair == (3, 3):
                n_tt += 1
            elif npair in ((3, 4), (4, 3)):
                n_tq += 1
            elif npair == (4, 4):
                n_qq += 1
        elif spair in (('C', 'O'), ('O', 'C')):
            n_co += 1
        elif spair == ('O', 'O'):
            n_oo += 1

    # Compile counts into a tuple
    return (n_pp, n_ps, n_pt, n_pq, n_ss, n_st, n_sq, n_tt, n_tq, n_qq, n_co,
            n_oo, n_ss_ring, n_rings)
Exemplo n.º 6
0
def _rotor_counts(gra, symbs):
    """ Count up various types of rotors
    """

    # Initialize the rotor counts
    n_pp, n_ps, n_pt, n_pq = 0, 0, 0, 0
    n_ss, n_st, n_sq = 0, 0, 0
    n_tt, n_tq = 0, 0
    n_qq = 0
    n_co, n_oo = 0, 0
    n_ss_ring, n_rings = 0, 0

    # Get the rings  and the number
    rings = automol.graph.rings(gra)
    ring_keys = set(ring_idxs(automol.graph.rings(gra)))
    n_rings = len(rings)

    # Loop over the bonds and count the number of atoms
    neighbors = automol.graph.atom_neighbor_keys(gra)
    for bnd in automol.graph.bond_keys(gra):
        key1, key2 = bnd
        spair = (symbs[key1], symbs[key2])
        if spair == ('C', 'C'):
            # Figure out which neighbors are carbons and count the number
            atom1_neighbors = neighbors[key1]
            numc1 = 0
            for neighbor1 in atom1_neighbors:
                if symbs[neighbor1] == 'C':
                    numc1 += 1
            atom2_neighbors = neighbors[key2]
            numc2 = 0
            for neighbor2 in atom2_neighbors:
                if symbs[neighbor2] == 'C':
                    numc2 += 1
            # Determine appropriate term to increment
            npair = (numc1, numc2)
            if npair == (1, 1):
                n_pp += 1
            elif npair in ((1, 2), (2, 1)):
                n_ps += 1
            elif npair in ((1, 3), (3, 1)):
                n_pt += 1
            elif npair in ((1, 4), (4, 1)):
                n_pq += 1
            elif npair == (2, 2):
                if {key1, key2} <= ring_keys:
                    n_ss_ring += 1
                else:
                    n_ss += 1
            elif npair in ((2, 3), (3, 2)):
                n_st += 1
            elif npair in ((2, 4), (4, 2)):
                n_sq += 1
            elif npair == (3, 3):
                n_tt += 1
            elif npair in ((3, 4), (4, 3)):
                n_tq += 1
            elif npair == (4, 4):
                n_qq += 1
        elif spair in (('C', 'O'), ('O', 'C')):
            n_co += 1
        elif spair == ('O', 'O'):
            n_oo += 1

    # Compile counts into a tuple
    return [
        n_pp, n_ps, n_pt, n_pq, n_ss, n_st, n_sq, n_tt, n_tq, n_qq, n_co, n_oo,
        n_ss_ring, n_rings
    ]
Exemplo n.º 7
0
def _rotor_counts(gra, symbs):
    """ Count up various types of rotors
    """

    # Initialize the rotor counts
    n_pp, n_ps, n_pt, n_pq = 0, 0, 0, 0
    n_ss, n_st, n_sq = 0, 0, 0
    n_tt, n_tq = 0, 0
    n_qq = 0
    n_co, n_oo = 0, 0
    n_ss_ring, n_rings = 0, 0

    # Get the rings  and the number
    rings = automol.graph.rings(gra)
    ring_keys = set(ring_idxs(automol.graph.rings(gra)))
    n_rings = len(rings)

    # Loop over the bonds and count the number of atoms
    neighbors = automol.graph.atom_neighbor_keys(gra)
    for bnd in automol.graph.bond_keys(gra):
        key1, key2 = bnd
        symb1, symb2 = symbs[key1], symbs[key2]
        if symb1 == 'C' and symb2 == 'C':
            # Figure out which neighbors are carbons and count the number
            atom1_neighbors = neighbors[key1]
            numc1 = 0
            for neighbor1 in atom1_neighbors:
                if symbs[neighbor1] == 'C':
                    numc1 += 1
            atom2_neighbors = neighbors[key2]
            numc2 = 0
            for neighbor2 in atom2_neighbors:
                if symbs[neighbor2] == 'C':
                    numc2 += 1
            # Determine appropriate term to increment
            if numc1 == 1 and numc2 == 1:
                n_pp += 1
            elif (numc1 == 1 and numc2 == 2) or (numc1 == 2 and numc2 == 1):
                n_ps += 1
            elif (numc1 == 1 and numc2 == 3) or (numc1 == 3 and numc2 == 1):
                n_pt += 1
            elif (numc1 == 1 and numc2 == 4) or (numc1 == 4 and numc2 == 1):
                n_pq += 1
            elif numc1 == 2 and numc2 == 2:
                if {key1, key2} <= ring_keys:
                    n_ss_ring += 1
                else:
                    n_ss += 1
            elif (numc1 == 2 and numc2 == 3) or (numc1 == 3 and numc2 == 2):
                n_st += 1
            elif (numc1 == 2 and numc2 == 4) or (numc1 == 4 and numc2 == 2):
                n_sq += 1
            elif numc1 == 3 and numc2 == 3:
                n_tt += 1
            elif (numc1 == 3 and numc2 == 4) or (numc1 == 4 and numc2 == 3):
                n_tq += 1
            elif numc1 == 4 and numc2 == 4:
                n_qq += 1
        elif (symb1 == 'C' and symb2 == 'O') or (symb1 == 'O'
                                                 and symb2 == 'C'):
            n_co += 1
        elif symb1 == 'O' and symb2 == 'O':
            n_oo += 1

    # Compile counts into a tuple
    return [
        n_pp, n_ps, n_pt, n_pq, n_ss, n_st, n_sq, n_tt, n_tq, n_qq, n_co, n_oo,
        n_ss_ring, n_rings
    ]