def to_bag_of_genomes(self, clustering_object):
        """
        Creates a bag of genomes representation for data mining purposes
        Each document (genome) in the representation is a set of metadata key and value pairs belonging to the same cluster.
        The bag of genomes are saved under ./bag_of_genomes/ directory

        :param clustering_object: The clustering.rst object
        """

        meta_files = Parser._get_files('meta', self._path)
        meta_dict = {}
        for f in meta_files:
            meta_dict[Parser.get_sample_id(f)] = f

        clusters = []
        if isinstance(clustering_object, Clustering):
            if Clustering.is_pyclustering_instance(clustering_object.model):
                no_clusters = len(clustering_object.model.get_clusters())
            else:
                no_clusters = clustering_object.model.n_clusters
            for c in range(0, no_clusters):
                clusters.append(clustering_object.retrieve_cluster(self.data, c).index.get_level_values(-1).values)

        elif isinstance(clustering_object, Biclustering):
            no_clusters = clustering_object.model.n_clusters[0]  # 0 for the rows
            no_col_clusters = clustering_object.model.n_clusters[1]  # 1 for the columns
            for c in range(0, no_clusters):
                clusters.append(clustering_object.retrieve_bicluster(self.data, c*no_col_clusters, 0).index.get_level_values(-1).values)  # sample names

        # to create the bag of genomes files
        print("creating the bag_of_genomes...")
        for c in tqdm(range(0, no_clusters)):
            document = open('./bag_of_genomes/document' + str(c) + '.bag_of_genome', 'w')
            for sample in clusters[c]:
                f = open(meta_dict[sample], 'r')
                for line in f:
                    line = line.replace(' ', '_')
                    splitted = line.split('\t')
                    document.write(splitted[0] + '=' + splitted[1])
                f.close()
            document.close()