#!/usr/bin/python # Read a PDB and output DSSP to console import sys, os from Bio.PDB import PDBParser from Bio.PDB.DSSP import DSSP import pandas as pd import pprint as pp #%% # TASK: read a pdb file and generate a dssp output file # FIXME: Pending output dssp hasn't been generated # needs dssp exe on linux # may be easier to run the dssp exe locally #%% # my working dir os.getcwd() homedir = os.path.expanduser('~') # spyder/python doesn't recognise tilde os.chdir(homedir + '/git/LSHTM_analysis/meta_data_analysis') os.getcwd() #%% # specify variables for input and output paths and filenames drug = "pyrazinamide" #gene = "pnca" datadir = homedir + "/git/Data" basedir = datadir + "/" + drug + "/input" # input inpath = "/original" # uncomment as necessary in_filename = "/3pl1.pdb" infile = basedir + inpath + in_filename #print(infile) # output file outpath = "/processed" outdir = datadir + "/" + drug + outpath out_filename = "/3pl1.dssp" outfile = outdir + out_filename #print(outdir) if not os.path.exists(datadir): print('Error!', datadir, 'does not exist. Please ensure it exists. Dir struc specified in README.md') os.makedirs(datadir) exit() if not os.path.exists(outdir): print('Error!', outdir, 'does not exist.Please ensure it exists. Dir struc specified in README.md') exit() else: print('Dir exists: Carrying on') # end of variable assignment for input and output files #%% p = PDBParser() structure = p.get_structure("3pl1", infile) model = structure[0] dssp = DSSP(model, infile) #dssp = DSSP(model, infile, dssp='mkdssp') #incase you used DSSP2 exe pp.pprint(dssp) #DSSP data is accessed by a tuple - (chain id, residue id): RSA a_key = list(dssp.keys())[3] dssp[a_key] pp.pprint(dssp.keys()) pp.pprint(dssp.property_dict) pp.pprint(dssp.property_keys) pp.pprint(dssp.property_list)