# Problem with adding a new marker to Metaphlan DB

**URL:** <https://forum.biobakery.org/t/problem-with-adding-a-new-marker-to-metaphlan-db/1611>\
**Category:** MetaPhlAn\
**Created:** [January 26, 2021, 7:32pm UTC](https://forum.biobakery.org/t/problem-with-adding-a-new-marker-to-metaphlan-db/1611 "2021-01-26T19:32:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielePietrucci](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@DanielePietrucci](https://forum.biobakery.org/u/DanielePietrucci)\
**Post date:** [January 26, 2021, 7:32pm UTC](https://forum.biobakery.org/t/problem-with-adding-a-new-marker-to-metaphlan-db/1611/1 "2021-01-26T19:32:27Z")

</div>

Hi,  
I am adding a new marker to the Metaphlan DB, and I’m following the tutorial reported here:

> **[biobakery/MetaPhlAn](https://github.com/biobakery/MetaPhlAn/wiki/MetaPhlAn-3.0)**
>
> MetaPhlAn-3.0

I’ve added a sequence called ‘prova\_tetB\_gilliamella’ inside a fasta file called ‘prova.gene.fa’ using these commands:

`bowtie2-inspect mpa_db/mpa_v30_CHOCOPhlAn_201901 > mpa_db/mpa_v30_CHOCOPhlAn_201901_markers.fasta`  
`cat DB/prova.gene.fa >> mpa_db/mpa_v30_CHOCOPhlAn_201901_markers.fasta`  
`bowtie2-build mpa_db/mpa_v30_CHOCOPhlAn_201901_markers.fasta mpa_db/mpa_v30_CHOCOPhlAn_NEW`

Subsequently, I’ve added the sequence inside the .pkl file using these commands:

` import pickle`  
` import bz2`  
` db = pickle.load(bz2.open('mpa_db/mpa_v30_CHOCOPhlAn_201901.pkl', 'r'))`  
` db['markers']['prova_tetB_gilliamella'] = {'ext': [], 'score': 0.0, 'clade': 's __Gilliamella_apicola_EXP','taxon': 'k__ Bacteria|p __Proteobacteria|c__ Gammaproteobacteria|o __Orbales|f__ Orbaceae|g __Gilliamellas__ Gilliamella_apicola_EXP','len':1206}`  
` # save`  
` with bz2.BZ2File('mpa_db/mpa_v30_CHOCOPhlAn_NEW.pkl', 'w') as ofile:`  
` pickle.dump(db, ofile, pickle.HIGHEST_PROTOCOL)`

Then I started my analysis:

```
`metaphlan $f --bowtie2db mpa_db --index mpa_v30_CHOCOPhlAn_NEW --input_type fastq -s sams/${bn}.sam.bz2 --bowtie2out bowtie2/${bn}.bowtie2.bz2 -o profiles/${bn}_profile.tsv`

```

However I got this error:

`Running metaphlan 3.0 on small_dataset/41290_ID1277_GC_18_S18_L001_R1_001.fastq.gz`  
`Traceback (most recent call last):`  
` File "/home/miniconda2/envs/mpa/bin/metaphlan", line 10, in <module>`  
` sys.exit(main())`  
` File "/home/miniconda2/envs/mpa/lib/python3.7/site-packages/metaphlan/metaphlan.py", line 1007, in main`  
` tree = TaxTree( mpa_pkl, ignore_markers )`  
` File "/home/miniconda2/envs/mpa/lib/python3.7/site-packages/metaphlan/metaphlan.py", line 679, in __init__ `  
` self.add_reads(k, 0)`  
` File "/home/miniconda2/envs/mpa/lib/python3.7/site-packages/metaphlan/metaphlan.py", line 697, in add_reads`  
` cl = self.all_clades[clade]`  
`KeyError: 's__Gilliamella_apicola_EXP'`

Why this is happening? It’s because I’ve added the “\_EXP” string?

---

<div class="post-metadata">

**Author:** ![fbeghini](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/fbeghini/32/81_2.png) [@fbeghini](https://forum.biobakery.org/u/fbeghini)\
**Post date:** [January 29, 2021, 4:44pm UTC](https://forum.biobakery.org/t/problem-with-adding-a-new-marker-to-metaphlan-db/1611/2 "2021-01-29T16:44:57Z")

</div>

The procedure is correct, you only forgot to create a new entry for `'k __Bacteria|p__ Proteobacteria|c __Gammaproteobacteria|o__ Orbales|f __Orbaceae|g__ Gilliamellas__Gilliamella_apicola_EXP'` in the `'taxonomy'` section.

This is the code snippet from the wiki:  
`# Add the taxonomy of the new genomes db['taxonomy']['7-levels taxonomy with clade names of genome1'] = ('7-levels NCBI taxonomy id of genome1', length of genome1) `

---

<div class="post-metadata">

**Author:** ![CK\_zhu](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/ck_zhu/32/151_2.png) [@CK\_zhu](https://forum.biobakery.org/u/CK_zhu)\
**Post date:** [March 6, 2021, 8:56am UTC](https://forum.biobakery.org/t/problem-with-adding-a-new-marker-to-metaphlan-db/1611/4 "2021-03-06T08:56:36Z")

</div>

How to make a fasta(Draft genome) to marker genes?

---

<div class="post-metadata">

**Author:** ![CK\_zhu](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/ck_zhu/32/151_2.png) [@CK\_zhu](https://forum.biobakery.org/u/CK_zhu)\
**Post date:** [March 6, 2021, 9:03am UTC](https://forum.biobakery.org/t/problem-with-adding-a-new-marker-to-metaphlan-db/1611/5 "2021-03-06T09:03:02Z")

</div>

Is it correct if I add the entire genome to the database? I don’t know how to extract maker genes from genome

---

<div class="post-metadata">

**Author:** ![fbeghini](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/fbeghini/32/81_2.png) [@fbeghini](https://forum.biobakery.org/u/fbeghini)\
**Post date:** [April 12, 2021, 8:29am UTC](https://forum.biobakery.org/t/problem-with-adding-a-new-marker-to-metaphlan-db/1611/6 "2021-04-12T08:29:10Z")

</div>

No, it is not possible to use the whole genome as a marker in MetaPhlAn. The procedure for extracting markers is described [here](https://github.com/biobakery/MetaPhlAn/issues/103#issuecomment-653523385) and in the MetaPhlAn 3 preprint [here](https://www.biorxiv.org/content/10.1101/2020.11.19.388223v1)
