Page MenuHomec4science

taxonomy_collection.py
No OneTemporary

File Metadata

Created
Thu, Jul 10, 03:05

taxonomy_collection.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-
" todo:: "
##########################################################################
from taxonomy import Taxonomy
##########################################################################
class TaxonomyCollection(object):
"""
class TaxonomyCollection: stores a collection of taxonomic affiliations in a dictionary self.dict with referenceID as key
"""
# ------------------------------------------------------------------ #
# Constructors/Destructors #
# ------------------------------------------------------------------ #
def __init__(self):
"""__init__: A taxonomic collection is initialised with a dictionnary of taxonomy containing the unknown taxonomy, the other taxonomy are added after with the function addTaxonomy """
# Members ---------------------- #
# create an unknown taxonomy
unknown_taxonomy = Taxonomy(['k__unknown','p__unknown','c__unknown','o__unknown','f__unknown','g__unknown','s__unknown'])
# dictionnary containing the clusters
self.dict = {'NONE': unknown_taxonomy}
def __del__(self):
"""__del__: to be implemented"""
pass
def addTaxonomy(self,ref_id,new_taxonomy):
""" addTaxonomy : add the argument ref_id as key in the taxonomy collection and the new_taxonomy as value """
self.dict[ref_id]= new_taxonomy
return 0
def getTaxonomy(self,ref_id):
""" getTaxonomy : return the taxonomy corresponding to the reference id given in argument """
return self.dict[ref_id]
##########################################################################
if __name__ == '__main__':
test = ClusterCollection()

Event Timeline