Skip to content

Commit

Permalink
Handle case where segment is missing while plotting scaffold (#33)
Browse files Browse the repository at this point in the history
* Handle case where segment is missing while plotting scaffold

* fill in docstring for make_plots

* Update usage in README
  • Loading branch information
dfornika authored Jul 3, 2024
1 parent 08f1d44 commit 04be147
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ pip3 install git+https://github.com/BCCDC-PHL/FluViewer.git
## Usage

```
usage: fluviewer [-h] -f FORWARD_READS -r REVERSE_READS -d DATABASE [-o OUTDIR] -n OUTPUT_NAME [-i [0-100]] [-l [32-]] [-D [1-]] [-q [0-]] [-v [0-1]] [-V [0-1]] [-N [1-]] [-L [1-]]
[-t [1-]] [-M [1-]] [-g] [--log-level {info,debug}]
usage: fluviewer [-h] -f FORWARD_READS -r REVERSE_READS -d DB [-o OUTDIR] -n OUTPUT_NAME [-i [0-100]] [-l [32-]] [-D [1-]] [-q [0-]] [-v [0-1]] [-V [0-1]] [-N [1-]] [-L [1-]] [-t [1-]] [-M [1-]] [-g] [--force]
[--log-level {info,debug}] [--version]
BCCDC-PHL/FluViewer: Influenza A virus consensus sequence generation and variant calling
Expand Down Expand Up @@ -145,8 +145,10 @@ optional arguments:
Gigabytes of memory allocated for normalizing reads (default=max)
-g, --disable-garbage-collection
Disable garbage collection and retain intermediate analysis files
--force Allow overwrite of existing files and directories.
--log-level {info,debug}
Log level (default=info)
--version show program's version number and exit
```


Expand Down
2 changes: 1 addition & 1 deletion fluviewer/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.11-2'
__version__ = '0.1.11-3'
17 changes: 17 additions & 0 deletions fluviewer/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,18 @@ def make_scaffolding_plots(alignment: list[dict], scaffold: dict, output: Path)
def make_plots(inputs, outdir, out_name):
"""
Generate plots for the analysis.
:param inputs: The inputs dictionary. Expected keys are:
['depth_of_cov_freebayes', 'alignment', 'depth_of_cov_freebayes',
'low_coverage_positions', 'ambiguous_positions', 'variant_positions',
'segment_contigs_alignments', 'scaffolds']
:type inputs: dict
:param outdir: The output directory.
:type outdir: str
:param out_name: The output name.
:type out_name: str
:return: The analysis summary. Keys are ['timestamp_analysis_start', 'inputs', 'outputs', 'timestamp_analysis_complete']
:rtype: dict
"""
timestamp_analysis_start = datetime.datetime.now().isoformat()
analysis_summary = {
Expand Down Expand Up @@ -222,6 +234,11 @@ def make_plots(inputs, outdir, out_name):
]
outputs['scaffold_alignment_plots'] = {}
for segment in segments:

if segment not in inputs['segment_contigs_alignments']:
log.warning(f'No contig alignment file found for segment {segment}. Skipping...')
continue

contig_alignment_path = inputs['segment_contigs_alignments'][segment]
if not os.path.exists(contig_alignment_path):
log.warning(f'Contig alignment file {contig_alignment_path} does not exist. Skipping...')
Expand Down

0 comments on commit 04be147

Please sign in to comment.