Commits

Qian Zhu committed 1fe3781

Add debug code in seekcentral.cpp
Update PCLServer, SeekMiner, SeekServer to allow reading CDatabaselets from multiple CDatabase's

  • Participants
  • Parent commits 0426a61

Comments (0)

Files changed (6)

File src/seekcentral.cpp

 		}
 	}
 	ss.clear();
+
 	//check
 	vector<char> vc;
 	utype tot = 0;
 		m_vc, src->m_vc, m_vp, src->m_vp, m_vecstrDatasets,
 		m_mapstrstrDatasetPlatform, m_mapstriPlatform);
 
-	if(!CalculateRestart())
+	if(!CalculateRestart()){
+		fprintf(stderr, "Error occurred during CalculateRestart()\n");
 		return false;
+	}
 
-	if(!EnableNetwork(iClient))
+	fprintf(stderr, "Finished CalculateRestart()\n");
+
+	if(!EnableNetwork(iClient)){
+		fprintf(stderr, "Error occurred during EnableNetwork()\n");
 		return false;
+	}
 
-	if(!CheckDatasets(true)) //replace parameter is true
+	fprintf(stderr, "Finished EnableNetworks()\n");
+
+	if(!CheckDatasets(true)){ //replace parameter is true
+		fprintf(stderr, "Error occurred during CheckDatasets()\n");
 		return false;
+	}
 
+	fprintf(stderr, "Finished CheckDatasets()\n");
 	return true;
 }
 
 		vector<int> count;
 		CSeekTools::InitVector(count, m_vecstrAllQuery[l].size(), (int) 0);
 		bool isFirst = true;
+		//fprintf(stderr, "iUserDatasets %d\n", iUserDatasets);
 
 		for(dd=0; dd<iUserDatasets; dd++){
 			utype i = allRDatasets[dd];
 			ss << "|";
 		}
 
+		//fprintf(stderr, "ss %s\n", ss.str().c_str());
 		isFirst = true;		
 		for(j=0; j<m_vecstrAllQuery[l].size(); j++){
 			sq << m_vecstrAllQuery[l][j] << ":" << count[j];
 			sq << "|";
 		}
 
+		//fprintf(stderr, "sq %s\n", sq.str().c_str());
+		//fprintf(stderr, "aq %s\n", aq.str().c_str());
 	}
 
 	string refinedQuery = aq.str();
 			CMeta::Tokenize(sd[i].c_str(), m_vecstrSearchDatasets[i], " ", false);
 		}
 
+		//fprintf(stderr, "replace datasets %d %d\n", sd.size(), m_vecstrSearchDatasets[0].size());
+		//fprintf(stderr, "searchdsetMap size %d\n", m_searchdsetMap.size());
+
 		for(i=0; i<m_searchdsetMap.size(); i++){
 			delete m_searchdsetMap[i];
 		}
 		m_searchdsetMap.clear();
+		//fprintf(stderr, "cleared searchdsetMap\n");
 
 		m_searchdsetMap.resize(m_vecstrAllQuery.size());
 		for(i=0; i<m_vecstrAllQuery.size(); i++){
 		}
 	}
 
-	if(!CalculateRestart()) return false;
+	if(!CalculateRestart()){
+		fprintf(stderr, "Error occurred during CalculateRestart()\n");
+		return false;
+	}
+	fprintf(stderr, "Finished CalculateRestart()\n");
 
 	return true;
 }

