Commits

Qian Zhu  committed 3a1ba63

Add Anti-correlations

  • Participants
  • Parent commits 0555932

Comments (0)

Files changed (21)

File src/seekcentral.cpp

 	m_bOutputText = false;
 	m_bSquareZ = false;
 	//m_bSharedDB = false;
+	m_bNegativeCor = false;
+	m_DEFAULT_NA = -320;
 
 	m_vecDBSetting.clear();
 	m_useNibble = false;
 
 	m_vecDBSetting.clear();
 	m_useNibble = false;
+	m_bNegativeCor = false;
 }
 
 bool CSeekCentral::CalculateRestart(){
 	const string &search_dset, CSeekCentral *src, const int iClient,
 	const float query_min_required, const float genome_min_required,
 	const enum CSeekDataset::DistanceMeasure eDistMeasure,
-	const bool bSubtractGeneAvg, const bool bNormPlatform){
+	const bool bSubtractGeneAvg, const bool bNormPlatform, 
+	const bool bNegativeCor){
 
 	fprintf(stderr, "Request received from client\n");
 
 	m_bLogit = src->m_bLogit;
 	m_eDistMeasure = eDistMeasure;
 
+	m_bNegativeCor = bNegativeCor;
+	if(m_bNegativeCor){
+		m_DEFAULT_NA = 320;
+	}else{
+		m_DEFAULT_NA = -320;
+	}
+
 	m_bOutputWeightComponent = src->m_bOutputWeightComponent;
 	m_bSimulateWeight = src->m_bSimulateWeight;
 
 	const bool bLogit, const float fCutOff, const float fPercentQueryRequired,
 	const float fPercentGenomeRequired,
 	const bool bSquareZ, const bool bRandom, const int iNumRandom,
+	const bool bNegativeCor,
 	gsl_rng *rand, const bool useNibble, const int numThreads){
 
 	m_maxNumDB = buffer;
 	m_fPercentGenomeRequired = fPercentGenomeRequired; 
 	m_bSquareZ = bSquareZ;
 
+	m_bNegativeCor = bNegativeCor;
+	if(m_bNegativeCor){
+		m_DEFAULT_NA = 320;
+	}else{
+		m_DEFAULT_NA = -320;
+	}
+
 	m_bOutputWeightComponent = bOutputWeightComponent;
 	m_bSimulateWeight = bSimulateWeight;
 
 	const bool bLogit, const float fCutOff, 
 	const float fPercentQueryRequired, const float fPercentGenomeRequired,
 	const bool bSquareZ, const bool bRandom, const int iNumRandom,
+	const bool bNegativeCor,
 	gsl_rng *rand, const bool useNibble, const int numThreads){
 
 	if(!CSeekCentral::Initialize(vecDBSetting, buffer, to_output_text,
 		bOutputWeightComponent, bSimulateWeight, dist_measure,
 		bSubtractAvg, bNormPlatform, bLogit, fCutOff, 
 		fPercentQueryRequired, fPercentGenomeRequired,
-		bSquareZ, bRandom, iNumRandom, rand, useNibble, numThreads)){
+		bSquareZ, bRandom, iNumRandom, bNegativeCor,
+		rand, useNibble, numThreads)){
 		return false;
 	}
 
 
 	for(j=0; j<m_iGenes; j++){
 		if(m_counts[j]<(int)(0.5*iSearchDatasets))
-			m_master_rank[j] = -320;
+			m_master_rank[j] = m_DEFAULT_NA;
 		else if(m_sum_weight[j]==0)
-			m_master_rank[j] = -320;
+			m_master_rank[j] = m_DEFAULT_NA;
 		else{
 			m_master_rank[j] =
-				//(m_master_rank[j] / m_sum_weight[j] - 320) / 100.0;
 				(m_master_rank[j] - 320 * m_sum_weight[j]) / 100.0 / m_sum_weight[j];
-				//(m_master_rank[j] - 320 * m_sum_weight[j]) / 100.0 / sqrt(m_sum_sq_weight[j]);
 			if(m_eDistMeasure==CSeekDataset::CORRELATION){
 				m_master_rank[j] = m_master_rank[j] / 3.0;
 			}
-			//m_master_rank[j] = m_master_rank[j];
-			//m_master_rank[j] = (m_master_rank[j] / iSearchDatasets - 320) / 100.0;
 		}
 		if(DEBUG) fprintf(stderr, "Gene %d %.5f\n", j, m_master_rank[j]);
 	}
 		vector<AResultFloat> wd;
 		Sort(wd);
 		for(j=0; j<2000; j++){
-			if(wd[j].f==-320) break;
+			if(wd[j].f==m_DEFAULT_NA) break;
 			vecOutput[1].push_back(m_vecstrGenes[wd[j].i]);
 		}
 		CSeekTools::Write2DArrayText(acBuffer, vecOutput);
 				if(current_sm==CV)
 					CSeekWeighter::CVWeighting(query, *m_vc[d], *RATE,
 						m_fPercentQueryAfterScoreCutOff, m_bSquareZ,
-						&m_rank_threads[tid]);
+						m_bNegativeCor, &m_rank_threads[tid]);
 				else
 					CSeekWeighter::CVWeighting(query, *m_vc[d], *RATE,
 						m_fPercentQueryAfterScoreCutOff, m_bSquareZ,
-						&m_rank_threads[tid], &customGoldStd);
+						m_bNegativeCor, &m_rank_threads[tid], &customGoldStd);
 
 				if( (w = m_vc[d]->GetDatasetSumWeight())==-1){
 					if(DEBUG) fprintf(stderr, "Bad weight\n");
 			}
 			else if(current_sm==AVERAGE_Z){
 				CSeekWeighter::AverageWeighting(query, *m_vc[d],
-					m_fPercentQueryAfterScoreCutOff, m_bSquareZ, w);
+					m_fPercentQueryAfterScoreCutOff, m_bSquareZ, w, m_bNegativeCor);
 				if(w==-1) continue;
 			}
 			else if(current_sm==EQUAL && redoWithEqual==0){
 				//calculate reported weight here!
 				CSeekWeighter::OneGeneWeighting(query, *m_vc[d], 0.95,
 					m_fPercentQueryAfterScoreCutOff, m_bSquareZ,
-					&m_rank_threads[tid], &equalWeightGold);
+					&m_rank_threads[tid], &equalWeightGold, m_bNegativeCor);
 				report_w = m_vc[d]->GetDatasetSumWeight();
 			}
 			//============================================
 			FilterResults(iSearchDatasets);
 		}else{
 			CSeekWeighter::OrderStatisticsRankAggregation(iSearchDatasets,
-				m_iGenes, m_rank_d, m_counts, m_master_rank, m_numThreads);
+				m_iGenes, m_rank_d, m_counts, m_master_rank, m_numThreads, m_bNegativeCor);
 			CSeekTools::Free2DArray(m_rank_d);
 			m_rank_d = NULL;
 		}
 	utype i, j;
 	vector<utype> topGenes;
 	for(i=0; i<top; i++){
-		if(src[i].f==-320) continue;
+		if(src[i].f==m_DEFAULT_NA) continue;
 		topGenes.push_back(src[i].i);
 	}
 	if(topGenes.size()==0){
 	utype j;
 	const vector<utype> &query = csq.GetQuery();
 	for(j=0; j<query.size(); j++){
-		m_master_rank[query[j]] = -320;
+		m_master_rank[query[j]] = m_DEFAULT_NA;
 	}
 	return true;	
 }

File src/seekcentral.h

 		const bool bLogit = false, const float fCutOff = -9999, 
 		const float fPercentQueryRequired = 0, const float fPercentGenomeRequired = 0,
 		const bool bSquareZ = false, const bool bRandom = false, const int iNumRandom = 10,
+		const bool bNegativeCor = false,
 		gsl_rng *rand = NULL, const bool useNibble = false, const int numThreads = 8);
 
     /*!
 		const bool bLogit = false, const float fCutOff = -9999, 
 		const float fPercentQueryRequired = 0, const float fPercentGenomeRequired = 0,
 		const bool bSquareZ = false, const bool bRandom = false, const int iNumRandom = 10,
+		const bool bNegativeCor = false,
 		gsl_rng *rand = NULL, const bool useNibble = false, const int numThreads = 8);
 
     /*!
 		const string &search_dset, CSeekCentral* src, const int iClient,
 		const float query_min_required = 0, const float genome_min_required = 0,
 		const enum CSeekDataset::DistanceMeasure = CSeekDataset::Z_SCORE,
-		const bool bSubtractGeneAvg = true, const bool bNormPlatform = false);
+		const bool bSubtractGeneAvg = true, const bool bNormPlatform = false,
+		const bool bNegativeCor = false);
 
 	/*!
 	 * \brief Run Seek with the cross-validated dataset weighting
 	int m_iClient;
 	bool m_bEnableNetwork;
 	//bool m_bSharedDB; //if m_DB is shared between multiple CSeekCentral instances
+	bool m_bNegativeCor;
 
 	vector<CSeekDBSetting*> m_vecDBSetting; //DBSetting
 	bool m_useNibble;
+
+	float m_DEFAULT_NA;
 };
 
 

File src/seekdataset.cpp

 	const utype &iColumns, const bool bSubtractAvg,
 	const bool bNormPlatform, const bool logit,
 	const enum CSeekDataset::DistanceMeasure dist_measure,
-	const float cutoff, 
+	const float cutoff,
 	const bool bRandom, gsl_rng *rand){
 	/* assume platform is already set */
 	//Assuming rData is not NULL

File src/seekevaluate.cpp

 bool CSeekPerformanceMeasure::SortRankVector(
 	const vector<utype> &rank,
 	const CSeekIntIntMap &mapG, vector<AResult> &a,
+	const bool bNegativeCor,
 	//optional argument
 	const utype top){
 
 	}
 
 	//printf("Top is %d", TOP); getchar();
