Beispiel #1
0
def AreaCOO (pr_init):
    """calculation of volume around nitrogen of primary amine
    in: filePDB with only primary amine, extreme value of l_angle, structure subs
    out: file format filePDB with water
    only one half of imidazole are inspected"""
    
    subs = "COO"
    pr_volume = pathManage.CreatePathDir(pr_init + "Volume/")
    filout = open (pr_volume + "volume_" + subs + ".pdb", "w")
    l_atom_sub = structure.substructureCoord(subs)
    def_volume = structure.criteraAngle(subs)
    writePDBfile.coordinateSection(filout, l_atom_sub, "HETATM")

    
    angle_inf = def_volume["angle"][0]
    angle_sup = def_volume["angle"][1]
    
    d_inf = def_volume["distance"][0]
    d_sup = def_volume["distance"][1]
    
    for atom_sub in l_atom_sub : 
        if atom_sub["name"] == "O01" : 
            atomO1 = atom_sub
        if atom_sub["name"] == "O02" : 
            atomO2 = atom_sub
        if atom_sub["name"] == "C02" : 
            atomC2 = atom_sub
        if atom_sub["name"] == "C01" : 
            atomC1 = atom_sub
        
    atom_center = calcul.CenterPoint(atomO1, atomO2)
    
    serial = 0
    for x_test in [atom_center["x"] + x * 0.2 for x in range (-50,60)] : 
        for y_test in [atom_center["y"] + y * 0.2 for y in range (-50,60)] : 
            for z_test in [atom_center["z"] + z * 0.2 for z in range (-50,60)] :  
                
                atom_test = structure.genericAtom(x_test, y_test, z_test)
                dist = calcul.distanceTwoatoms(atom_test, atom_center)
                
                # case where the calculation of angle is impossible
                try : angle = calcul.Angle3Atoms(atomC2, atom_center, atom_test)
                except : continue
                
                if dist <= d_sup and dist >= d_inf: 
                    if angle >= angle_inf and angle <= angle_sup :
                        serial = serial + 1
                        atom_test["serial"] = serial
                        atom_test["resSeq"] = serial
                        
                        writePDBfile.coordinateStructure(atom_test, "HETATM", filout)
                    
                    
    filout.close()
    WriteParameter (pr_volume + subs + ".param", subs, def_volume, serial) 
Beispiel #2
0
def AeraTertiary (pr_init):
    """calculation of volume around nitrogen of primary amine
    in: filePDB with only primary amine, extreme value of l_angle, structure subs
    out: file format filePDB with water"""
    
    subs = "III"
    pr_volume = pathManage.CreatePathDir(pr_init + "Volume/")
    filout = open (pr_volume + "volume_" + subs + ".pdb", "w")
    l_atom_sub = structure.substructureCoord(subs)
    def_volume = structure.criteraAngle(subs)
    writePDBfile.coordinateSection(filout, l_atom_sub, "HETATM")

    
    angle_inf = def_volume["angle"][0]
    angle_sup = def_volume["angle"][1]
    
    d_inf = def_volume["distance"][0]
    d_sup = def_volume["distance"][1]
    
    
    for atom_sub in l_atom_sub :
        if atom_sub["element"] == "N" : 
            atomN = atom_sub
        elif atom_sub["element"] == "C" : 
            if "atomC1" in locals() :
                if "atomC2" in locals():
                    atomC3 = atom_sub
                else : 
                    atomC2 = atom_sub
            else : 
                atomC1 = atom_sub
        

    serial = 0
    for x_test in [atomN["x"] + x * 0.2 for x in range (-50,60)] : 
        for y_test in [atomN["y"] + y * 0.2 for y in range (-50,60)] : 
            for z_test in [atomN["z"] + z * 0.2 for z in range (-50,60)] :  
                atom_test = structure.genericAtom(x_test, y_test, z_test)
                distance = calcul.distanceTwoatoms(atom_test, atomN)
                if distance < d_sup and distance > d_inf: 
                    
                    l_angles = calcul.angleTertiaryAmineCalculVol(atomN, atom_test, atomC1, atomC2, atomC3)
                    
                    if l_angles[0] > angle_inf and l_angles[1] > angle_inf and l_angles[2] > angle_inf:
                        if l_angles[0] < angle_sup and l_angles[1] < angle_sup and l_angles[2] < angle_sup:
                            serial = serial + 1
                            atom_test["serial"] = serial
                            atom_test["resSeq"] = serial
                            writePDBfile.coordinateStructure(atom_test, "HETATM", filout)
                    
    filout.close()
    WriteParameter (pr_volume + subs + ".param", subs, def_volume, serial)
