tidy code and renamed kd.py to kd_df.py
This commit is contained in:
parent
73e0029b65
commit
a074d29f6e
6 changed files with 156 additions and 194 deletions
|
@ -10,15 +10,17 @@ Created on Tue Aug 6 12:56:03 2019
|
|||
#=======================================================================
|
||||
# TASK: calculate how many mutations result in
|
||||
# electrostatic changes wrt wt
|
||||
|
||||
# Input: mcsm and AF_OR file
|
||||
|
||||
# Output: mut_elec_changes_results.txt
|
||||
#=======================================================================
|
||||
#%% load libraries
|
||||
import os, sys
|
||||
import pandas as pd
|
||||
#import numpy as np
|
||||
|
||||
#%% specify homedir as python doesn't recognise tilde
|
||||
#=======================================================================
|
||||
#%% specify homedir and curr dir
|
||||
homedir = os.path.expanduser('~')
|
||||
|
||||
# set working dir
|
||||
|
@ -26,7 +28,7 @@ os.getcwd()
|
|||
os.chdir(homedir + '/git/LSHTM_analysis/meta_data_analysis')
|
||||
os.getcwd()
|
||||
#=======================================================================
|
||||
#%% variable assignment: input and output paths & filenames
|
||||
#%% variable assignment: input and output
|
||||
drug = 'pyrazinamide'
|
||||
gene = 'pncA'
|
||||
gene_match = gene + '_p.'
|
||||
|
@ -59,7 +61,6 @@ print('Output filename: ', out_filename
|
|||
#%% end of variable assignment for input and output files
|
||||
#=======================================================================
|
||||
#%% Read input files
|
||||
#in_filename = gene.lower() + '_meta_data_with_AFandOR.csv'
|
||||
print('Reading input file (merged file):', infile)
|
||||
|
||||
comb_df = pd.read_csv(infile, sep = ',')
|
||||
|
@ -136,17 +137,11 @@ print('Total number of electrostatic changes resulting from Mutation is (%):', e
|
|||
no_change_muts = ap_df[ap_df['aa_calcprop'].isin(['neg->neg','non-polar->non-polar','polar->polar', 'pos->pos']) == True]
|
||||
|
||||
no_change_muts.mut_count.sum()
|
||||
|
||||
|
||||
###########
|
||||
# Step 5: output from console
|
||||
###########
|
||||
#%% output from console
|
||||
#sys.stdout = open(file, 'w')
|
||||
sys.stdout = open(outfile, 'w')
|
||||
|
||||
#print(no_change_muts, '\n',
|
||||
# all_prop_change)
|
||||
|
||||
|
||||
print('======================\n'
|
||||
,'Unchanged muts'
|
||||
,'\n=====================\n'
|
||||
|
@ -156,16 +151,11 @@ print('======================\n'
|
|||
, '\n============================\n'
|
||||
, all_prop_change)
|
||||
|
||||
#print('======================================================================')
|
||||
#print('Total number of electrostatic changes resulting from Mutation is (%):', elec_changes)
|
||||
#print('Total no. of muts: ', total_muts)
|
||||
#print('Total no. of changed muts: ', all_prop_change.mut_count.sum())
|
||||
#print('Total no. of unchanged muts: ', no_change_muts.mut_count.sum() )
|
||||
#print('=======================================================================')
|
||||
|
||||
print('========================================================================'
|
||||
, '\nTotal number of electrostatic changes resulting from Mtation is (%):', elec_changes
|
||||
, '\nTotal no. of muts: ', total_muts
|
||||
, '\nTotal no. of changed muts: ', all_prop_change.mut_count.sum()
|
||||
, '\nTotal no. of unchanged muts: ', no_change_muts.mut_count.sum()
|
||||
, '\n=========================================================================')
|
||||
#%% end of script
|
||||
#=======================================================================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue