Example #1
0
def Builder(name_database, RX = 3.00, RFree = 0.25, one_PDB_by_lig = 0, debug = 1):
    """
    Dataset Builder
    in : - open file result of filter ligand PDB
    out : - log file
          - dataset file -> ligand with associated PDB
    """
    
    if one_PDB_by_lig == 0 : 
        name_dataset = name_database + "/" + str (RX) + "_" + str (RFree) + "_multiPDB"
    else : 
        name_dataset = name_database + "/" + str (RX) + "_" + str (RFree) + "_uniquePDB"
    
    pr_database = pathManage.result(name_database)
    pr_result = pathManage.result(name_dataset)
    if debug : print "== Path result " + pr_result + "==\n"
    
    # check dataSet exist !!!!!!
    # short cut
    l_file_dataset = pathManage.retriveDataSetFile (pr_result)
    if len(l_file_dataset) != 0 : 
        return l_file_dataset


    # load structure    
    d_lig_PDB = loadFile.LigandInPDB(pr_database + "resultLigandInPDB")
    
    nb_lig = len(d_lig_PDB.keys())
    print "NB ligand included database:", nb_lig
    
    # print d_lig_PDB.keys().index("HSO") -> search index ligand
    
    i = 0
    while i < nb_lig:
        name_lig = d_lig_PDB.keys()[i]
        
        #######################################
        # step 1 search chemical substructure #
        #######################################
        PDB_ref = d_lig_PDB[name_lig][0]
        if debug : print PDB_ref, name_lig, i, nb_lig
        # if not possible to load the ligand -> remove lig
        try : l_atom_lig_ref = loadFile.ligandInPDBConnectMatrixLigand(PDB_ref, name_lig)
        except : 
            if debug == 1 : print "Exit => load ligand-l59"
            del d_lig_PDB[name_lig]
            nb_lig = nb_lig - 1
            continue
        
        # search substructure interest
        l_interest_sub = searchPDB.interestStructure(l_atom_lig_ref) # search interest structure
        if debug : print "Interest substructures in " + str(name_lig) + "-" + str (PDB_ref) + " " + "-".join(l_interest_sub)
        if l_interest_sub == []:
            if debug == 1 : print "Exit => Not substructure-l68"
            del d_lig_PDB[name_lig]
            nb_lig = nb_lig - 1
            continue
        
        #######################################################
        # Step 2 Control quality of PDB + ligand hooked + option one #
        #######################################################
        else : 
            # control dataset quality
            if debug : print "List PDB checked -> ", d_lig_PDB[name_lig]
            l_PDB = checkPDBfile.CheckComplexQuality(d_lig_PDB[name_lig], name_lig, RX, RFree, one_PDB_by_lig)
            # remove the entrance key with the ligand
            if l_PDB == []:
                if debug == 1 : print "Exit => Not No PDB selected-l82"
                del d_lig_PDB[name_lig]
                nb_lig = nb_lig - 1
                continue
            else : 
                d_lig_PDB[name_lig] = l_PDB
        i = i + 1
        
        
    if debug == 1 : print "Number of ligand selected =>", nb_lig
                
    # structure and file dataset and control RX + length bond
    WriteDataset (d_lig_PDB, pr_result)
    
       
    return  Builder(name_database, RX , RFree , one_PDB_by_lig , debug = 1) 
Example #2
0

ligandWithPDB = loadFile.resultLigandPDB(repertory.resultSerineProtease() + "resultLigandInPDB")
listLigand = ligandWithPDB.keys()
print listLigand

nbLigand = len(listLigand)
print nbLigand

j = 0
while j < nbLigand :
    ligand = listLigand[j]
    print ligand , j
    pdb = ligandWithPDB[ligand][0].split("_")[2]
    pdb = lower(pdb)
    atomLigand = loadFile.ligandInPDBConnectMatrixLigand(pdb, ligand)
    writePDBfile.globalStruct(ligand + "_" + pdb + ".pdb", atomLigand)
    nbAtom = len(atomLigand)
    # print atomLigand

    searchPDB.cycleGlobal(atomLigand)
#    print atomLigand
    listResult = []
    for atom in atomLigand : 
        if atom["element"] == "N" or atom["element"] == "O" or atom["element"] == "C":  # impact point
            if atom["cycle"] == 1 : 
                cycleRetrieve = retrieveAtom.cycle(atom, atomLigand)
                listResult.append(cycleRetrieve)
                continue
            for serialAtom in atom["connect"] : 
                atomRetrieve = retrieveAtom.serial(serialAtom, atomLigand)
Example #3
0
def GlobalBondLength (name_database, RX_thresold = 1.5):
    
    # directory
    pr_result = pathManage.result(name_database + "/CXbound" + str (RX_thresold))
    pr_database = pathManage.result(name_database)
    
    # filout with distance
    p_CN = pr_result + "distanceCN"
    p_CO = pr_result + "distanceCO"
    p_CC = pr_result + "distanceCC"
    p_coplar = pr_result + "distanceCoplar"
    
    
    filout_CN = open (p_CN, "w")
    filout_CO = open (p_CO, "w")
    filout_CC = open (p_CC, "w")
    filout_coplar = open (p_coplar, "w")
    
    # load PDB with logand
    if not path.exists(pr_database + "resultLigandInPDB") : 
        print "ERROR => file with ligand and PDB does not exist"
        return
    else : 
        d_lig_PDB = loadFile.LigandInPDB(pr_database + "resultLigandInPDB")
    
 
    nb_lig = len(d_lig_PDB.keys())
    print d_lig_PDB.keys()
    
    i = 0
    while (i < nb_lig):
        name_lig = d_lig_PDB.keys()[i]
        
        l_PDB = d_lig_PDB[name_lig]
        
        for PDB in l_PDB : 
            # controle RX
            RX = parsing.Quality(PDB)[0]
#             print RX
            
            if RX <= RX_thresold : 
                l_atom_lig = loadFile.ligandInPDBConnectMatrixLigand(PDB, name_lig)
                
                l_distCN = BondLengthCandX (l_atom_lig, "N")
                l_distCO = BondLengthCandX (l_atom_lig, "O")
                l_distCC = BondLengthCandX (l_atom_lig, "C")
                l_coplarIII = CoplanarityIII(l_atom_lig)
                
                if l_distCN != [] : 
                    filout_CN.write ("\n".join (l_distCN) + "\n")
                
                if l_distCO != [] : 
                    filout_CO.write ("\n".join (l_distCO) + "\n")    
                
                if l_distCC != [] : 
                    filout_CC.write ("\n".join (l_distCC) + "\n")                
                
                if l_coplarIII != [] : 
                    filout_coplar.write ("\n".join (l_coplarIII) + "\n")  
                
                # take only one PDB by ligand not more
                i = i + 1
                continue
            i = i + 1
        
    filout_CO.close ()
    filout_CN.close ()
    filout_CC.close ()
    filout_coplar.close ()
    
    runScriptR.histDistance(p_CN, "CN")
    runScriptR.histDistance(p_CO, "CO") 
    runScriptR.histDistance(p_CC, "CC") 
    runScriptR.histDistance(p_coplar, "coplar")