ran struc param analysis
This commit is contained in:
parent
96da4d8ed5
commit
2cebd338ba
5 changed files with 373 additions and 382 deletions
|
@ -46,10 +46,8 @@ 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 = 'TESTDRUG')
|
||||
#arg_parser.add_argument('-g', '--gene', help='gene name (case sensitive)', default = 'testGene') # case sensitive
|
||||
arg_parser.add_argument('-d', '--drug', help='drug name', default = None)
|
||||
arg_parser.add_argument('-g', '--gene', help='gene name', default = None) # case sensitive
|
||||
args = arg_parser.parse_args()
|
||||
#=======================================================================
|
||||
#%% variable assignment: input and output
|
||||
|
@ -288,8 +286,7 @@ def main():
|
|||
, 'output csv:', out_filename)
|
||||
combine_dfs(infile1, infile2, infile3, infile4, outfile)
|
||||
print('Finished Writing file:'
|
||||
, '\nFilename:', out_filename
|
||||
, '\nPath:', outdir
|
||||
, '\nFilename:', outfile
|
||||
## , '\nNo. of rows:', ''
|
||||
## , '\nNo. of cols:', ''
|
||||
, '\n===========================================================')
|
||||
|
|
|
@ -57,8 +57,8 @@ args = arg_parser.parse_args()
|
|||
|
||||
drug = args.drug
|
||||
gene = args.gene
|
||||
|
||||
gene_match = gene + '_p.'
|
||||
|
||||
# building cols to extract
|
||||
dr_muts_col = 'dr_mutations_' + drug
|
||||
other_muts_col = 'other_mutations_' + drug
|
||||
|
@ -80,8 +80,8 @@ datadir = homedir + '/' + 'git/Data'
|
|||
#=======
|
||||
# input
|
||||
#=======
|
||||
#in_filename = 'original_tanushree_data_v2.csv'
|
||||
in_filename = 'mtb_gwas_v3.csv'
|
||||
in_filename = 'original_tanushree_data_v2.csv'
|
||||
#in_filename = 'mtb_gwas_v3.csv'
|
||||
infile = datadir + '/' + in_filename
|
||||
print('Input file: ', infile
|
||||
, '\n============================================================')
|
||||
|
@ -1028,25 +1028,25 @@ del(k, v, wt, mut, lookup_dict)
|
|||
|
||||
########
|
||||
# combine the wild_type+poistion+mutant_type columns to generate
|
||||
# Mutationinformation (matches mCSM output field)
|
||||
# mutationinformation (matches mCSM output field)
|
||||
# Remember to use .map(str) for int col types to allow string concatenation
|
||||
#########
|
||||
gene_LF1['Mutationinformation'] = gene_LF1['wild_type'] + gene_LF1.position.map(str) + gene_LF1['mutant_type']
|
||||
print('Created column: Mutationinformation'
|
||||
gene_LF1['mutationinformation'] = gene_LF1['wild_type'] + gene_LF1.position.map(str) + gene_LF1['mutant_type']
|
||||
print('Created column: mutationinformation'
|
||||
, '\n====================================================================='
|
||||
, gene_LF1.Mutationinformation.head(10))
|
||||
, gene_LF1.mutationinformation.head(10))
|
||||
|
||||
#%% Write file: mCSM muts
|
||||
snps_only = pd.DataFrame(gene_LF1['Mutationinformation'].unique())
|
||||
snps_only = pd.DataFrame(gene_LF1['mutationinformation'].unique())
|
||||
snps_only.head()
|
||||
# assign column name
|
||||
snps_only.columns = ['Mutationinformation']
|
||||
snps_only.columns = ['mutationinformation']
|
||||
|
||||
# count how many positions this corresponds to
|
||||
pos_only = pd.DataFrame(gene_LF1['position'].unique())
|
||||
|
||||
print('Checking NA in snps...')# should be 0
|
||||
if snps_only.Mutationinformation.isna().sum() == 0:
|
||||
if snps_only.mutationinformation.isna().sum() == 0:
|
||||
print ('PASS: NO NAs/missing entries for SNPs'
|
||||
, '\n===============================================================')
|
||||
else:
|
||||
|
@ -1090,27 +1090,27 @@ print('Finished writing:', out_filename3
|
|||
del(out_filename3)
|
||||
|
||||
#%% write file: mCSM style but with repitions for MSA and logo plots
|
||||
all_muts_msa = pd.DataFrame(gene_LF1['Mutationinformation'])
|
||||
all_muts_msa = pd.DataFrame(gene_LF1['mutationinformation'])
|
||||
all_muts_msa.head()
|
||||
# assign column name
|
||||
all_muts_msa.columns = ['Mutationinformation']
|
||||
all_muts_msa.columns = ['mutationinformation']
|
||||
|
||||
# make sure it is string
|
||||
all_muts_msa.columns.dtype
|
||||
|
||||
# sort the column
|
||||
all_muts_msa_sorted = all_muts_msa.sort_values(by = 'Mutationinformation')
|
||||
all_muts_msa_sorted = all_muts_msa.sort_values(by = 'mutationinformation')
|
||||
|
||||
# create an extra column with protein name
|
||||
all_muts_msa_sorted = all_muts_msa_sorted.assign(fasta_name = '3PL1')
|
||||
all_muts_msa_sorted.head()
|
||||
|
||||
# rearrange columns so the fasta name is the first column (required for mutate.script)
|
||||
all_muts_msa_sorted = all_muts_msa_sorted[['fasta_name', 'Mutationinformation']]
|
||||
all_muts_msa_sorted = all_muts_msa_sorted[['fasta_name', 'mutationinformation']]
|
||||
all_muts_msa_sorted.head()
|
||||
|
||||
print('Checking NA in snps...')# should be 0
|
||||
if all_muts_msa.Mutationinformation.isna().sum() == 0:
|
||||
if all_muts_msa.mutationinformation.isna().sum() == 0:
|
||||
print ('PASS: NO NAs/missing entries for SNPs'
|
||||
, '\n===============================================================')
|
||||
else:
|
||||
|
|
|
@ -30,10 +30,8 @@ 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 = 'TESTDRUG')
|
||||
arg_parser.add_argument('-g', '--gene', help='gene name (case sensitive)', default = 'testGene') # case sensitive
|
||||
arg_parser.add_argument('-d', '--drug', help='drug name', default = None)
|
||||
arg_parser.add_argument('-g', '--gene', help='gene name (case sensitive)', default = None) # case sensitive
|
||||
args = arg_parser.parse_args()
|
||||
#=======================================================================
|
||||
#%% variable assignment: input and output
|
||||
|
@ -49,6 +47,8 @@ args = arg_parser.parse_args()
|
|||
|
||||
drug = args.drug
|
||||
gene = args.gene
|
||||
gene_match = gene + '_p.'
|
||||
|
||||
#==========
|
||||
# data dir
|
||||
#==========
|
||||
|
@ -147,7 +147,7 @@ def extract_chain_dssp(inputpdbfile):
|
|||
return pdbchainlist
|
||||
#=======================================================================
|
||||
#%% write csv of processed dssp output
|
||||
def dssp_to_csv(inputdsspfile, outfile, pdbchainlist):
|
||||
def dssp_to_csv(inputdsspfile, outfile, pdbchainlist = ['A']):
|
||||
"""
|
||||
Create a df from a dssp file containing ASA, RSA, SS for all chains
|
||||
|
||||
|
|
|
@ -39,10 +39,8 @@ 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 = 'DRUGNAME')
|
||||
arg_parser.add_argument('-g', '--gene', help='gene name', default = 'geneName')
|
||||
arg_parser.add_argument('-d', '--drug', help='drug name', default = None)
|
||||
arg_parser.add_argument('-g', '--gene', help='gene name', default = None)
|
||||
#arg_parser.add_argument('-p', '--plot', help='show plot', action='store_true')
|
||||
args = arg_parser.parse_args()
|
||||
#=======================================================================
|
||||
|
@ -81,7 +79,7 @@ print('Output filename:', out_filename
|
|||
#%% end of variable assignment for input and output files
|
||||
#=======================================================================
|
||||
#%% kd values from fasta file and output csv
|
||||
def kd_to_csv(inputfasta, outputkdcsv, windowsize):
|
||||
def kd_to_csv(inputfasta, outputkdcsv, windowsize = 3):
|
||||
"""
|
||||
Calculate kd (hydropathy values) from input fasta file
|
||||
|
||||
|
@ -223,8 +221,7 @@ def main():
|
|||
, '\noutfile:', out_filename)
|
||||
kd_to_csv(infile, outfile, 3)
|
||||
print('Finished writing file:'
|
||||
, '\nFilename:', out_filename
|
||||
, '\nPath:', outdir
|
||||
, '\nFilename:', outfile
|
||||
, '\n=============================================================')
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -31,10 +31,8 @@ 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 = 'TESTDRUG')
|
||||
arg_parser.add_argument('-g', '--gene', help='gene name (case sensitive)', default = 'testGene') # case sensitive
|
||||
arg_parser.add_argument('-d', '--drug', help='drug name', default = None)
|
||||
arg_parser.add_argument('-g', '--gene', help='gene name', default = None) # case sensitive
|
||||
args = arg_parser.parse_args()
|
||||
#=======================================================================
|
||||
#%% variable assignment: input and output
|
||||
|
@ -165,8 +163,7 @@ def main():
|
|||
, '\noutfile:', out_filename)
|
||||
rd_to_csv(infile, outfile)
|
||||
print('Finished Writing file:'
|
||||
, '\nFilename:', out_filename
|
||||
, '\nPath:', outdir
|
||||
, '\nFilename:', outfile
|
||||
, '\n=============================================================')
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue