1. libsleipnir
  2. sleipnir

Commits

Jian Zhou  committed 83726d4 Merge

Merge

  • Participants
  • Parent commits 78945af, 3f4afc5
  • Branches sleipnir

Comments (0)

Files changed (28)

File configure.ac

View file
  • Ignore whitespace
                  tools/Data2Svm/Makefile \
 		 tools/SVMer/Makefile \
 		 tools/SVMperfer/Makefile \
+		 tools/SVMperfing/Makefile \
 		 tools/VWer/Makefile \
                  tools/OntoShell/Makefile \
                  tools/BNServer/Makefile])

File gen_tools_am

View file
  • Ignore whitespace
 			    OntoShell => ['READLINE'],
 			    SVMer => ['SVM_PERF'],
 			    SVMperfer => ['SVM_PERF'],
+			    SVMperfing => ['SVM_PERF'],
 			    VWer => ['VOWPAL_WABBIT'],
 			    );
 

File src/dat.cpp

View file
  • Ignore whitespace
 	unsigned char bufferB;
 	
 	float nan_val;
-
+	
 	if( !OpenGenes( istm, true, false ) )
 		return false;
 	m_Data.Initialize( GetGenes( ) );
 			continue; }
 		if( ( eFilter == EFilterEdge ) && vecfGenes[ i ] )
 			continue;
+		if( ( eFilter == EFilterExEdge ) && !vecfGenes[ i ] )
+			continue;
 		for( j = ( i + 1 ); j < GetGenes( ); ++j )
 			switch( eFilter ) {
 				case EFilterInclude:
 					if( !( vecfGenes[ i ] && vecfGenes[ j ] ) &&
 						( !( vecfGenes[ i ] || vecfGenes[ j ] ) || Get( i, j ) ) )
 						Set( i, j, CMeta::GetNaN( ) );
-					break;
-
+					break;					
+			        case EFilterExEdge:
+				        if( vecfGenes[ j ] )
+					  Set( i, j, CMeta::GetNaN( ) );
+				        break;
 				case EFilterExclude:
 					if( vecfGenes[ j ] )
 						Set( i, j, CMeta::GetNaN( ) );

File src/dat.h

View file
  • Ignore whitespace
 		 * \brief
 		 * Remove any positive edge including a node outside the given set. 
 		 */
-		EFilterIncludePos	= EFilterHefalmp +1
-		
+		EFilterIncludePos	= EFilterHefalmp +1,		
+		/*!
+		 * \brief
+		 * Remove edges which both gene is in the given set. 
+		 */
+		EFilterExEdge	= EFilterIncludePos +1
+
 	};
 
 	/*!

File src/pcl.cpp

View file
  • Ignore whitespace
 //}
 
 
-bool CPCL::Open(const char* szFile, size_t iSkip, bool Memmap) {
+bool CPCL::Open(const char* szFile, size_t iSkip, bool Memmap, bool rTable) {
 	bool isBinary = false;
 	bool isDAB = false;
 	ifstream ifsm;
 	} else {
 		ifstream ifsm;
 		if (szFile)
-			ifsm.open(szFile);
-		return Open(szFile ? ifsm : cin, iSkip);
+		  ifsm.open(szFile);
+		return Open(szFile ? ifsm : cin, iSkip, rTable);
 	}
 }
 
  * \param iSkip
  * Number of feature columns to skip between the gene IDs and first experimental column.
  *
+ * \param rTable
+ * Is this PCL file generated by R language (This means its missing the "YORF" label in the first line, thus has 1 less token compared to sleipnir PCL format)
+ *
  * \returns
  * True if the PCL was opened successfully.
  *
  * Save
  */
 
-bool CPCL::Open(std::istream& istm, size_t iSkip) {
+bool CPCL::Open(std::istream& istm, size_t iSkip, bool rTable) {
 	vector<float> vecdData;
 	size_t i;
 	char* acBuf;
 		return false;
 
 	acStr.reserve(c_iBufferSize);
-
-	if (!OpenExperiments(istm, iSkip, acStr))
+	
+	if (!OpenExperiments(istm, iSkip, acStr, rTable))
 		fRet = false;
 	else {
 		m_vecvecstrFeatures.resize(m_vecstrFeatures.size() - 1);
 }
 
 bool CPCLImpl::OpenExperiments(std::istream& istmInput, size_t iFeatures,
-		string& acStr) {
+			       string& acStr, bool rTable) {
 	const char* pc;
 	string strToken;
 	size_t iToken;
-
+	
 	Reset();
 	if (!m_fHeader) {
 		m_vecstrFeatures.resize(1 + iFeatures);
 	if (!acStr.size()) {
 		return false;
 	}
+	
+	if(rTable){	  
+	  m_vecstrFeatures.push_back("");
+	}
+	
 	for (iToken = 0, pc = acStr.c_str(); (strToken = OpenToken(pc, &pc)).length()
 			|| *pc; ++iToken)
-		if (iToken <= iFeatures)
-			m_vecstrFeatures.push_back(strToken);
-		else
-			m_vecstrExperiments.push_back(strToken);
-
+	  if (iToken < iFeatures)
+	    m_vecstrFeatures.push_back(strToken);
+	  else if (iToken <= iFeatures && !rTable)
+	    m_vecstrFeatures.push_back(strToken);
+	  else
+	    m_vecstrExperiments.push_back(strToken);
+	
 	return true;
 }
 

File src/pcl.h

View file
  • Ignore whitespace
 		 * \param iSkip
 		 * Number of feature columns to skip between the gene IDs and first experimental column.
 		 *
+		 * \param rTable
+		 * Is this PCL file generated by R language (This means its missing the "YORF" label in the first line, thus has 1 less token compared to sleipnir PCL format)
+		 *
 		 * \returns
 		 * True if the PCL was opened successfully.
 		 *
 		 * \see
 	 * Save
 	 */
-
-	bool Open(const char* szFile, size_t iSkip = 2, bool fMemmap = false);
-
-	bool Open(std::istream& istm, size_t iSkip );
+	
+	bool Open(const char* szFile, size_t iSkip = 2, bool fMemmap = false, bool rTable = false);
+	
+	bool Open(std::istream& istm, size_t iSkip, bool rTable = false);
 
 	/*!
 	 * \brief

File src/pcli.h

View file
  • Ignore whitespace
 		m_fHeader(fHeader) {
 	}
 	~CPCLImpl();
-
-	bool OpenExperiments(std::istream&, size_t, string&);
+	
+	bool OpenExperiments(std::istream&, size_t, string&, bool rTable=false);
 	bool OpenGene(std::istream&, std::vector<float>&, string&);
 	void Reset();
 	void MedianMultiplesMapped(const std::vector<std::vector<size_t> >&,

File src/svmperf.cpp

View file
  • Ignore whitespace
 	}
 }
 
+
+// populate docs for each label gene pair from a vector of dat file names
+bool CSVMPERF::CreateDoc(vector<string>& vecstrDatasets,
+			 vector<SVMLabelPair*>& vecLabels,
+			 const vector<string>& LabelsGene){
+  
+  size_t i, j, k, iGene, jGene, iDoc, iWord, iWords;
+  float d;
+  vector<size_t> veciGene;  
+  vector<WORD*> vec_pWord;
+  vector<size_t> labelg2dat;  
+  
+  WORD* aWords;
+  DOC* pRet;	
+  //Sleipnir::CDat Dat;
+  
+  iWords = vecstrDatasets.size();
+  
+  vec_pWord.reserve(vecLabels.size());
+  
+  // initialize all the WORDs
+  for(i=0; i < vecLabels.size(); i++){
+    aWords = new WORD[iWords + 1];
+    
+    // set wnum values
+    for (k = 0; k < iWords; ++k) {
+      //   cout<<i<<endl;
+      aWords[k].wnum = k + 1;
+      // asWords[ i ].wnum = 0;
+    }
+    aWords[k].wnum = 0;    
+    vec_pWord[i] = aWords;
+  }
+  
+  // initialize the gene mappings 
+  labelg2dat.resize(LabelsGene.size());
+  
+  // now open up all datasets
+  for(i=0; i < vecstrDatasets.size(); i++){
+    Sleipnir::CDat Dat;
+    if(!Dat.Open(vecstrDatasets[i].c_str())) {
+      cerr << vecstrDatasets[i].c_str() << endl;
+      cerr << "Could not open: " << vecstrDatasets[i] << endl;
+      return false;
+    }
+    
+    cerr << "Open: " << vecstrDatasets[i] << endl;
+    
+    // construct gene name mapping
+    for(k=0; k < LabelsGene.size(); k++){
+      labelg2dat[k] = Dat.GetGene(LabelsGene[k]);
+    }    
+    /////
+    
+    for (j = 0; j < vecLabels.size(); j++) {
+      aWords = vec_pWord[j];
+            
+      if( ((iGene = labelg2dat[vecLabels[j]->iidx]) == -1 ) || 
+	  ((jGene = labelg2dat[vecLabels[j]->jidx]) == -1 )){
+	aWords[i].weight = 0;
+	continue;
+      }      
+      
+      if (!Sleipnir::CMeta::IsNaN(d = Dat.Get(iGene, jGene))) {
+	aWords[i].weight = d;
+      } else
+	aWords[i].weight = 0;            
+    }
+  }
+  
+  // now create a Doc per label
+  for (j = 0; j < vecLabels.size(); j++) {
+    //pRet->fvec->words[0].weight;
+    aWords = vec_pWord[j];
+    pRet = create_example(j, 0, 0, 1, create_svector(aWords, "", 1));
+    vecLabels[j]->pDoc = pRet;
+    delete[] aWords;
+  }
+  
+  return true;
 }
 
+SAMPLE* CSVMPERF::CreateSample(vector<SVMLabelPair*>& SVMLabels) {
+	size_t i, j, iGene, iDoc;
+	vector<DOC*> vec_pDoc;
+	vector<double> vecClass;
+	iDoc = 0;
+	for (i = 0; i < SVMLabels.size(); i++) {
+	  iDoc++;
+	  vec_pDoc.push_back(SVMLabels[i]->pDoc);
+	  vecClass.push_back(SVMLabels[i]->Target);
+	}
+	
+	DOC** ppDoc;
+	ppDoc = new DOC*[vec_pDoc.size()];
+	copy(vec_pDoc.begin(), vec_pDoc.end(), ppDoc);
+	vec_pDoc.clear();
+	PATTERN* pPattern = new PATTERN;
+	pPattern->doc = ppDoc;
+
+	pPattern->totdoc = iDoc;
+	//   cout << "number of document=" << pPattern->totdoc << endl;
+	LABEL* pLabel = new LABEL;
+	double* aClass;
+	aClass = new double[vecClass.size()];
+	copy(vecClass.begin(), vecClass.end(), aClass);
+	vecClass.clear();
+	pLabel->Class = aClass;
+	pLabel->totdoc = iDoc;
+	
+	EXAMPLE* aExample;
+	aExample = new EXAMPLE[1];
+	//cout<<"aExample @"<<aExample<<endl;
+	aExample[0].x = *pPattern;
+	aExample[0].y = *pLabel;
+	SAMPLE* pSample = new SAMPLE;
+	pSample->n = 1;
+	pSample->examples = aExample;
+	/* cout << "examples @" << pSample->examples << endl;
+	 cout<< "ppDoc="<<ppDoc<<endl;
+	 cout << "docs @" << pSample->examples[0].x.doc << endl;
+	 cout<<"done creating sample"<<endl;
+	 cout<<"sample @ "<<pSample<<endl;*/
+	return pSample;
+}
+
+void CSVMPERF::Classify(Sleipnir::CDat &Results,
+				  vector<SVMLabelPair*>& SVMLabels) {
+	size_t i, iGene, iDoc;
+	iDoc = 0;
+	DOC** ppDoc;
+	ppDoc = new DOC*[1];
+	PATTERN pattern;
+	pattern.doc = ppDoc;
+	pattern.totdoc = 1;
+	//cerr << "CLASSIFY classifying " << endl;
+	LABEL label;
+	for (i = 0; i < SVMLabels.size(); i++) {
+	  ppDoc[0] = SVMLabels[i]->pDoc;
+	  label
+	    = classify_struct_example(pattern, &structmodel,
+				      &struct_parm);
+	  
+	  Results.Set(SVMLabels[i]->iidx, SVMLabels[i]->jidx, label.Class[0]);
+	}
+	
+	
+	delete ppDoc;
+}
+
+void CSVMPERF::FreeSample_leave_Doc(SAMPLE s){
+  /* Frees the memory of sample s. */
+  int i;
+  for(i=0;i<s.n;i++) {
+    free(s.examples[i].x.doc);
+    free_label(s.examples[i].y);
+  }
+  free(s.examples);
+}
+
+  
+}
+

File src/svmperf.h

View file
  • Ignore whitespace
 	}
 };
 