-	if(TOP==rank.size()){
-		sort(a.begin(), a.end());
+	if(bNegativeCor){
+		if(TOP==rank.size()){
+			sort(a.begin(), a.end(), Ascending());
+		}else{
+			nth_element(a.begin(), a.begin()+TOP, a.end(), Ascending());
+			sort(a.begin(), a.begin()+TOP, Ascending());
+		}
+
 	}else{
-		nth_element(a.begin(), a.begin()+TOP, a.end());
-		sort(a.begin(), a.begin()+TOP);
+		if(TOP==rank.size()){
+			sort(a.begin(), a.end());
+		}else{
+			nth_element(a.begin(), a.begin()+TOP, a.end());
+			sort(a.begin(), a.begin()+TOP);
+		}
 	}
 
 	return true;
 	const vector<utype> &rank, float &rbp,
 	const vector<char> &mask, const vector<char> &gold,
 	const CSeekIntIntMap &mapG, vector<AResult> *ar,
+	const bool bNegativeCor,
 	/* optional arguments */
 	const utype top){
 
 	//ar should be same size as rank
 	vector<AResult> *sing = ar;
 	bool ret =
-		CSeekPerformanceMeasure::SortRankVector(rank, mapG, *sing, top);
+		CSeekPerformanceMeasure::SortRankVector(rank, mapG, *sing, bNegativeCor, top);
 
 	if(!ret){
 		rbp = -1;
 bool CSeekPerformanceMeasure::AveragePrecision(
 	const vector<utype> &rank, float &ap,
 	const vector<char> &mask, const vector<char> &gold,
-	const CSeekIntIntMap &mapG, vector<AResult> *ar){
+	const CSeekIntIntMap &mapG, vector<AResult> *ar, const bool bNegativeCor){
 
 	utype i, ii, j, jj;
 	float x;
 	//ar should be same size as rank
 	vector<AResult> *sing = ar;
 	bool ret =
-		CSeekPerformanceMeasure::SortRankVector(rank, mapG, *sing, TOP);
+		CSeekPerformanceMeasure::SortRankVector(rank, mapG, *sing, bNegativeCor, TOP);
 
 	if(!ret){
 		ap = -1;

File src/seekevaluate.h

 
 struct Ascending{
     bool operator()( const AResult& lx, const AResult& rx ) const {
-        return lx.f < rx.f;
+		if(lx.f < rx.f){
+			return true;
+		}else if(lx.f > rx.f){
+			return false;
+		}else if(lx.i < rx.i){
+			return true;
+		}else{
+			return false;
+		}
+        //return lx.f < rx.f;
     }
 };
 
 
 struct AscendingFloat{
     bool operator()( const AResultFloat& lx, const AResultFloat& rx ) const {
-        return lx.f < rx.f;
+		if(lx.f < rx.f){
+			return true;
+		}else if(lx.f > rx.f){
+			return false;
+		}else if(lx.i < rx.i){
+			return true;
+		}else{
+			return false;
+		}
+        //return lx.f < rx.f;
     }
 };
 
 	 */
 	static bool SortRankVector(const vector<utype> &rank,
 		const CSeekIntIntMap &mapG, vector<AResult> &a,
+		const bool bNegativeCor,
 		const utype top = 0);
 
 	/*!
 		const vector<utype> &rank, float &rbp,
 		const vector<char> &mask, const vector<char> &gold,
 		const CSeekIntIntMap &mapG, vector<AResult> *sing,
+		const bool bNegativeCor,
 		/* optional */
 		const utype top = 0);
 
 	static bool AveragePrecision(
 		const vector<utype> &rank, float &ap,
 		const vector<char> &mask, const vector<char> &gold,
-		const CSeekIntIntMap &mapG, vector<AResult> *ar);
+		const CSeekIntIntMap &mapG, vector<AResult> *ar, const bool bNegativeCor);
 
 };
 

File src/seekweight.cpp

 
 bool CSeekWeighter::OrderStatisticsRankAggregation(const utype &iDatasets,
 	const utype &iGenes, utype **rank_d, const vector<utype> &counts,
-	vector<float> &master_rank, const utype &numThreads){
+	vector<float> &master_rank, const utype &numThreads, const bool bNegativeCor){
+
+	float DEFAULT_NA = -320;
+	if(bNegativeCor){
+		DEFAULT_NA = 320;
+	}
 
 	//vector<float> precompute;
 	//CSeekTools::ReadArray("/tmp/order_stats.binomial.bin", precompute);
 	float **rank_f =
 		CSeekTools::Init2DArray(iDatasets, iGenes, (float) 1.1);
 
-	const float DEFAULT_NULL = -320;
-
 	for(j=0; j<iDatasets; j++){
 		vector<AResult> this_d;
 		utype numNonZero = 0;
 			this_d[kk].f = rank_d[j][k];
 			kk++;
 		}
-		sort(this_d.begin(), this_d.end());
+		if(bNegativeCor){
+			sort(this_d.begin(), this_d.end(), Ascending());
+		}else{
+			sort(this_d.begin(), this_d.end());
+		}
 		for(k=0; k<numNonZero; k++){
 			rank_f[j][this_d[k].i] =
 				(float) (k+1) / (float) numNonZero;
 		gsl_permutation *perm = perms[tid];
 		gsl_permutation *rk = rks[tid];
 
-		master_rank[k] = DEFAULT_NULL;
+		master_rank[k] = DEFAULT_NA;
 		if(counts[k]<(int)(0.5*iDatasets)) continue;
 
 		for(dd=0; dd<iDatasets; dd++)
 		gsl_sort_vector_float_index(perm, gs);
 		gsl_permutation_inverse(rk, perm);
 
-		float max = DEFAULT_NULL;
+		float max = DEFAULT_NA;
 		int max_rank = -1;
 		float max_p = -1;
 		for(dd=0; dd<iDatasets; dd++){
 			*/
 			//end=================================
 
-			if(isinf(tmp)) tmp = DEFAULT_NULL;
+			if(isinf(tmp)) tmp = DEFAULT_NA;
 			if(tmp>max){
 				max = tmp;
 				max_rank = rrk;
 				max_p = p;
 			}
 		}
-		if(max!=DEFAULT_NULL){
+		if(max!=DEFAULT_NA){
 			master_rank[k] = max;
 			//fprintf(stderr, "rank %.5f %.5f\n", max_p, max);
 		}
 bool CSeekWeighter::OneGeneWeighting(CSeekQuery &sQuery, 
 	CSeekDataset &sDataset, const float &rate, 
 	const float &percent_required, const bool &bSquareZ,
-	vector<utype> *rrank, const CSeekQuery *goldStd){
+	vector<utype> *rrank, const CSeekQuery *goldStd, const bool bNegativeCor){
 
 	CSeekIntIntMap *mapG = sDataset.GetGeneMap();
 	CSeekIntIntMap *mapQ = sDataset.GetQueryMap();
 		bool ret = LinearCombine(rank, query, sDataset,
 			MIN_QUERY_REQUIRED, bSquareZ);
 		ret = CSeekPerformanceMeasure::RankBiasedPrecision(rate,
-			rank, w, is_query, is_gold, *mapG, &ar, TOP);
+			rank, w, is_query, is_gold, *mapG, &ar, bNegativeCor, TOP);
 		if(!ret) sDataset.SetCVWeight(0, -1);
 		else sDataset.SetCVWeight(0, w);
 	}
 }
 
 bool CSeekWeighter::AverageWeighting(CSeekQuery &sQuery, CSeekDataset &sDataset,
-	const float &percent_required, const bool &bSquareZ, float &w){
+	const float &percent_required, const bool &bSquareZ, float &w, 
+	const bool bNegativeCor){
 
 	CSeekIntIntMap *mapQ = sDataset.GetQueryMap();
 	if(mapQ==NULL) return true;
 		w /= (float) pairs;
 		w /= (float) 640;
 	}
+
+	if(bNegativeCor){
+		w = w * -1.0;
+	}
+
 	return true;
 }
 
 bool CSeekWeighter::CVWeighting(CSeekQuery &sQuery, CSeekDataset &sDataset,
 	const float &rate, const float &percent_required, const bool &bSquareZ,
+	const bool bNegativeCor,
 	vector<utype> *rrank, const CSeekQuery *goldStd){
 
 	CSeekIntIntMap *mapG = sDataset.GetGeneMap();
 			bool ret = LinearCombine(rank, cv_query, sDataset,
 				MIN_QUERY_REQUIRED, bSquareZ);
 			ret = CSeekPerformanceMeasure::RankBiasedPrecision(rate,
-				rank, w, is_query_cross, is_gold, *mapG, &ar, TOP);
+				rank, w, is_query_cross, is_gold, *mapG, &ar, bNegativeCor, TOP);
 			//fprintf(stderr, "Weight %.5f\n", w);
 			//ret = CSeekPerformanceMeasure::AveragePrecision(
 			//	rank, w, is_query_cross, is_gold, *mapG, &ar);

File src/seekweight.h

 	 */
 	static bool CVWeighting(CSeekQuery &sQuery, CSeekDataset &sDataset,
 		const float &rate, const float &percent_required, const bool &bsquareZ,
+		const bool bNegativeCor,
 		vector<utype> *rrank, const CSeekQuery *goldStd = NULL);
 
 	/*!
 	 * A significance p-value is calculated for this gene, and \a -log(p) values are stored in master_rank. 
 	 */
 	static bool OrderStatisticsRankAggregation(const utype&, const utype&,
-		utype**, const vector<utype> &, vector<float>&, const utype&);
+		utype**, const vector<utype> &, vector<float>&, const utype&, const bool);
 	static bool OrderStatisticsPreCompute();
 
 
 	 */
 	static bool OneGeneWeighting(CSeekQuery&, 
 		CSeekDataset&, const float&, const float&, const bool&, 
-		vector<utype>*, const CSeekQuery*);
+		vector<utype>*, const CSeekQuery*, const bool);
 
 	static bool AverageWeighting(CSeekQuery &sQuery, CSeekDataset &sDataset,
-		const float &percent_required, const bool &bSquareZ, float &w);
+		const float &percent_required, const bool &bSquareZ, float &w, const bool);
 };
 
 

File tools/PCLServer/PCLServer.cpp

 
 #define BACKLOG 10   // how many pending connections queue will hold
 char *PORT;
-int NUM_DSET_MEMORY = 2000;
+int NUM_DSET_MEMORY = 100;
 string pcl_input_dir;
 
 CPCL **pcl;

