Skip to content

Commit

Permalink
Merge pull request #25 from ryanjameskennedy/dev
Browse files Browse the repository at this point in the history
Add --save_dbs arg to cli
  • Loading branch information
ryanjameskennedy authored Mar 11, 2024
2 parents 05a896a + 6f884ab commit 1d7d644
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jasentool convert [-i INPUT_FILE [INPUT_FILE ...]] -o OUTPUT_FILE [-f OUT_FORMAT

### Converge tuberculosis mutation catlogues
```
jasentool converge --output_dir OUTPUT_DIR
jasentool converge --output_dir OUTPUT_DIR [--save_dbs]
```

### Extract QC values after alignment
Expand Down
6 changes: 6 additions & 0 deletions jasentool/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ def __combined_output(group):
group.add_argument('--combined_output', dest='combined_output', action='store_true',
help='combine all of the outputs into one output')

def __save_dbs(group):
"""Save all intermediary dbs created for TBProfiler db convergence"""
group.add_argument('--save_dbs', dest='save_dbs', action='store_true',
help='save all intermediary dbs created for TBProfiler db convergence')

def __sample_sheet(group, required):
"""Add sample_sheet argument to group"""
group.add_argument('--sample_sheet', required=required, dest='sample_sheet',
Expand Down Expand Up @@ -262,6 +267,7 @@ def get_main_parser():
with subparser(sub_parsers, 'converge', 'Converge TB mutation catalogues') as parser:
with arg_group(parser, 'optional arguments') as group:
__output_dir(group, required=False)
__save_dbs(group)
__help(group)

with subparser(sub_parsers, 'qc', 'Run qc on bwa alignment') as parser:
Expand Down
5 changes: 3 additions & 2 deletions jasentool/converge.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def rm_intermediary_files(self):
elif os.path.isdir(filepath):
shutil.rmtree(filepath)

def run(self):
def run(self, save_all_dbs):
"""Run the retrieval and convergance of mutation catalogues"""
utils = Utils()
# Download the genome
Expand All @@ -86,4 +86,5 @@ def run(self):
dfs_to_converge = [intersection_df, unique_tbdb_df, unique_who_df, fohm_df]
converged_df = pd.concat(dfs_to_converge, ignore_index=True).drop_duplicates()
converged_df.to_csv(self.convereged_outfpath, index=False)
self.rm_intermediary_files()
if not save_all_dbs:
self.rm_intermediary_files()
2 changes: 1 addition & 1 deletion jasentool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def fix(self, options):
def converge(self, options):
"""Execute convergence of mutation catalogues"""
converge = Converge(options.output_dir)
converge.run()
converge.run(options.save_dbs)

def qc(self, options):
"""Execute retrieval of qc results"""
Expand Down

0 comments on commit 1d7d644

Please sign in to comment.