+class SVMLabelPair {
+public:
+	double Target;
+	size_t iidx;
+	size_t jidx;
+	bool hasIndex;
+	DOC* pDoc;
+	
+	SVMLabelPair(double target, size_t i, size_t j) {
+		Target = target;
+		hasIndex = true;
+		iidx = i;
+		jidx = j;
+	}
+
+	SVMLabelPair() {
+		Target = 0;
+		hasIndex = false;
+	}
+	
+	void SetIndex(size_t i, size_t j) {
+		iidx = i;
+		jidx = j;
+		hasIndex = true;
+	}
+	
+	void SetDoc(DOC* inDoc) {
+	  pDoc = inDoc;
+	}
+	DOC* GetDoc() {
+	  return pDoc;
+	}	
+};
+
 class Result {
 public:
 	std::string GeneName;
 		}
 		cerr << "ALG=" << Alg << endl;
 		svm_learn_struct_joint(sample, &struct_parm, &learn_parm, &kernel_parm,
-				&structmodel, Alg);
+				       &structmodel, Alg);
 		//
 	}
 
 			string>& CVGenes);
 	bool parms_check();
 	bool initialize();
+	
+	
+	//Pair & Multiple dabs learning
+	static bool CreateDoc(vector<string>& vecstrDatasets,
+				 vector<SVMLabelPair*>& vecLabels,
+				 const vector<string>& LabelsGene);
+	
+	static SAMPLE* CreateSample(vector<SVMLabelPair*>& SVMLabels);	
+	void Classify(Sleipnir::CDat &Results,
+		      vector<SVMLabelPair*>& SVMLabels);
+	
+	// free the sample but don't free the Docs
+	static void FreeSample_leave_Doc(SAMPLE s);
 };
 }
 

File tools/Counter/Counter.cpp

View file
  • Ignore whitespace
 					}
 					else
 					psData->m_pMatCounts->Get( iVal, iAnswer )++;
