def best_descriptive_meta_dict(path_to_bag_of_genomes, cluster_no):
        """
        Computes the importance of each metadata by using tf * coverage (the percentage of the term occuring in a cluster)

        :param path_to_bag_of_genomes: The directory path
        :param cluster_no: cluster number
        :param preprocess: to remove the redundant information from the metadata
        :return: returns the computed dictionary
        """
        from nltk.corpus import stopwords
        clusters = []
        for file in Parser._get_files('.bag_of_genome', path_to_bag_of_genomes):
            f = open(file, 'r')
            text = f.read()
            # process the text
            word_list = []
            for line in text.split('\n'):
                try:
                    # take the right hand side of the = character
                    rhs = line.split('=')[1]
                    # omit the numbers

                    if not (len(rhs) < 3 or rhs[0].isdigit() or any([x in rhs for x in ['.','//','tcga']]) or GenometricSpace.validate_uuid(rhs)):
                        word_list.append(rhs)
                except Exception as e:
                    #  logging.exception(e)
                    pass

            english_stopwords = stopwords.words('english')
            genomic_stopwords = ['tcga']
            extra_stopwords = ['yes','no', 'normal', 'low', 'high']
            all_stopwords = english_stopwords + genomic_stopwords + extra_stopwords
            filtered_words = [word for word in word_list if word not in all_stopwords]

            new_text = ""
            for word in filtered_words:
                new_text += word
                new_text += ' '
            clusters.append(new_text)

        all_clusters = ""
        for c in clusters:
            all_clusters += c

        all_clusters_tf = GenometricSpace.tf(all_clusters)

        cluster_dict = GenometricSpace.tf(clusters[cluster_no])
        for key, value in cluster_dict.items():
            new_val = cluster_dict[key] * (cluster_dict[key] / all_clusters_tf[key])
            cluster_dict[key] = new_val
            return cluster_dict
def best_descriptive_meta_dict ( path_to_bag_of_genomes , cluster_no ) : from nltk . corpus import stopwords clusters = [ ] for file in Parser . _get_files ( '.bag_of_genome' , path_to_bag_of_genomes ) : f = open ( file , 'r' ) text = f . read ( ) word_list = [ ] for line in text . split ( '\n' ) : try : rhs = line . split ( '=' ) [ 1 ] if not ( len ( rhs ) < 3 or rhs [ 0 ] . isdigit ( ) or any ( [ x in rhs for x in [ '.' , '//' , 'tcga' ] ] ) or GenometricSpace . validate_uuid ( rhs ) ) : word_list . append ( rhs ) except Exception as e : pass english_stopwords = stopwords . words ( 'english' ) genomic_stopwords = [ 'tcga' ] extra_stopwords = [ 'yes' , 'no' , 'normal' , 'low' , 'high' ] all_stopwords = english_stopwords + genomic_stopwords + extra_stopwords filtered_words = [ word for word in word_list if word not in all_stopwords ] new_text = "" for word in filtered_words : new_text += word new_text += ' ' clusters . append ( new_text ) all_clusters = "" for c in clusters : all_clusters += c all_clusters_tf = GenometricSpace . tf ( all_clusters ) cluster_dict = GenometricSpace . tf ( clusters [ cluster_no ] ) for key , value in cluster_dict . items ( ) : new_val = cluster_dict [ key ] * ( cluster_dict [ key ] / all_clusters_tf [ key ] ) cluster_dict [ key ] = new_val return cluster_dict
Computes the importance of each metadata by using tf * coverage (the percentage of the term occuring in a cluster)

        :param path_to_bag_of_genomes: The directory path
        :param cluster_no: cluster number
        :param preprocess: to remove the redundant information from the metadata
        :return: returns the computed dictionary