phac-nml / staramr

Scans genome contigs against the ResFinder, PlasmidFinder, and PointFinder databases.
Apache License 2.0
120 stars 26 forks source link

AttributeError: 'NoneType' object has no attribute 'tolist' #134

Closed arif-tanmoy closed 3 years ago

arif-tanmoy commented 3 years ago

Hi, I ran staramr v0.7.2 for many isolates successfully. However, came across this error for a few isolates (all are previously published and publicly available). All genome data I gathered had the same assembler, Unicycler. I am copying the error message here, with the run_accession of the isolate. Thanks :) Note: I have installed the program from conda.

ERR126109 2021-09-23 09:25:17 INFO: No --plasmidfinder-database-type specified. Will search the entire PlasmidFinder database 2021-09-23 09:25:17 INFO: --output-dir set. All files will be output to [/media/arif/Home04/ERR126109/5_Staramr/] 2021-09-23 09:25:17 INFO: Will exclude ResFinder/PointFinder genes listed in [/home/arif/miniconda3/lib/python3.8/site-packages/staramr/databases/exclude/data/genes_to_exclude.tsv]. Use --no-exclude-genes to disable 2021-09-23 09:25:17 INFO: Making BLAST databases for input files 2021-09-23 09:25:17 INFO: Scheduling blasts and MLST for ERR126109_contigs.fasta 2021-09-23 09:25:20 INFO: Note: NumExpr detected 12 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 8. 2021-09-23 09:25:20 INFO: NumExpr defaulting to 8 threads. 2021-09-23 09:25:21 ERROR: 'NoneType' object has no attribute 'tolist' Traceback (most recent call last): File "/home/arif/miniconda3/bin/staramr", line 68, in args.run_command(args) File "/home/arif/miniconda3/lib/python3.8/site-packages/staramr/subcommand/Search.py", line 447, in run results = self._generate_results(database_repos=database_repos, File "/home/arif/miniconda3/lib/python3.8/site-packages/staramr/subcommand/Search.py", line 283, in _generate_results amr_detection.run_amr_detection(files,pid_threshold, plength_threshold_resfinder, File "/home/arif/miniconda3/lib/python3.8/site-packages/staramr/detection/AMRDetection.py", line 197, in run_amr_detection self._summary_dataframe = self._create_amr_summary(files, self._resfinder_dataframe,self._quality_module_dataframe, File "/home/arif/miniconda3/lib/python3.8/site-packages/staramr/detection/AMRDetectionResistance.py", line 70, in _create_amr_summary return amr_detection_summary.create_summary(self._include_negative_results) File "/home/arif/miniconda3/lib/python3.8/site-packages/staramr/results/AMRDetectionSummary.py", line 134, in create_summary resistance_frame = self._compile_results(resistance_frame) File "/home/arif/miniconda3/lib/python3.8/site-packages/staramr/results/AMRDetectionSummaryResistance.py", line 40, in _compile_results df_summary = df_summary \ File "/home/arif/miniconda3/lib/python3.8/site-packages/pandas/core/groupby/generic.py", line 948, in aggregate result = self._aggregate_multiple_funcs([func], _axis=self.axis) File "/home/arif/miniconda3/lib/python3.8/site-packages/pandas/core/base.py", line 523, in _aggregate_multiple_funcs new_res = colg.aggregate(arg) File "/home/arif/miniconda3/lib/python3.8/site-packages/pandas/core/groupby/generic.py", line 253, in aggregate ret = self._aggregate_multiple_funcs(func) File "/home/arif/miniconda3/lib/python3.8/site-packages/pandas/core/groupby/generic.py", line 321, in _aggregate_multiple_funcs results[name] = obj.aggregate(func) File "/home/arif/miniconda3/lib/python3.8/site-packages/pandas/core/groupby/generic.py", line 265, in aggregate return self._python_agg_general(func, *args, *kwargs) File "/home/arif/miniconda3/lib/python3.8/site-packages/pandas/core/groupby/groupby.py", line 927, in _python_agg_general result, counts = self.grouper.agg_series(obj, f) File "/home/arif/miniconda3/lib/python3.8/site-packages/pandas/core/groupby/ops.py", line 641, in agg_series return self._aggregate_series_fast(obj, func) File "/home/arif/miniconda3/lib/python3.8/site-packages/pandas/core/groupby/ops.py", line 666, in _aggregate_series_fast result, counts = grouper.get_result() File "pandas/_libs/reduction.pyx", line 378, in pandas._libs.reduction.SeriesGrouper.get_result File "pandas/_libs/reduction.pyx", line 195, in pandas._libs.reduction._BaseGrouper._apply_to_group File "/home/arif/miniconda3/lib/python3.8/site-packages/pandas/core/groupby/groupby.py", line 914, in f = lambda x: func(x, args, **kwargs) File "/home/arif/miniconda3/lib/python3.8/site-packages/staramr/results/AMRDetectionSummaryResistance.py", line 25, in _aggregate_gene_phenotype flattened_phenotype_list = [y.strip() for x in dataframe.get('Predicted Phenotype').tolist() for y in AttributeError: 'NoneType' object has no attribute 'tolist'

apetkau commented 3 years ago

Hello @arif-tanmoy, thanks for reporting this.

It looks like there is an issue in staramr with using a new version of a dependency pandas >= 1.3.0. Try installing an older version of this library to the staramar conda environment and see if this works:

conda install pandas==1.2.5
arif-tanmoy commented 3 years ago

older version of panda worked. Thanks :)

apetkau commented 3 years ago

Great, I'm glad to hear it worked.