def test_motif_scoring(self): meme_suite = meme.MemeSuite430({'MEME': {'max_width': 24, 'background_order': 3, 'use_revcomp': 'True', 'arg_mod': 'zoops'}}) sequence_filters = [ motif.unique_filter, motif.get_remove_low_complexity_filter(meme_suite), motif.get_remove_atgs_filter(self.search_distances['upstream'])] motif_scoring = motif.MemeScoringFunction( self.organism, self.membership, self.ratio_matrix, config_params=self.config_params) motscores = motif_scoring.compute(self.iteration_result).sorted_by_row_name() motscores.fix_extreme_values() ref_motscores = read_matrix('testdata/ref_motscores.tsv') self.assertTrue(check_matrix_values(motscores, ref_motscores))
def __setup_meme_suite(self, config_params): background_file = None bgmodel = None meme_version = config_params['MEME']['version'] search_distance = config_params['search_distances'][self.seqtype] if config_params['MEME']['global_background'] == 'True': background_file, bgmodel = meme.global_background_file( self.organism, self.ratios.row_names, self.seqtype, bgorder=int(self.config_params['MEME']['background_order'])) # store background in results database conn = sqlite3.connect(config_params['out_database'], 15, isolation_level='DEFERRED') for order in bgmodel: for subseq, pvalue in order.items(): conn.execute( 'insert into global_background (subsequence, pvalue) values (?,?)', (subseq, pvalue)) conn.commit() conn.close() if meme_version == '4.3.0': self.meme_suite = meme.MemeSuite430( self.config_params, background_file=background_file, bgmodel=bgmodel) elif meme_version and (meme_version.startswith('4.8') or meme_version.startswith('4.9') or meme_version.startswith('4.10') or meme_version.startswith('4.11')): self.meme_suite = meme.MemeSuite481( self.config_params, background_file=background_file, bgmodel=bgmodel) else: logging.error("MEME version %s currently not supported !", meme_version) raise Exception("unsupported MEME version: '%s'" % meme_version) self.__sequence_filters = [ unique_filter, get_remove_low_complexity_filter(self.meme_suite), get_remove_atgs_filter(search_distance) ]
def __setup_meme_suite(self, config_params): background_file = None bgmodel = None meme_version = config_params['MEME']['version'] search_distance = config_params['search_distances'][self.seqtype] if config_params['MEME']['global_background'] == 'True': background_file, bgmodel = meme.global_background_file( self.organism, self.ratios.row_names, self.seqtype, bgorder=int(self.config_params['MEME']['background_order'])) # store background in results database session = cm2db.make_session_from_config(config_params) for order in bgmodel: session.add_all([ cm2db.GlobalBackground(subsequence=subseq, pvalue=pvalue) for subseq, pvalue in order.items() ]) session.commit() session.close() if meme_version == '4.3.0': self.meme_suite = meme.MemeSuite430( self.config_params, background_file=background_file, bgmodel=bgmodel) elif meme_version and (meme_version.startswith('4.8') or meme_version.startswith('4.9') or meme_version.startswith('4.10') or meme_version.startswith('4.11')): self.meme_suite = meme.MemeSuite481( self.config_params, background_file=background_file, bgmodel=bgmodel) else: logging.error("MEME version %s currently not supported !", meme_version) raise Exception("unsupported MEME version: '%s'" % meme_version) self.__sequence_filters = [ unique_filter, get_remove_low_complexity_filter(self.meme_suite), get_remove_atgs_filter(search_distance) ]
def test_meme_simple(self): """simplest of all: just run meme and parse the output, just tests if there will be appropriate output for the input""" meme_suite = meme.MemeSuite430({ 'MEME': { 'max_width': 24, 'background_order': 3, 'use_revcomp': 'True', 'arg_mod': 'zoops' } }) motif_infos, out = meme_suite.meme('testdata/meme_input1.fasta', 'testdata/meme1.bg', num_motifs=1) self.assertEquals(1, len(motif_infos)) self.assertEquals(24, motif_infos[0].width) self.assertEquals(3, motif_infos[0].num_sites) self.assertEquals(79, motif_infos[0].llr) self.assertAlmostEquals(1700, motif_infos[0].evalue)