Beispiel #3
0
def coordinates3DPDB (l_atom_in, l_atom_subs = [], subs = "", p_filout = "") : 
    
    if p_filout == "" : 
        return
    
    filout = open (p_filout, "w")
    
    l_atom_ref =  structure.substructureCoord(subs)
    writePDBfile.coordinateSection(filout, l_atom_ref , "HETATM")
    writePDBfile.coordinateSection(filout, l_atom_subs , "HETATM")
    writePDBfile.coordinateSection(filout, l_atom_in, "ATOM")
    
    filout.close ()
Beispiel #4
0
def AreaGuanidium (pr_init):
    """calculation of volume around nitrogen of primary amine
    in: filePDB with only primary amine, extreme value of l_angle, structure subs
    out: file format filePDB with water"""
    
    subs = "GAI"
    pr_volume = pathManage.CreatePathDir(pr_init + "Volume/")
    filout = open (pr_volume + "volume_" + subs + ".pdb", "w")
    l_atom_sub = structure.substructureCoord(subs)
    def_volume = structure.criteraAngle(subs)
    writePDBfile.coordinateSection(filout, l_atom_sub, "HETATM")
    #filout.close ()
    #ddd

    
    angle_inf = def_volume["angle"][0]
    angle_sup = def_volume["angle"][1]
    
    
    d_inf = def_volume["distance"][0]
    d_sup = def_volume["distance"][1]
    
    
    for atom_sub in l_atom_sub : 
        if atom_sub["name"] == "N01" : 
            atomN1 = atom_sub
        if atom_sub["name"] == "C01" : 
            atomC1 = atom_sub
        
    count = 0
    for x_test in [atomC1["x"] + x * 0.3 for x in range (-100,100)] : 
        for y_test in [atomC1["y"] + y * 0.3 for y in range (-100,100)] : 
            for z_test in [atomC1["z"] + z * 0.3 for z in range (-100,100)] :  
                atom_test = structure.genericAtom(x_test, y_test, z_test)
                distance = calcul.distanceTwoatoms(atom_test, atomC1)
                l_angleC1 = calcul.anglePrimaryAmineCalculVol(atomC1, atomN1, atom_test)
                
#                 print distance, l_angleC1
                if distance < d_sup and distance > d_inf: 
                    if l_angleC1[0] > angle_inf and l_angleC1[0] < angle_sup :
                        count = count + 1
                        atom_test["count"] = count
                        atom_test["resSeq"] = count
                        writePDBfile.coordinateStructure(atom_test, "HETATM", filout)
                
                
                            
    filout.close()
    WriteParameter (pr_volume + subs + ".param", subs, def_volume, count) 
Beispiel #5
0
def coordinates3D (l_atom, p_filout, type_substruct) : 
    
    filout = open (p_filout, "w") 
    
    substruct =  structure.substructureCoord(type_substruct)
    
    for atom in substruct : 
        filout.write (str(atom["x"]) + "\t" + str(atom["y"]) + "\t" + str(atom["z"]) + "\t" + "REF" + "\n")
    
    for atom in l_atom : 
        if not "occupancy" in atom.keys () : 
            filout.write (str(atom["x"]) + "\t" + str(atom["y"]) + "\t" + str(atom["z"]) + "\t" + structure.classificationATOM (atom) + "\n")
    filout.close () 
    
    return  p_filout    
