minor tweaks

This commit is contained in:
Tanushree Tunstall 2020-04-08 18:27:09 +01:00
parent fe3d431a3d
commit 7a8bbc6595
4 changed files with 30 additions and 26 deletions

View file

@ -7,29 +7,29 @@ Created on Tue Aug 6 12:56:03 2019
''' '''
# FIXME: change filename 4 (mcsm normalised data) # FIXME: change filename 4 (mcsm normalised data)
# to be consistent like (pnca_complex_mcsm_norm.csv) : changed manually, but ensure this is done in the mcsm pipeline # 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 (filenames in lowercase) # merge 1: of 3 dfs (filenames in lowercase)
# <gene.lower()>_dssp.csv # <gene.lower()>_dssp.csv
# <gene.lower()>_kd.csv # <gene.lower()>_kd.csv
# <gene.lower()>_pnca_rd.csv # <gene.lower()>_rd.csv
# merge 2: of 2 dfs # merge 2: of 2 dfs
# pnca_complex_mcsm_norm.csv (!fix name) # gene.lower() + '_complex_mcsm_norm.csv' (!fix name)
# output df from merge1 # output df from merge1
# Input: 3 dfs # Input: 3 dfs
# <gene.lower()>_dssp.csv # <gene.lower()>_dssp.csv
# <gene.lower()>_kd.csv # <gene.lower()>_kd.csv
# <gene.lower()>_pnca_rd.csv # <gene.lower()>_rd.csv
# pnca_complex_mcsm_norm.csv (!fix name) # gene.lower() + '_complex_mcsm_norm.csv' (!fix name)
# 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
@ -46,10 +46,10 @@ os.getcwd()
#======================================================================= #=======================================================================
#%% command line args #%% command line args
arg_parser = argparse.ArgumentParser() arg_parser = argparse.ArgumentParser()
#arg_parser.add_argument('-d', '--drug', help='drug name', default = 'pyrazinamide') 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('-g', '--gene', help='gene name', default = 'pncA') # case sensitive
arg_parser.add_argument('-d', '--drug', help='drug name', default = 'pyrazin') #arg_parser.add_argument('-d', '--drug', help='drug name', default = 'TESTDRUG')
arg_parser.add_argument('-g', '--gene', help='gene name', default = 'pn') # case sensitive #arg_parser.add_argument('-g', '--gene', help='gene name (case sensitive)', default = 'testGene') # case sensitive
args = arg_parser.parse_args() args = arg_parser.parse_args()
#======================================================================= #=======================================================================
#%% variable assignment: input and output #%% variable assignment: input and output
@ -68,11 +68,11 @@ datadir = homedir + '/' + 'git/Data'
# input # input
#======= #=======
indir = datadir + '/' + drug + '/' + 'output' indir = datadir + '/' + drug + '/' + 'output'
in_filename1 = 'pnca_dssp.csv' in_filename1 = gene.lower() + '_dssp.csv'
in_filename2 = 'pnca_kd.csv' in_filename2 = gene.lower() + '_kd.csv'
in_filename3 = 'pnca_rd.csv' in_filename3 = gene.lower() + '_rd.csv'
#in_filename4 = 'mcsm_complex1_normalised.csv' # FIXNAME #in_filename4 = 'mcsm_complex1_normalised.csv' # FIXNAME
in_filename4 = 'pnca_complex_mcsm_norm.csv' in_filename4 = gene.lower() + '_complex_mcsm_norm.csv'
infile1 = indir + '/' + in_filename1 infile1 = indir + '/' + in_filename1
infile2 = indir + '/' + in_filename2 infile2 = indir + '/' + in_filename2

View file