File src/seekreader.h

 	static bool ReadArray(const char *fileName, vector<tType> &vData){
 		FILE *f = fopen(fileName, "rb");
 		if(f==NULL){
-			cerr << "File not found" << endl;
+			fprintf(stderr, "File not found %s\n", fileName);
 			return false;
 		}
 
 	static bool WriteArray(const char *fileName, const vector<tType> &vData){
 		FILE *f = fopen(fileName, "wb");
 		if(f==NULL){
-			cerr << "File not found" << endl;
+			fprintf(stderr, "File not found %s\n", fileName);
 			return false;
 		}
 		size_t i;

File tools/PCLServer/PCLServer.cpp

 		}
 		char acBuffer[lineSize];
 		utype c_iBuffer = lineSize;
-		map<string,string> parameters;
-		i=0;
+		vector<map<string,string> > parameters; //an array of CDatabase's
 		while(!ifsm.eof()){
 			ifsm.getline(acBuffer, c_iBuffer-1);
 			if(acBuffer[0]==0) break;
 			acBuffer[c_iBuffer-1]=0;
-			vector<string> tok;
-			CMeta::Tokenize(acBuffer, tok); //separator tab
-			parameters[tok[0]] = tok[1];
+			string strB = acBuffer;
+			if(strB=="START"){
+				map<string,string> p;
+				while(!ifsm.eof()){
+					ifsm.getline(acBuffer, c_iBuffer-1);
+					if(acBuffer[0]==0){
+						fprintf(stderr, "Invalid line (empty)\n");
+						return 1;
+					}
+					strB = acBuffer;
+					if(strB=="END") break;
+					vector<string> tok;
+					CMeta::Tokenize(acBuffer, tok); //separator is tab
+					p[tok[0]] = tok[1];
+				}
+				parameters.push_back(p);
+			}
 		}
 		ifsm.close();
+		if(parameters.size()==0){
+			fprintf(stderr, "Error, extra_db setting file must begin with START and end with END lines\n");
+			return 1;
+		}
 
+		for(i=0; i<parameters.size(); i++){
 		string sinfo_dir = "NA";
 		string gvar_dir = "NA";
 		string platform_dir = "NA";
 		string quant_file = "NA";
 		int num_db = -1;
 
-		if(parameters.find("SINFO_DIR")->second=="NA"){
+		if(parameters[i].find("SINFO_DIR")->second=="NA"){
 			fprintf(stderr, "Please specify an sinfo directory for the extra db\n");
 			return false;
 		}
-		sinfo_dir = parameters.find("SINFO_DIR")->second;
-		if(parameters.find("GVAR_DIR")!=parameters.end())
-			gvar_dir = parameters.find("GVAR_DIR")->second;
-		if(parameters.find("PREP_DIR")==parameters.end() ||
-			parameters.find("PLATFORM_DIR")==parameters.end() ||
-			parameters.find("DB_DIR")==parameters.end() ||
-			parameters.find("DSET_MAP_FILE")==parameters.end() ||
-			parameters.find("GENE_MAP_FILE")==parameters.end() ||
-			parameters.find("QUANT_FILE")==parameters.end() ||
-			parameters.find("NUMBER_OF_DB")==parameters.end()){
+		sinfo_dir = parameters[i].find("SINFO_DIR")->second;
+		if(parameters[i].find("GVAR_DIR")!=parameters[i].end())
+			gvar_dir = parameters[i].find("GVAR_DIR")->second;
+		if(parameters[i].find("PREP_DIR")==parameters[i].end() ||
+			parameters[i].find("PLATFORM_DIR")==parameters[i].end() ||
+			parameters[i].find("DB_DIR")==parameters[i].end() ||
+			parameters[i].find("DSET_MAP_FILE")==parameters[i].end() ||
+			parameters[i].find("GENE_MAP_FILE")==parameters[i].end() ||
+			parameters[i].find("QUANT_FILE")==parameters[i].end() ||
+			parameters[i].find("NUMBER_OF_DB")==parameters[i].end()){
 			fprintf(stderr, "Some arguments are missing. Please make sure the following are provided:\n");
 			fprintf(stderr, "PREP_DIR, DB_DIR, DSET_MAP_FILE, GENE_MAP_FILE, QUANT_FILE, NUMBER_OF_DB\n");
 			return false;
 		}
 
-		platform_dir = parameters.find("PLATFORM_DIR")->second;
-		db_dir = parameters.find("DB_DIR")->second;
-		prep_dir = parameters.find("PREP_DIR")->second;
-		dset_map_file = parameters.find("DSET_MAP_FILE")->second;
-		gene_map_file = parameters.find("GENE_MAP_FILE")->second;
-		quant_file = parameters.find("QUANT_FILE")->second;
-		num_db = atoi(parameters.find("NUMBER_OF_DB")->second.c_str());
+		platform_dir = parameters[i].find("PLATFORM_DIR")->second;
+		db_dir = parameters[i].find("DB_DIR")->second;
+		prep_dir = parameters[i].find("PREP_DIR")->second;
+		dset_map_file = parameters[i].find("DSET_MAP_FILE")->second;
+		gene_map_file = parameters[i].find("GENE_MAP_FILE")->second;
+		quant_file = parameters[i].find("QUANT_FILE")->second;
+		num_db = atoi(parameters[i].find("NUMBER_OF_DB")->second.c_str());
 
 		CSeekDBSetting *dbSetting2 = new CSeekDBSetting(gvar_dir, sinfo_dir,
 			platform_dir, prep_dir, db_dir, gene_map_file, quant_file, dset_map_file,
 			num_db);
 		cc.push_back(dbSetting2);
+		}
 	}
 	
 	if(!CSeekTools::ReadListTwoColumns(sArgs.gene_arg, vecstrGeneID, vecstrGenes))

File tools/SeekMiner/SeekMiner.cpp

 		}
 		char acBuffer[lineSize];
 		utype c_iBuffer = lineSize;
-		map<string,string> parameters;
-		i=0;
+		vector<map<string,string> > parameters; //an array of CDatabase's
 		while(!ifsm.eof()){
 			ifsm.getline(acBuffer, c_iBuffer-1);
 			if(acBuffer[0]==0) break;
 			acBuffer[c_iBuffer-1]=0;
-			vector<string> tok;
-			CMeta::Tokenize(acBuffer, tok); //separator tab
-			parameters[tok[0]] = tok[1];
+			string strB = acBuffer;
+			if(strB=="START"){
+				map<string,string> p;
+				while(!ifsm.eof()){
+					ifsm.getline(acBuffer, c_iBuffer-1);
+					if(acBuffer[0]==0){
+						fprintf(stderr, "Invalid line (empty)\n");
+						return 1;
+					}
+					strB = acBuffer;
+					if(strB=="END") break;
+					vector<string> tok;
+					CMeta::Tokenize(acBuffer, tok); //separator is tab
+					p[tok[0]] = tok[1];
+				}
+				parameters.push_back(p);
+			}
 		}
 		ifsm.close();
+		if(parameters.size()==0){
+			fprintf(stderr, "Error, extra_db setting file must begin with START and end with END lines\n");
+			return 1;
+		}
 
+		//i=0;
+		for(i=0; i<parameters.size(); i++){
 		string sinfo_dir = "NA";
 		string gvar_dir = "NA";
 		string platform_dir = "NA";
 		int num_db = -1;
 
 		if(eDistMeasure==CSeekDataset::CORRELATION){
-			if(parameters.find("SINFO_DIR")==parameters.end() ||
-				parameters.find("SINFO_DIR")->second=="NA"){
+			if(parameters[i].find("SINFO_DIR")==parameters[i].end() ||
+				parameters[i].find("SINFO_DIR")->second=="NA"){
 				fprintf(stderr, "Please specify an sinfo directory for the extra db\n");
 				return false;
 			}
-			sinfo_dir = parameters.find("SINFO_DIR")->second;
+			sinfo_dir = parameters[i].find("SINFO_DIR")->second;
 		}
-		if(parameters.find("GVAR_DIR")!=parameters.end())
-			gvar_dir = parameters.find("GVAR_DIR")->second;
-		if(parameters.find("PREP_DIR")==parameters.end() ||
-			parameters.find("PLATFORM_DIR")==parameters.end() ||
-			parameters.find("DB_DIR")==parameters.end() ||
-			parameters.find("DSET_MAP_FILE")==parameters.end() ||
-			parameters.find("GENE_MAP_FILE")==parameters.end() ||
-			parameters.find("QUANT_FILE")==parameters.end() ||
-			parameters.find("NUMBER_OF_DB")==parameters.end()){
+		if(parameters[i].find("GVAR_DIR")!=parameters[i].end())
+			gvar_dir = parameters[i].find("GVAR_DIR")->second;
+		if(parameters[i].find("PREP_DIR")==parameters[i].end() ||
+			parameters[i].find("PLATFORM_DIR")==parameters[i].end() ||
+			parameters[i].find("DB_DIR")==parameters[i].end() ||
+			parameters[i].find("DSET_MAP_FILE")==parameters[i].end() ||
+			parameters[i].find("GENE_MAP_FILE")==parameters[i].end() ||
+			parameters[i].find("QUANT_FILE")==parameters[i].end() ||
+			parameters[i].find("NUMBER_OF_DB")==parameters[i].end()){
 			fprintf(stderr, "Some arguments are missing. Please make sure the following are provided:\n");
 			fprintf(stderr, "PREP_DIR, DB_DIR, DSET_MAP_FILE, GENE_MAP_FILE, QUANT_FILE, NUMBER_OF_DB\n");
 		}
 
-		platform_dir = parameters.find("PLATFORM_DIR")->second;
-		db_dir = parameters.find("DB_DIR")->second;
-		prep_dir = parameters.find("PREP_DIR")->second;
-		dset_map_file = parameters.find("DSET_MAP_FILE")->second;
-		gene_map_file = parameters.find("GENE_MAP_FILE")->second;
-		quant_file = parameters.find("QUANT_FILE")->second;
-		num_db = atoi(parameters.find("NUMBER_OF_DB")->second.c_str());
+		platform_dir = parameters[i].find("PLATFORM_DIR")->second;
+		db_dir = parameters[i].find("DB_DIR")->second;
+		prep_dir = parameters[i].find("PREP_DIR")->second;
+		dset_map_file = parameters[i].find("DSET_MAP_FILE")->second;
+		gene_map_file = parameters[i].find("GENE_MAP_FILE")->second;
+		quant_file = parameters[i].find("QUANT_FILE")->second;
+		num_db = atoi(parameters[i].find("NUMBER_OF_DB")->second.c_str());
 
 		CSeekDBSetting *dbSetting2 = new CSeekDBSetting(gvar_dir, sinfo_dir,
 			platform_dir, prep_dir, db_dir, gene_map_file, quant_file, dset_map_file,
 			num_db);
 		cc.push_back(dbSetting2);
+		}
 	}
 
 	if(!csfinal->Initialize(cc,
 	//csfinal->EqualWeightSearch();
 	//csfinal->CVSearch(rnd, PART_M, FOLD, RATE);
 	//csfinal->OrderStatistics();
+	fprintf(stderr, "Destructing...\n");
 	csfinal->Destruct();
+	fprintf(stderr, "Deleting...\n");
 	delete csfinal;
-	delete dbSetting;
 
+	fprintf(stderr, "Deleting DBSetting...\n");
 	if(add_db!="NA"){
-		delete cc[1];
+		for(i=0; i<cc.size(); i++){
+			delete cc[i];
+		}
 	}
+	fprintf(stderr, "Finished deleting DBSetting...\n");
 
 	cc.clear();
 

File tools/SeekPrep/SeekPrep.cpp

 				}
 			}
 
-			//for(i=0; i<numPlatforms; i++){
-				//printf("Platform %s\n", mapistrPlatform[i].c_str());
-				/*for(j=0; j<vecstrQuery.size(); j++){
+			/*
+			for(i=0; i<numPlatforms; i++){
+				printf("Platform %s\n", mapistrPlatform[i].c_str());
+				for(j=0; j<vecstrQuery.size(); j++){
 					size_t iGene = mapstriGenes[vecstrQuery[j]];
 					printf("Gene %s %.5f %.5f\n", vecstrQuery[j].c_str(), 
 						platform_avg.Get(i, iGene), platform_stdev.Get(i,iGene));
-				}*/
-			//}
+				}
+			}*/
 
 			char outFile[125];
 			sprintf(outFile, "%s/all_platforms.gplatavg", sArgs.dir_out_arg);

