Mykrobe-tools / mykrobe

Antibiotic resistance prediction in minutes
MIT License
102 stars 26 forks source link

Mykrobe predict error using custom probes #186

Closed Danderson123 closed 3 weeks ago

Danderson123 commented 3 weeks ago

Hey Martin,

I have hit the following error using Mykrobe v0.13.0 predict on an E. coli sample with custom probes. The command, the error I hit and a link to the data I am using are below:

singularity run /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_mykrobe/mykrobe/mykrobe.img predict --ont -s GCA_027944875.1_ASM2794487v1_genomic -t 6 -S custom --custom_probe_set_path /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_mykrobe/ncbi_converted.fa --custom_variant_to_resistance_json /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_mykrobe/ncbi_converted.json -i /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_resfinder/nanopore_reads/SRR23044204_1.fastq -O json -o /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_mykrobe/read_results/GCA_027944875.1_ASM2794487v1_genomic/mykrobe_results.json

/home/daniel/.local/lib/python3.8/site-packages/requests/__init__.py:109: RequestsDependencyWarning: urllib3 (2.0.7) or chardet (3.0.4)/charset_normalizer (2.0.12) doesn't match a supported version!
  warnings.warn(
[mykrobe 2024-06-13T09:51:01 INFO] Start runnning mykrobe predict. Command line: /usr/local/bin/mykrobe predict -s GCA_027944875.1_ASM2794487v1_genomic -t 6 -S custom --custom_probe_set_path /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_mykrobe/ncbi_converted.fa --custom_variant_to_resistance_json /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_mykrobe/ncbi_converted.json -i /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_resfinder/reference_assemblies/GCA_027944875.1_ASM2794487v1_genomic.fna -O json -o /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_mykrobe/assembly_results/GCA_027944875.1_ASM2794487v1_genomic/mykrobe_results.json
[mykrobe 2024-06-13T09:51:01 INFO] Running mykrobe predict using species custom, and panel version custom
[mykrobe 2024-06-13T09:51:01 INFO] Run command: /usr/local/lib/python3.8/dist-packages/mykrobe/cortex/mccortex31 geno -t 6 -m 1GB -k 21 -o /tmp/tmpfhbmua8d/GCA_027944875.1_ASM2794487v1_genomic-21_ncbi_converted.covgs -I mykrobe/data/skeletons/ncbi_converted_21.ctx -s GCA_027944875.1_ASM2794487v1_genomic-21 -1 /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_resfinder/reference_assemblies/GCA_027944875.1_ASM2794487v1_genomic.fna -c /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_mykrobe/ncbi_converted.fa /tmp/tmpfhbmua8d/GCA_027944875.1_ASM2794487v1_genomic-21_ncbi_converted.ctx
[mykrobe 2024-06-13T09:51:07 INFO] Progress: writing output
[mykrobe 2024-06-13T09:51:07 INFO] Progress: finished
/home/daniel/.local/lib/python3.8/site-packages/requests/__init__.py:109: RequestsDependencyWarning: urllib3 (2.0.7) or chardet (3.0.4)/charset_normalizer (2.0.12) doesn't match a supported version!
  warnings.warn(
[mykrobe 2024-06-13T09:51:08 INFO] Start runnning mykrobe predict. Command line: /usr/local/bin/mykrobe predict --ont -s GCA_027944875.1_ASM2794487v1_genomic -t 6 -S custom --custom_probe_set_path /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_mykrobe/ncbi_converted.fa --custom_variant_to_resistance_json /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_mykrobe/ncbi_converted.json -i /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_resfinder/nanopore_reads/SRR23044204_1.fastq -O json -o /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_mykrobe/read_results/GCA_027944875.1_ASM2794487v1_genomic/mykrobe_results.json
[mykrobe 2024-06-13T09:51:08 INFO] Running mykrobe predict using species custom, and panel version custom
[mykrobe 2024-06-13T09:51:08 INFO] Set expected error rate to 0.08 because --ont flag was used
[mykrobe 2024-06-13T09:51:08 INFO] Set ploidy to haploid because --ont flag used
[mykrobe 2024-06-13T09:51:08 INFO] Run command: /usr/local/lib/python3.8/dist-packages/mykrobe/cortex/mccortex31 geno -t 6 -m 1GB -k 21 -o /tmp/tmp3fe0tceo/GCA_027944875.1_ASM2794487v1_genomic-21_ncbi_converted.covgs -I mykrobe/data/skeletons/ncbi_converted_21.ctx -s GCA_027944875.1_ASM2794487v1_genomic-21 -1 /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_resfinder/nanopore_reads/SRR23044204_1.fastq -c /home/daniel/Documents/GitHub/thesis_figures/AMR_genotyping_with_mykrobe/ncbi_converted.fa /tmp/tmp3fe0tceo/GCA_027944875.1_ASM2794487v1_genomic-21_ncbi_converted.ctx
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/mykrobe/predict/amr.py", line 152, in _get_drugs
    drugs = self.variant_or_gene_name_to_resistance_drug[name]
KeyError: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/mykrobe/predict/amr.py", line 155, in _get_drugs
    drugs = self.variant_or_gene_name_to_resistance_drug[
KeyError: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/mykrobe", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/mykrobe/cli.py", line 9, in main
    args.func(parser, args)
  File "/usr/local/lib/python3.8/dist-packages/mykrobe/parser.py", line 53, in run_subtool
    run(parser, args)
  File "/usr/local/lib/python3.8/dist-packages/mykrobe/cmds/amr.py", line 438, in run
    mykrobe_predictor_susceptibility_result = predictor.run()
  File "/usr/local/lib/python3.8/dist-packages/mykrobe/predict/amr.py", line 205, in run
    self.predict_antibiogram()
  File "/usr/local/lib/python3.8/dist-packages/mykrobe/predict/amr.py", line 99, in predict_antibiogram
    self._update_resistance_prediction(name, gene)
  File "/usr/local/lib/python3.8/dist-packages/mykrobe/predict/amr.py", line 108, in _update_resistance_prediction
    drugs = self._get_drugs(name)
  File "/usr/local/lib/python3.8/dist-packages/mykrobe/predict/amr.py", line 159, in _get_drugs
    talt_name[-1] = "X"
IndexError: list assignment index out of range

https://drive.google.com/file/d/1stFVSyIquiC8eQvQD7ea5Kaqmza9rR4N/view?usp=drive_link

martinghunt commented 3 weeks ago

After a bit of digging, found that it makes assumptions about the format of the names and tries splitting on -. If you remove the -'s from the names then it works. I ran sed 's/-/X/g' on ncbi_converted.fa and ncbi_converted.json and then mykrobe ran ok.

Is that ok for a workaround? Can imagine trying to get the code to handle your original input files could be pretty fiddly.

Danderson123 commented 3 weeks ago

Ah right ok! Thanks for looking into it, I can work around that. I was just using the output of ariba prepareref directly to get the gene names but I can modify them.