@ -47,8 +47,10 @@ from reference_dict import my_aa_dict # CHECK DIR STRUC THERE!
#======================================================================= #=======================================================================
#%% command line args #%% command line args
arg_parser = argparse.ArgumentParser() arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('-d', '--drug', help='drug name', default = 'pyrazinamide') #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('-g', '--gene', help='gene name', default = 'pncA') # case sensitive
arg_parser.add_argument('-d', '--drug', help='drug name', default = 'TESTDRUG')
arg_parser.add_argument('-g', '--gene', help='gene name (case sensitive)', default = 'testGene') # case sensitive
args = arg_parser.parse_args() args = arg_parser.parse_args()
#======================================================================= #=======================================================================
#%% variable assignment: input and output paths & filenames #%% variable assignment: input and output paths & filenames
@ -346,7 +348,7 @@ print('expected no. of gene samples:', expected_gene_samples)
print('=================================================================') print('=================================================================')
#%% write file #%% write file
#print(outdir) #print(outdir)
out_filename0 = gene.lower() + '_' + 'common_ids.csv' out_filename0 = gene.lower() + '_common_ids.csv'
outfile0 = outdir + '/' + out_filename0 outfile0 = outdir + '/' + out_filename0
#FIXME: CHECK line len(common_ids) #FIXME: CHECK line len(common_ids)
@ -741,7 +743,7 @@ del(c1, c2, col_to_split1, col_to_split2, comp_gene_samples, dr_WF0, dr_df, dr_m
#dr_muts.to_csv('dr_muts.csv', header = True) #dr_muts.to_csv('dr_muts.csv', header = True)
#other_muts.to_csv('other_muts.csv', header = True) #other_muts.to_csv('other_muts.csv', header = True)
out_filename1 = gene.lower() + '_' + 'ambiguous_muts.csv' out_filename1 = gene.lower() + '_ambiguous_muts.csv'
outfile1 = outdir + '/' + out_filename1 outfile1 = outdir + '/' + out_filename1
print('Writing file: ambiguous muts', print('Writing file: ambiguous muts',
'\nFilename:', out_filename1, '\nFilename:', out_filename1,
@ -1053,7 +1055,7 @@ else:
, '\nDebug please!' , '\nDebug please!'
, '\n=========================================================') , '\n=========================================================')
out_filename2 = gene.lower() + '_' + 'mcsm_snps.csv' out_filename2 = gene.lower() + '_mcsm_snps.csv'
outfile2 = outdir + '/' + out_filename2 outfile2 = outdir + '/' + out_filename2
print('Writing file: mCSM style muts' print('Writing file: mCSM style muts'
@ -1074,7 +1076,7 @@ del(out_filename2)
#%% Write file: gene_metadata (i.e gene_LF1) #%% Write file: gene_metadata (i.e gene_LF1)
# where each row has UNIQUE mutations NOT unique sample ids # where each row has UNIQUE mutations NOT unique sample ids
out_filename3 = gene.lower() + '_' + 'metadata.csv' out_filename3 = gene.lower() + '_metadata.csv'
outfile3 = outdir + '/' + out_filename3 outfile3 = outdir + '/' + out_filename3
print('Writing file: LF formatted data' print('Writing file: LF formatted data'
, '\nFilename:', out_filename3 , '\nFilename:', out_filename3
@ -1117,7 +1119,7 @@ else:
, '\nDebug please!' , '\nDebug please!'
, '\n=========================================================') , '\n=========================================================')
out_filename4 = gene.lower() + '_' + 'all_muts_msa.csv' out_filename4 = gene.lower() +'_all_muts_msa.csv'
outfile4 = outdir + '/' + out_filename4 outfile4 = outdir + '/' + out_filename4
print('Writing file: mCSM style muts for msa', print('Writing file: mCSM style muts for msa',
@ -1149,7 +1151,7 @@ pos_only.position.dtype
# sort by position value # sort by position value
pos_only_sorted = pos_only.sort_values(by = 'position', ascending = True) pos_only_sorted = pos_only.sort_values(by = 'position', ascending = True)
out_filename5 = gene.lower() + '_' + 'mutational_positons.csv' out_filename5 = gene.lower() + '_mutational_positons.csv'
outfile5 = outdir + '/' + out_filename5 outfile5 = outdir + '/' + out_filename5
print('Writing file: mutational positions' print('Writing file: mutational positions'

View file

@ -30,8 +30,10 @@ os.getcwd()
#======================================================================= #=======================================================================
#%% command line args #%% command line args
arg_parser = argparse.ArgumentParser() arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('-d', '--drug', help='drug name', default = 'pyrazinamide') #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('-g', '--gene', help='gene name', default = 'pncA') # case sensitive
arg_parser.add_argument('-d', '--drug', help='drug name', default = 'TESTDRUG')
arg_parser.add_argument('-g', '--gene', help='gene name (case sensitive)', default = 'testGene') # case sensitive
args = arg_parser.parse_args() args = arg_parser.parse_args()
#======================================================================= #=======================================================================
#%% variable assignment: input and output #%% variable assignment: input and output

View file

@ -33,8 +33,8 @@ os.getcwd()
arg_parser = argparse.ArgumentParser() arg_parser = argparse.ArgumentParser()
#arg_parser.add_argument('-d', '--drug', help='drug name', default = 'pyrazinamide') #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('-g', '--gene', help='gene name', default = 'pncA') # case sensitive
arg_parser.add_argument('-d', '--drug', help='drug name', default = 'DRUGNAME') arg_parser.add_argument('-d', '--drug', help='drug name', default = 'TESTDRUG')
arg_parser.add_argument('-g', '--gene', help='gene name', default = 'geneName') arg_parser.add_argument('-g', '--gene', help='gene name (case sensitive)', default = 'testGene') # case sensitive
args = arg_parser.parse_args() args = arg_parser.parse_args()
#======================================================================= #=======================================================================
#%% variable assignment: input and output #%% variable assignment: input and output