File tools/SeekServer/SeekServer.cpp

 		}
 		char acBuffer[lineSize];
 		utype c_iBuffer = lineSize;
-		map<string,string> parameters;
-		i=0;
+		vector<map<string,string> > parameters; //an array of CDatabase's
 		while(!ifsm.eof()){
 			ifsm.getline(acBuffer, c_iBuffer-1);
 			if(acBuffer[0]==0) break;
 			acBuffer[c_iBuffer-1]=0;
-			vector<string> tok;
-			CMeta::Tokenize(acBuffer, tok); //separator tab
-			parameters[tok[0]] = tok[1];
+			string strB = acBuffer;
+			if(strB=="START"){
+				map<string,string> p;
+				while(!ifsm.eof()){
+					ifsm.getline(acBuffer, c_iBuffer-1);
+					if(acBuffer[0]==0){
+						fprintf(stderr, "Invalid line (empty)\n");
+						return 1;
+					}
+					strB = acBuffer;
+					if(strB=="END") break;
+					vector<string> tok;
+					CMeta::Tokenize(acBuffer, tok); //separator is tab
+					p[tok[0]] = tok[1];
+				}
+				parameters.push_back(p);
+			}
 		}
 		ifsm.close();
+		if(parameters.size()==0){
+			fprintf(stderr, "Error, extra_db setting file must begin with START and end with END lines\n");
+			return 1;
+		}
 