Beispiel #6
0
def coordinates3DPDBbyNeighborType (l_atom_in, ll_atom_subs, subs, pr_init) : 
    
    d_file = {}
    l_type_neighbors = structure.classificationATOM (out_list = 1)
    l_atom_sub_ref =  structure.substructureCoord(subs)
    for type_neighbors in l_type_neighbors : 
        d_file[type_neighbors] = open (pr_init + subs + "_" + type_neighbors + ".pdb", "w")
        writePDBfile.coordinateSection(d_file [type_neighbors], l_atom_sub_ref , "HETATM") 
        
        #writePDBfile.coordinateSection(d_file [type_neighbors], ll_atom_subs[0] , "HETATM")
        
        #l_write = []
        #for l_atom_subs in ll_atom_subs : 
        #    writePDBfile.coordinateSection(d_file [type_neighbors], l_atom_subs , "HETATM")
#             l_write = l_write + l_atom_subs
#         writePDBfile.coordinateSection(d_file [type_neighbors], l_write , "HETATM")
    
    
    for atom in l_atom_in : 
        type_neighbor = structure.classificationATOM (atom)
        writePDBfile.coordinateSection(d_file [type_neighbor], [atom] , "ATOM", header = 0)
        
    for type_neighbors in l_type_neighbors : 
        d_file[type_neighbors].close ()
Beispiel #7
0
def SuperimposeFirstNeighbors (st_atom, pr_result):
    
    
    d_nb_neighbor = structure.nbNeighbor ()
    
    
    for subs in st_atom.keys () : 
        if subs == "global" : 
            continue
        
        l_at_ref =  structure.substructureCoord(subs)
        d_atom_superiposed = {}
        
        pr_superimpose = pr_result +  subs + "/"
        pathManage.CreatePathDir(pr_superimpose)
        
        nb_ind = d_nb_neighbor[subs] # number of considered neighbors
        
        for at_central in st_atom[subs] : 
            PDB_ID = at_central["PDB"]
            name_ligand =  at_central["resName"] 
        
            # all atom ligand
            l_at_lig = loadFile.ExtractInfoPDBID(PDB_ID)[name_ligand][0] # change not tested
            l_at_subs = retrieveAtom.substructure (subs, at_central, l_at_lig)
        
        
        
            v_atom_ref = mat(array(groupAtomCoord(l_at_ref[0:3])))
            v_atom_central = mat(array(groupAtomCoord(l_at_subs[0:3])))


            rotation, translocation =  rigid_transform_3D(v_atom_central, v_atom_ref)
            if rotation == None or translocation == None : 
                continue
        
            v_atom_rotated = applyTranformation(rotation, translocation, v_atom_central)
            l_atom_rotated = applyTranformation(rotation, translocation, l_atom_in=l_at_subs)

            print rmse(v_atom_central, v_atom_ref), "RMSE 1"
            print rmse(v_atom_ref, v_atom_rotated), "RMSE 2"


            #         print v_atom_rotated
            #         print "************compare**********"
            #         print l_at_subs
            #         print l_atom_rotated
        
        
        
            
            l_neighbor = deepcopy(at_central["neighbors"])
            if len (l_neighbor) < nb_ind : 
                continue
            else : 
                l_combination = []
                l_atom_neighbors = []
                for i_neighbors in range (1, nb_ind + 1) : 
                    atom_class, d_atom = statistic.searchMoreClose (l_neighbor) 
                    l_combination.append (atom_class)
                    l_atom_neighbors.append (d_atom)
                    
                
                l_combination.sort ()
                k = "_".join (l_combination)
                
                
                if not k in d_atom_superiposed.keys () : 
                    d_atom_superiposed[k] = []
                
                l_atom_neighbor_rotated = applyTranformation(rotation, translocation, l_atom_in = l_atom_neighbors)
                d_atom_superiposed[k] = d_atom_superiposed[k] + l_atom_rotated + l_atom_neighbor_rotated
                
                
        for k in d_atom_superiposed.keys () : 
            # write gif
            pr_init_gif = pr_superimpose + "gif/" 
            pathManage.CreatePathDir(pr_init_gif)
            p_file_coord = writeFile.coordinates3D (d_atom_superiposed[k], pr_init_gif + k + ".coord", subs) 
            runScriptR.plot3D (p_file_coord, option = "global")
    
            # write one PDB by atom close type 
            pr_init_PDB = pr_superimpose + "/PDB/"
            pathManage.CreatePathDir(pr_init_PDB)
            writeFile.coordinates3DPDB (d_atom_superiposed[k], subs, pr_init_PDB + k + ".pdb" )   
