# Problem with metaphlan2krona.py

**URL:** <https://forum.biobakery.org/t/problem-with-metaphlan2krona-py/4644>\
**Category:** MetaPhlAn\
**Created:** [January 13, 2023, 3:32pm UTC](https://forum.biobakery.org/t/problem-with-metaphlan2krona-py/4644 "2023-01-13T15:32:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![khoojj](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/khoojj/32/1886_2.png) [@khoojj](https://forum.biobakery.org/u/khoojj)\
**Post date:** [January 13, 2023, 3:32pm UTC](https://forum.biobakery.org/t/problem-with-metaphlan2krona-py/4644/1 "2023-01-13T15:32:00Z")

</div>

Hi,

I fed the Metaphlan output to metaphlan2krona.py but I got the following error. Is there anything I need to do with the output file from metaphlan?

Thanks!

Error:

```auto
Traceback (most recent call last):
  File "/pub59/jingk/miniconda3/envs/metaphlan4/bin/metaphlan2krona.py", line 10, in <module>
    sys.exit(main())
  File "/pub59/jingk/miniconda3/envs/metaphlan4/lib/python3.10/site-packages/metaphlan/utils/metaphlan2krona.py", line 42, in main
    abundance = float(x_cells[-2].rstrip('\n')) 
ValueError: could not convert string to float: 'Bradyrhizobium'
(metaphlan4) jingk@ada18:/pub59/jingk/04_chigger_mito01/07_metaphlan$ metaphlan2krona.py -p metaphlan4_out.txt -k R9P_metaphlan4_krona.out 
Traceback (most recent call last):
  File "/pub59/jingk/miniconda3/envs/metaphlan4/bin/metaphlan2krona.py", line 10, in <module>
    sys.exit(main())
  File "/pub59/jingk/miniconda3/envs/metaphlan4/lib/python3.10/site-packages/metaphlan/utils/metaphlan2krona.py", line 42, in main
    abundance = float(x_cells[-2].rstrip('\n')) 
ValueError: could not convert string to float: 'Bradyrhizobium'
(metaphlan4) jingk@ada18:/pub59/jingk/04_chigger_mito01/07_metaphlan$ metaphlan2krona.py -p metaphlan4_out.txt -k R9P_metaphlan4_krona.out 
Traceback (most recent call last):
  File "/pub59/jingk/miniconda3/envs/metaphlan4/bin/metaphlan2krona.py", line 10, in <module>
    sys.exit(main())
  File "/pub59/jingk/miniconda3/envs/metaphlan4/lib/python3.10/site-packages/metaphlan/utils/metaphlan2krona.py", line 42, in main
    abundance = float(x_cells[-2].rstrip('\n')) 
ValueError: could not convert string to float: 'Bradyrhizobium'

```

More info if it helps:

```auto
$ metaphlan --version
MetaPhlAn version 4.0.3 (24 Oct 2022)

```

Command used to run Metaphlan:

```auto
metaphlan R1.fastq.gz,R2.fastq.gz --bowtie2out R1.bowtie2.bz2,R2.bowtie2.bz2 --nproc 5 --input_type fastq --unclassified_estimation -o metaphlan4_out.txt &

```

Command used to run metaphlan2krona.py:

```auto
metaphlan2krona.py -p metaphlan4_out.txt -k R9P_metaphlan4_krona.out 

```

---

<div class="post-metadata">

**Author:** ![aitor.blancomiguez](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/aitor.blancomiguez/32/86_2.png) [@aitor.blancomiguez](https://forum.biobakery.org/u/aitor.blancomiguez)\
**Post date:** [January 17, 2023, 4:48pm UTC](https://forum.biobakery.org/t/problem-with-metaphlan2krona-py/4644/2 "2023-01-17T16:48:09Z")

</div>

Hi @khoojj  
I will have a look into the problem (it seems some changes in the code when moving to version 4 had affected the konda exporter script) I will keep you updated when the new version fixing this issue is available

---

<div class="post-metadata">

**Author:** ![khoojj](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/khoojj/32/1886_2.png) [@khoojj](https://forum.biobakery.org/u/khoojj)\
**Post date:** [January 17, 2023, 5:24pm UTC](https://forum.biobakery.org/t/problem-with-metaphlan2krona-py/4644/3 "2023-01-17T17:24:20Z")

</div>

That will be great! Thanks!

---

<div class="post-metadata">

**Author:** ![SamuelBloomfield](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/samuelbloomfield/32/2179_2.png) [@SamuelBloomfield](https://forum.biobakery.org/u/SamuelBloomfield)\
**Post date:** [June 3, 2023, 3:58pm UTC](https://forum.biobakery.org/t/problem-with-metaphlan2krona-py/4644/4 "2023-06-03T15:58:20Z")

</div>

Hi, I was wondering if this was fixed, as I am having the same problem when I apply metaphlan2krona.py to my Metaphlan4 outputs.

---

<div class="post-metadata">

**Author:** ![aitor.blancomiguez](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/aitor.blancomiguez/32/86_2.png) [@aitor.blancomiguez](https://forum.biobakery.org/u/aitor.blancomiguez)\
**Post date:** [June 6, 2023, 9:40am UTC](https://forum.biobakery.org/t/problem-with-metaphlan2krona-py/4644/5 "2023-06-06T09:40:41Z")

</div>

Hi Samuel, it should be fixed in the latest version, which version are you using?

---

<div class="post-metadata">

**Author:** ![SamuelBloomfield](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/samuelbloomfield/32/2179_2.png) [@SamuelBloomfield](https://forum.biobakery.org/u/SamuelBloomfield)\
**Post date:** [June 6, 2023, 12:03pm UTC](https://forum.biobakery.org/t/problem-with-metaphlan2krona-py/4644/6 "2023-06-06T12:03:34Z")

</div>

I used Metaphlan v4.0.3 for the analysis and downloaded the most latest version of metaphlan2krona.py from Github. metaphlan2krona.py seems to have worked, but I still get the error:

> ValueError: could not convert string to float: ‘Bacillus’  
> Traceback (most recent call last):  
> File “metaphlan2krona.py”, line 49, in   
> main()  
> File “metaphlan2krona.py”, line 42, in main  
> abundance = float(x\_cells[-2].rstrip(‘\n’))  
> ValueError: could not convert string to float: ‘Bacillus’

---

<div class="post-metadata">

**Author:** ![aitor.blancomiguez](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/aitor.blancomiguez/32/86_2.png) [@aitor.blancomiguez](https://forum.biobakery.org/u/aitor.blancomiguez)\
**Post date:** [June 16, 2023, 12:45pm UTC](https://forum.biobakery.org/t/problem-with-metaphlan2krona-py/4644/7 "2023-06-16T12:45:37Z")

</div>

Hi @SamuelBloomfield  
Are you using the default/standard MetaPhlAn output?

---

<div class="post-metadata">

**Author:** ![maringa](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/maringa/32/2784_2.png) [@maringa](https://forum.biobakery.org/u/maringa)\
**Post date:** [March 20, 2024, 7:55pm UTC](https://forum.biobakery.org/t/problem-with-metaphlan2krona-py/4644/8 "2024-03-20T19:55:26Z")

</div>

I am having the same error (below) using MetaPhlAn version 4.0.6. The command was metaphlan2krona.py -p IBD1.txt -k IBD1.krona.txt , using the standard MetaPhlAn output text file attached  
[IBD1.txt](https://forum.biobakery.org/uploads/short-url/nzLicsBtylvrEVeOFMj1d7Ku0wz.txt) (6.3 KB)  
.

Traceback (most recent call last):  
File “/scratch/maringa/ENV/bin/metaphlan2krona.py”, line 8, in   
sys.exit(main())  
^^^^^^  
File “/scratch/maringa/ENV/lib/python3.11/site-packages/metaphlan/utils/metaphlan2krona.py”, line 42, in main  
abundance = float(x\_cells[-2].rstrip(‘\n’))  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
ValueError: could not convert string to float: ‘Burkholderiales\_unclassified’