+		for(i=0; i<parameters.size(); i++){
 		string sinfo_dir = "NA";
 		string gvar_dir = "NA";
 		string platform_dir = "NA";
 		string quant_file = "NA";
 		int num_db = -1;
 
-		if(parameters.find("SINFO_DIR")->second=="NA"){
+		if(parameters[i].find("SINFO_DIR")->second=="NA"){
 			fprintf(stderr, "Please specify an sinfo directory for the extra db\n");
 			return false;
 		}
-		sinfo_dir = parameters.find("SINFO_DIR")->second;
-		if(parameters.find("GVAR_DIR")!=parameters.end())
-			gvar_dir = parameters.find("GVAR_DIR")->second;
-		if(parameters.find("PREP_DIR")==parameters.end() ||
-			parameters.find("PLATFORM_DIR")==parameters.end() ||
-			parameters.find("DB_DIR")==parameters.end() ||
-			parameters.find("DSET_MAP_FILE")==parameters.end() ||
-			parameters.find("GENE_MAP_FILE")==parameters.end() ||
-			parameters.find("QUANT_FILE")==parameters.end() ||
-			parameters.find("NUMBER_OF_DB")==parameters.end()){
+		sinfo_dir = parameters[i].find("SINFO_DIR")->second;
+		if(parameters[i].find("GVAR_DIR")!=parameters[i].end())
+			gvar_dir = parameters[i].find("GVAR_DIR")->second;
+		if(parameters[i].find("PREP_DIR")==parameters[i].end() ||
+			parameters[i].find("PLATFORM_DIR")==parameters[i].end() ||
+			parameters[i].find("DB_DIR")==parameters[i].end() ||
+			parameters[i].find("DSET_MAP_FILE")==parameters[i].end() ||
+			parameters[i].find("GENE_MAP_FILE")==parameters[i].end() ||
+			parameters[i].find("QUANT_FILE")==parameters[i].end() ||
+			parameters[i].find("NUMBER_OF_DB")==parameters[i].end()){
 			fprintf(stderr, "Some arguments are missing. Please make sure the following are provided:\n");
 			fprintf(stderr, "PREP_DIR, DB_DIR, DSET_MAP_FILE, GENE_MAP_FILE, QUANT_FILE, NUMBER_OF_DB\n");
 			return false;
 		}
 
-		platform_dir = parameters.find("PLATFORM_DIR")->second;
-		db_dir = parameters.find("DB_DIR")->second;
-		prep_dir = parameters.find("PREP_DIR")->second;
-		dset_map_file = parameters.find("DSET_MAP_FILE")->second;
-		gene_map_file = parameters.find("GENE_MAP_FILE")->second;
-		quant_file = parameters.find("QUANT_FILE")->second;
-		num_db = atoi(parameters.find("NUMBER_OF_DB")->second.c_str());
+		platform_dir = parameters[i].find("PLATFORM_DIR")->second;
+		db_dir = parameters[i].find("DB_DIR")->second;
+		prep_dir = parameters[i].find("PREP_DIR")->second;
+		dset_map_file = parameters[i].find("DSET_MAP_FILE")->second;
+		gene_map_file = parameters[i].find("GENE_MAP_FILE")->second;
+		quant_file = parameters[i].find("QUANT_FILE")->second;
+		num_db = atoi(parameters[i].find("NUMBER_OF_DB")->second.c_str());
 
 		CSeekDBSetting *dbSetting2 = new CSeekDBSetting(gvar_dir, sinfo_dir,
 			platform_dir, prep_dir, db_dir, gene_map_file, quant_file, dset_map_file,
 			num_db);
 		cc.push_back(dbSetting2);
+		}
 	}
 
 	if(!csfinal->Initialize(cc,
 		0.0, //min query fraction (to be overwrriten)
 		!!sArgs.square_z_flag, //default
 		false, 1, NULL, useNibble)) //default
+	{
+		fprintf(stderr, "Error occurred!\n");
 		return -1;
+	}
 
 	signal(SIGPIPE, SIG_IGN);
 	//utype i;