adding scripts for struct params
This commit is contained in:
parent
4ef68bdc1b
commit
b56c0b8b68
5 changed files with 270 additions and 0 deletions
68
meta_data_analysis/dssp_df.py
Executable file
68
meta_data_analysis/dssp_df.py
Executable file
|
@ -0,0 +1,68 @@
|
|||
#!/home/tanu/anaconda3/envs/ContactMap/bin/python3
|
||||
# Read a DSSP file into a data frame and pretty-print it
|
||||
|
||||
#https://jbloomlab.github.io/dms_tools2/dms_tools2.dssp.html
|
||||
import sys, os
|
||||
import pandas as pd
|
||||
import pprint as pp
|
||||
import dms_tools2
|
||||
import dms_tools2.dssp
|
||||
|
||||
#%%
|
||||
# my working dir
|
||||
homedir = os.path.expanduser('~') # spyder/python doesn't recognise tilde
|
||||
os.getcwd()
|
||||
os.chdir(homedir + '/git/LSHTM_analysis/meta_data_analysis/struct_params')
|
||||
os.getcwd()
|
||||
#%%
|
||||
# sample example
|
||||
dssp_file = "./3pl1.dssp"
|
||||
dssp_df = dms_tools2.dssp.processDSSP(dssp_file, chain='A')
|
||||
|
||||
# outputs to console
|
||||
#returns df with ASA and RSA (base on Tien at al 2013 (theor.) values)
|
||||
#Link: https://en.wikipedia.org/wiki/Relative_accessible_surface_area
|
||||
pp.pprint(dssp_df)
|
||||
|
||||
# write to csv
|
||||
dssp_df.to_csv('3pl1_dssp_df', header=True, index = False)
|
||||
|
||||
#%% specify variables for input and output paths and filenames
|
||||
drug = "pyrazinamide"
|
||||
#gene = "pnca"
|
||||
|
||||
datadir = homedir + "/git/Data"
|
||||
basedir = datadir + "/" + drug + "/input"
|
||||
|
||||
# input
|
||||
inpath = "/processed"
|
||||
in_filename = "/3pl1.dssp"
|
||||
infile = basedir + inpath + in_filename
|
||||
#print(infile)
|
||||
|
||||
# output file
|
||||
outpath = "/output"
|
||||
outdir = datadir + "/" + drug + outpath
|
||||
out_filename = "/3pl1_dssp_df"
|
||||
outfile = outdir + out_filename
|
||||
print(outdir); print(outfile)
|
||||
|
||||
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
|
||||
#%% <----- fixme
|
||||
dssp_file = infile
|
||||
dssp_df = dms_tools2.dssp.processDSSP(dssp_file, chain='A')
|
||||
|
||||
#%%
|
||||
# write to csv
|
||||
dssp_df.to_csv(outfile, header=True, index = False)
|
Loading…
Add table
Add a link
Reference in a new issue