Exemplo n.º 1
0
def match_lig_list(file_in,
                   file_init_geo,
                   catoms_arr,
                   flag_loose,
                   flag_lbd=True,
                   debug=False,
                   depth=3,
                   BondedOct=False):
    flag_match = True
    my_mol = create_mol_with_xyz(_file_in=file_in)
    init_mol = create_mol_with_xyz(_file_in=file_init_geo)
    if flag_lbd:  # Also do ligand breakdown for opt geo
        my_mol_trunc = obtain_truncation_metal(my_mol, depth)
        init_mol_trunc = obtain_truncation_metal(init_mol, depth)
        my_mol_trunc.createMolecularGraph()
        init_mol_trunc.createMolecularGraph()
        init_mol_trunc.writexyz('init_trunc_tmp.xyz')
        my_mol_trunc.writexyz('mymol_trunc_tmp.xyz')
        liglist_init, ligdents_init, ligcons_init = ligand_breakdown(
            init_mol_trunc)
        liglist, ligdents, ligcons = ligand_breakdown(my_mol_trunc)
        liglist_atom = [[my_mol_trunc.getAtom(x).symbol() for x in ele]
                        for ele in liglist]
        liglist_init_atom = [[init_mol_trunc.getAtom(x).symbol() for x in ele]
                             for ele in liglist_init]
        if debug:
            print(('!!!!:', [x.symbol() for x in init_mol_trunc.getAtoms()]))
            print(('liglist_init, ligdents_init, ligcons_init', liglist_init,
                   ligdents_init, ligcons_init))
            # print('liglist, ligdents, ligcons', liglist, ligdents, ligcons)
    else:  # ceate/use the liglist, ligdents, ligcons of initial geo as we just wanna track them down
        # _start = time.clock()
        if debug:
            print('Just inherit the ligand list from init structure.')
        liglist_init, ligdents_init, ligcons_init = ligand_breakdown(
            init_mol, flag_loose=flag_loose, BondedOct=BondedOct)
        # _elapsed = (time.clock() - _start)
        # print('time on lig_breakdoen:', _elapsed)
        liglist, ligdents, ligcons = liglist_init[:], ligdents_init[:], ligcons_init[:]
        liglist_atom = [[my_mol.getAtom(x).symbol() for x in ele]
                        for ele in liglist]
        liglist_init_atom = [[init_mol.getAtom(x).symbol() for x in ele]
                             for ele in liglist_init]

    if debug:
        print(('ligand_list opt in symbols:', liglist_atom))
        print(('ligand_list init in symbols: ', liglist_init_atom))
    liglist_shifted = []
    for ele in liglist_init_atom:
        # posi = liglist_atom.index(ele)
        # liglist_shifted.append(liglist[posi])
        # liglist_atom.pop(posi)
        try:
            _flag = False
            for idx, _ele in enumerate(liglist_atom):
                if set(ele) == set(_ele) and len(ele) == len(_ele):
                    if debug:
                        print(('fragment in liglist_init', ele))
                        print(('fragment in liglist', _ele))
                    posi = idx
                    _flag = True
            liglist_shifted.append(liglist[posi])
            liglist_atom.pop(posi)
            liglist.pop(posi)
            if not _flag:
                if debug:
                    print('Ligands cannot match!')
                flag_match = False
        except:
            print('Ligands cannot match!')
            flag_match = False
    if debug:
        print(('!!!!!returns', liglist_shifted, liglist_init))
    return liglist_shifted, liglist_init, flag_match
Exemplo n.º 2
0
def match_lig_list(file_in, file_init_geo, catoms_arr,
                   flag_loose, flag_lbd=True, debug=False,
                   depth=3, BondedOct=False):
    flag_match = True
    my_mol = create_mol_with_xyz(_file_in=file_in)
    init_mol = create_mol_with_xyz(_file_in=file_init_geo)
    if flag_lbd:  ## Also do ligand breakdown for opt geo
        my_mol_trunc = obtain_truncation_metal(my_mol, depth)
        init_mol_trunc = obtain_truncation_metal(init_mol, depth)
        my_mol_trunc.createMolecularGraph()
        init_mol_trunc.createMolecularGraph()
        init_mol_trunc.writexyz('init_trunc_tmp.xyz')
        my_mol_trunc.writexyz('mymol_trunc_tmp.xyz')
        liglist_init, ligdents_init, ligcons_init = ligand_breakdown(init_mol_trunc)
        liglist, ligdents, ligcons = ligand_breakdown(my_mol_trunc)
        liglist_atom = [[my_mol_trunc.getAtom(x).symbol() for x in ele]
                        for ele in liglist]
        liglist_init_atom = [[init_mol_trunc.getAtom(x).symbol() for x in ele]
                             for ele in liglist_init]
        if debug:
            print('!!!!:', [x.symbol() for x in init_mol_trunc.getAtoms()])
            print('liglist_init, ligdents_init, ligcons_init', liglist_init, ligdents_init, ligcons_init)
            # print('liglist, ligdents, ligcons', liglist, ligdents, ligcons)
    else:  ## ceate/use the liglist, ligdents, ligcons of initial geo as we just wanna track them down
        # _start = time.clock()
        if debug:
            print('Just inherit the ligand list from init structure.')
        liglist_init, ligdents_init, ligcons_init = ligand_breakdown(init_mol,
                                                                     flag_loose=flag_loose,
                                                                     BondedOct=BondedOct)
        # _elapsed = (time.clock() - _start)
        # print('time on lig_breakdoen:', _elapsed)
        liglist, ligdents, ligcons = liglist_init[:], ligdents_init[:], ligcons_init[:]
        liglist_atom = [[my_mol.getAtom(x).symbol() for x in ele]
                        for ele in liglist]
        liglist_init_atom = [[init_mol.getAtom(x).symbol() for x in ele]
                             for ele in liglist_init]

    if debug:
        print('ligand_list opt in symbols:', liglist_atom)
        print('ligand_list init in symbols: ', liglist_init_atom)
    liglist_shifted = []
    for ele in liglist_init_atom:
        # posi = liglist_atom.index(ele)
        # liglist_shifted.append(liglist[posi])
        # liglist_atom.pop(posi)
        try:
            _flag = False
            for idx, _ele in enumerate(liglist_atom):
                if set(ele) == set(_ele) and len(ele) == len(_ele):
                    if debug:
                        print('fragment in liglist_init', ele)
                        print('fragment in liglist', _ele)
                    posi = idx
                    _flag = True
            liglist_shifted.append(liglist[posi])
            liglist_atom.pop(posi)
            liglist.pop(posi)
            if not _flag:
                if debug:
                    print('Ligands cannot match!')
                flag_match = False
        except:
            print('Ligands cannot match!')
            flag_match = False
    if debug:
        print('!!!!!returns', liglist_shifted, liglist_init)
    return liglist_shifted, liglist_init, flag_match