Exemple #1
0
def ligands(name_database, pr_init):
    '''search ligands in PDB database
    out : list of ligands with PDB files associated'''
    
    print "Start Search Ligand In PDB file"
    # control file exist
    if path.exists(pr_init + "resultLigandInPDB") and path.getsize(pr_init + "resultLigandInPDB") != 0: 
        return pr_init + "resultLigandInPDB"
    
    # import list PBD from file .dat
    # http://www.rcsb.org/pdb/rest/representatives?cluster=50
    l_PDB = managePDB.retriveListPDB(name_database)
    
    l_d_lig = []

    for PDB_ID in l_PDB:
        d_lig_PDB = structure.ligandPDB()
        d_lig_PDB["name"] = PDB_ID
        l_lig_in = parsing.retrieveListLigand(pathManage.pathDitrectoryPDB() + PDB_ID.lower() + ".pdb")
        d_lig_PDB["ligands"] = l_lig_in
        l_d_lig.append(d_lig_PDB)
    
    # write result file
    p_out = writeFile.resultLigandInPDB(l_d_lig, pr_init)

    print "END Search Ligand In PDB file"
    return p_out
Exemple #2
0
def ControlHETATOMModelFile (pr_data, pr_result, l_lig_control = []):
    
    # Write file ligand  
    
    l_ligand = listdir(pr_data)
    for ligand in l_ligand : 
        # control if file exist and size
        p_file_lig = pathManage.CreatePathDir(pr_result + str (ligand) + "/" ) + "ligInModel"
        
        if path.exists(p_file_lig) : 
            return
        
        else : 
            file_lig = open (p_file_lig, "w")
            print "ligand", ligand
        
            l_file = listdir(pr_data + ligand + "/")
        
            d_temp = {}
            for model_file in l_file :
            
                l_lig_PDB = parsing.retrieveListLigand(pr_data + ligand + "/" + model_file)
                print "***", l_lig_PDB
                if len (l_lig_PDB) == 0 : 
                    continue
                else : 
                    for lig in l_lig_PDB :
                        if not l_lig_control == [] and lig in l_lig_control :  
                            if not lig in d_temp.keys () : 
                                d_temp[lig] = []
                            d_temp[lig].append (pr_data + ligand + "/" + model_file)
                        else : 
                            continue
                
            # write temp control
            for lig in d_temp.keys () : 
                file_lig.write (str (lig) + "\t" + " ".join(d_temp[lig]) + "\n")
    
            file_lig.close ()
        
    return