# Is it required to have all 7-levels of taxonomy to add a genome to the Metaphlan database?

**URL:** <https://forum.biobakery.org/t/is-it-required-to-have-all-7-levels-of-taxonomy-to-add-a-genome-to-the-metaphlan-database/6019>\
**Category:** MetaPhlAn\
**Created:** [October 9, 2023, 4:52am UTC](https://forum.biobakery.org/t/is-it-required-to-have-all-7-levels-of-taxonomy-to-add-a-genome-to-the-metaphlan-database/6019 "2023-10-09T04:52:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jolespin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/jolespin/32/1838_2.png) [@jolespin](https://forum.biobakery.org/u/jolespin)\
**Post date:** [October 9, 2023, 4:52am UTC](https://forum.biobakery.org/t/is-it-required-to-have-all-7-levels-of-taxonomy-to-add-a-genome-to-the-metaphlan-database/6019/1 "2023-10-09T04:52:40Z")

</div>

> **[MetaPhlAn 4](https://github.com/biobakery/MetaPhlAn/wiki/MetaPhlAn-4#customizing-the-database)**
>
> MetaPhlAn is a computational tool for profiling the composition of microbial communities from metagenomic shotgun sequencing data - biobakery/MetaPhlAn

Following these guidelines:

```auto
import pickle
import bz2

db = pickle.load(bz2.open('metaphlan_databases/mpa_vJan21_CHOCOPhlAnSGB_202103.pkl', 'r'))

# 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)
db['taxonomy']['7-levels taxonomy with clade names of genome2'] = ('7-levels NCBI taxonomy id of genome1', length of genome2)

# Add the information of the new marker as the other markers
db['markers'][new_marker_name] = {
                                   'clade': the clade that the marker belongs to,
                                   'ext': {the GCA of the first external genome where the marker appears,
                                           the GCA of the second external genome where the marker appears,
                                          },
                                   'len': length of the marker,
                                   'taxon': the taxon of the marker
                                }
                                   
To see an example, try to print the first marker information:
 print list(db['markers'].items())[0]

# Save the new mpa_pkl file
with bz2.BZ2File('metaphlan_databases/mpa_vJan21_CHOCOPhlAnSGB_NEW.pkl', 'w') as ofile:
    pickle.dump(db, ofile, pickle.HIGHEST_PROTOCOL)

```

The reason why I am asking is because there are many eukaryotes and viruses that do not have this clearly defined structure:

```auto
echo "65574" | taxonkit lineage -R
65574	cellular organisms;Eukaryota;Sar;Rhizaria;Retaria;Acantharea	no rank;superkingdom;clade;clade;clade;class

echo "335924" | taxonkit lineage -R
335924	Viruses;Duplodnaviria;Heunggongvirae;Uroviricota;Caudoviricetes;Myoviridae;unclassified Myoviridae;Cyanobacteria phage AS-1	superkingdom;clade;kingdom;phylum;class;family;no rank;species

```

**Is it possible to add to the database (or build custom databases) that do not have taxonomy with 7-levels defined?**

---

<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:** [March 5, 2024, 9:16am UTC](https://forum.biobakery.org/t/is-it-required-to-have-all-7-levels-of-taxonomy-to-add-a-genome-to-the-metaphlan-database/6019/2 "2024-03-05T09:16:23Z")

</div>

Hi @jolespin  
Yes, it is important and the database will not work well without

---

<div class="post-metadata">

**Author:** ![HassanSaeed](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.biobakery.org/hassansaeed/32/2885_2.png) [@HassanSaeed](https://forum.biobakery.org/u/HassanSaeed)\
**Post date:** [June 10, 2024, 1:41pm UTC](https://forum.biobakery.org/t/is-it-required-to-have-all-7-levels-of-taxonomy-to-add-a-genome-to-the-metaphlan-database/6019/3 "2024-06-10T13:41:24Z")

</div>

Hi @aitor.blancomiguez,

What about the NCBI taxonomy ID of genomes? In case, genomes are not yet published.

I am trying to create a new database using my genomes against which I will map corresponding metagenomics samples.