File tools/SVMperfer/cmdline.c

 /*
-  File autogenerated by gengetopt version 2.22
+  File autogenerated by gengetopt version 2.22.5
   generated with the following command:
-  /Genomics/grid/users/jzthree/bin/gengetopt -iSVMperfer.ggo --default-optional -u -N -e 
+  /usr/bin/gengetopt -iSVMperfer.ggo --default-optional -u -N -e 
 
   The developers of gengetopt consider the fixed text that goes in all
   gengetopt output files to be in the public domain:
 #include <stdlib.h>
 #include <string.h>
 
-#include "getopt.h"
+#ifndef FIX_UNUSED
+#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
+#endif
+
+#include <getopt.h>
 
 #include "cmdline.h"
 
 void clear_args (struct gengetopt_args_info *args_info);
 
 static int
-cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
                         struct cmdline_parser_params *params, const char *additional_error);
 
 static int
 static
 void clear_args (struct gengetopt_args_info *args_info)
 {
+  FIX_UNUSED (args_info);
   args_info->labels_arg = NULL;
   args_info->labels_orig = NULL;
   args_info->output_arg = NULL;
 void
 cmdline_parser_print_version (void)
 {
-  printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
+  printf ("%s %s\n",
+     (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
+     CMDLINE_PARSER_VERSION);
 }
 
 static void print_help_common(void) {
   printf("\n");
 
   if (strlen(gengetopt_args_info_description) > 0)
-    printf("%s\n", gengetopt_args_info_description);
+    printf("%s\n\n", gengetopt_args_info_description);
 }
 
 void
   clear_args (args_info);
   init_args_info (args_info);
 
-  args_info->inputs = NULL;
+  args_info->inputs = 0;
   args_info->inputs_num = 0;
 }
 
 
 
 static void
-write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[])
+write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
 {
+  FIX_UNUSED (values);
   if (arg) {
     fprintf(outfile, "%s=\"%s\"\n", opt, arg);
   } else {
 char *
 gengetopt_strdup (const char *s)
 {
-  char *result = NULL;
+  char *result = 0;
   if (!s)
     return result;
 
 }
 
 int
-cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
+cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
 {
   return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
 }
 
 int
-cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
                    struct cmdline_parser_params *params)
 {
   int result;
-  result = cmdline_parser_internal (argc, argv, args_info, params, NULL);
+  result = cmdline_parser_internal (argc, argv, args_info, params, 0);
 
   return result;
 }
 
 int
-cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
+cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
 {
   int result;
   struct cmdline_parser_params params;
   params.check_ambiguity = 0;
   params.print_errors = 1;
 
-  result = cmdline_parser_internal (argc, argv, args_info, &params, NULL);
+  result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
 
   return result;
 }
 {
   int result = EXIT_SUCCESS;
 
-  if (cmdline_parser_required2(args_info, prog_name, NULL) > 0)
+  if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
     result = EXIT_FAILURE;
 
   return result;
 cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
 {
   int error = 0;
+  FIX_UNUSED (additional_error);
 
   /* checks for required options */
   if (! args_info->input_given)
 static
 int update_arg(void *field, char **orig_field,
                unsigned int *field_given, unsigned int *prev_given, 
-               char *value, char *possible_values[], const char *default_value,
+               char *value, const char *possible_values[],
+               const char *default_value,
                cmdline_parser_arg_type arg_type,
                int check_ambiguity, int override,
                int no_free, int multiple_option,
   const char *val = value;
   int found;
   char **string_field;
+  FIX_UNUSED (field);
 
   stop_char = 0;
   found = 0;
       return 1; /* failure */
     }
 
+  FIX_UNUSED (default_value);
     
   if (field_given && *field_given && ! override)
     return 0;
 
 
 int
-cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+cmdline_parser_internal (
+  int argc, char **argv, struct gengetopt_args_info *args_info,
                         struct cmdline_parser_params *params, const char *additional_error)
 {
   int c;	/* Character of the parsed option.  */
         { "simple_model",	0, NULL, 'A' },
         { "params",	1, NULL, 'p' },
         { "mmap",	0, NULL, 'M' },
-        { NULL,	0, NULL, 0 }
+        { 0,  0, 0, 0 }
       };
 
       c = getopt_long (argc, argv, "hVl:o:i:m:T:aSv:s:nc:e:k:t:Ap:M", long_options, &option_index);
         3\tPrec/Rec Breakeven: 100 minus PRBEP in percent.
         4\tPrec@k: 100 minus precision at k in percent.
         5\tRec@k: 100 minus recall at k in percent.
-        10\tROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea).\n.  */
+        10\tROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea).
+.  */
         
         
           if (update_arg( (void *)&(args_info->error_function_arg), 

File tools/SVMperfer/cmdline.h

 /** @file cmdline.h
  *  @brief The header file for the command line option parser
- *  generated by GNU Gengetopt version 2.22
+ *  generated by GNU Gengetopt version 2.22.5
  *  http://www.gnu.org/software/gengetopt.
  *  DO NOT modify this file, since it can be overwritten
  *  @author GNU Gengetopt by Lorenzo Bettini */
 #endif /* __cplusplus */
 
 #ifndef CMDLINE_PARSER_PACKAGE
-/** @brief the program name */
+/** @brief the program name (used for printing errors) */
 #define CMDLINE_PARSER_PACKAGE "SVMperfer"
 #endif
 
+#ifndef CMDLINE_PARSER_PACKAGE_NAME
+/** @brief the complete program name (used for help and version) */
+#define CMDLINE_PARSER_PACKAGE_NAME "SVMperfer"
+#endif
+
 #ifndef CMDLINE_PARSER_VERSION
 /** @brief the program version */
 #define CMDLINE_PARSER_VERSION "1.0"
   3\tPrec/Rec Breakeven: 100 minus PRBEP in percent.
   4\tPrec@k: 100 minus precision at k in percent.
   5\tRec@k: 100 minus recall at k in percent.
-  10\tROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea).\n (default='10').  */
+  10\tROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea).
+ (default='10').  */
   char * error_function_orig;	/**< @brief Sets the loss function for SVM learning: Choice of:
   0\tZero/one loss: 1 if vector of predictions contains error, 0 otherwise.
   1\tF1: 100 minus the F1-score in percent.
   3\tPrec/Rec Breakeven: 100 minus PRBEP in percent.
   4\tPrec@k: 100 minus precision at k in percent.
   5\tRec@k: 100 minus recall at k in percent.
-  10\tROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea).\n original value given at command line.  */
+  10\tROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea).
+ original value given at command line.  */
   const char *error_function_help; /**< @brief Sets the loss function for SVM learning: Choice of:
   0\tZero/one loss: 1 if vector of predictions contains error, 0 otherwise.
   1\tF1: 100 minus the F1-score in percent.
   3\tPrec/Rec Breakeven: 100 minus PRBEP in percent.
   4\tPrec@k: 100 minus precision at k in percent.
   5\tRec@k: 100 minus recall at k in percent.
-  10\tROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea).\n help description.  */
+  10\tROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea).
+ help description.  */
   float k_value_arg;	/**< @brief Value of k parameter used for Prec@k and Rec@k in (0,1) (default='0.5').  */
   char * k_value_orig;	/**< @brief Value of k parameter used for Prec@k and Rec@k in (0,1) original value given at command line.  */
   const char *k_value_help; /**< @brief Value of k parameter used for Prec@k and Rec@k in (0,1) help description.  */
  * @param args_info the structure where option information will be stored
  * @return 0 if everything went fine, NON 0 if an error took place
  */