-					//FIXME: Regularization has not support weighted context
+					//FIXME: Regularization has not supportted weighted context
 					psData->m_pRegularize->Add( psData->m_iDat, *psData->m_pDat, i, j, iVal );
 			}
 			else{

File tools/Dat2Dab/Dat2Dab.cpp

View file
  • Ignore whitespace
 		Dat.FilterGenes( sArgs.genex_arg, CDat::EFilterExclude );
 	if( sArgs.genee_arg )
 		Dat.FilterGenes( sArgs.genee_arg, CDat::EFilterEdge );
-
+	if( sArgs.gexedges_arg )
+		Dat.FilterGenes( sArgs.gexedges_arg, CDat::EFilterExEdge );
+	
 	if( sArgs.paircount_flag ) {
 		size_t			iTotal, iCutoff;
 		float			d, dAve, dStd;

File tools/Dat2Dab/Dat2Dab.ggo

View file
  • Ignore whitespace
 							string	typestr="filename"
 option	"exedges"		x	"Exclude edges from the given DAT/DAB"
 							string	typestr="filename"
+option	"gexedges"		X	"Exclude all edges which both genes from the given set"
+							string	typestr="filename"
 option	"cutoff"		c	"Exclude edges below cutoff"
 							double
 option	"zero"			Z	"Zero missing values"

File tools/Dat2Dab/cmdline.c

View file
  • Ignore whitespace
 /*
   File autogenerated by gengetopt version 2.22
   generated with the following command:
-  /r03/cypark/sleipnir/../sleipnir-extlib/gengetopt-2.22/src/gengetopt -iDat2Dab.ggo --default-optional -u -N -e 
+  /Genomics/ogtr03/cypark/sleipnir/../sleipnir-extlib/gengetopt-2.22/src/gengetopt -iDat2Dab.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:
   "  -D, --genee=filename     Process only edges including a gene from the given \n                             set",
   "  -e, --edges=filename     Process only edges from the given DAT/DAB",
   "  -x, --exedges=filename   Exclude edges from the given DAT/DAB",
+  "  -X, --gexedges=filename  Exclude all edges which both genes from the given \n                             set",
   "  -c, --cutoff=DOUBLE      Exclude edges below cutoff",
   "  -Z, --zero               Zero missing values  (default=off)",
   "  -V, --dval=FLOAT         set all non-missing values to a set default value",
   args_info->genee_given = 0 ;
   args_info->edges_given = 0 ;
   args_info->exedges_given = 0 ;
+  args_info->gexedges_given = 0 ;
   args_info->cutoff_given = 0 ;
   args_info->zero_given = 0 ;
   args_info->dval_given = 0 ;
   args_info->edges_orig = NULL;
   args_info->exedges_arg = NULL;
   args_info->exedges_orig = NULL;
+  args_info->gexedges_arg = NULL;
+  args_info->gexedges_orig = NULL;
   args_info->cutoff_orig = NULL;
   args_info->zero_flag = 0;
   args_info->dval_orig = NULL;
   args_info->genee_help = gengetopt_args_info_help[15] ;
   args_info->edges_help = gengetopt_args_info_help[16] ;
   args_info->exedges_help = gengetopt_args_info_help[17] ;
-  args_info->cutoff_help = gengetopt_args_info_help[18] ;
-  args_info->zero_help = gengetopt_args_info_help[19] ;
-  args_info->dval_help = gengetopt_args_info_help[20] ;
-  args_info->dmissing_help = gengetopt_args_info_help[21] ;
-  args_info->duplicates_help = gengetopt_args_info_help[22] ;
-  args_info->subsample_help = gengetopt_args_info_help[23] ;
-  args_info->lookup1_help = gengetopt_args_info_help[25] ;
-  args_info->lookup2_help = gengetopt_args_info_help[26] ;
-  args_info->lookups1_help = gengetopt_args_info_help[27] ;
-  args_info->lookups2_help = gengetopt_args_info_help[28] ;
-  args_info->genelist_help = gengetopt_args_info_help[29] ;
-  args_info->paircount_help = gengetopt_args_info_help[30] ;
-  args_info->remap_help = gengetopt_args_info_help[32] ;
-  args_info->table_help = gengetopt_args_info_help[33] ;
-  args_info->skip_help = gengetopt_args_info_help[34] ;
-  args_info->memmap_help = gengetopt_args_info_help[35] ;
-  args_info->random_help = gengetopt_args_info_help[36] ;
-  args_info->noise_help = gengetopt_args_info_help[37] ;
-  args_info->verbosity_help = gengetopt_args_info_help[38] ;
+  args_info->gexedges_help = gengetopt_args_info_help[18] ;
+  args_info->cutoff_help = gengetopt_args_info_help[19] ;
+  args_info->zero_help = gengetopt_args_info_help[20] ;
+  args_info->dval_help = gengetopt_args_info_help[21] ;
+  args_info->dmissing_help = gengetopt_args_info_help[22] ;
+  args_info->duplicates_help = gengetopt_args_info_help[23] ;
+  args_info->subsample_help = gengetopt_args_info_help[24] ;
+  args_info->lookup1_help = gengetopt_args_info_help[26] ;
+  args_info->lookup2_help = gengetopt_args_info_help[27] ;
+  args_info->lookups1_help = gengetopt_args_info_help[28] ;
+  args_info->lookups2_help = gengetopt_args_info_help[29] ;
+  args_info->genelist_help = gengetopt_args_info_help[30] ;
+  args_info->paircount_help = gengetopt_args_info_help[31] ;
+  args_info->remap_help = gengetopt_args_info_help[33] ;
+  args_info->table_help = gengetopt_args_info_help[34] ;
+  args_info->skip_help = gengetopt_args_info_help[35] ;
+  args_info->memmap_help = gengetopt_args_info_help[36] ;
+  args_info->random_help = gengetopt_args_info_help[37] ;
+  args_info->noise_help = gengetopt_args_info_help[38] ;
+  args_info->verbosity_help = gengetopt_args_info_help[39] ;
   
 }
 
   free_string_field (&(args_info->edges_orig));
   free_string_field (&(args_info->exedges_arg));
   free_string_field (&(args_info->exedges_orig));
+  free_string_field (&(args_info->gexedges_arg));
+  free_string_field (&(args_info->gexedges_orig));
   free_string_field (&(args_info->cutoff_orig));
   free_string_field (&(args_info->dval_orig));
   free_string_field (&(args_info->dmissing_orig));
     write_into_file(outfile, "edges", args_info->edges_orig, 0);
   if (args_info->exedges_given)
     write_into_file(outfile, "exedges", args_info->exedges_orig, 0);
+  if (args_info->gexedges_given)
+    write_into_file(outfile, "gexedges", args_info->gexedges_orig, 0);
   if (args_info->cutoff_given)
     write_into_file(outfile, "cutoff", args_info->cutoff_orig, 0);
   if (args_info->zero_given)
         { "genee",	1, NULL, 'D' },
         { "edges",	1, NULL, 'e' },
         { "exedges",	1, NULL, 'x' },
+        { "gexedges",	1, NULL, 'X' },
         { "cutoff",	1, NULL, 'c' },
         { "zero",	0, NULL, 'Z' },
         { "dval",	1, NULL, 'V' },
         { NULL,	0, NULL, 0 }
       };
 
-      c = getopt_long (argc, argv, "hi:o:q:fnzrag:G:D:e:x:c:ZV:M:du:l:L:t:T:EPp:bs:mR:Nv:", long_options, &option_index);
+      c = getopt_long (argc, argv, "hi:o:q:fnzrag:G:D:e:x:X:c:ZV:M:du:l:L:t:T:EPp:bs:mR:Nv:", long_options, &option_index);
 
       if (c == -1) break;	/* Exit from `while (1)' loop.  */
 
             goto failure;
         
           break;
+        case 'X':	/* Exclude all edges which both genes from the given set.  */
+        
+        
+          if (update_arg( (void *)&(args_info->gexedges_arg), 
+               &(args_info->gexedges_orig), &(args_info->gexedges_given),
+              &(local_args_info.gexedges_given), optarg, 0, 0, ARG_STRING,
+              check_ambiguity, override, 0, 0,
+              "gexedges", 'X',
+              additional_error))
+            goto failure;
+        
+          break;
         case 'c':	/* Exclude edges below cutoff.  */
         
         

File tools/Dat2Dab/cmdline.h

View file
  • Ignore whitespace
   char * exedges_arg;	/**< @brief Exclude edges from the given DAT/DAB.  */
   char * exedges_orig;	/**< @brief Exclude edges from the given DAT/DAB original value given at command line.  */
   const char *exedges_help; /**< @brief Exclude edges from the given DAT/DAB help description.  */
+  char * gexedges_arg;	/**< @brief Exclude all edges which both genes from the given set.  */
+  char * gexedges_orig;	/**< @brief Exclude all edges which both genes from the given set original value given at command line.  */
+  const char *gexedges_help; /**< @brief Exclude all edges which both genes from the given set help description.  */
   double cutoff_arg;	/**< @brief Exclude edges below cutoff.  */
   char * cutoff_orig;	/**< @brief Exclude edges below cutoff original value given at command line.  */
   const char *cutoff_help; /**< @brief Exclude edges below cutoff help description.  */
   unsigned int genee_given ;	/**< @brief Whether genee was given.  */
   unsigned int edges_given ;	/**< @brief Whether edges was given.  */
   unsigned int exedges_given ;	/**< @brief Whether exedges was given.  */
+  unsigned int gexedges_given ;	/**< @brief Whether gexedges was given.  */
   unsigned int cutoff_given ;	/**< @brief Whether cutoff was given.  */
   unsigned int zero_given ;	/**< @brief Whether zero was given.  */
   unsigned int dval_given ;	/**< @brief Whether dval was given.  */

File tools/Dat2PCL/Dat2PCL.cpp

View file
  • Ignore whitespace
 	CGenome Genome;
 	CGenes Genes(Genome);       
 	CPCL PCL;
+	CPCL aPCL;
 	CDat Dat;
-	size_t i, j;
+	size_t i, j, iArg;
 	bool fModified;
 	vector<string> features;
+	vector<string> input_files;
 	
 	if (cmdline_parser(iArgs, aszArgs, &sArgs)) {
 		cmdline_parser_print_help();
 	}
 	CMeta Meta(sArgs.verbosity_arg);
 	
-	if( !Dat.Open( sArgs.input_arg, false, 0, false, true)){
-	  cerr << "Could not open: " << sArgs.input_arg << endl;
-	  return 1; }
+	if(sArgs.input_given){
+	  if( !Dat.Open( sArgs.input_arg, false, 0, false, true)){
+	    cerr << "Could not open: " << sArgs.input_arg << endl;
+	    return 1; }
+	  
+	  PCL.Open( Dat.GetGeneNames( ), Dat.GetGeneNames( ), features);
 	
-	PCL.Open( Dat.GetGeneNames( ), Dat.GetGeneNames( ), features);
+	  cerr << "Gene count: " << Dat.GetGenes() << endl;
 	
-	cerr << "Gene count: " << Dat.GetGenes() << endl;
+	  PCL.populate( sArgs.input_arg );
+	}
+	else{
+	  if(sArgs.inputs_num > 0){
+	    input_files.resize( sArgs.inputs_num );
+	    copy( sArgs.inputs, sArgs.inputs + sArgs.inputs_num, input_files.begin( ) );
+	    
+	    for( iArg = 0; iArg < input_files.size(); ++iArg ) {
+	      
+	      if( !aPCL.Open(input_files[ iArg ].c_str(), sArgs.skip_arg, false, sArgs.rPCL_flag ) ) {
+		cerr << "Could not open: " << input_files[ iArg ] << endl;
+		return 1; }
+	      
+	      cerr << "Open: " << input_files[ iArg ] << endl;
+	      
+	      if(iArg == 0)
+		PCL.Open(aPCL);
+	      else{
+		for( i = 0; i < PCL.GetGenes( ); ++i )
+		  for( j = 0; j < PCL.GetExperiments( ); ++j )
+		    PCL.Set(i,j, aPCL.Get(i,j)+PCL.Get(i,j) );
+	      }
+	    }
+	  }
+	  else{
+	    return 1;
+	  }
+	}
 	
-	PCL.populate( sArgs.input_arg );
-		
+	
 	if (sArgs.output_arg) {	  
 	  PCL.Save(sArgs.output_arg);
 	} else {

File tools/Dat2PCL/Dat2PCL.ggo

View file
  • Ignore whitespace
 section "Optional"
 option	"verbosity"		v	"Message verbosity"
 							int	default="5" no
+option	"skip"			s	"Columns to skip in input PCL"
+							int	default="0" no
+option	"rPCL"			r	"Is the input PCL files generated by R, thus missing the first token in the col names row"
+							flag	off

File tools/Dat2PCL/cmdline.c

View file
  • Ignore whitespace
   "  -o, --output=filename  Output PCL/BIN file",
   "\nOptional:",
   "  -v, --verbosity=INT    Message verbosity  (default=`5')",
+  "  -s, --skip=INT         Columns to skip in input PCL  (default=`0')",
+  "  -r, --rPCL             Is the input PCL files generated by R, thus missing \n                           the first token in the col names row  (default=off)",
     0
 };
 
 typedef enum {ARG_NO
+  , ARG_FLAG
   , ARG_STRING
   , ARG_INT
 } cmdline_parser_arg_type;
   args_info->input_given = 0 ;
   args_info->output_given = 0 ;
   args_info->verbosity_given = 0 ;
+  args_info->skip_given = 0 ;
+  args_info->rPCL_given = 0 ;
 }
 
 static
   args_info->output_orig = NULL;
   args_info->verbosity_arg = 5;
   args_info->verbosity_orig = NULL;
+  args_info->skip_arg = 0;
+  args_info->skip_orig = NULL;
+  args_info->rPCL_flag = 0;
   
 }
 
   args_info->input_help = gengetopt_args_info_help[3] ;
   args_info->output_help = gengetopt_args_info_help[4] ;
   args_info->verbosity_help = gengetopt_args_info_help[6] ;
