def make_weeder_scoring(self, seqtype, meme_suite, sequence_filters):
     motif_scaling_fun = scoring.get_default_motif_scaling(self['num_iterations'])
     return motif.WeederScoringFunction(
         self.organism(), self.membership(), self.ratio_matrix,
         meme_suite,
         seqtype=seqtype,
         sequence_filters=sequence_filters,
         scaling_func=motif_scaling_fun,
         num_motif_func=motif.default_nmotif_fun,
         update_in_iteration=scoring.schedule(MOTIF_START_ITERATION, MOTIF_UPDATE_INTERVAL),
         motif_in_iteration=scoring.schedule(MOTIF_START_ITERATION, MOTIF_COMPUTE_INTERVAL),
         config_params=self.config_params)
    def make_row_scoring(self):
        """makes a row scoring function on demand"""
        # Default row scoring functions
        row_scoring = microarray.RowScoringFunction(
            self.membership(), self.ratio_matrix,
            scaling_func=lambda iteration: self['row_scaling'],
            config_params=self.config_params)
        self.row_scoring = row_scoring

        meme_suite = meme.MemeSuite430()
        sequence_filters = [
            motif.unique_filter,
            motif.get_remove_low_complexity_filter(meme_suite),
            motif.get_remove_atgs_filter(self['search_distances']['upstream'])]

        motif_scaling_fun = scoring.get_default_motif_scaling(
            self['num_iterations'])
        motif_scoring = motif.MemeScoringFunction(
            self.organism(),
            self.membership(),
            self.ratio_matrix,
            meme_suite,
            sequence_filters=sequence_filters,
            scaling_func=motif_scaling_fun,
            num_motif_func=motif.default_nmotif_fun,
            update_in_iteration=scoring.schedule(601, 3),
            motif_in_iteration=scoring.schedule(600, 100),
            #update_in_iteration=scoring.schedule(100, 10),
            #motif_in_iteration=scoring.schedule(100, 100),
            config_params=self.config_params)
        self.motif_scoring = motif_scoring

        network_scaling_fun = scoring.get_default_network_scaling(
            self['num_iterations'])
        network_scoring = nw.ScoringFunction(
            self.organism(),
            self.membership(),
            self.ratio_matrix,
            scaling_func=network_scaling_fun,
            run_in_iteration=scoring.schedule(1, 7),
            config_params=self.config_params)
        self.network_scoring = network_scoring

        row_scoring_functions = [row_scoring, motif_scoring, network_scoring]
        return scoring.ScoringFunctionCombiner(
            self.membership(),
            row_scoring_functions,
            config_params=self.config_params,
            log_subresults=True)
 def make_network_scoring(self, scaling_fun):
     return nw.ScoringFunction(self.organism(),
                               self.membership(),
                               self.ratio_matrix,
                               scaling_func=scaling_fun,
                               run_in_iteration=scoring.schedule(1, 7),
                               config_params=self.config_params)
 def __init__(self, membership, matrix, scaling_func=None,
              run_in_iteration=scoring.schedule(1, 2),
              config_params=None):
     """Create scoring function instance"""
     scoring.ScoringFunctionBase.__init__(self, membership,
                                          matrix, scaling_func,
                                          run_in_iteration,
                                          config_params)
     self.cache_result = True
     self.run_log = scoring.RunLog("row_scoring", config_params)
 def make_set_scoring(self, scaling_fun, use_set_types):
     set_types = []
     if 'pita' in use_set_types:
         set_types.append(se.SetType.read_csv('pita', 'human_data/gbmTCGA/pita_miRNA_sets_geneSymbol.csv'))
     if 'target_scan' in use_set_types:
         set_types.append(se.SetType.read_csv('target_scan',
                                              'human_data/gbmTCGA/targetScan_miRNA_sets_geneSymbol.csv'))
     return se.ScoringFunction(self.membership(), self.ratio_matrix,
                               set_types, scaling_fun,
                               scoring.schedule(1, 7),
                               config_params=self.config_params)
    def make_row_scoring(self):
        """returns the row scoring function"""
        row_scoring = microarray.RowScoringFunction(
            self.membership(), self.ratio_matrix,
            scaling_func=lambda iteration: self['row_scaling'],
            config_params=self.config_params)

        background_file_prom = meme_FS.global_background_file_FS(
            self.organism(), self.ratio_matrix.row_names(), 'Promoter',
            alphabet, alphabet_replacement,
            use_revcomp=True, resultsDir = "/".join([self['meme_dir'], 'backgroundFiles']))
        meme_suite = meme_FS.MemeSuite481(background_file=background_file_prom,
                                          remove_tempfiles=True,
                                          resultsDir = self['meme_dir'])
        """
        background_file_p3utr = meme_FS.global_background_file_FS(
            self.organism(), self.ratio_matrix.row_names(), '3pUTR',
            alphabet, alphabet_replacement,
            use_revcomp=True)
        meme_suite_p3utr = meme_FS.MemeSuite430(background_file=background_file_p3utr)
        """
        
        sequence_filters = [
            motif_FS.unique_filter,
            motif_FS.get_remove_low_complexity_filter(meme_suite),
            motif_FS.get_remove_atgs_filter(self['search_distances']['Promoter'])]


        sequence_filters = [motif_FS.get_remove_atgs_filter(self['search_distances']['Promoter'])]


        motif_scaling_fun = scoring.get_default_motif_scaling(self['num_iterations'])
        motif_scoring = motif_FS.MemeScoringFunction(
            self.organism(),
            self.membership(),
            self.ratio_matrix,
            meme_suite,
            seqtype='Promoter',
            sequence_filters=sequence_filters,
            pvalue_filter=motif_FS.MinPValueFilter(-9),
            scaling_func=motif_scaling_fun,
            update_in_iteration=scoring.schedule(11, 3),
            motif_in_iteration=scoring.schedule(10, 100),
            config_params=self.config_params)
        """
        motif_scoring_3pUTR = motif_FS.MemeScoringFunction(
            self.organism(),
            self.membership(),
            self.ratio_matrix,
            meme_suite,
            seqtype='3pUTR',
            sequence_filters=sequence_filters,
            pvalue_filter=motif_FS.MinPValueFilter(-9),
            scaling_func=motif_scaling_fun,
            run_in_iteration=scoring.schedule(100, 50),
            config_params=self.config_params)
        motif_combiner = scoring.ScoringFunctionCombiner(
            self.membership(),
            [motif_scoring, motif_scoring_3pUTR],
            scaling_func=lambda iteration: 0.5)
        """

        '''
        weeder_scoring = motif.WeederScoringFunction(
            self.organism(), self.membership(), self.ratio_matrix,
            meme_suite_p3utr, '3pUTR',
            pvalue_filter=motif.MinPValueFilter(-20.0),
            scaling_func=lambda iteration: 0.0,
            run_in_iteration=scoring.default_motif_iterations,
            config_params=self.config_params)

        motif_combiner = scoring.ScoringFunctionCombiner(
            self.membership(),
            [motif_scoring, weeder_scoring],
            scaling_func=lambda iteration: 0.5)
        '''

        network_scaling_fun = scoring.get_default_network_scaling(self['num_iterations'])
        network_scoring = nw.ScoringFunction(self.organism(),
                                             self.membership(),
                                             self.ratio_matrix,
                                             scaling_func=network_scaling_fun,
                                             run_in_iteration=scoring.schedule(1, 7),
                                             config_params=self.config_params)

        row_scoring_functions = [row_scoring, motif_scoring, network_scoring]
        #row_scoring_functions = [row_scoring]
        return scoring.ScoringFunctionCombiner(self.membership(),
                                               row_scoring_functions,
                                               log_subresults=True)