Index: src/cisml.c =================================================================== --- src/cisml.c (revision 4587) +++ src/cisml.c (working copy) @@ -7,6 +7,7 @@ ********************************************************************/ #include +#include #include #include #include @@ -1508,27 +1509,62 @@ pattern->name ); } - // Delete least significant items. - double max_sig_pvalue = 1.0; + // Delete least significant matched elements. + double min_pvalue_discarded = 1.0; MATCHED_ELEMENT_T *victim = NULL; int deletion_count = 0; for (deletion_count = 0; deletion_count < num_elements_to_delete; ++deletion_count) { victim = (MATCHED_ELEMENT_T *) pop_heap_root(heap); - max_sig_pvalue = *(victim->pvalue); + min_pvalue_discarded = *(victim->pvalue); --pattern->num_stored_matches; free_matched_element(victim); } - // Delete further elements with pvalue equal the to the - // minimum pvalue of the removed elements. - while (*(((MATCHED_ELEMENT_T *) get_node(heap, 1))->pvalue) >= max_sig_pvalue) { + // Keep deleting matched elements until we find an element more + // significant then the elements we've already deleted. + while (*(((MATCHED_ELEMENT_T *) get_node(heap, 1))->pvalue) + >= min_pvalue_discarded) { victim = (MATCHED_ELEMENT_T *) pop_heap_root(heap); + assert(victim != NULL); --pattern->num_stored_matches; free_matched_element(victim); + if (get_num_nodes(heap) == 0) { + // All the matched elements have been deleted! + break; + } } + if (verbosity >= NORMAL_VERBOSE) { + fprintf( + stderr, + "Warning: Reached max stored scores (%d).\n" + "Motif matches with p-value >= %3.2g have been " + "deleted to reclaim memory.\n", + pattern->max_stored_matches, + min_pvalue_discarded + ); + } + + if (get_num_nodes(heap) > 0) { + // Get the largest p-value retained from the top element of the heap. + pattern->max_pvalue_retained = *((MATCHED_ELEMENT_T *) get_node(heap, 1))->pvalue; + } + else { + // All items have been deleted! + fprintf( + stderr, + "Warning: there are no motif matches with p-value < %3.2g.\n" + "Use --max-stored-scores to allocate more space for " + "storing motif matches.\n", + min_pvalue_discarded + ); + // Set the largest p-value retained to something + // slightly less the smallest p-value discarded. + pattern->max_pvalue_retained + = get_next_smaller_double(min_pvalue_discarded); + } + set_pattern_has_all_pvalues(pattern, FALSE); - pattern->max_pvalue_retained = *((MATCHED_ELEMENT_T *) get_node(heap, 1))->pvalue; } /********************************************************************** Index: src/utils.c =================================================================== --- src/utils.c (revision 4597) +++ src/utils.c (working copy) @@ -532,8 +532,32 @@ return(lower_value + interpolation); } +/************************************************************************** + * Return the nearest double smaller then the given double + **************************************************************************/ +double get_next_smaller_double(double x) { + // IEEE doubles run in lexigraphical order + // so if we want the next smaller double + // we just need to cast to integer type and + // decrement. + *(long long *) &x = *(long long *) &x - 1; + return x; +} /************************************************************************** + * Return the nearest double larger then the given double + **************************************************************************/ +double get_next_larger_double(double x) { + // IEEE doubles run in lexigraphical order + // so if we want the next larger double + // we just need to cast to integer type and + // increment. + *(long long *) &x = *(long long *) &x + 1; + return x; +} + + +/************************************************************************** * See .h file for description. **************************************************************************/ BOOLEAN_T is_zero Index: src/utils.h =================================================================== --- src/utils.h (revision 4597) +++ src/utils.h (working copy) @@ -267,6 +267,16 @@ ) /************************************************************************** + * Return the nearest double smaller then the given double + **************************************************************************/ +double get_next_smaller_double(double x); + +/************************************************************************** + * Return the nearest double larger then the given double + **************************************************************************/ +double get_next_larger_double(double x); + +/************************************************************************** * Test for zero on a value that may be either a log or a raw float. **************************************************************************/ BOOLEAN_T is_zero Index: website/html/meme-suite-menu.in =================================================================== --- website/html/meme-suite-menu.in (revision 4587) +++ website/html/meme-suite-menu.in (working copy) @@ -33,7 +33,7 @@ ['Downloads', html_path+'downloads.html', ['Download MEME Suite Software', html_path+'meme-download.html'], ['Copyright', html_path+'COPYRIGHT.html'], - ['Commercial Licenses', 'http://invent.ucsd.edu/technology/cases/2002/SD2002-802.htm'], + ['Commercial Licenses', 'http://invent.ucsd.edu/technology/cases/2010/SD2010-808.shtml'], //['Download GLAM2/GLAM2SCAN software separately', glam2_web.concat('/archive')] ], ['User Support', html_path+'resources.html',