+  args_info->skip_help = gengetopt_args_info_help[7] ;
+  args_info->rPCL_help = gengetopt_args_info_help[8] ;
   
 }
 
   free_string_field (&(args_info->output_arg));
   free_string_field (&(args_info->output_orig));
   free_string_field (&(args_info->verbosity_orig));
+  free_string_field (&(args_info->skip_orig));
   
   
   for (i = 0; i < args_info->inputs_num; ++i)
     write_into_file(outfile, "output", args_info->output_orig, 0);
   if (args_info->verbosity_given)
     write_into_file(outfile, "verbosity", args_info->verbosity_orig, 0);
+  if (args_info->skip_given)
+    write_into_file(outfile, "skip", args_info->skip_orig, 0);
+  if (args_info->rPCL_given)
+    write_into_file(outfile, "rPCL", 0, 0 );
   
 
   i = EXIT_SUCCESS;
     val = possible_values[found];
 
   switch(arg_type) {
+  case ARG_FLAG:
+    *((int *)field) = !*((int *)field);
+    break;
   case ARG_INT:
     if (val) *((int *)field) = strtol (val, &stop_char, 0);
     break;
   /* store the original value */
   switch(arg_type) {
   case ARG_NO:
+  case ARG_FLAG:
     break;
   default:
     if (value && orig_field) {
         { "input",	1, NULL, 'i' },
         { "output",	1, NULL, 'o' },
         { "verbosity",	1, NULL, 'v' },
+        { "skip",	1, NULL, 's' },
+        { "rPCL",	0, NULL, 'r' },
         { NULL,	0, NULL, 0 }
       };
 
-      c = getopt_long (argc, argv, "hVi:o:v:", long_options, &option_index);
+      c = getopt_long (argc, argv, "hVi:o:v:s:r", long_options, &option_index);
 
       if (c == -1) break;	/* Exit from `while (1)' loop.  */
 
             goto failure;
         
           break;
+        case 's':	/* Columns to skip in input PCL.  */
+        
+        
+          if (update_arg( (void *)&(args_info->skip_arg), 
+               &(args_info->skip_orig), &(args_info->skip_given),
+              &(local_args_info.skip_given), optarg, 0, "0", ARG_INT,
+              check_ambiguity, override, 0, 0,
+              "skip", 's',
+              additional_error))
+            goto failure;
+        
+          break;
+        case 'r':	/* Is the input PCL files generated by R, thus missing the first token in the col names row.  */
+        
+        
+          if (update_arg((void *)&(args_info->rPCL_flag), 0, &(args_info->rPCL_given),
+              &(local_args_info.rPCL_given), optarg, 0, 0, ARG_FLAG,
+              check_ambiguity, override, 1, 0, "rPCL", 'r',
+              additional_error))
+            goto failure;
+        
+          break;
 
         case 0:	/* Long option with no short option */
         case '?':	/* Invalid option.  */

File tools/Dat2PCL/cmdline.h

View file
  • Ignore whitespace
   int verbosity_arg;	/**< @brief Message verbosity (default='5').  */
   char * verbosity_orig;	/**< @brief Message verbosity original value given at command line.  */
   const char *verbosity_help; /**< @brief Message verbosity help description.  */
+  int skip_arg;	/**< @brief Columns to skip in input PCL (default='0').  */
+  char * skip_orig;	/**< @brief Columns to skip in input PCL original value given at command line.  */
+  const char *skip_help; /**< @brief Columns to skip in input PCL help description.  */
+  int rPCL_flag;	/**< @brief Is the input PCL files generated by R, thus missing the first token in the col names row (default=off).  */
+  const char *rPCL_help; /**< @brief Is the input PCL files generated by R, thus missing the first token in the col names row help description.  */
   
   unsigned int help_given ;	/**< @brief Whether help was given.  */
   unsigned int version_given ;	/**< @brief Whether version was given.  */
   unsigned int input_given ;	/**< @brief Whether input was given.  */
   unsigned int output_given ;	/**< @brief Whether output was given.  */
   unsigned int verbosity_given ;	/**< @brief Whether verbosity was given.  */
+  unsigned int skip_given ;	/**< @brief Whether skip was given.  */
+  unsigned int rPCL_given ;	/**< @brief Whether rPCL was given.  */
 
   char **inputs ; /**< @brief unamed options (options without names) */
   unsigned inputs_num ; /**< @brief unamed options number */

File tools/Makefile.am

View file
  • Ignore whitespace
     SVM_TOOLS_SUBDIRS = \
           Data2Svm \
 	  SVMer \
+	  SVMperfing \
 	  SVMperfer
 endif
 if WITH_VW_TOOLS

File tools/PCL2Bin/PCL2Bin.cpp

View file
  • Ignore whitespace
 	CMeta Meta(sArgs.verbosity_arg);
 
 	if (sArgs.input_arg) {
-		if (!PCL.Open(sArgs.input_arg, sArgs.skip_arg, !!sArgs.mmap_flag)) {
+	  if (!PCL.Open(sArgs.input_arg, sArgs.skip_arg, !!sArgs.mmap_flag, sArgs.rPCL_flag)) {
 			cerr << "Could not open: " << sArgs.input_arg << endl;
 			return 1;
 		}

File tools/PCL2Bin/PCL2Bin.ggo

View file
  • Ignore whitespace
 							int	default="0" no
 option	"verbosity"		v	"Message verbosity"
 							int	default="5" no
-option	"mmap"		m	"Memmap binary input"
-						flag	off 
+option	"mmap"			m	"Memmap binary input"
+						flag	off 
+option	"rPCL"			R	"Is the input PCL files generated by R, thus missing the first token in the col names row"
+						flag	off

File tools/PCL2Bin/cmdline.c

View file
  • Ignore whitespace
 /*
-  File autogenerated by gengetopt version 2.22.4
+  File autogenerated by gengetopt version 2.22
   generated with the following command:
-  /usr/bin/gengetopt -iPCL2Bin.ggo --default-optional -u -N -e 
+  /Genomics/ogtr03/cypark/sleipnir/../sleipnir-extlib/gengetopt-2.22/src/gengetopt -iPCL2Bin.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>
 
-#ifndef FIX_UNUSED
-#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
-#endif
-
-#include <getopt.h>
+#include "getopt.h"
 
 #include "cmdline.h"
 
   "  -s, --skip=INT         Columns to skip in input PCL  (default=`0')",
   "  -v, --verbosity=INT    Message verbosity  (default=`5')",
   "  -m, --mmap             Memmap binary input  (default=off)",
+  "  -R, --rPCL             Is the input PCL files generated by R, thus missing \n                           the first token in the col names row  (default=off)",
     0
 };
 
 void clear_args (struct gengetopt_args_info *args_info);
 
 static int
-cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
+cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
                         struct cmdline_parser_params *params, const char *additional_error);
 
 
   args_info->skip_given = 0 ;
   args_info->verbosity_given = 0 ;
   args_info->mmap_given = 0 ;
+  args_info->rPCL_given = 0 ;
 }
 
 static
 void clear_args (struct gengetopt_args_info *args_info)
 {
-  FIX_UNUSED (args_info);
   args_info->input_arg = NULL;
   args_info->input_orig = NULL;
   args_info->output_arg = NULL;
   args_info->verbosity_arg = 5;
   args_info->verbosity_orig = NULL;
   args_info->mmap_flag = 0;
+  args_info->rPCL_flag = 0;
   
 }
 
   args_info->skip_help = gengetopt_args_info_help[15] ;
   args_info->verbosity_help = gengetopt_args_info_help[16] ;
   args_info->mmap_help = gengetopt_args_info_help[17] ;
+  args_info->rPCL_help = gengetopt_args_info_help[18] ;
   
 }
 
 void
 cmdline_parser_print_version (void)
 {
-  printf ("%s %s\n",
-     (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
-     CMDLINE_PARSER_VERSION);
+  printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
 }
 
 static void print_help_common(void) {
   printf("\n");
 
   if (strlen(gengetopt_args_info_description) > 0)
-    printf("%s\n\n", gengetopt_args_info_description);
+    printf("%s\n", gengetopt_args_info_description);
 }
 
 void
   clear_args (args_info);
   init_args_info (args_info);
 
-  args_info->inputs = 0;
+  args_info->inputs = NULL;
   args_info->inputs_num = 0;
 }
 
 
 
 static void
-write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
+write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[])
 {
-  FIX_UNUSED (values);
   if (arg) {
     fprintf(outfile, "%s=\"%s\"\n", opt, arg);
   } else {
     write_into_file(outfile, "verbosity", args_info->verbosity_orig, 0);
   if (args_info->mmap_given)
     write_into_file(outfile, "mmap", 0, 0 );
+  if (args_info->rPCL_given)
+    write_into_file(outfile, "rPCL", 0, 0 );
   
 
   i = EXIT_SUCCESS;
 char *
 gengetopt_strdup (const char *s)
 {
-  char *result = 0;
+  char *result = NULL;
   if (!s)
     return result;
 
 }
 
 int
-cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
+cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
 {
   return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
 }
 
 int
-cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
+cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info,
                    struct cmdline_parser_params *params)
 {
   int result;
-  result = cmdline_parser_internal (argc, argv, args_info, params, 0);
+  result = cmdline_parser_internal (argc, argv, args_info, params, NULL);
 
   return result;
 }
 
 int
-cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
+cmdline_parser2 (int argc, char * const *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, 0);
+  result = cmdline_parser_internal (argc, argv, args_info, &params, NULL);
 
   return result;
 }
 int
 cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
 {
-  FIX_UNUSED (args_info);
-  FIX_UNUSED (prog_name);
   return EXIT_SUCCESS;
 }
 
 static
 int update_arg(void *field, char **orig_field,
                unsigned int *field_given, unsigned int *prev_given, 
-               char *value, const char *possible_values[],
-               const char *default_value,
+               char *value, 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 **argv, struct gengetopt_args_info *args_info,
+cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
                         struct cmdline_parser_params *params, const char *additional_error)
 {
   int c;	/* Character of the parsed option.  */
         { "skip",	1, NULL, 's' },
         { "verbosity",	1, NULL, 'v' },
         { "mmap",	0, NULL, 'm' },
-        { 0,  0, 0, 0 }
+        { "rPCL",	0, NULL, 'R' },
+        { NULL,	0, NULL, 0 }
       };
 
-      c = getopt_long (argc, argv, "hVi:o:g:G:ErcCnts:v:m", long_options, &option_index);
+      c = getopt_long (argc, argv, "hVi:o:g:G:ErcCnts:v:mR", long_options, &option_index);
 
       if (c == -1) break;	/* Exit from `while (1)' loop.  */
 
             goto failure;
         
           break;
+        case 'R':	/* Is the input PCL files generated by R, thus missing the first token in the col names row.  */
+        
+        
+          if (update_arg((void *)&(args_info->rPCL_flag), 0, &(args_info->rPCL_given),
+              &(local_args_info.rPCL_given), optarg, 0, 0, ARG_FLAG,
+              check_ambiguity, override, 1, 0, "rPCL", 'R',
+              additional_error))
+            goto failure;
+        
+          break;
 
         case 0:	/* Long option with no short option */
         case '?':	/* Invalid option.  */

File tools/PCL2Bin/cmdline.h

View file
  • Ignore whitespace
 /** @file cmdline.h
  *  @brief The header file for the command line option parser
- *  generated by GNU Gengetopt version 2.22.4
+ *  generated by GNU Gengetopt version 2.22
  *  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 (used for printing errors) */
+/** @brief the program name */
 #define CMDLINE_PARSER_PACKAGE "PCL2Bin"
 #endif
 
-#ifndef CMDLINE_PARSER_PACKAGE_NAME
-/** @brief the complete program name (used for help and version) */
-#define CMDLINE_PARSER_PACKAGE_NAME "PCL2Bin"
-#endif
-
 #ifndef CMDLINE_PARSER_VERSION
 /** @brief the program version */
 #define CMDLINE_PARSER_VERSION "1.0"
   const char *verbosity_help; /**< @brief Message verbosity help description.  */
   int mmap_flag;	/**< @brief Memmap binary input (default=off).  */
   const char *mmap_help; /**< @brief Memmap binary input help description.  */
+  int rPCL_flag;	/**< @brief Is the input PCL files generated by R, thus missing the first token in the col names row (default=off).  */
+  const char *rPCL_help; /**< @brief Is the input PCL files generated by R, thus missing the first token in the col names row help description.  */
   
   unsigned int help_given ;	/**< @brief Whether help was given.  */
   unsigned int version_given ;	/**< @brief Whether version was given.  */
   unsigned int skip_given ;	/**< @brief Whether skip was given.  */
   unsigned int verbosity_given ;	/**< @brief Whether verbosity was given.  */
   unsigned int mmap_given ;	/**< @brief Whether mmap was given.  */
+  unsigned int rPCL_given ;	/**< @brief Whether rPCL was given.  */
 
   char **inputs ; /**< @brief unamed options (options without names) */
   unsigned inputs_num ; /**< @brief unamed options number */
  * @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 **argv,
+int cmdline_parser (int argc, char * const *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 **argv,
+int cmdline_parser2 (int argc, char * const *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 **argv,
+int cmdline_parser_ext (int argc, char * const *argv,
   struct gengetopt_args_info *args_info,
   struct cmdline_parser_params *params);
 

File tools/SVMperfing/SVMperfing.cpp

View file
  • Ignore whitespace
+#include <fstream>
+
+#include <vector>
+#include <queue>
+
+/*****************************************************************************
+ * This file is provided under the Creative Commons Attribution 3.0 license.
+ *
+ * You are free to share, copy, distribute, transmit, or adapt this work
+ * PROVIDED THAT you attribute the work to the authors listed below.
+ * For more information, please see the following web page:
+ * http://creativecommons.org/licenses/by/3.0/
+ *
+ * This file is a component of the Sleipnir library for functional genomics,
+ * authored by:
+ * Curtis Huttenhower (chuttenh@princeton.edu)
+ * Mark Schroeder
+ * Maria D. Chikina
+ * Olga G. Troyanskaya (ogt@princeton.edu, primary contact)
+ *
+ * If you use this library, the included executable tools, or any related
+ * code in your work, please cite the following publication:
+ * Curtis Huttenhower, Mark Schroeder, Maria D. Chikina, and
+ * Olga G. Troyanskaya.
+ * "The Sleipnir library for computational functional genomics"
+ *****************************************************************************/
+#include "stdafx.h"
+#include "cmdline.h"
+#include "statistics.h"
+
+using namespace SVMLight;
+
+struct ParamStruct {
+	vector<float> vecK, vecTradeoff;
+	vector<size_t> vecLoss;
+	vector<char*> vecNames;
+};
+
+ParamStruct ReadParamsFromFile(ifstream& ifsm, string outFile) {
+	static const size_t c_iBuffer = 1024;
+	char acBuffer[c_iBuffer];
+	char* nameBuffer;
+	vector<string> vecstrTokens;
+	size_t extPlace;
+	string Ext, FileName;
+	if ((extPlace = outFile.find_first_of(".")) != string::npos) {
+		FileName = outFile.substr(0, extPlace);
+		Ext = outFile.substr(extPlace, outFile.size());
+	} else {
+		FileName = outFile;
+		Ext = "";
+	}
+	ParamStruct PStruct;
+	size_t index = 0;
+	while (!ifsm.eof()) {
+		ifsm.getline(acBuffer, c_iBuffer - 1);
+		acBuffer[c_iBuffer - 1] = 0;
+		vecstrTokens.clear();
+		CMeta::Tokenize(acBuffer, vecstrTokens);
+		if (vecstrTokens.empty())
+			continue;
+		if (vecstrTokens.size() != 3) {
+			cerr << "Illegal params line (" << vecstrTokens.size() << "): "
+					<< acBuffer << endl;
+			continue;
+		}
+		if (acBuffer[0] == '#') {
+			cerr << "skipping " << acBuffer << endl;
+		} else {
+			PStruct.vecLoss.push_back(atoi(vecstrTokens[0].c_str()));
+			PStruct.vecTradeoff.push_back(atof(vecstrTokens[1].c_str()));
+			PStruct.vecK.push_back(atof(vecstrTokens[2].c_str()));
+			PStruct.vecNames.push_back(new char[c_iBuffer]);
+			if (PStruct.vecLoss[index] == 4 || PStruct.vecLoss[index] == 5)
+				sprintf(PStruct.vecNames[index], "%s_l%d_c%4.6f_k%4.3f%s",
+						FileName.c_str(), PStruct.vecLoss[index],
+						PStruct.vecTradeoff[index], PStruct.vecK[index],
+						Ext.c_str());
+			else
+				sprintf(PStruct.vecNames[index], "%s_l%d_c%4.6f%s",
+						FileName.c_str(), PStruct.vecLoss[index],
+						PStruct.vecTradeoff[index], Ext.c_str());
+			index++;
+		}
+
+	}
+	return PStruct;
+}
+
+int main(int iArgs, char** aszArgs) {
+	gengetopt_args_info sArgs;	
+	SVMLight::CSVMPERF SVM;
+	
+	size_t i, j, iGene, jGene;
+	ifstream ifsm;
+	float d;
+	int   iRet;
+	map<string, size_t>	mapstriZeros, mapstriDatasets;
+	vector<string>  vecstrDatasets;
+	DIR* dp;
+	struct dirent* ep;
+	
+	if (cmdline_parser(iArgs, aszArgs, &sArgs)) {
+		cmdline_parser_print_help();
+		return 1;
+	}
+	SVM.SetVerbosity(sArgs.verbosity_arg);
+	SVM.SetLossFunction(sArgs.error_function_arg);
+	if (sArgs.k_value_arg > 1) {
+		cerr << "k_value is >1. Setting default 0.5" << endl;
+		SVM.SetPrecisionFraction(0.5);
+	} else if (sArgs.k_value_arg <= 0) {
+		cerr << "k_value is <=0. Setting default 0.5" << endl;
+		SVM.SetPrecisionFraction(0.5);
+	} else {
+		SVM.SetPrecisionFraction(sArgs.k_value_arg);
+	}
+
+	
+	if (sArgs.cross_validation_arg < 1){
+	  cerr << "cross_valid is <1. Must be set at least 1" << endl;
+	  return 1;
+	}
+	else if(sArgs.cross_validation_arg < 2){
+	  cerr << "cross_valid is set to 1. No cross validation holdouts will be run." << endl;
+	}
+	
+	SVM.SetTradeoff(sArgs.tradeoff_arg);
+	if (sArgs.slack_flag)
+		SVM.UseSlackRescaling();
+	else
+		SVM.UseMarginRescaling();
+
+	
+	if (!SVM.parms_check()) {
+		cerr << "Sanity check failed, see above errors" << endl;
+		return 1;
+	}
+
+	//  cout << "there are " << vecLabels.size() << " labels processed" << endl;
+	/*
+	if (sArgs.input_given) {
+		if (!PCL.Open(sArgs.input_arg, sArgs.skip_arg, sArgs.mmap_flag)) {
+		cerr << "Could not open input PCL" << endl;
+		return 1;
+		}
+	}
+	*/
+	
+	// read in the list of datasets
+	if(sArgs.directory_arg ) {
+	  dp = opendir (sArgs.directory_arg);
+	  if (dp != NULL){
+	    while (ep = readdir (dp)){
+	      // skip . .. files and temp files with ~
+	      if (ep->d_name[0] == '.' || ep->d_name[strlen(ep->d_name)-1] == '~') 
+		continue;
+	      
+	      // currently opens all files. Add filter here if want pick file extensions
+	      vecstrDatasets.push_back((string)sArgs.directory_arg + "/" + ep->d_name);	      
+	    }
+	    (void) closedir (dp);	    
+	    
+	    cerr << "Input Dir contrains # datasets: " << vecstrDatasets.size() << '\n';
+	  }
+	  else{
+	    cerr << "Couldn't open the directory: " << sArgs.directory_arg << '\n';
+	    return 1;
+	  }	  
+	}
+	
+	///######################
+	// Chris added
+	vector<SVMLight::SVMLabelPair*> vecLabels;
+	/*********
+	 ** PCL gold standard later
+	 
+	CPCL Labels;
+	if (sArgs.labels_given) {	  
+	  if (!Labels.Open(sArgs.labels_arg, sArgs.skip_arg, sArgs.mmap_flag)) {
+	    cerr << "Could not open input PCL" << endl;
+	    return 1;
+	  }
+	  
+	  for(size_t i = 0; i < PCL.GetGenes(); i++)
+	    for(size_t j = 0; j < PCL.GetExperiments(); j++)
+	      if (!CMeta::IsNaN(d = PCL.Get(i, j)))  
+		vecLabels.push_back(SVMLight::SVMLabelPairPair(d, i, j));
+	  
+	}
+	****/
+	CDat Labels;
+	CDat Results;
+	if (sArgs.labels_given) {	  
+	  if (!Labels.Open(sArgs.labels_arg, sArgs.mmap_flag)) {
+	    cerr << "Could not open input labels Dat" << endl;
+	    return 1;
+	  }
+	  
+	  // set all NaN values to negatives
+	  if( sArgs.nan2neg_given ){
+	    for(i = 0; i < Labels.GetGenes(); i++)
+	      for(j = (i+1); j < Labels.GetGenes(); j++)
+		if (CMeta::IsNaN(d = Labels.Get(i, j)))  
+		  Labels.Set(i, j, -1);
+	  }
+	  
+	  // 
+	  //if( sArgs.geneq_arg ) {
+	    
+	  //}
+	  	  
+	  for(i = 0; i < Labels.GetGenes(); i++)
+	    for(j = (i+1); j < Labels.GetGenes(); j++)
+	      if (!CMeta::IsNaN(d = Labels.Get(i, j)))  
+		vecLabels.push_back(new SVMLight::SVMLabelPair(d, i, j));
+	  
+	}
+	
+	SVMLight::SAMPLE* pTrainSample;
+	SVMLight::SAMPLE* pAllSample;
+	vector<SVMLight::SVMLabelPair*> pTrainVector[sArgs.cross_validation_arg];
+	vector<SVMLight::SVMLabelPair*> pTestVector[sArgs.cross_validation_arg];
+	//vector<SVMLight::Result> AllResults;
+	//vector<SVMLight::Result> tmpAllResults;
+	
+	if (sArgs.model_given && sArgs.labels_given) { //learn once and write to file
+	  //DEBUG implement
+	  //pTrainSample = CSVMPERF::CreateSample(vecstrDatasets, vecLabels, Labels.GetGeneNames());
+	  //SVM.Learn(*pTrainSample);
+	  //SVM.WriteModel(sArgs.model_arg);
+	} else if (sArgs.model_given && sArgs.output_given) { //read model and classify all
+	  
+	  // DEBUG need to figure out which/where to select all genes to predict
+	  // Also, need to paralize the full predictions
+	  
+	  SVM.ReadModel(sArgs.model_arg);
+	  //AllResults = SVM.Classify(PCL, vecAllLabels);
+	  
+	  // DEBUG output predictions
+	  // sArgs.output_arg
+	  
+	} else if (sArgs.output_given && sArgs.labels_given) {
+		//do learning and classifying with cross validation
+	        if( sArgs.cross_validation_arg > 1){
+		  for (i = 0; i < sArgs.cross_validation_arg; i++) {
+		    pTestVector[i].reserve((size_t) vecLabels.size()
+					   / sArgs.cross_validation_arg + sArgs.cross_validation_arg);
+		    pTrainVector[i].reserve((size_t) vecLabels.size()
+					    / (sArgs.cross_validation_arg)
+					    * (sArgs.cross_validation_arg - 1)
+					    + sArgs.cross_validation_arg);
+		    for (j = 0; j < vecLabels.size(); j++) {
+		      if (j % sArgs.cross_validation_arg == i) {
+			pTestVector[i].push_back(vecLabels[j]);
+		      } else {
+			pTrainVector[i].push_back((vecLabels[j]));
+		      }
+		    }
+		  }
+		}
+		else{ // if you have less than 2 fold cross, no cross validation is done, all train genes are used and predicted
+		  
+		  // no holdout so train is the same as test gene set
+		  pTestVector[0].reserve((size_t) vecLabels.size() + sArgs.cross_validation_arg);
+		  pTrainVector[0].reserve((size_t) vecLabels.size() + sArgs.cross_validation_arg);
+		  
+		  for (j = 0; j < vecLabels.size(); j++) {
+		    pTestVector[0].push_back(vecLabels[j]);		      
+		    pTrainVector[0].push_back(vecLabels[j]);		    
+		  }
+		}
+				
+		// initalize the results
+		Results.Open(Labels.GetGeneNames(), true);
+		
+		//if (sArgs.all_flag) {
+		  // DEBUG, probably don't allow all flag
+		  // orig for classify all genes
+		//}
+		if (sArgs.params_given) { //reading paramters from file
+			ifsm.close();
+			ifsm.clear();
+			ifsm.open(sArgs.params_arg);
+			if (!ifsm.is_open()) {
+				cerr << "Could not open: " << sArgs.params_arg << endl;
+				return 1;
+			}
+			ParamStruct PStruct;
+			string outFile(sArgs.output_arg);
+			PStruct = ReadParamsFromFile(ifsm, outFile);
+
+			size_t iParams;
+			ofstream ofsm;
+			SVMLight::SAMPLE * ppTrainSample[sArgs.cross_validation_arg];
+			
+			//build all the samples since they are being reused
+			/*
+			for (i = 0; i < sArgs.cross_validation_arg; i++)
+			  ppTrainSample[i] = SVMLight::CSVMPERF::CreateSample(vecstrDatasets,
+									      pTrainVector[i]);
+			
+			for (iParams = 0; iParams < PStruct.vecTradeoff.size(); iParams++) {
+			  // DEBUG need to implement			  
+			}
+			*/
+		} else { //run once
+		  
+		  // create sample for all labels
+		  // DEBUG need to implement
+		  cerr << "CreateDocs!"<< endl;
+		  SVMLight::CSVMPERF::CreateDoc(vecstrDatasets,
+						vecLabels,
+						Labels.GetGeneNames());
+		  
+		  for (i = 0; i < sArgs.cross_validation_arg; i++) {
+		    cerr << "Cross validation: " << i << endl;
+		    
+		    // DEBUG need to implement
+		    pTrainSample = SVMLight::CSVMPERF::CreateSample(pTrainVector[i]);
+		    cerr << "Cross Validation Trial " << i << endl;		    
+		    
+		    SVM.Learn(*pTrainSample);
+		    cerr << "Learned" << endl;
+		    SVM.Classify(Results,
+				 pTestVector[i]);
+		    //cerr << "Classified " << tmpAllResults.size() << " examples"
+		    //<< endl;
+		    //AllResults.insert(AllResults.end(), tmpAllResults.begin(),
+		    //				      tmpAllResults.end());
+		    //tmpAllResults.resize(0);
+		    ///if (sArgs.all_flag) {
+		      // DEBUG, probably don't allow all flag
+		      // orig for classify all genes				  
+		    //}
+		    
+		    // MAIRA, Also, why did you not start at i==0???
+		    
+		    // DEBUG
+		    SVMLight::CSVMPERF::FreeSample_leave_Doc(*pTrainSample);
+		    free(pTrainSample);
+		  }
+		  
+		  //if (sArgs.all_flag) { //add the unlabeled results
+		    // DEBUG, probably don't allow all flag
+		    // orig for classify all genes
+		  //}
+		  
+		  Results.Save(sArgs.output_arg);
+		  return 0;
+		}
+	} else {
+		cerr << "More options are needed" << endl;
+	}
+
+}
+

File tools/SVMperfing/SVMperfing.ggo

View file
  • Ignore whitespace
+package	"SVMperfer"
+version	"1.0"
+purpose	"Wrapper for SVM perf"
+
+section "Main"
+option	"labels"				l	"Labels file"
+										string	typestr="filename"	no
+option	"output"				o	"Output file "
+										string	typestr="filename"  no
+option  "directory"     			d       "input directory (must only contain input files)"
+                                                string  typestr="directory" yes
+option	"model"					m	"Model file"
+										string	typestr="filename"  no
+option  "slack"       			S   "Use slack rescaling (not implemented for ROC loss)"
+										flag off
+
+section "Options"
+option "verbosity"  			v   "Sets the svm_struct verbosity"
+										int default="0" no
+option	"cross_validation"		c	"Number of cross-validation sets ( arg of 1 will turn off cross-validation )"
+										int default="5" no
+option "error_function" 		e   "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.
+2\tErrorrate: Percentage of errors in prediction vector.
+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" 
+										int default="10" no
+
+option "k_value"    			k   "Value of k parameter used for Prec@k and Rec@k in (0,1)"
+										float default="0.5" no
+option "tradeoff"    			t   "SVM tradeoff constant C"
+										float default="1" no
+option "params"   			p   "NOT IMPLEMENTED YET: Parameter file"
+										string  typestr="filename"   no
+option  "nan2neg"       		n   "set missing values(NaN in dab file) from labels file as negative examples"
+										flag off
+option	"mmap"				M	"Memory map binary input"
+										flag	off
+section "Filtering"
+option	"geneq"				q	"Exclude all label edges where both genes come from the given gene list"
+							string	typestr="filename"

File tools/SVMperfing/cmdline.c

View file
  • Ignore whitespace
+/*
+  File autogenerated by gengetopt version 2.22
+  generated with the following command:
+  /Genomics/ogtr03/cypark/sleipnir/../sleipnir-extlib/gengetopt-2.22/src/gengetopt -iSVMperfing.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:
+  we make no copyright claims on it.
+*/
+
+/* If we use autoconf.  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "getopt.h"
+
+#include "cmdline.h"
+
+const char *gengetopt_args_info_purpose = "Wrapper for SVM perf";
+
+const char *gengetopt_args_info_usage = "Usage: SVMperfer [OPTIONS]... [FILES]...";
+
+const char *gengetopt_args_info_description = "";
+
+const char *gengetopt_args_info_help[] = {
+  "  -h, --help                  Print help and exit",
+  "  -V, --version               Print version and exit",
+  "\nMain:",
+  "  -l, --labels=filename       Labels file",
+  "  -o, --output=filename       Output file ",
+  "  -d, --directory=directory   input directory (must only contain input files)",
+  "  -m, --model=filename        Model file",
+  "  -S, --slack                 Use slack rescaling (not implemented for ROC \n                                loss)  (default=off)",
+  "\nOptions:",
+  "  -v, --verbosity=INT         Sets the svm_struct verbosity  (default=`0')",
+  "  -c, --cross_validation=INT  Number of cross-validation sets ( arg of 1 will \n                                turn off cross-validation )  (default=`5')",
+  "  -e, --error_function=INT    Sets the loss function for SVM learning: Choice \n                                of:\n\n                                0\tZero/one loss: 1 if vector of predictions \n                                contains error, 0 otherwise.\n\n                                1\tF1: 100 minus the F1-score in percent.\n\n                                2\tErrorrate: Percentage of errors in \n                                prediction vector.\n\n                                3\tPrec/Rec Breakeven: 100 minus PRBEP in \n                                percent.\n\n                                4\tPrec@k: 100 minus precision at k in percent.\n\n                                5\tRec@k: 100 minus recall at k in percent.\n\n                                10\tROCArea: Percentage of swapped pos/neg \n                                pairs (i.e. 100 - ROCArea).\n                                  (default=`10')",
+  "  -k, --k_value=FLOAT         Value of k parameter used for Prec@k and Rec@k in \n                                (0,1)  (default=`0.5')",
+  "  -t, --tradeoff=FLOAT        SVM tradeoff constant C  (default=`1')",
+  "  -p, --params=filename       NOT IMPLEMENTED YET: Parameter file",
+  "  -n, --nan2neg               set missing values(NaN in dab file) from labels \n                                file as negative examples  (default=off)",
+  "  -M, --mmap                  Memory map binary input  (default=off)",
+  "\nFiltering:",
+  "  -q, --geneq=filename        Exclude all label edges where both genes come \n                                from the given gene list",
+    0
+};
+
+typedef enum {ARG_NO
+  , ARG_FLAG
+  , ARG_STRING
+  , ARG_INT
+  , ARG_FLOAT
+} cmdline_parser_arg_type;
+
+static
+void clear_given (struct gengetopt_args_info *args_info);
+static
+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,
+                        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);
+
+static char *
+gengetopt_strdup (const char *s);
+
+static
+void clear_given (struct gengetopt_args_info *args_info)
+{
+  args_info->help_given = 0 ;
+  args_info->version_given = 0 ;
+  args_info->labels_given = 0 ;
+  args_info->output_given = 0 ;
+  args_info->directory_given = 0 ;
+  args_info->model_given = 0 ;
+  args_info->slack_given = 0 ;
+  args_info->verbosity_given = 0 ;
+  args_info->cross_validation_given = 0 ;
+  args_info->error_function_given = 0 ;
+  args_info->k_value_given = 0 ;
+  args_info->tradeoff_given = 0 ;
+  args_info->params_given = 0 ;
+  args_info->nan2neg_given = 0 ;
+  args_info->mmap_given = 0 ;
+  args_info->geneq_given = 0 ;
+}
+
+static
+void clear_args (struct gengetopt_args_info *args_info)
+{
+  args_info->labels_arg = NULL;
+  args_info->labels_orig = NULL;
+  args_info->output_arg = NULL;
+  args_info->output_orig = NULL;
+  args_info->directory_arg = NULL;
+  args_info->directory_orig = NULL;
+  args_info->model_arg = NULL;
+  args_info->model_orig = NULL;
+  args_info->slack_flag = 0;
+  args_info->verbosity_arg = 0;
+  args_info->verbosity_orig = NULL;
+  args_info->cross_validation_arg = 5;
+  args_info->cross_validation_orig = NULL;
+  args_info->error_function_arg = 10;
+  args_info->error_function_orig = NULL;
+  args_info->k_value_arg = 0.5;
+  args_info->k_value_orig = NULL;
+  args_info->tradeoff_arg = 1;
+  args_info->tradeoff_orig = NULL;
+  args_info->params_arg = NULL;
+  args_info->params_orig = NULL;
+  args_info->nan2neg_flag = 0;
+  args_info->mmap_flag = 0;
+  args_info->geneq_arg = NULL;
+  args_info->geneq_orig = NULL;
+  
+}
+
+static
+void init_args_info(struct gengetopt_args_info *args_info)
+{
+
+
+  args_info->help_help = gengetopt_args_info_help[0] ;
+  args_info->version_help = gengetopt_args_info_help[1] ;
+  args_info->labels_help = gengetopt_args_info_help[3] ;
+  args_info->output_help = gengetopt_args_info_help[4] ;
+  args_info->directory_help = gengetopt_args_info_help[5] ;
+  args_info->model_help = gengetopt_args_info_help[6] ;
+  args_info->slack_help = gengetopt_args_info_help[7] ;
+  args_info->verbosity_help = gengetopt_args_info_help[9] ;
+  args_info->cross_validation_help = gengetopt_args_info_help[10] ;
+  args_info->error_function_help = gengetopt_args_info_help[11] ;
+  args_info->k_value_help = gengetopt_args_info_help[12] ;
+  args_info->tradeoff_help = gengetopt_args_info_help[13] ;
+  args_info->params_help = gengetopt_args_info_help[14] ;
+  args_info->nan2neg_help = gengetopt_args_info_help[15] ;
+  args_info->mmap_help = gengetopt_args_info_help[16] ;
+  args_info->geneq_help = gengetopt_args_info_help[18] ;
+  
+}
+
+void
+cmdline_parser_print_version (void)
+{
+  printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
+}
+
+static void print_help_common(void) {
+  cmdline_parser_print_version ();
+
+  if (strlen(gengetopt_args_info_purpose) > 0)
+    printf("\n%s\n", gengetopt_args_info_purpose);
+
+  if (strlen(gengetopt_args_info_usage) > 0)
+    printf("\n%s\n", gengetopt_args_info_usage);
+
+  printf("\n");
+
+  if (strlen(gengetopt_args_info_description) > 0)
+    printf("%s\n", gengetopt_args_info_description);
+}
+
+void
+cmdline_parser_print_help (void)
+{
+  int i = 0;
+  print_help_common();
+  while (gengetopt_args_info_help[i])
+    printf("%s\n", gengetopt_args_info_help[i++]);
+}
+
+void
+cmdline_parser_init (struct gengetopt_args_info *args_info)
+{
+  clear_given (args_info);
+  clear_args (args_info);
+  init_args_info (args_info);
+
+  args_info->inputs = NULL;
+  args_info->inputs_num = 0;
+}
+
+void
+cmdline_parser_params_init(struct cmdline_parser_params *params)
+{
+  if (params)
+    { 
+      params->override = 0;
+      params->initialize = 1;
+      params->check_required = 1;
+      params->check_ambiguity = 0;
+      params->print_errors = 1;
+    }
+}
+
+struct cmdline_parser_params *
+cmdline_parser_params_create(void)
+{
+  struct cmdline_parser_params *params = 
+    (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
+  cmdline_parser_params_init(params);  
+  return params;
+}
+
+static void
+free_string_field (char **s)
+{
+  if (*s)
+    {
+      free (*s);
+      *s = 0;
+    }
+}
+
+
+static void
+cmdline_parser_release (struct gengetopt_args_info *args_info)
+{
+  unsigned int i;
+  free_string_field (&(args_info->labels_arg));
+  free_string_field (&(args_info->labels_orig));
+  free_string_field (&(args_info->output_arg));
+  free_string_field (&(args_info->output_orig));
+  free_string_field (&(args_info->directory_arg));
+  free_string_field (&(args_info->directory_orig));
+  free_string_field (&(args_info->model_arg));
+  free_string_field (&(args_info->model_orig));
+  free_string_field (&(args_info->verbosity_orig));
+  free_string_field (&(args_info->cross_validation_orig));
+  free_string_field (&(args_info->error_function_orig));
+  free_string_field (&(args_info->k_value_orig));
+  free_string_field (&(args_info->tradeoff_orig));
+  free_string_field (&(args_info->params_arg));
+  free_string_field (&(args_info->params_orig));
+  free_string_field (&(args_info->geneq_arg));
+  free_string_field (&(args_info->geneq_orig));
+  
+  
+  for (i = 0; i < args_info->inputs_num; ++i)
+    free (args_info->inputs [i]);
+
+  if (args_info->inputs_num)
+    free (args_info->inputs);
+
+  clear_given (args_info);
+}
+
+
+static void
+write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[])
+{
+  if (arg) {
+    fprintf(outfile, "%s=\"%s\"\n", opt, arg);
+  } else {
+    fprintf(outfile, "%s\n", opt);
+  }
+}
+
+
+int
+cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
+{
+  int i = 0;
+
+  if (!outfile)
+    {
+      fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
+      return EXIT_FAILURE;
+    }
+
+  if (args_info->help_given)
+    write_into_file(outfile, "help", 0, 0 );
+  if (args_info->version_given)
+    write_into_file(outfile, "version", 0, 0 );
+  if (args_info->labels_given)
+    write_into_file(outfile, "labels", args_info->labels_orig, 0);
+  if (args_info->output_given)
+    write_into_file(outfile, "output", args_info->output_orig, 0);
+  if (args_info->directory_given)
+    write_into_file(outfile, "directory", args_info->directory_orig, 0);
+  if (args_info->model_given)
+    write_into_file(outfile, "model", args_info->model_orig, 0);
+  if (args_info->slack_given)
+    write_into_file(outfile, "slack", 0, 0 );
+  if (args_info->verbosity_given)
+    write_into_file(outfile, "verbosity", args_info->verbosity_orig, 0);
+  if (args_info->cross_validation_given)
+    write_into_file(outfile, "cross_validation", args_info->cross_validation_orig, 0);
+  if (args_info->error_function_given)
+    write_into_file(outfile, "error_function", args_info->error_function_orig, 0);
+  if (args_info->k_value_given)
+    write_into_file(outfile, "k_value", args_info->k_value_orig, 0);
+  if (args_info->tradeoff_given)
+    write_into_file(outfile, "tradeoff", args_info->tradeoff_orig, 0);
+  if (args_info->params_given)
+    write_into_file(outfile, "params", args_info->params_orig, 0);
+  if (args_info->nan2neg_given)
+    write_into_file(outfile, "nan2neg", 0, 0 );
+  if (args_info->mmap_given)
+    write_into_file(outfile, "mmap", 0, 0 );
+  if (args_info->geneq_given)
+    write_into_file(outfile, "geneq", args_info->geneq_orig, 0);
+  
+
+  i = EXIT_SUCCESS;
+  return i;
+}
+
+int
+cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
+{
+  FILE *outfile;
+  int i = 0;
+
+  outfile = fopen(filename, "w");
+
+  if (!outfile)
+    {
+      fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
+      return EXIT_FAILURE;
+    }
+
+  i = cmdline_parser_dump(outfile, args_info);
+  fclose (outfile);
+
+  return i;
+}
+
+void
+cmdline_parser_free (struct gengetopt_args_info *args_info)
+{
+  cmdline_parser_release (args_info);
+}
+
+/** @brief replacement of strdup, which is not standard */
+char *
+gengetopt_strdup (const char *s)
+{
+  char *result = NULL;
+  if (!s)
+    return result;
+
+  result = (char*)malloc(strlen(s) + 1);
+  if (result == (char*)0)
+    return (char*)0;
+  strcpy(result, s);
+  return result;
+}
+
+int
+cmdline_parser (int argc, char * const *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,
+                   struct cmdline_parser_params *params)
+{
+  int result;
+  result = cmdline_parser_internal (argc, argv, args_info, params, NULL);
+
+  return result;
+}