Ejemplo n.º 1
0
def find_C3C4(C2, O1, mol_C):
    # Find the possible neighboring C(s) of C2 (C3/C4)
    C3_possibles = filter(lambda m: m['index'] != C2['index'],
                          mt.find_possibles(mol_C))
    d_C2O1 = mt.distance(C2['rvec'], O1['rvec'])
    C3_af = filter(
        lambda m: mt.bond_length_filter(m['rvec'], C2[
            'rvec'], CC_BOND_LENGTH, TOLERANCE_LEVEL) and mt.distance(
                m['rvec'], O1['rvec']) > d_C2O1, C3_possibles
    )  # Change the selection of O1 to see how the code below works # Extra filter: Make sure C3 is not close to O1 (which is adjacent to C2)
    C3_af_index = set()

    for c3 in C3_af:
        C3_af_index.add(c3['index'])

    if len(C3_af_index) == 1:
        C2_adj = 1  # C2 is adjacent to one C. Choose that C to be C3.
        C3C4_af = C3_af
    elif len(C3_af_index) == 2:
        C2_adj = 2  # C2 is adjacent to two C-s. Let those C-s be C3 and C4 respectively.
        C3_af_grps = []
        for i in C3_af_index:
            C3_af_grps.append(filter(lambda m: m['index'] == i, C3_af))
        C3C4_af = list(
            map(list, itertools.product(C3_af_grps[0], C3_af_grps[1])))
    else:
        C2_adj = 0
        C3C4_af = []

    return C2_adj, C3C4_af
Ejemplo n.º 2
0
def find_C2(O1, mol_C):
    # Find the neighboring C of O1 (C2)
    C2_possibles = mt.find_possibles(mol_C)
    C2_af = filter(
        lambda m: mt.bond_length_filter(m['rvec'], O1['rvec'], CO_BOND_LENGTH,
                                        TOLERANCE_LEVEL), C2_possibles
    )  # Change the tolerance range here to see how this filter works
    return C2_af
Ejemplo n.º 3
0
def rcs_filter(a_r, base_group, tol_range=0.1):
    possible_a = mt.find_possibles([a_r])  # Find all possible rvec for a_r

    possible_af1 = filter(
        lambda m: mt.bond_length_atom_finder(base_group, m, tol_range),
        possible_a)

    return possible_af1
Ejemplo n.º 4
0
def find_O5_C2adj1(
    C2, C3, mol_Or
):  # If C2 is adjacent to one C (C3), then C3 must be connected to an O (O5).
    O5_possibles = mt.find_possibles(mol_Or)
    O5_af = filter(
        lambda m: mt.bond_length_filter(m['rvec'], C3[
            'rvec'], CO_BOND_LENGTH, TOLERANCE_LEVEL) and mt.distance(
                m['rvec'], C2['rvec']) > (CO_BOND_LENGTH + TOLERANCE_LEVEL),
        O5_possibles)
    return O5_af
Ejemplo n.º 5
0
def find_C4_C2adj1(C2, C3, O5, mol_C):
    # Find the possible C4
    C4_possibles = filter(
        lambda m: m['index'] not in (C2['index'], C3['index']),
        mt.find_possibles(mol_C))
    d_C3O5 = mt.distance(C3['rvec'], O5['rvec'])
    C4_af = filter(
        lambda m: mt.bond_length_filter(m['rvec'], C3[
            'rvec'], CC_BOND_LENGTH, TOLERANCE_LEVEL) and mt.distance(
                m['rvec'], O5['rvec']) > d_C3O5, C4_possibles
    )  # Extra filter: Make sure C4 is not close to O5 (which is adjacent to C3)

    return C4_af
Ejemplo n.º 6
0
def find_O5_C2adj2(
    C3, C4, mol_Or
):  # If C2 is adjacent to two C-s (C3, C4), then O5 must be adjacent to one of C3 and C4.
    O5_possibles = mt.find_possibles(mol_Or)
    O5_afC3 = filter(
        lambda m: mt.bond_length_filter(m['rvec'], C3[
            'rvec'], CO_BOND_LENGTH, TOLERANCE_LEVEL) and mt.distance(
                m['rvec'], C4['rvec']) > (CO_BOND_LENGTH + TOLERANCE_LEVEL),
        O5_possibles
    )  # Extra filter: If O5 is connected to C3, make sure it is not too close to C4 (vice versa)
    O5_afC4 = filter(
        lambda m: mt.bond_length_filter(m['rvec'], C4[
            'rvec'], CO_BOND_LENGTH, TOLERANCE_LEVEL) and mt.distance(
                m['rvec'], C3['rvec']) > (CO_BOND_LENGTH + TOLERANCE_LEVEL),
        O5_possibles)

    O5_af = O5_afC3 + O5_afC4
    return O5_af