def super_impose_only_on_planar_rings(ringlist, mol, count):
    #for now, I'll only extend planar ring systems
    pred = OEPartPredAtom(ringlist)
    refmol = OECreateOEMol()

    old_list = ringlist
    ring_count = 0

    match_list = []
    for j in old_list:
        match_list.append(j)

    for i in xrange(1, count + 1):
        pred.SelectPart(i)
        OESubsetMol(refmol, mol, pred)
        if chemistry.check_planar(refmol):
            #print "keep this ring"
            #print ringlist
            ring_count = ring_count + 1

        else:
            #print "reject this ring"
            #delete this ring from ring_list
            for atom_number in range(0, len(match_list)):
                #print match_list[atom_number]
                if match_list[atom_number] == i:
                    match_list[atom_number] = 0
#print 'test'
#adjust ring_numbers
                elif match_list[atom_number] > i:
                    match_list[atom_number] = match_list[atom_number] - 1

    #print match_list
    return match_list, ring_count
Exemplo n.º 2
0
def find_atoms_in_plane(mol, debug):

    #only check if ring is planar
    #should not be necessary to extend rings as we say exactly which atom matches which one
    ri = mol.GetRingInfo()
    #print(ri.AtomRings())
    atom_list = []
    for ring in range(0, len(ri.AtomRings())
                      ):  #convert tulple to list so that it can be modified
        atom_list.append(
            [[]])  #list should also hold information about planarity
        for atmidx in ri.AtomRings()[ring]:
            atom_list[ring][0].append(atmidx)
        #print (atom_list)

    for i in range(0, len(atom_list)):
        #need to create indepent copy of list
        atom_idx_list = atom_list[i][0][:]
        #print (atom_idx_list, 'atom_idx_list')
        if chemistry.check_planar(mol, atom_idx_list, debug):
            atom_list[i].append(True)
        else:
            atom_list[i].append(False)  #ring is not planar

    #check if two planar rings are fused together

    remove_from_list = []
    #print (atom_list)

    for i in range(0, len(atom_list)):
        #print (i, 'i here')
        if atom_list[i][1]:  #planar ring
            for j in range(1, len(atom_list)):
                #print (j, 'j **********')
                if atom_list[j][
                        1] and i != j and j not in remove_from_list:  #planar ring, don't compare identical rings
                    #check if they have atoms in common => fused
                    for atom_idx in atom_list[j][0]:
                        #print (atom_idx, 'atom_idx')
                        if atom_idx in atom_list[i][0]:  #fused
                            for atom_idex_2 in atom_list[i][0]:
                                if atom_idex_2 not in atom_list[j][0]:
                                    atom_list[j][0].append(atom_idex_2)
                            #print (atom_list[j][0], "joined list")
                            remove_from_list.append(i)
                            #print ('remove form list', remove_from_list)
                            break  #no need to ceck remaining atoms of this list, is already fused and joined

    for i in range(0, len(remove_from_list)):
        del atom_list[remove_from_list[i] - i]  #index will change

    #print (atom_list)
    count = len(atom_list)
    return atom_list, count  #---------------------
def find_atoms_in_plane_extend_ring(mol, debug):

    #get all (non H) substituents of planr ring atoms that are not part of a ring, if not planar, do not search, as their position might change depending on ring conformation
    #should not be necessary as we say exactly which atom matches which one
    ri = mol.GetRingInfo()
    #print(ri.AtomRings())
    atom_list = []
    for ring in range(0, len(ri.AtomRings())
                      ):  #convert tulple to list so that it can be modified
        atom_list.append(
            [[]])  #list should also hold information about planarity
        for atmidx in ri.AtomRings()[ring]:
            atom_list[ring][0].append(atmidx)
        #print (atom_list)

    for i in range(0, len(atom_list)):
        #need to create indepent copy of list
        atom_idx_list = atom_list[i][0][:]
        #print (atom_idx_list, 'atom_idx_list')
        if chemistry.check_planar(mol, atom_idx_list, debug):
            atom_list[i].append(True)
            for atom in mol.GetAtoms():
                #print (atom.GetIdx())
                #print (atom_idx_list,  'atom_idx_list 2')
                if atom.GetIdx(
                ) in atom_idx_list:  #atom is part of this ring system, check for neighbours
                    #print (atom.GetIdx(), 'checked')
                    for neighbour in atom.GetNeighbors():
                        #print (neighbour.GetIdx(), atom_idx_list)
                        if neighbour.GetIdx(
                        ) not in atom_idx_list and neighbour.GetAtomicNum(
                        ) != 1:  #do not add H
                            #atom_list[i][0].append(neighbour.GetIdx())
                            continue
                            #print ('added',neighbour.GetSmarts(),neighbour.GetAtomicNum())

        else:
            atom_list[i].append(False)  #ring is not planar

    #print (atom_list)
    count = len(atom_list)
    return atom_list, count