def read_PDB(file, atom):
    "\n    extracts coordinates for some side chain atom in some PDB file\n    For instance, atom will have value 'CA' if you care about the alpha carbons\n    \n    TODO: Fix this so it can deal with chain labels\n    Right now if the PDB has a chain label in the fifth column, this will give nonsense results\n    "
    openfile = open(file)
    resis = []
    coords = []
    for line in openfile.readlines():
        line = line.rstrip('\n')
        entries = line.split()
        if (entries[0] == 'ATOM'):
            if ((entries[2] == atom) and (entries[4] == 'A') and (entries[3] != 'GLY')):
                resis.append(entries[3])
                coords.append([float(entries[6]), float(entries[7]), float(entries[8])])
            elif ((len(entries) > 1) and (entries[2] == atom) and (entries[4] != 'A') and (entries[3] != 'GLY')):
                if ('-' in entries[5][1:(- 1)]):
                    x = entries[5]
                    entries[5] = x[0:(x[1:(- 1)].index('-') + 1)]
                    entries[6] = x[(x[1:(- 1)].index('-') + 1):]
                if ('-' in entries[6][1:(- 1)]):
                    x = entries[6]
                    entries[6] = x[0:(x[1:(- 1)].index('-') + 1)]
                    entries[7] = x[(x[1:(- 1)].index('-') + 1):]
                resis.append(entries[3])
                coords.append([float(entries[5]), float(entries[6]), float(entries[7])])
            elif ((len(entries) > 1) and (entries[2] == 'CA') and (entries[4] == 'A') and (entries[3] == 'GLY')):
                resis.append(entries[3])
                coords.append([float(entries[6]), float(entries[7]), float(entries[8])])
            elif ((len(entries) > 1) and (entries[2] == 'CA') and (entries[4] != 'A') and (entries[3] == 'GLY')):
                if ('-' in entries[5][1:(- 1)]):
                    x = entries[5]
                    entries[5] = x[0:(x[1:(- 1)].index('-') + 1)]
                    entries[6] = x[(x[1:(- 1)].index('-') + 1):]
                if ('-' in entries[6][1:(- 1)]):
                    x = entries[6]
                    entries[6] = x[0:(x[1:(- 1)].index('-') + 1)]
                    entries[7] = x[(x[1:(- 1)].index('-') + 1):]
                resis.append(entries[3])
                coords.append([float(entries[5]), float(entries[6]), float(entries[7])])
    coords = np.array(coords)
    return (coords, resis)
extracts coordinates for some side chain atom in some PDB file
For instance, atom will have value 'CA' if you care about the alpha carbons

TODO: Fix this so it can deal with chain labels
Right now if the PDB has a chain label in the fifth column, this will give nonsense results
def read_PDB(file, atom):
    "\n    extracts coordinates for some side chain atom in some PDB file\n    For instance, atom will have value 'CA' if you care about the alpha carbons\n    \n    TODO: Fix this so it can deal with chain labels\n    Right now if the PDB has a chain label in the fifth column, this will give nonsense results\n    "
    openfile = open(file)
    resis = []
    coords = []
    for line in openfile.readlines():
        line = line.rstrip('\n')
        entries = line.split()
        if (entries[0] == 'ATOM'):
            if ((entries[2] == atom) and (entries[4] == 'A') and (entries[3] != 'GLY')):
                resis.append(entries[3])
                coords.append([float(entries[6]), float(entries[7]), float(entries[8])])
            elif ((len(entries) > 1) and (entries[2] == atom) and (entries[4] != 'A') and (entries[3] != 'GLY')):
                if ('-' in entries[5][1:(- 1)]):
                    x = entries[5]
                    entries[5] = x[0:(x[1:(- 1)].index('-') + 1)]
                    entries[6] = x[(x[1:(- 1)].index('-') + 1):]
                if ('-' in entries[6][1:(- 1)]):
                    x = entries[6]
                    entries[6] = x[0:(x[1:(- 1)].index('-') + 1)]
                    entries[7] = x[(x[1:(- 1)].index('-') + 1):]
                resis.append(entries[3])
                coords.append([float(entries[5]), float(entries[6]), float(entries[7])])
            elif ((len(entries) > 1) and (entries[2] == 'CA') and (entries[4] == 'A') and (entries[3] == 'GLY')):
                resis.append(entries[3])
                coords.append([float(entries[6]), float(entries[7]), float(entries[8])])
            elif ((len(entries) > 1) and (entries[2] == 'CA') and (entries[4] != 'A') and (entries[3] == 'GLY')):
                if ('-' in entries[5][1:(- 1)]):
                    x = entries[5]
                    entries[5] = x[0:(x[1:(- 1)].index('-') + 1)]
                    entries[6] = x[(x[1:(- 1)].index('-') + 1):]
                if ('-' in entries[6][1:(- 1)]):
                    x = entries[6]
                    entries[6] = x[0:(x[1:(- 1)].index('-') + 1)]
                    entries[7] = x[(x[1:(- 1)].index('-') + 1):]
                resis.append(entries[3])
                coords.append([float(entries[5]), float(entries[6]), float(entries[7])])
    coords = np.array(coords)
    return (coords, resis)