Skip to content

Commit

Permalink
Merge pull request #126 from phac-nml/fix/keyerror
Browse files Browse the repository at this point in the history
Fixes staramr so it works for newer pandas
  • Loading branch information
Takadonet authored Oct 13, 2020
2 parents 80173a4 + 1de848f commit d96aa81
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
sudo: required
language: python
python:
- "3.5"
- "3.6"
- "3.7"

env:
matrix:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 0.7.2

* Fixed `KeyError` issue with later versions of pandas (#115, thanks @javiertognarelli).

# Version 0.7.1

* Fix a bug so that the Sequence column in resfinder.tsv uses the isolate sequence instead of the reference sequence
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ staramr db restore-default
* Git
* MLST

**Note: if you wish to use Python 3.5 you will have to install BioPython <= 1.76 as later versions no longer support Python 3.5.**

# Input

## List of genes to exclude
Expand Down
2 changes: 1 addition & 1 deletion staramr/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.7.1'
__version__ = '0.7.2'
4 changes: 2 additions & 2 deletions staramr/results/AMRDetectionSummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ def __init__(self, files, resfinder_dataframe: DataFrame, quality_module_datafra

def _compile_results(self, resistance_frame: DataFrame) -> DataFrame:
df_summary = resistance_frame.sort_values(by=['Gene']).groupby(['Isolate ID']).aggregate(
lambda x: {'Gene': (self.SEPARATOR + ' ').join(x['Gene'])})
lambda x: {'Gene': (self.SEPARATOR + ' ').join(x.get('Gene'))})
return df_summary[['Gene']]

def _compile_plasmids(self, plasmid_frame: DataFrame) -> DataFrame:
ds_summary = plasmid_frame.sort_values(by=['Gene']).groupby(['Isolate ID']).aggregate(
lambda x: {'Gene': (self.SEPARATOR + ' ').join(x['Gene'])})
lambda x: {'Gene': (self.SEPARATOR + ' ').join(x.get('Gene'))})

ds_frame = ds_summary[['Gene']]

Expand Down
2 changes: 1 addition & 1 deletion staramr/results/AMRDetectionSummaryResistance.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, files, resfinder_dataframe, quality_module_dataframe,pointfin
super().__init__(files, resfinder_dataframe,quality_module_dataframe, pointfinder_dataframe, plasmidfinder_dataframe, mlst_dataframe)

def _aggregate_gene_phenotype(self, dataframe):
flattened_phenotype_list = [y.strip() for x in dataframe['Predicted Phenotype'].tolist() for y in
flattened_phenotype_list = [y.strip() for x in dataframe.get('Predicted Phenotype').tolist() for y in
x.split(self.SEPARATOR)]
uniq_phenotype = OrderedDict.fromkeys(flattened_phenotype_list)

Expand Down

0 comments on commit d96aa81

Please sign in to comment.