Skip to content

Commit

Permalink
1.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Olm authored and Matt Olm committed May 16, 2023
1 parent 28d4de3 commit 0daf835
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project (attempts to) adhere to [Semantic Versioning](http://semver.org/).

## [1.7.4] - 2023-05-16
- Fix a division by 0 when you don't have any annos detected in a sample

## [1.7.3] - 2023-05-11
- Fix but in 1.7.2 that resulted in all 0s with parse_gene_annotations

Expand Down
2 changes: 1 addition & 1 deletion inStrain/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.7.3"
__version__ = "1.7.4"
5 changes: 4 additions & 1 deletion inStrain/parse_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,10 @@ def create_annotation_tables2(sdb, s2a2g2vals, **kwargs):

db = metric2table[metric].copy()
for d in TOTAL_KOS:
db[d] = [x / s2norm[s] for x, s in zip(db[d], db['sample'])]
if s2norm[s] == 0:
db[d] = 0
else:
db[d] = [x / s2norm[s] for x, s in zip(db[d], db['sample'])]

metric2table[metric + '_fraction'] = db

Expand Down
20 changes: 20 additions & 0 deletions test/tests/test_parse_gene_annotations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import glob
import pandas as pd
import shutil

from test_utils import BTO
import test_utils
Expand Down Expand Up @@ -121,3 +123,21 @@ def test_PA_4(BTO):
ori_table = pd.read_csv(outloc + name)
assert test_utils.compare_dfs2(ori_table, table)

def test_PA_5(BTO):
"""
Test the case where one sample doesn't have any annotations detected
"""
# Heavily edit one of the files
new_IS2 = BTO.test_dir + os.path.basename(BTO.IS2)
shutil.copytree(BTO.IS2, new_IS2)
gloc = os.path.join(new_IS2, 'output/N5_271_010G1_scaffold_min1000.fa-vs-N5_271_010G2.forRC.IS_gene_info.tsv')
gdb = pd.read_csv(gloc, sep='\t')
gdb = gdb.head(1)
gdb.to_csv(gloc, sep='\t', index=False)

# Run program
base = BTO.test_dir + 'testA'

cmd = f"inStrain parse_annotations -i {BTO.IS1} {new_IS2} -o {base} -a {BTO.anno_loc}"
print(cmd)
inStrain.parse_annotations.PAController(inStrain.argumentParser.parse_args(cmd.split(' ')[1:])).main()

0 comments on commit 0daf835

Please sign in to comment.