tidy code and saving work for the day

This commit is contained in:
Tanushree Tunstall 2020-03-26 17:58:39 +00:00
parent 69e2567ffc
commit afd6ca8881
6 changed files with 307 additions and 284 deletions

View file

@ -48,9 +48,8 @@ indir = datadir + '/' + drug + '/' + 'output'
in_filename = '3pl1_rd.tsv'
infile = indir + '/' + in_filename
print('Input filename:', in_filename
, '\nInput path:', indir)
print('======================================================================')
, '\nInput path:', indir
, '\n=============================================================')
#=======
# output
#=======
@ -58,9 +57,9 @@ outdir = datadir + '/' + drug + '/' + 'output'
out_filename = gene.lower() + '_rd.csv'
outfile = outdir + '/' + out_filename
print('Output filename:', out_filename
, '\nOutput path:', outdir)
print('======================================================================')
, '\nOutput path:', outdir
, '\n=============================================================')
#%% end of variable assignment for input and output files
#=======================================================================
#%% Read input file
@ -69,9 +68,8 @@ print('Reading input file:', infile
, '\nNo. of rows:', len(rd_data)
, '\nNo. of cols:', len(rd_data.columns))
print('Column names:', rd_data.columns)
print('======================================================================')
print('Column names:', rd_data.columns
, '\n===============================================================')
#========================
# creating position col
#========================
@ -85,19 +83,18 @@ rd_data['position'].dtype
print('Extracted residue num from index and assigned as a column:'
, '\ncolumn name: position'
, '\ntotal no. of cols now:', len(rd_data.columns))
print('======================================================================')
, '\ntotal no. of cols now:', len(rd_data.columns)
, '\n=============================================================')
#========================
# Renaming amino-acid
# and all-atom cols
#========================
print('Renaming columns:'
,'\ncolname==> # chain:residue: wt_3letter_caps'
,'\nYES... the column name *actually* contains a # ..!'
,'\ncolname==> all-atom: rd_values')
print('======================================================================')
, '\ncolname==> # chain:residue: wt_3letter_caps'
, '\nYES... the column name *actually* contains a # ..!'
, '\ncolname==> all-atom: rd_values'
, '\n=============================================================')
rd_data.rename(columns = {'# chain:residue':'wt_3letter_caps', 'all-atom':'rd_values'}, inplace = True)
print('Column names:', rd_data.columns)
@ -117,22 +114,22 @@ if len(rd_df) == len(rd_data):
,'\nNo. of cols:', len(rd_df.columns))
else:
print('FAIL: no. of rows mimatch'
,'\nExpected no. of rows:', len(rd_data)
,'\nGot no. of rows:', len(rd_df))
print('======================================================================')
, '\nExpected no. of rows:', len(rd_data)
, '\nGot no. of rows:', len(rd_df)
, '\n=========================================================')
#%% write file
print('Writing file:'
, '\nFilename:', out_filename
, '\nPath:', outdir)
, '\nPath:', outdir
, '\n=============================================================')
rd_df.to_csv(outfile, header = True, index = False)
print('======================================================================')
print('Finished writing:', out_filename
, '\nNo. of rows:', len(rd_df)
, '\nNo. of cols:', len(rd_df.columns))
, '\nNo. of cols:', len(rd_df.columns)
, '\n=============================================================')
#%% end of script
#=======================================================================