Exemplo n.º 1
0
def ligandInPDBConnectMatrixLigand(PDB_ID, ligand):
    """load ligand in structure in PDB file
    out : list atom in ligands with connect matrix calculated"""

    l_lines = openPdbFile(PDB_ID)
    l_atom = []
    l_serial = []
    for line in l_lines:
        if search ("^HETATM", line):
            atom = parsing.lineCoords(line)
            if atom["resName"] == ligand and atom["element"] != "H":
                if not atom["serial"] in l_serial : 
                    l_atom.append(atom)
                    l_serial.append(atom["serial"])
    checkOnlyOneLigand(l_atom)  ####retrieve only first ligand
    calcul.buildConnectMatrix(l_atom, PDB_ID)

    return l_atom
Exemplo n.º 2
0
def coordinateSection (f_write, l_atom, recorder = "ATOM", header = "", connect_matrix = 0):
    """
    Write list atom in PDB file
    in: list atoms, name of file out
    out: write file
    
    arg -> header = 0 not header in file
    """
    
    
    if type (f_write) == str : 
        filout = open(f_write, "w")
    elif  type (f_write) == file  : 
        filout = f_write
    else : 
        print "======ERROR========"
        print "flux writing ERROR"
        print "l17 - write PDB file"
        print "==================="
        return 0
        
    if header != 0 : 
        filout.write ("HEADER " + str (header) + "\n")
    for atom in l_atom : 
        coordinateStructure(atom, recorder, filout)
    
    if connect_matrix == 1 :
        calcul.buildConnectMatrix (l_atom)
        for atom in l_atom : 
            connect(atom, filout)
            
    if header != 0 :        
        filout.write("END\n")
    
    if type (f_write) == str : 
        filout.close ()
    else : 
        pass
    
    return f_write
Exemplo n.º 3
0
def ExtractInfoPDBID(PDB_ID) : 

    # control PDB exist in the folder where the PDB is included
    p_PDBfile = pathManage.pathDitrectoryPDB() + PDB_ID.lower() + ".pdb"
    if not path.exists(p_PDBfile) :
        print "ERROR load PDB ID -> ", PDB_ID
        return {} 
    
    # initialisation of the output
    d_out = {}
    d_out["protein"] = []
    d_out["RX"] = 100.0
    d_out["RFree"] = 100.0
    
    
    filin = open (p_PDBfile, "r")
    l_linesPDB = filin.readlines ()
    filin.close ()
    
    d_out["Header"] = l_linesPDB[0][6:].lower().strip ()
    
    for linePDB in l_linesPDB : 
        # Resolution
        if search("^REMARK   2 RESOLUTION", linePDB):
            
            lineRX = sub('[ ]{2,}', ' ', linePDB)
            try : d_out["RX"] = float (lineRX.split(" ")[3].replace (" ", ""))
            except : pass
            
        # Rfree
        elif search ("REMARK   3   R VALUE", linePDB) : 
            rfactor = linePDB.strip ().split (":")[-1].replace (" ", "")
            if rfactor == "NULL" : 
                rfactor = 0.0
            else : 
                rfactor =  float (rfactor)
            d_out["RFree"] =  rfactor
        
        # protein
        elif search ("^ATOM", linePDB) :
            atom_prot = parsing.lineCoords (linePDB, remove_H = 1)
            if atom_prot != None : 
                d_out["protein"].append (atom_prot)
        
        elif search ("^HETATM", linePDB) : 
            atom_HET = parsing.lineCoords (linePDB, remove_H = 1)
            if atom_HET != None : 
                name_lig = atom_HET["resName"]
                if not name_lig in d_out.keys () : 
                    d_out[name_lig] = []
                d_out[name_lig].append (atom_HET)
        
        # kept only first model in the protein in case of RMN structure
        elif search ("^ENDMDL", linePDB) : 
            break
        
        
    # separate the ligand in double
    for k in d_out.keys() : 
        if k != "protein" and k != "RX" and k != "RFree" and k != "Header" : 
            d_out[k] = parsing.separateByLigand (d_out[k], debug = 0)
            for l_atom_lig in d_out[k] :
                l_atom_lig = calcul.buildConnectMatrix(l_atom_lig) 
            
    return d_out