-int cmdline_parser (int argc, char * const *argv,
+int cmdline_parser (int argc, char **argv,
   struct gengetopt_args_info *args_info);
 
 /**
  * @return 0 if everything went fine, NON 0 if an error took place
  * @deprecated use cmdline_parser_ext() instead
  */
-int cmdline_parser2 (int argc, char * const *argv,
+int cmdline_parser2 (int argc, char **argv,
   struct gengetopt_args_info *args_info,
   int override, int initialize, int check_required);
 
  * @param params additional parameters for the parser
  * @return 0 if everything went fine, NON 0 if an error took place
  */
-int cmdline_parser_ext (int argc, char * const *argv,
+int cmdline_parser_ext (int argc, char **argv,
   struct gengetopt_args_info *args_info,
   struct cmdline_parser_params *params);
 

File tools/SeekEvaluator/SeekEvaluator.cpp

 	vector<AResultFloat> master_rank;
 	utype i, j;
 	float nan = sArgs.nan_arg;
+	if(sArgs.neg_cor_flag==1 && nan==-320){
+		nan = 320;
+	}
 	result.clear();
 
+	bool bNegativeCor = false;
+	if(sArgs.neg_cor_flag==1){
+		bNegativeCor = true;
+	}
+
 	vector<char> *q = new vector<char>[listSize];
 	for(i=0; i<listSize; i++){
 		q[i] = vector<char>();
 			for(j=0; j<sortedGenes[0].size(); j++)
 				master_score[j].f /= (float)listSize;
 
-			sort(master_score.begin(), master_score.end());
+			if(bNegativeCor){
+				sort(master_score.begin(), master_score.end(), AscendingFloat());
+			}else{		
+				sort(master_score.begin(), master_score.end());
+			}
 
 			master = &master_score;
 		}
 			for(j=0; j<sortedGenes[0].size(); j++)
 				master_rank[j].f /= (float) listSize;
 
-			sort(master_rank.begin(), master_rank.end());
+			if(bNegativeCor){
+				sort(master_score.begin(), master_score.end(), AscendingFloat());
+			}else{		
+				sort(master_score.begin(), master_score.end());
+			}
 
 			master = &master_rank;
 
 				sortedGenes[i][j].f = nan;
 			}
 		}
-
-		sort(sortedGenes[i].begin(), sortedGenes[i].end());
-
+		if(bNegativeCor){
+			sort(sortedGenes[i].begin(), sortedGenes[i].end(), AscendingFloat());
+		}else{
+			sort(sortedGenes[i].begin(), sortedGenes[i].end());
+		}
 		if(met!=PR_ALL){
 			float fEval;
 			bool ret = EvaluateOneQuery(sArgs, met, sortedGenes[i],
 		for(i=0; i<listSize; i++){
 			GetRandom(rnd, sortedGenes[i], randomScores[i], excludeGene[i], 
 				includeGene[i], queryGeneID[i], nan);
-			sort(randomScores[i].begin(), randomScores[i].end());
+			if(bNegativeCor){
+				sort(randomScores[i].begin(), randomScores[i].end(), AscendingFloat());
+			}else{
+				sort(randomScores[i].begin(), randomScores[i].end());
+			}
 			if(met!=PR_ALL){
 				float fEval;
 				bool ret = EvaluateOneQuery(sArgs, met, randomScores[i],
 		//	geneScores.end());
 
 		float nan = sArgs.nan_arg;
+		if(sArgs.neg_cor_flag==1 && nan==-320){
+			nan = 320;
+		}
+		bool bNegativeCor = false;
+		if(sArgs.neg_cor_flag==1){
+			bNegativeCor = true;
+		}
+
 		vector<AResultFloat> sortedGenes;
 		sortedGenes.resize(geneScores.size());
 		for(i=0; i<sortedGenes.size(); i++){
 		for(i=0; i<queryGeneID.size(); i++)
 			sortedGenes[queryGeneID[i]].f = nan;
 
-		sort(sortedGenes.begin(), sortedGenes.end());
-
+		if(bNegativeCor){
+			sort(sortedGenes.begin(), sortedGenes.end(), AscendingFloat());
+		}else{
+			sort(sortedGenes.begin(), sortedGenes.end());
+		}
 		if(sArgs.p_value_flag==1){
+			if(bNegativeCor){
+				fprintf(stderr, "WARNING: Negative correlation enabled! Ensure null distributions also use negative correlations!\n");
+			}
 			string random_directory = sArgs.random_dir_arg;
 			int num_random = sArgs.random_num_arg;
 			int ii, jj;
 					sortedRandom[jj].i = jj;
 					sortedRandom[jj].f = randomScores[jj];
 				}
-				sort(sortedRandom.begin(), sortedRandom.end());
+				if(bNegativeCor){
+					sort(sortedRandom.begin(), sortedRandom.end(), AscendingFloat());
+				}else{
+					sort(sortedRandom.begin(), sortedRandom.end());
+				}
 				for(jj=0; jj<randomScores.size(); jj++){
 					randomRank[sortedRandom[jj].i][ii] = jj;
 					randomSc[sortedRandom[jj].i][ii] = sortedRandom[jj].f;
 
 			for(jj=0; jj<geneScores.size(); jj++){
 				sort(randomRank[jj].begin(), randomRank[jj].end());
-				sort(randomSc[jj].begin(), randomSc[jj].end(), std::greater<float>());
+				if(bNegativeCor){
+					sort(randomSc[jj].begin(), randomSc[jj].end(), std::less<float>());
+				}else{
+					sort(randomSc[jj].begin(), randomSc[jj].end(), std::greater<float>());
+				}
 				geneRank[sortedGenes[jj].i] = jj;
 			}
 

File tools/SeekEvaluator/SeekEvaluator.ggo

 option	"random_num"		N	"Number of random trials"
 								int		default="100"
 
+section "Options for NaN score"
+option	"nan"				n	"Define NaN score (320 if negative correlation is enabled)"
+								float	default="-320"
+option	"neg_cor"			K	"Negative correlations"
+								flag	off
+
 section "Input required by single-query"
 option	"goldstd"			s	"Gold standard gene set file (one line, space delimited)"
 								string typestr="filename"
 								string typestr="filename"
 option	"exclude"			y	"Exclude genes (.exclude)"
 								string typestr="filename"
-option	"nan"				n	"Define NaN score"
-								float	default="-320"
 								
 section	"Input required by multi-query"
 option	"goldstd_list"		S	"List of gold standard gene set files"
 option	"include_list"		Y	"List of annotated genes"
 								string typestr="filename"
 
-
 section "Output"
 option	"dir_out"			d	"Output directory"
 								string typestr="directory"	yes

File tools/SeekEvaluator/cmdline.c

 /*
-  File autogenerated by gengetopt version 2.22
+  File autogenerated by gengetopt version 2.22.5
   generated with the following command:
-  gengetopt -iSeekEvaluator.ggo --default-optional -u -N -e 
+  /usr/bin/gengetopt -iSeekEvaluator.ggo --default-optional -u -N -e 
 
   The developers of gengetopt consider the fixed text that goes in all
   gengetopt output files to be in the public domain:
 #include <stdlib.h>
 #include <string.h>
 
-#include "getopt.h"
+#ifndef FIX_UNUSED
+#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
+#endif
+
+#include <getopt.h>
 
 #include "cmdline.h"
 
   "  -P, --p_value                Simulated p-value  (default=off)",
   "  -R, --random_dir=directory   Random directory",
   "  -N, --random_num=INT         Number of random trials  (default=`100')",
+  "\nOptions for NaN score:",
+  "  -n, --nan=FLOAT              Define NaN score (320 if negative correlation is \n                                 enabled)  (default=`-320')",
+  "  -K, --neg_cor                Negative correlations  (default=off)",
   "\nInput required by single-query:",
   "  -s, --goldstd=filename       Gold standard gene set file (one line, space \n                                 delimited)",
   "  -g, --gscore=filename        Gene score file (.gscore)",
   "  -q, --query=filename         Query gene set file (to be excluded from \n                                 evaluation) (.query)",
   "  -y, --exclude=filename       Exclude genes (.exclude)",
-  "  -n, --nan=FLOAT              Define NaN score  (default=`-320')",
   "\nInput required by multi-query:",
   "  -S, --goldstd_list=filename  List of gold standard gene set files",
   "  -G, --gscore_list=filename   List of gene score files",
 void clear_args (struct gengetopt_args_info *args_info);
 
 static int
-cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
                         struct cmdline_parser_params *params, const char *additional_error);
 
 static int
   args_info->p_value_given = 0 ;
   args_info->random_dir_given = 0 ;
   args_info->random_num_given = 0 ;
+  args_info->nan_given = 0 ;
+  args_info->neg_cor_given = 0 ;
   args_info->goldstd_given = 0 ;
   args_info->gscore_given = 0 ;
   args_info->query_given = 0 ;
   args_info->exclude_given = 0 ;
-  args_info->nan_given = 0 ;
   args_info->goldstd_list_given = 0 ;
   args_info->gscore_list_given = 0 ;
   args_info->query_list_given = 0 ;
 static
 void clear_args (struct gengetopt_args_info *args_info)
 {
+  FIX_UNUSED (args_info);
   args_info->single_flag = 0;
   args_info->aggregate_flag = 0;
   args_info->multi_weight_flag = 0;
   args_info->random_dir_orig = NULL;
   args_info->random_num_arg = 100;
   args_info->random_num_orig = NULL;
+  args_info->nan_arg = -320;
+  args_info->nan_orig = NULL;
+  args_info->neg_cor_flag = 0;
   args_info->goldstd_arg = NULL;
   args_info->goldstd_orig = NULL;
   args_info->gscore_arg = NULL;
   args_info->query_orig = NULL;
   args_info->exclude_arg = NULL;
   args_info->exclude_orig = NULL;
-  args_info->nan_arg = -320;
-  args_info->nan_orig = NULL;
   args_info->goldstd_list_arg = NULL;
   args_info->goldstd_list_orig = NULL;
   args_info->gscore_list_arg = NULL;
   args_info->p_value_help = gengetopt_args_info_help[33] ;
   args_info->random_dir_help = gengetopt_args_info_help[34] ;
   args_info->random_num_help = gengetopt_args_info_help[35] ;
-  args_info->goldstd_help = gengetopt_args_info_help[37] ;
-  args_info->gscore_help = gengetopt_args_info_help[38] ;
-  args_info->query_help = gengetopt_args_info_help[39] ;
-  args_info->exclude_help = gengetopt_args_info_help[40] ;
-  args_info->nan_help = gengetopt_args_info_help[41] ;
-  args_info->goldstd_list_help = gengetopt_args_info_help[43] ;
-  args_info->gscore_list_help = gengetopt_args_info_help[44] ;
-  args_info->query_list_help = gengetopt_args_info_help[45] ;
-  args_info->exclude_list_help = gengetopt_args_info_help[46] ;
-  args_info->include_list_help = gengetopt_args_info_help[47] ;
-  args_info->dir_out_help = gengetopt_args_info_help[49] ;
+  args_info->nan_help = gengetopt_args_info_help[37] ;
+  args_info->neg_cor_help = gengetopt_args_info_help[38] ;
+  args_info->goldstd_help = gengetopt_args_info_help[40] ;
+  args_info->gscore_help = gengetopt_args_info_help[41] ;
+  args_info->query_help = gengetopt_args_info_help[42] ;
+  args_info->exclude_help = gengetopt_args_info_help[43] ;
+  args_info->goldstd_list_help = gengetopt_args_info_help[45] ;
+  args_info->gscore_list_help = gengetopt_args_info_help[46] ;
+  args_info->query_list_help = gengetopt_args_info_help[47] ;
+  args_info->exclude_list_help = gengetopt_args_info_help[48] ;
+  args_info->include_list_help = gengetopt_args_info_help[49] ;
+  args_info->dir_out_help = gengetopt_args_info_help[51] ;
   
 }
 
 void
 cmdline_parser_print_version (void)
 {
-  printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
+  printf ("%s %s\n",
+     (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
+     CMDLINE_PARSER_VERSION);
 }
 
 static void print_help_common(void) {
   printf("\n");
 
   if (strlen(gengetopt_args_info_description) > 0)
-    printf("%s\n", gengetopt_args_info_description);
+    printf("%s\n\n", gengetopt_args_info_description);
 }
 
 void
   clear_args (args_info);
   init_args_info (args_info);
 
-  args_info->inputs = NULL;
+  args_info->inputs = 0;
   args_info->inputs_num = 0;
 }
 
   free_string_field (&(args_info->random_dir_arg));
   free_string_field (&(args_info->random_dir_orig));
   free_string_field (&(args_info->random_num_orig));
+  free_string_field (&(args_info->nan_orig));
   free_string_field (&(args_info->goldstd_arg));
   free_string_field (&(args_info->goldstd_orig));
   free_string_field (&(args_info->gscore_arg));
   free_string_field (&(args_info->query_orig));
   free_string_field (&(args_info->exclude_arg));
   free_string_field (&(args_info->exclude_orig));
-  free_string_field (&(args_info->nan_orig));
   free_string_field (&(args_info->goldstd_list_arg));
   free_string_field (&(args_info->goldstd_list_orig));
   free_string_field (&(args_info->gscore_list_arg));
 
 
 static void
-write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[])
+write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
 {
+  FIX_UNUSED (values);
   if (arg) {
     fprintf(outfile, "%s=\"%s\"\n", opt, arg);
   } else {
     write_into_file(outfile, "random_dir", args_info->random_dir_orig, 0);
   if (args_info->random_num_given)
     write_into_file(outfile, "random_num", args_info->random_num_orig, 0);
+  if (args_info->nan_given)
+    write_into_file(outfile, "nan", args_info->nan_orig, 0);
+  if (args_info->neg_cor_given)
+    write_into_file(outfile, "neg_cor", 0, 0 );
   if (args_info->goldstd_given)
     write_into_file(outfile, "goldstd", args_info->goldstd_orig, 0);
   if (args_info->gscore_given)
     write_into_file(outfile, "query", args_info->query_orig, 0);
   if (args_info->exclude_given)
     write_into_file(outfile, "exclude", args_info->exclude_orig, 0);
-  if (args_info->nan_given)
-    write_into_file(outfile, "nan", args_info->nan_orig, 0);
   if (args_info->goldstd_list_given)
     write_into_file(outfile, "goldstd_list", args_info->goldstd_list_orig, 0);
   if (args_info->gscore_list_given)
 char *
 gengetopt_strdup (const char *s)
 {
-  char *result = NULL;
+  char *result = 0;
   if (!s)
     return result;
 
 }
 
 int
-cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
+cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
 {
   return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
 }
 
 int
-cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
                    struct cmdline_parser_params *params)
 {
   int result;
-  result = cmdline_parser_internal (argc, argv, args_info, params, NULL);
+  result = cmdline_parser_internal (argc, argv, args_info, params, 0);
 
   return result;
 }
 
 int
-cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
+cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
 {
   int result;
   struct cmdline_parser_params params;
   params.check_ambiguity = 0;
   params.print_errors = 1;
 
-  result = cmdline_parser_internal (argc, argv, args_info, &params, NULL);
+  result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
 
   return result;
 }
 {
   int result = EXIT_SUCCESS;
 
-  if (cmdline_parser_required2(args_info, prog_name, NULL) > 0)
+  if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
     result = EXIT_FAILURE;
 
   return result;
 cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
 {
   int error = 0;
+  FIX_UNUSED (additional_error);
 
   /* checks for required options */
   if (! args_info->input_given)
 static
 int update_arg(void *field, char **orig_field,
                unsigned int *field_given, unsigned int *prev_given, 
-               char *value, char *possible_values[], const char *default_value,
+               char *value, const char *possible_values[],
+               const char *default_value,
                cmdline_parser_arg_type arg_type,
                int check_ambiguity, int override,
                int no_free, int multiple_option,
   const char *val = value;
   int found;
   char **string_field;
+  FIX_UNUSED (field);
 
   stop_char = 0;
   found = 0;
       return 1; /* failure */
     }
 
+  FIX_UNUSED (default_value);
     
   if (field_given && *field_given && ! override)
     return 0;
 
 
 int
-cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+cmdline_parser_internal (
+  int argc, char **argv, struct gengetopt_args_info *args_info,
                         struct cmdline_parser_params *params, const char *additional_error)
 {
   int c;	/* Character of the parsed option.  */
         { "p_value",	0, NULL, 'P' },
         { "random_dir",	1, NULL, 'R' },
         { "random_num",	1, NULL, 'N' },
+        { "nan",	1, NULL, 'n' },
+        { "neg_cor",	0, NULL, 'K' },
         { "goldstd",	1, NULL, 's' },
         { "gscore",	1, NULL, 'g' },
         { "query",	1, NULL, 'q' },
         { "exclude",	1, NULL, 'y' },
-        { "nan",	1, NULL, 'n' },
         { "goldstd_list",	1, NULL, 'S' },
         { "gscore_list",	1, NULL, 'G' },
         { "query_list",	1, NULL, 'Q' },
         { "exclude_list",	1, NULL, 'X' },
         { "include_list",	1, NULL, 'Y' },
         { "dir_out",	1, NULL, 'd' },
-        { NULL,	0, NULL, 0 }
+        { 0,  0, 0, 0 }
       };
 
-      c = getopt_long (argc, argv, "hVOMTzratcux:e:p:FWABCDEi:I:w:Z:fPR:N:s:g:q:y:n:S:G:Q:X:Y:d:", long_options, &option_index);
+      c = getopt_long (argc, argv, "hVOMTzratcux:e:p:FWABCDEi:I:w:Z:fPR:N:n:Ks:g:q:y:S:G:Q:X:Y:d:", long_options, &option_index);
 
       if (c == -1) break;	/* Exit from `while (1)' loop.  */
 
             goto failure;
         
           break;
+        case 'n':	/* Define NaN score (320 if negative correlation is enabled).  */
+        
+        
+          if (update_arg( (void *)&(args_info->nan_arg), 
+               &(args_info->nan_orig), &(args_info->nan_given),
+              &(local_args_info.nan_given), optarg, 0, "-320", ARG_FLOAT,
+              check_ambiguity, override, 0, 0,
+              "nan", 'n',
+              additional_error))
+            goto failure;
+        
+          break;
+        case 'K':	/* Negative correlations.  */
+        
+        
+          if (update_arg((void *)&(args_info->neg_cor_flag), 0, &(args_info->neg_cor_given),
+              &(local_args_info.neg_cor_given), optarg, 0, 0, ARG_FLAG,
+              check_ambiguity, override, 1, 0, "neg_cor", 'K',
+              additional_error))
+            goto failure;
+        
+          break;
         case 's':	/* Gold standard gene set file (one line, space delimited).  */
         
         
             goto failure;
         
           break;
-        case 'n':	/* Define NaN score.  */
-        
-        
-          if (update_arg( (void *)&(args_info->nan_arg), 
-               &(args_info->nan_orig), &(args_info->nan_given),
-              &(local_args_info.nan_given), optarg, 0, "-320", ARG_FLOAT,
-              check_ambiguity, override, 0, 0,
-              "nan", 'n',
-              additional_error))
-            goto failure;
-        
-          break;
         case 'S':	/* List of gold standard gene set files.  */
         
         

File tools/SeekEvaluator/cmdline.h

 /** @file cmdline.h
  *  @brief The header file for the command line option parser
- *  generated by GNU Gengetopt version 2.22
+ *  generated by GNU Gengetopt version 2.22.5
  *  http://www.gnu.org/software/gengetopt.
  *  DO NOT modify this file, since it can be overwritten
  *  @author GNU Gengetopt by Lorenzo Bettini */
 #endif /* __cplusplus */
 
 #ifndef CMDLINE_PARSER_PACKAGE
-/** @brief the program name */
+/** @brief the program name (used for printing errors) */
 #define CMDLINE_PARSER_PACKAGE "SeekEvaluator"
 #endif
 
+#ifndef CMDLINE_PARSER_PACKAGE_NAME
+/** @brief the complete program name (used for help and version) */
+#define CMDLINE_PARSER_PACKAGE_NAME "SeekEvaluator"
+#endif
+
 #ifndef CMDLINE_PARSER_VERSION
 /** @brief the program version */
 #define CMDLINE_PARSER_VERSION "1.0"
   int random_num_arg;	/**< @brief Number of random trials (default='100').  */
   char * random_num_orig;	/**< @brief Number of random trials original value given at command line.  */
   const char *random_num_help; /**< @brief Number of random trials help description.  */
+  float nan_arg;	/**< @brief Define NaN score (320 if negative correlation is enabled) (default='-320').  */
+  char * nan_orig;	/**< @brief Define NaN score (320 if negative correlation is enabled) original value given at command line.  */
+  const char *nan_help; /**< @brief Define NaN score (320 if negative correlation is enabled) help description.  */
+  int neg_cor_flag;	/**< @brief Negative correlations (default=off).  */
+  const char *neg_cor_help; /**< @brief Negative correlations help description.  */
   char * goldstd_arg;	/**< @brief Gold standard gene set file (one line, space delimited).  */
   char * goldstd_orig;	/**< @brief Gold standard gene set file (one line, space delimited) original value given at command line.  */
   const char *goldstd_help; /**< @brief Gold standard gene set file (one line, space delimited) help description.  */
   char * exclude_arg;	/**< @brief Exclude genes (.exclude).  */
   char * exclude_orig;	/**< @brief Exclude genes (.exclude) original value given at command line.  */
   const char *exclude_help; /**< @brief Exclude genes (.exclude) help description.  */
-  float nan_arg;	/**< @brief Define NaN score (default='-320').  */
-  char * nan_orig;	/**< @brief Define NaN score original value given at command line.  */
-  const char *nan_help; /**< @brief Define NaN score help description.  */
   char * goldstd_list_arg;	/**< @brief List of gold standard gene set files.  */
   char * goldstd_list_orig;	/**< @brief List of gold standard gene set files original value given at command line.  */
   const char *goldstd_list_help; /**< @brief List of gold standard gene set files help description.  */
   unsigned int p_value_given ;	/**< @brief Whether p_value was given.  */
   unsigned int random_dir_given ;	/**< @brief Whether random_dir was given.  */
   unsigned int random_num_given ;	/**< @brief Whether random_num was given.  */
+  unsigned int nan_given ;	/**< @brief Whether nan was given.  */
+  unsigned int neg_cor_given ;	/**< @brief Whether neg_cor was given.  */
   unsigned int goldstd_given ;	/**< @brief Whether goldstd was given.  */
   unsigned int gscore_given ;	/**< @brief Whether gscore was given.  */
   unsigned int query_given ;	/**< @brief Whether query was given.  */
   unsigned int exclude_given ;	/**< @brief Whether exclude was given.  */
-  unsigned int nan_given ;	/**< @brief Whether nan was given.  */
   unsigned int goldstd_list_given ;	/**< @brief Whether goldstd_list was given.  */
   unsigned int gscore_list_given ;	/**< @brief Whether gscore_list was given.  */
   unsigned int query_list_given ;	/**< @brief Whether query_list was given.  */
  * @param args_info the structure where option information will be stored
  * @return 0 if everything went fine, NON 0 if an error took place
  */
-int cmdline_parser (int argc, char * const *argv,
+int cmdline_parser (int argc, char **argv,
   struct gengetopt_args_info *args_info);
 
 /**
  * @return 0 if everything went fine, NON 0 if an error took place
  * @deprecated use cmdline_parser_ext() instead
  */
-int cmdline_parser2 (int argc, char * const *argv,
+int cmdline_parser2 (int argc, char **argv,
   struct gengetopt_args_info *args_info,
   int override, int initialize, int check_required);
 
  * @param params additional parameters for the parser
  * @return 0 if everything went fine, NON 0 if an error took place
  */
-int cmdline_parser_ext (int argc, char * const *argv,
+int cmdline_parser_ext (int argc, char **argv,
   struct gengetopt_args_info *args_info,
   struct cmdline_parser_params *params);
 

File tools/SeekMiner/SeekMiner.cpp

 		sArgs.score_cutoff_arg, 
 		sArgs.per_q_required_arg, sArgs.per_g_required_arg,
 		!!sArgs.square_z_flag,
-		!!sArgs.random_flag, sArgs.num_random_arg, random_ranking_rnd, useNibble, 
+		!!sArgs.random_flag, sArgs.num_random_arg, !!sArgs.neg_cor_flag,
+		random_ranking_rnd, useNibble, 
 		sArgs.num_threads_arg))
 		return -1;
 
 		csfinal->VarianceWeightSearch();
 	}else if(method=="AVERAGE_Z"){
 		csfinal->AverageWeightSearch();
+	}else if(method=="CV_CUSTOM"){
+		string uw = sArgs.user_gene_list_arg;
+		vector<vector<string> > user_gene_list;
+		if(!CSeekTools::ReadMultipleQueries(uw, user_gene_list, 2048)){
+			fprintf(stderr, "Error reading user gene lists!\n");
+			return -1;
+		}	
+		csfinal->CVCustomSearch(user_gene_list, rnd, PART_M, FOLD, RATE);
 	}
 	//csfinal->WeightSearch(csk_weight_copy);
 	//csfinal->CVCustomSearch(newQ, rnd, PART_M, FOLD, RATE);

File tools/SeekMiner/SeekMiner.ggo

 								int default="8"
 option	"per_g_required"	H	"Fraction (max 1.0) of genome required to be present in a dataset. Datasets not meeting the minimum required genes are skipped."
 								float default="0.0"
+option	"neg_cor"			k	"Rank genes and datasets by negative correlations"
+								flag	off
 
 section "Dataset weighting"
-option	"weighting_method"	V	"Weighting method: query cross-validated weighting (CV), equal weighting (EQUAL), order statistics weighting (ORDER_STAT), variance weighting (VAR), user-given weighting (USER), SPELL weighting (AVERAGE_Z)"
-								values="CV","EQUAL","ORDER_STAT","VAR","USER","AVERAGE_Z" default="CV"
+option	"weighting_method"	V	"Weighting method: query cross-validated weighting (CV), equal weighting (EQUAL), order statistics weighting (ORDER_STAT), variance weighting (VAR), user-given weighting (USER), SPELL weighting (AVERAGE_Z), user cross-validated weighting (CV_CUSTOM)"
+								values="CV","EQUAL","ORDER_STAT","VAR","USER","AVERAGE_Z","CV_CUSTOM" default="CV"
 
 section "Optional - Functional Network Expansion"
 option	"func_db"			w	"Functional network db path"
 option	"func_logit"		l	"Functional network, integrate using logit values"
 								flag	off
 
+section "Dataset weighting: User Cross-validated Weighting (CV_CUSTOM)"
+option	"user_gene_list"	K	"List of user's gene-sets to which queries will be judged upon (text, 1 line per query)"
+								string typestr="filename"
+
 section "Optional - User-given Weighting"
 option	"user_weight_list"	J	"List of pre-computed dataset weight files (.dweight)"
 								string typestr="filename"

File tools/SeekMiner/cmdline.c

 /*
-  File autogenerated by gengetopt version 2.22
+  File autogenerated by gengetopt version 2.22.5
   generated with the following command:
-  gengetopt -iSeekMiner.ggo --default-optional -u -N -e 
+  /usr/bin/gengetopt -iSeekMiner.ggo --default-optional -u -N -e 
 
   The developers of gengetopt consider the fixed text that goes in all
   gengetopt output files to be in the public domain:
 #include <stdlib.h>
 #include <string.h>
 
-#include "getopt.h"
+#ifndef FIX_UNUSED
+#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
+#endif
+
+#include <getopt.h>
 
 #include "cmdline.h"
 
   "  -n, --num_db=INT              Number of databaselets in database  \n                                  (default=`1000')",
   "  -T, --num_threads=INT         Number of threads  (default=`8')",
   "  -H, --per_g_required=FLOAT    Fraction (max 1.0) of genome required to be \n                                  present in a dataset. Datasets not meeting \n                                  the minimum required genes are skipped.  \n                                  (default=`0.0')",
+  "  -k, --neg_cor                 Rank genes and datasets by negative \n                                  correlations  (default=off)",
   "\nDataset weighting:",
-  "  -V, --weighting_method=STRING Weighting method: query cross-validated \n                                  weighting (CV), equal weighting (EQUAL), \n                                  order statistics weighting (ORDER_STAT), \n                                  variance weighting (VAR), user-given \n                                  weighting (USER), SPELL weighting (AVERAGE_Z) \n                                   (possible values=\"CV\", \"EQUAL\", \n                                  \"ORDER_STAT\", \"VAR\", \"USER\", \n                                  \"AVERAGE_Z\" default=`CV')",
+  "  -V, --weighting_method=STRING Weighting method: query cross-validated \n                                  weighting (CV), equal weighting (EQUAL), \n                                  order statistics weighting (ORDER_STAT), \n                                  variance weighting (VAR), user-given \n                                  weighting (USER), SPELL weighting \n                                  (AVERAGE_Z), user cross-validated weighting \n                                  (CV_CUSTOM)  (possible values=\"CV\", \n                                  \"EQUAL\", \"ORDER_STAT\", \"VAR\", \"USER\", \n                                  \"AVERAGE_Z\", \"CV_CUSTOM\" default=`CV')",
   "\nOptional - Functional Network Expansion:",
   "  -w, --func_db=directory       Functional network db path",
   "  -f, --func_n=INT              Functional network number of databaselets  \n                                  (default=`1000')",
   "  -R, --func_quant=filename     Functional network quant file",
   "  -F, --func_dset=filename      Functional network dset-list file (1 dataset)",
   "  -l, --func_logit              Functional network, integrate using logit \n                                  values  (default=off)",
+  "\nDataset weighting: User Cross-validated Weighting (CV_CUSTOM):",
+  "  -K, --user_gene_list=filename List of user's gene-sets to which queries will \n                                  be judged upon (text, 1 line per query)",
   "\nOptional - User-given Weighting:",
   "  -J, --user_weight_list=filename\n                                List of pre-computed dataset weight files \n                                  (.dweight)",
   "\nOptional - Random simulations:",
 void clear_args (struct gengetopt_args_info *args_info);
 
 static int
-cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
                         struct cmdline_parser_params *params, const char *additional_error);
 
 static int
 cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
 
-char *cmdline_parser_weighting_method_values[] = {"CV", "EQUAL", "ORDER_STAT", "VAR", "USER", "AVERAGE_Z", 0} ;	/* Possible values for weighting_method.  */
-char *cmdline_parser_dist_measure_values[] = {"pearson", "z_score", 0} ;	/* Possible values for dist_measure.  */
-char *cmdline_parser_CV_partition_values[] = {"LOI", "LOO", "XFOLD", 0} ;	/* Possible values for CV_partition.  */
+const char *cmdline_parser_weighting_method_values[] = {"CV", "EQUAL", "ORDER_STAT", "VAR", "USER", "AVERAGE_Z", "CV_CUSTOM", 0}; /*< Possible values for weighting_method. */
+const char *cmdline_parser_dist_measure_values[] = {"pearson", "z_score", 0}; /*< Possible values for dist_measure. */
+const char *cmdline_parser_CV_partition_values[] = {"LOI", "LOO", "XFOLD", 0}; /*< Possible values for CV_partition. */
 
 static char *
 gengetopt_strdup (const char *s);
   args_info->num_db_given = 0 ;
   args_info->num_threads_given = 0 ;
   args_info->per_g_required_given = 0 ;
+  args_info->neg_cor_given = 0 ;
   args_info->weighting_method_given = 0 ;
   args_info->func_db_given = 0 ;
   args_info->func_n_given = 0 ;
   args_info->func_quant_given = 0 ;
   args_info->func_dset_given = 0 ;
   args_info->func_logit_given = 0 ;
+  args_info->user_gene_list_given = 0 ;
   args_info->user_weight_list_given = 0 ;
   args_info->random_given = 0 ;
   args_info->num_random_given = 0 ;
 static
 void clear_args (struct gengetopt_args_info *args_info)
 {
+  FIX_UNUSED (args_info);
   args_info->dset_arg = NULL;
   args_info->dset_orig = NULL;
   args_info->search_dset_arg = gengetopt_strdup ("NA");
   args_info->num_threads_orig = NULL;
   args_info->per_g_required_arg = 0.0;
   args_info->per_g_required_orig = NULL;
+  args_info->neg_cor_flag = 0;
   args_info->weighting_method_arg = gengetopt_strdup ("CV");
   args_info->weighting_method_orig = NULL;
   args_info->func_db_arg = NULL;
   args_info->func_dset_arg = NULL;
   args_info->func_dset_orig = NULL;
   args_info->func_logit_flag = 0;
+  args_info->user_gene_list_arg = NULL;
+  args_info->user_gene_list_orig = NULL;
   args_info->user_weight_list_arg = NULL;
   args_info->user_weight_list_orig = NULL;
   args_info->random_flag = 0;
   args_info->num_db_help = gengetopt_args_info_help[13] ;
   args_info->num_threads_help = gengetopt_args_info_help[14] ;
   args_info->per_g_required_help = gengetopt_args_info_help[15] ;
-  args_info->weighting_method_help = gengetopt_args_info_help[17] ;
-  args_info->func_db_help = gengetopt_args_info_help[19] ;
-  args_info->func_n_help = gengetopt_args_info_help[20] ;
-  args_info->func_prep_help = gengetopt_args_info_help[21] ;
-  args_info->func_quant_help = gengetopt_args_info_help[22] ;
-  args_info->func_dset_help = gengetopt_args_info_help[23] ;
-  args_info->func_logit_help = gengetopt_args_info_help[24] ;
-  args_info->user_weight_list_help = gengetopt_args_info_help[26] ;
-  args_info->random_help = gengetopt_args_info_help[28] ;
-  args_info->num_random_help = gengetopt_args_info_help[29] ;
-  args_info->dist_measure_help = gengetopt_args_info_help[31] ;
-  args_info->norm_subavg_help = gengetopt_args_info_help[32] ;
-  args_info->norm_subavg_plat_help = gengetopt_args_info_help[33] ;
-  args_info->score_cutoff_help = gengetopt_args_info_help[34] ;
-  args_info->square_z_help = gengetopt_args_info_help[35] ;
-  args_info->per_q_required_help = gengetopt_args_info_help[37] ;
-  args_info->CV_partition_help = gengetopt_args_info_help[39] ;
-  args_info->CV_fold_help = gengetopt_args_info_help[40] ;
-  args_info->CV_rbp_p_help = gengetopt_args_info_help[41] ;
-  args_info->is_nibble_help = gengetopt_args_info_help[43] ;
-  args_info->buffer_help = gengetopt_args_info_help[44] ;
-  args_info->output_text_help = gengetopt_args_info_help[45] ;
-  args_info->output_dir_help = gengetopt_args_info_help[46] ;
-  args_info->output_w_comp_help = gengetopt_args_info_help[47] ;
-  args_info->simulate_w_help = gengetopt_args_info_help[48] ;
-  args_info->additional_db_help = gengetopt_args_info_help[49] ;
+  args_info->neg_cor_help = gengetopt_args_info_help[16] ;
+  args_info->weighting_method_help = gengetopt_args_info_help[18] ;
+  args_info->func_db_help = gengetopt_args_info_help[20] ;
+  args_info->func_n_help = gengetopt_args_info_help[21] ;
+  args_info->func_prep_help = gengetopt_args_info_help[22] ;
+  args_info->func_quant_help = gengetopt_args_info_help[23] ;
+  args_info->func_dset_help = gengetopt_args_info_help[24] ;
+  args_info->func_logit_help = gengetopt_args_info_help[25] ;
+  args_info->user_gene_list_help = gengetopt_args_info_help[27] ;
+  args_info->user_weight_list_help = gengetopt_args_info_help[29] ;
+  args_info->random_help = gengetopt_args_info_help[31] ;
+  args_info->num_random_help = gengetopt_args_info_help[32] ;
+  args_info->dist_measure_help = gengetopt_args_info_help[34] ;
+  args_info->norm_subavg_help = gengetopt_args_info_help[35] ;
+  args_info->norm_subavg_plat_help = gengetopt_args_info_help[36] ;
+  args_info->score_cutoff_help = gengetopt_args_info_help[37] ;
+  args_info->square_z_help = gengetopt_args_info_help[38] ;
+  args_info->per_q_required_help = gengetopt_args_info_help[40] ;
+  args_info->CV_partition_help = gengetopt_args_info_help[42] ;
+  args_info->CV_fold_help = gengetopt_args_info_help[43] ;
+  args_info->CV_rbp_p_help = gengetopt_args_info_help[44] ;
+  args_info->is_nibble_help = gengetopt_args_info_help[46] ;
+  args_info->buffer_help = gengetopt_args_info_help[47] ;
+  args_info->output_text_help = gengetopt_args_info_help[48] ;
+  args_info->output_dir_help = gengetopt_args_info_help[49] ;
+  args_info->output_w_comp_help = gengetopt_args_info_help[50] ;
+  args_info->simulate_w_help = gengetopt_args_info_help[51] ;
+  args_info->additional_db_help = gengetopt_args_info_help[52] ;
   
 }
 
 void
 cmdline_parser_print_version (void)
 {
-  printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
+  printf ("%s %s\n",
+     (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
+     CMDLINE_PARSER_VERSION);
 }
 
 static void print_help_common(void) {
   printf("\n");
 
   if (strlen(gengetopt_args_info_description) > 0)
-    printf("%s\n", gengetopt_args_info_description);
+    printf("%s\n\n", gengetopt_args_info_description);
 }
 
 void
   clear_args (args_info);
   init_args_info (args_info);
 
-  args_info->inputs = NULL;
+  args_info->inputs = 0;
   args_info->inputs_num = 0;
 }
 
   free_string_field (&(args_info->func_quant_orig));
   free_string_field (&(args_info->func_dset_arg));
   free_string_field (&(args_info->func_dset_orig));
+  free_string_field (&(args_info->user_gene_list_arg));
+  free_string_field (&(args_info->user_gene_list_orig));
   free_string_field (&(args_info->user_weight_list_arg));
   free_string_field (&(args_info->user_weight_list_orig));
   free_string_field (&(args_info->num_random_orig));
  * -2 if more than one value has matched
  */
 static int
-check_possible_values(const char *val, char *values[])
+check_possible_values(const char *val, const char *values[])
 {
   int i, found, last;
   size_t len;
 
 
 static void
-write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[])
+write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
 {
   int found = -1;
   if (arg) {
     write_into_file(outfile, "num_threads", args_info->num_threads_orig, 0);
   if (args_info->per_g_required_given)
     write_into_file(outfile, "per_g_required", args_info->per_g_required_orig, 0);
+  if (args_info->neg_cor_given)
+    write_into_file(outfile, "neg_cor", 0, 0 );
   if (args_info->weighting_method_given)
     write_into_file(outfile, "weighting_method", args_info->weighting_method_orig, cmdline_parser_weighting_method_values);
   if (args_info->func_db_given)
     write_into_file(outfile, "func_dset", args_info->func_dset_orig, 0);
   if (args_info->func_logit_given)
     write_into_file(outfile, "func_logit", 0, 0 );
+  if (args_info->user_gene_list_given)
+    write_into_file(outfile, "user_gene_list", args_info->user_gene_list_orig, 0);
   if (args_info->user_weight_list_given)
     write_into_file(outfile, "user_weight_list", args_info->user_weight_list_orig, 0);
   if (args_info->random_given)
 char *
 gengetopt_strdup (const char *s)
 {
-  char *result = NULL;
+  char *result = 0;
   if (!s)
     return result;
 
 }
 
 int
-cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
+cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
 {
   return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
 }
 
 int
-cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
                    struct cmdline_parser_params *params)
 {
   int result;
-  result = cmdline_parser_internal (argc, argv, args_info, params, NULL);
+  result = cmdline_parser_internal (argc, argv, args_info, params, 0);
 
   return result;
 }
 
 int
-cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
+cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
 {
   int result;
   struct cmdline_parser_params params;
   params.check_ambiguity = 0;
   params.print_errors = 1;
 
-  result = cmdline_parser_internal (argc, argv, args_info, &params, NULL);
+  result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
 
   return result;
 }
 {
   int result = EXIT_SUCCESS;
 
-  if (cmdline_parser_required2(args_info, prog_name, NULL) > 0)
+  if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
     result = EXIT_FAILURE;
 
   return result;
 cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
 {
   int error = 0;
+  FIX_UNUSED (additional_error);
 
   /* checks for required options */
   if (! args_info->dset_given)
 static
 int update_arg(void *field, char **orig_field,
                unsigned int *field_given, unsigned int *prev_given, 
-               char *value, char *possible_values[], const char *default_value,
+               char *value, const char *possible_values[],
+               const char *default_value,
                cmdline_parser_arg_type arg_type,
                int check_ambiguity, int override,
                int no_free, int multiple_option,
   const char *val = value;
   int found;
   char **string_field;
+  FIX_UNUSED (field);
 
   stop_char = 0;
   found = 0;
 
 
 int
-cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
+cmdline_parser_internal (
+  int argc, char **argv, struct gengetopt_args_info *args_info,
                         struct cmdline_parser_params *params, const char *additional_error)
 {
   int c;	/* Character of the parsed option.  */
         { "num_db",	1, NULL, 'n' },
         { "num_threads",	1, NULL, 'T' },
         { "per_g_required",	1, NULL, 'H' },
+        { "neg_cor",	0, NULL, 'k' },
         { "weighting_method",	1, NULL, 'V' },
         { "func_db",	1, NULL, 'w' },
         { "func_n",	1, NULL, 'f' },
         { "func_quant",	1, NULL, 'R' },
         { "func_dset",	1, NULL, 'F' },
         { "func_logit",	0, NULL, 'l' },
+        { "user_gene_list",	1, NULL, 'K' },
         { "user_weight_list",	1, NULL, 'J' },
         { "random",	0, NULL, 'S' },
         { "num_random",	1, NULL, 't' },
         { "output_w_comp",	0, NULL, 'Y' },
         { "simulate_w",	0, NULL, 'E' },
         { "additional_db",	1, NULL, 'B' },
-        { NULL,	0, NULL, 0 }
+        { 0,  0, 0, 0 }
       };
 
-      c = getopt_long (argc, argv, "hx:D:i:q:d:p:P:u:U:Q:n:T:H:V:w:f:W:R:F:lJ:St:z:mMc:eC:I:X:G:Nb:Oo:YEB:", long_options, &option_index);
+      c = getopt_long (argc, argv, "hx:D:i:q:d:p:P:u:U:Q:n:T:H:kV:w:f:W:R:F:lK:J:St:z:mMc:eC:I:X:G:Nb:Oo:YEB:", long_options, &option_index);
 
       if (c == -1) break;	/* Exit from `while (1)' loop.  */
 
             goto failure;
         
           break;
-        case 'V':	/* Weighting method: query cross-validated weighting (CV), equal weighting (EQUAL), order statistics weighting (ORDER_STAT), variance weighting (VAR), user-given weighting (USER), SPELL weighting (AVERAGE_Z).  */
+        case 'k':	/* Rank genes and datasets by negative correlations.  */
+        
+        
+          if (update_arg((void *)&(args_info->neg_cor_flag), 0, &(args_info->neg_cor_given),
+              &(local_args_info.neg_cor_given), optarg, 0, 0, ARG_FLAG,
+              check_ambiguity, override, 1, 0, "neg_cor", 'k',
+              additional_error))
+            goto failure;
+        
+          break;
+        case 'V':	/* Weighting method: query cross-validated weighting (CV), equal weighting (EQUAL), order statistics weighting (ORDER_STAT), variance weighting (VAR), user-given weighting (USER), SPELL weighting (AVERAGE_Z), user cross-validated weighting (CV_CUSTOM).  */
         
         
           if (update_arg( (void *)&(args_info->weighting_method_arg), 
             goto failure;
         
           break;
+        case 'K':	/* List of user's gene-sets to which queries will be judged upon (text, 1 line per query).  */
+        
+        
+          if (update_arg( (void *)&(args_info->user_gene_list_arg), 
+               &(args_info->user_gene_list_orig), &(args_info->user_gene_list_given),
+              &(local_args_info.user_gene_list_given), optarg, 0, 0, ARG_STRING,
+              check_ambiguity, override, 0, 0,
+              "user_gene_list", 'K',
+              additional_error))
+            goto failure;
+        
+          break;
         case 'J':	/* List of pre-computed dataset weight files (.dweight).  */
         
         

File tools/SeekMiner/cmdline.h

 /** @file cmdline.h
  *  @brief The header file for the command line option parser
- *  generated by GNU Gengetopt version 2.22
+ *  generated by GNU Gengetopt version 2.22.5
  *  http://www.gnu.org/software/gengetopt.
  *  DO NOT modify this file, since it can be overwritten
  *  @author GNU Gengetopt by Lorenzo Bettini */
 #endif /* __cplusplus */
 
 #ifndef CMDLINE_PARSER_PACKAGE
-/** @brief the program name */
+/** @brief the program name (used for printing errors) */
 #define CMDLINE_PARSER_PACKAGE "SeekMiner"
 #endif
 
+#ifndef CMDLINE_PARSER_PACKAGE_NAME
+/** @brief the complete program name (used for help and version) */
+#define CMDLINE_PARSER_PACKAGE_NAME "SeekMiner"
+#endif
+
 #ifndef CMDLINE_PARSER_VERSION
 /** @brief the program version */
 #define CMDLINE_PARSER_VERSION "1.0"
   float per_g_required_arg;	/**< @brief Fraction (max 1.0) of genome required to be present in a dataset. Datasets not meeting the minimum required genes are skipped. (default='0.0').  */
   char * per_g_required_orig;	/**< @brief Fraction (max 1.0) of genome required to be present in a dataset. Datasets not meeting the minimum required genes are skipped. original value given at command line.  */
   const char *per_g_required_help; /**< @brief Fraction (max 1.0) of genome required to be present in a dataset. Datasets not meeting the minimum required genes are skipped. help description.  */
-  char * weighting_method_arg;	/**< @brief Weighting method: query cross-validated weighting (CV), equal weighting (EQUAL), order statistics weighting (ORDER_STAT), variance weighting (VAR), user-given weighting (USER), SPELL weighting (AVERAGE_Z) (default='CV').  */
-  char * weighting_method_orig;	/**< @brief Weighting method: query cross-validated weighting (CV), equal weighting (EQUAL), order statistics weighting (ORDER_STAT), variance weighting (VAR), user-given weighting (USER), SPELL weighting (AVERAGE_Z) original value given at command line.  */
-  const char *weighting_method_help; /**< @brief Weighting method: query cross-validated weighting (CV), equal weighting (EQUAL), order statistics weighting (ORDER_STAT), variance weighting (VAR), user-given weighting (USER), SPELL weighting (AVERAGE_Z) help description.  */
+  int neg_cor_flag;	/**< @brief Rank genes and datasets by negative correlations (default=off).  */
+  const char *neg_cor_help; /**< @brief Rank genes and datasets by negative correlations help description.  */
+  char * weighting_method_arg;	/**< @brief Weighting method: query cross-validated weighting (CV), equal weighting (EQUAL), order statistics weighting (ORDER_STAT), variance weighting (VAR), user-given weighting (USER), SPELL weighting (AVERAGE_Z), user cross-validated weighting (CV_CUSTOM) (default='CV').  */
+  char * weighting_method_orig;	/**< @brief Weighting method: query cross-validated weighting (CV), equal weighting (EQUAL), order statistics weighting (ORDER_STAT), variance weighting (VAR), user-given weighting (USER), SPELL weighting (AVERAGE_Z), user cross-validated weighting (CV_CUSTOM) original value given at command line.  */
+  const char *weighting_method_help; /**< @brief Weighting method: query cross-validated weighting (CV), equal weighting (EQUAL), order statistics weighting (ORDER_STAT), variance weighting (VAR), user-given weighting (USER), SPELL weighting (AVERAGE_Z), user cross-validated weighting (CV_CUSTOM) help description.  */
   char * func_db_arg;	/**< @brief Functional network db path.  */
   char * func_db_orig;	/**< @brief Functional network db path original value given at command line.  */
   const char *func_db_help; /**< @brief Functional network db path help description.  */
   const char *func_dset_help; /**< @brief Functional network dset-list file (1 dataset) help description.  */
   int func_logit_flag;	/**< @brief Functional network, integrate using logit values (default=off).  */
   const char *func_logit_help; /**< @brief Functional network, integrate using logit values help description.  */
+  char * user_gene_list_arg;	/**< @brief List of user's gene-sets to which queries will be judged upon (text, 1 line per query).  */
+  char * user_gene_list_orig;	/**< @brief List of user's gene-sets to which queries will be judged upon (text, 1 line per query) original value given at command line.  */
+  const char *user_gene_list_help; /**< @brief List of user's gene-sets to which queries will be judged upon (text, 1 line per query) help description.  */
   char * user_weight_list_arg;	/**< @brief List of pre-computed dataset weight files (.dweight).  */
   char * user_weight_list_orig;	/**< @brief List of pre-computed dataset weight files (.dweight) original value given at command line.  */
   const char *user_weight_list_help; /**< @brief List of pre-computed dataset weight files (.dweight) help description.  */
   unsigned int num_db_given ;	/**< @brief Whether num_db was given.  */
   unsigned int num_threads_given ;	/**< @brief Whether num_threads was given.  */
   unsigned int per_g_required_given ;	/**< @brief Whether per_g_required was given.  */
+  unsigned int neg_cor_given ;	/**< @brief Whether neg_cor was given.  */
   unsigned int weighting_method_given ;	/**< @brief Whether weighting_method was given.  */
   unsigned int func_db_given ;	/**< @brief Whether func_db was given.  */
   unsigned int func_n_given ;	/**< @brief Whether func_n was given.  */
   unsigned int func_quant_given ;	/**< @brief Whether func_quant was given.  */
   unsigned int func_dset_given ;	/**< @brief Whether func_dset was given.  */
   unsigned int func_logit_given ;	/**< @brief Whether func_logit was given.  */
+  unsigned int user_gene_list_given ;	/**< @brief Whether user_gene_list was given.  */
   unsigned int user_weight_list_given ;	/**< @brief Whether user_weight_list was given.  */
   unsigned int random_given ;	/**< @brief Whether random was given.  */
   unsigned int num_random_given ;	/**< @brief Whether num_random was given.  */
  * @param args_info the structure where option information will be stored
  * @return 0 if everything went fine, NON 0 if an error took place
  */
-int cmdline_parser (int argc, char * const *argv,
+int cmdline_parser (int argc, char **argv,
   struct gengetopt_args_info *args_info);
 
 /**
  * @return 0 if everything went fine, NON 0 if an error took place
  * @deprecated use cmdline_parser_ext() instead
  */
-int cmdline_parser2 (int argc, char * const *argv,
+int cmdline_parser2 (int argc, char **argv,
   struct gengetopt_args_info *args_info,
   int override, int initialize, int check_required);
 
  * @param params additional parameters for the parser
  * @return 0 if everything went fine, NON 0 if an error took place
  */
-int cmdline_parser_ext (int argc, char * const *argv,
+int cmdline_parser_ext (int argc, char **argv,
   struct gengetopt_args_info *args_info,
   struct cmdline_parser_params *params);
 
 int cmdline_parser_required (struct gengetopt_args_info *args_info,
   const char *prog_name);
 
-extern char *cmdline_parser_weighting_method_values[] ;	/**< @brief Possible values for weighting_method.  */
-extern char *cmdline_parser_dist_measure_values[] ;	/**< @brief Possible values for dist_measure.  */
-extern char *cmdline_parser_CV_partition_values[] ;	/**< @brief Possible values for CV_partition.  */
+extern const char *cmdline_parser_weighting_method_values[];  /**< @brief Possible values for weighting_method. */
+extern const char *cmdline_parser_dist_measure_values[];  /**< @brief Possible values for dist_measure. */
+extern const char *cmdline_parser_CV_partition_values[];  /**< @brief Possible values for CV_partition. */
 
 
 #ifdef __cplusplus

File tools/SeekReader/cmdline.c

 /*
-  File autogenerated by gengetopt version 2.22
+  File autogenerated by gengetopt version 2.22.5
   generated with the following command:
-  gengetopt -iSeekReader.ggo --default-optional -u -N -e 
+  /usr/bin/gengetopt -iSeekReader.ggo --default-optional -u -N -e 
 
   The developers of gengetopt consider the fixed text that goes in all
   gengetopt output files to be in the public domain:
 #include <stdlib.h>
 #include <string.h>
 
-#include "getopt.h"
+#ifndef FIX_UNUSED
+#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
+#endif
+
+#include <getopt.h>
 
 #include "cmdline.h"
 
 
 const char *gengetopt_args_info_help[] = {
   "      --help                    Print help and exit",
-  "      --version                 Print version and exit",
+  "  -V, --version                 Print version and exit",
   "\nDiagnosis:",
   "  -D, --databaselet             Display values from databaselet(s)  \n