Skip to content

Commit

Permalink
Merge pull request #24 from phac-nml/fix/seq-id-str
Browse files Browse the repository at this point in the history
Fix up issue when sequence id was a number
  • Loading branch information
peterk87 authored Aug 13, 2018
2 parents 73ce601 + e0ad1d6 commit d17a1b0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 0.2.2

* Fix issue where `staramr` crashes if an input contig id is a number.

# Version 0.2.1

* Minor
Expand Down
4 changes: 3 additions & 1 deletion staramr/blast/results/BlastResultsParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import Bio.SeqIO
import pandas as pd
import numpy as np

from staramr.blast.BlastHandler import BlastHandler
from staramr.blast.results.BlastHitPartitions import BlastHitPartitions
Expand Down Expand Up @@ -82,7 +83,8 @@ def _get_out_file_name(self, in_file):
pass

def _handle_blast_hit(self, in_file, database_name, blast_file, results, hit_seq_records):
blast_table = pd.read_table(blast_file, header=None, names=BlastHandler.BLAST_COLUMNS, index_col=False)
blast_table = pd.read_table(blast_file, header=None, names=BlastHandler.BLAST_COLUMNS, index_col=False).astype(
dtype={'qseqid': np.unicode_, 'sseqid': np.unicode_})
partitions = BlastHitPartitions()

blast_table['plength'] = (blast_table.length / blast_table.qlen) * 100.0
Expand Down
9 changes: 9 additions & 0 deletions staramr/tests/integration/data/test-seq-id.fsa
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
>1
ATGGACATCAGGCAAATGAACAGAACCCATCTGGATCACTGGCGCGGATTGCGAAAACAG
CTCTGGCCTGGTCACCCGGATGACGCCCATCTGGCGGACGGCGAAGAAATTCTGCAAGCC
GATCATCTGGCATCATTTATTGCGATGGCAGACGGGGTGGCGATTGGCTTTGCGGATGCC
TCAATCCGCCACGATTATGTCAATGGCTGTGACAGTTCGCCCGTGGTTTTCCTTGAAGGT
ATTTTTGTTCTCCCCTCATTCCGTCAACGCGGCGTAGCGAAACAATTGATTGCAGCGGTG
CAACGATGGGGAACGAATAAAGGGTGTCGGGAAATGGCCTCCGATACCTCGCCGGAAAAT
ACAATTTCCCAGAAAGTTCATCAGGCGTTAGGATTTGAGGAAACAGAGCGCGTCATTTTC
TACCGAAAGCGTTGTTGA
11 changes: 11 additions & 0 deletions staramr/tests/integration/detection/test_AMRDetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ def testResfinderAminoglycosideNameSuccess(self):
self.assertAlmostEqual(result['%Overlap'].iloc[0], 100.00, places=2, msg='Wrong overlap')
self.assertEqual(result['Accession'].iloc[0], 'NC_003197', msg='Wrong accession')

def testNumericalSequenceID(self):
file = path.join(self.test_data_dir, "test-seq-id.fsa")
files = [file]
self.amr_detection.run_amr_detection(files, 99, 90, 90)

resfinder_results = self.amr_detection.get_resfinder_results()
self.assertEqual(len(resfinder_results.index), 1, 'Wrong number of rows in result')

result = resfinder_results[resfinder_results['Gene'] == "aac(6')-Iaa"]
self.assertEqual(result['Contig'].iloc[0], "1", "Incorrect contig id")

def testResfinderBetaLactam2MutationsSuccess(self):
file = path.join(self.test_data_dir, "beta-lactam-blaIMP-42-mut-2.fsa")
files = [file]
Expand Down

0 comments on commit d17a1b0

Please sign in to comment.