Beispiel #8
0
def globalNeighbor (atom_interest_close, subs, p_dir_result, option_filter = 1) : 
    
    p_dir_result = pathManage.imposeNeighbors (p_dir_result)
    # extract from ideal position
    l_at_ref =  structure.substructureCoord(subs)
    l_superimpose_neighbor = []
    l_superimpose_subs = []
    
    l_RMSE = []
    
    for at_central in atom_interest_close[subs] : 
        PDB_ID = at_central["PDB"]
        serial_at_central = at_central["serial"]
        name_ligand =  at_central["resName"] 
        
        # all atom ligand
        l_at_lig = loadFile.ExtractInfoPDBID(PDB_ID)[name_ligand][0] # change not tested
#         for at_ligand in l_at_lig : 
#             print at_ligand
        l_at_subs = retrieveAtom.substructure (subs, at_central, l_at_lig)
        
        
        if subs == "GAI" : 
            v_atom_central = mat(array(groupAtomCoord(l_at_subs)))
            v_atom_ref = mat(array(groupAtomCoord(l_at_ref)))
        elif subs == "COO" : 
            v_atom_central = mat(array(groupAtomCoord(l_at_subs)))
            v_atom_ref = mat(array(groupAtomCoord(l_at_ref[1:])))            
        else : 
            v_atom_central = mat(array(groupAtomCoord(l_at_subs)))
            v_atom_ref = mat(array(groupAtomCoord(l_at_ref))) 
            
        rotation, translocation =  rigid_transform_3D(v_atom_central, v_atom_ref)
        if rotation == None or translocation == None : 
            continue
        
        v_atom_rotated = applyTranformation(rotation, translocation, v_atom_central)
        l_subs_rotated = applyTranformation(rotation, translocation, l_atom_in = l_at_subs)

        RMSE_rot = rmse(v_atom_ref, v_atom_rotated)
        print rmse(v_atom_central, v_atom_ref), "RMSE 1"
        print rmse(v_atom_ref, v_atom_rotated), "RMSE 2"

        l_RMSE.append (str(RMSE_rot))

#         print v_atom_rotated
#         print "************compare**********"
#         print l_at_subs
#         print l_subs_rotated
#         print "/////////////////////////////"
        
        l_atom_neighbors = deepcopy(at_central["neighbors"])
        
        if option_filter == 1 : 
            # reduce the list of neighbor
            criteria = structure.criteraAngle(subs)
            d_min = criteria["distance"][0]
            d_max = criteria["distance"][1]
            n_neighbor = len (l_atom_neighbors)
            i = 0
            while i < n_neighbor : 
                if l_atom_neighbors[i]["distance"] < d_min or l_atom_neighbors[i]["distance"] > d_max : 
                    del l_atom_neighbors[i]
                    n_neighbor = n_neighbor - 1
                else : 
                    i = i +1
        
        try : 
            l_atom_neighbor_rotated = applyTranformation(rotation, translocation, l_atom_in=l_atom_neighbors)
            l_superimpose_neighbor = l_superimpose_neighbor + l_atom_neighbor_rotated
            l_superimpose_subs.append (l_subs_rotated)
        except : 
            continue
    
    # color with b factor
    tool.colorAtomType (l_superimpose_neighbor)
    
    # write gif
#     pr_init_gif = p_dir_result + "/gif/" + subs + "/"
#     pathManage.CreatePathDir(pr_init_gif)
#     p_file_coord = writeFile.coordinates3D (l_superimpose_neighbor + l_superimpose_subs, pr_init_gif + subs + "_neigbor.coord", subs) 
#     runScriptR.plot3D (p_file_coord)
    
    # write one PDB by atom close type 
    pr_init_PDB = p_dir_result + "/PDB/" + subs + "/" 
    pathManage.CreatePathDir(pr_init_PDB)
    file_RMSE = open (pr_init_PDB + "RMSE", "w")
    file_RMSE.write ("\n".join(l_RMSE) + "\n")
    file_RMSE.close ()
    writeFile.coordinates3DPDBbyNeighborType (l_superimpose_neighbor, l_superimpose_subs, subs, pr_init_PDB)