refactoring: added command line args to combine_dfs
This commit is contained in:
parent
49a38dd1ae
commit
30aa64fd2b
1 changed files with 30 additions and 20 deletions
|
@ -6,35 +6,36 @@ Created on Tue Aug 6 12:56:03 2019
|
||||||
@author: tanu
|
@author: tanu
|
||||||
'''
|
'''
|
||||||
# FIXME: change filename 4 (mcsm normalised data)
|
# FIXME: change filename 4 (mcsm normalised data)
|
||||||
# to be consistent like (pnca_mcsm_norm.csv)
|
# to be consistent like (pnca_complex_mcsm_norm.csv) : changed manually, but ensure this is done in the mcsm pipeline
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
# Task: combine 4 dfs with aa position as linking column
|
# Task: combine 4 dfs with aa position as linking column
|
||||||
# This is done in 2 steps:
|
# This is done in 2 steps:
|
||||||
# merge 1: of 3 dfs
|
# merge 1: of 3 dfs (filenames in lowercase)
|
||||||
# pnca_dssp.csv
|
# <gene.lower()>_dssp.csv
|
||||||
# pnca_kd.csv
|
# <gene.lower()>_kd.csv
|
||||||
# pnca_rd.csv
|
# <gene.lower()>_pnca_rd.csv
|
||||||
|
|
||||||
# merge 2: of 2 dfs
|
# merge 2: of 2 dfs
|
||||||
# mcsm_complex1_normalised.csv (!fix name)
|
# pnca_complex_mcsm_norm.csv (!fix name in mcsm script)
|
||||||
# output df from merge1
|
# output df from merge1
|
||||||
|
|
||||||
# Input: 3 dfs
|
# Input: 3 dfs
|
||||||
# pnca_dssp.csv
|
# <gene.lower()>_dssp.csv
|
||||||
# pnca_kd.csv
|
# <gene.lower()>_kd.csv
|
||||||
# pnca_rd.csv
|
# <gene.lower()>_pnca_rd.csv
|
||||||
# mcsm_complex1_normalised.csv (!fix name)
|
# pnca_complex_mcsm_norm.csv (!fix name in mcsm script)
|
||||||
|
|
||||||
# Output: .csv of all 4 dfs combined
|
# Output: .csv of all 4 dfs combined
|
||||||
|
|
||||||
# useful link
|
# useful link
|
||||||
#https://stackoverflow.com/questions/23668427/pandas-three-way-joining-multiple-dataframes-on-columns
|
# https://stackoverflow.com/questions/23668427/pandas-three-way-joining-multiple-dataframes-on-columns
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
#%% load packages
|
#%% load packages
|
||||||
import sys, os
|
import sys, os
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
#import numpy as np
|
#import numpy as np
|
||||||
#=============================================================================
|
import argparse
|
||||||
|
#=======================================================================
|
||||||
#%% specify input and curr dir
|
#%% specify input and curr dir
|
||||||
homedir = os.path.expanduser('~')
|
homedir = os.path.expanduser('~')
|
||||||
|
|
||||||
|
@ -42,27 +43,36 @@ homedir = os.path.expanduser('~')
|
||||||
os.getcwd()
|
os.getcwd()
|
||||||
os.chdir(homedir + '/git/LSHTM_analysis/meta_data_analysis')
|
os.chdir(homedir + '/git/LSHTM_analysis/meta_data_analysis')
|
||||||
os.getcwd()
|
os.getcwd()
|
||||||
#=============================================================================
|
#=======================================================================
|
||||||
|
#%% command line args
|
||||||
|
arg_parser = argparse.ArgumentParser()
|
||||||
|
#arg_parser.add_argument('-d', '--drug', help='drug name', default = 'pyrazinamide')
|
||||||
|
#arg_parser.add_argument('-g', '--gene', help='gene name', default = 'pncA') # case sensitive
|
||||||
|
arg_parser.add_argument('-d', '--drug', help='drug name', default = 'pyrazin')
|
||||||
|
arg_parser.add_argument('-g', '--gene', help='gene name', default = 'pn') # case sensitive
|
||||||
|
args = arg_parser.parse_args()
|
||||||
|
#=======================================================================
|
||||||
#%% variable assignment: input and output
|
#%% variable assignment: input and output
|
||||||
drug = 'pyrazinamide'
|
#drug = 'pyrazinamide'
|
||||||
gene = 'pncA'
|
#gene = 'pncA'
|
||||||
gene_match = gene + '_p.'
|
#gene_match = gene + '_p.'
|
||||||
|
|
||||||
|
drug = args.drug
|
||||||
|
gene = args.gene
|
||||||
#==========
|
#==========
|
||||||
# data dir
|
# data dir
|
||||||
#==========
|
#==========
|
||||||
#indir = 'git/Data/pyrazinamide/input/original'
|
|
||||||
datadir = homedir + '/' + 'git/Data'
|
datadir = homedir + '/' + 'git/Data'
|
||||||
|
|
||||||
#=======
|
#=======
|
||||||
# input
|
# input
|
||||||
#=======
|
#=======
|
||||||
#indir = 'git/Data/pyrazinamide/input/original'
|
|
||||||
indir = datadir + '/' + drug + '/' + 'output'
|
indir = datadir + '/' + drug + '/' + 'output'
|
||||||
in_filename1 = 'pnca_dssp.csv'
|
in_filename1 = 'pnca_dssp.csv'
|
||||||
in_filename2 = 'pnca_kd.csv'
|
in_filename2 = 'pnca_kd.csv'
|
||||||
in_filename3 = 'pnca_rd.csv'
|
in_filename3 = 'pnca_rd.csv'
|
||||||
in_filename4 = 'mcsm_complex1_normalised.csv' # FIXNAME
|
#in_filename4 = 'mcsm_complex1_normalised.csv' # Fix name in mcsm script
|
||||||
|
in_filename4 = 'pnca_complex_mcsm_norm.csv' # manually changed temporarily
|
||||||
|
|
||||||
infile1 = indir + '/' + in_filename1
|
infile1 = indir + '/' + in_filename1
|
||||||
infile2 = indir + '/' + in_filename2
|
infile2 = indir + '/' + in_filename2
|
||||||
|
@ -235,4 +245,4 @@ print('Finished writing:', out_filename
|
||||||
, '\n===================================================================')
|
, '\n===================================================================')
|
||||||
|
|
||||||
#%% end of script
|
#%% end of script
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue