def GetPdbCoordinates( filename,
                       select_atom = ("CA",),
                       select_chain = None,
                       renumber = None,
                       only_coordinates = None):

    if not os.path.exists(filename):
        raise "pdb file %s does not exist" % filename

    if filename[-3:] == ".gz":
        lines = os.popen("gunzip < %s" % filename).readlines()
    else:
        lines = open(filename,"r").readlines()

    result = []

    current_number = 1
    
    for line in lines:
        if line[:6] not in ("ATOM  ", "HETATM"): continue

        chain   = line[21]
        number  = line[22:26]
        aa      = line[17:20]
        atom    = string.strip(line[13:17])
        
        x,y,z = map(string.atof, (line[30:38], line[38:46], line[46:54]))

        if select_chain and chain not in select_chain: continue
        if select_atom and atom not in select_atom: continue
        
        if renumber:
            number = current_number
            current_number += 1

        if AMINOACIDS.has_key(aa):
            aminoacid = AMINOACIDS[aa]
        else:
            sys.stderr.write( "# error in PdbCoordinates: aminoacid %s not known\n" % aa )
            continue

        if only_coordinates:
            result.append( (x, y, z) )
        else:
            result.append( (number, aminoacid, x, y, z) )            
        
    return result
Convert dfp dictionary to AdUnit targeting model
dataset/ETHPy150Open CGATOxford/cgat/legacy/PdbTools.py/GetPdbCoordinates--crossover with--dataset/ETHPy150Open chartbeat-labs/parselmouth/parselmouth/adapters/dfp/targeting_utils.py/_adunit_from_dfp