[Genabel-commits] r1115 - pkg/OmicABEL/src/reshuffle

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 6 14:18:00 CET 2013


Author: sharapovsodbo
Date: 2013-03-06 14:17:59 +0100 (Wed, 06 Mar 2013)
New Revision: 1115

Added:
   pkg/OmicABEL/src/reshuffle/DONE.txt
Modified:
   pkg/OmicABEL/src/reshuffle/Parameters.cpp
   pkg/OmicABEL/src/reshuffle/Parameters.h
   pkg/OmicABEL/src/reshuffle/iout_file.cpp
   pkg/OmicABEL/src/reshuffle/iout_file.h
   pkg/OmicABEL/src/reshuffle/main.cpp
   pkg/OmicABEL/src/reshuffle/reshuffle.cpp
Log:
ver 0.01

Added: pkg/OmicABEL/src/reshuffle/DONE.txt
===================================================================
--- pkg/OmicABEL/src/reshuffle/DONE.txt	                        (rev 0)
+++ pkg/OmicABEL/src/reshuffle/DONE.txt	2013-03-06 13:17:59 UTC (rev 1115)
@@ -0,0 +1,5 @@
+ver 0.001
+	improved parsing of command line:
+		search for parameter's name only after separator
+		delete parameter's name and value from command line in case of finding it
+		
\ No newline at end of file

Modified: pkg/OmicABEL/src/reshuffle/Parameters.cpp
===================================================================
--- pkg/OmicABEL/src/reshuffle/Parameters.cpp	2013-03-05 11:52:43 UTC (rev 1114)
+++ pkg/OmicABEL/src/reshuffle/Parameters.cpp	2013-03-06 13:17:59 UTC (rev 1115)
@@ -2,7 +2,7 @@
  * Parameters.cpp
  *
  *  Created on: 28.02.2013
- *      Author: lima
+ *      Author: Sodbo
  */
 #include "Parameters.h"
 #include <stdlib.h>
@@ -55,8 +55,8 @@
 Parameter::Parameter(string cmdline, string paramname) {
 
 	name = paramname;
-	int parpos = cmdline.find(name); //	position of substring with param's name
-	if (parpos != string::npos) { //	check  [FOUND OR NOT]
+	int parpos = cmdline.find("--"+name)+2; //	position of substring with param's name
+	if (parpos != string::npos+2) { //	check  [FOUND OR NOT]
 		string val = "";
 		unsigned int iter = parpos + name.size() + 1; //	iterator, which run from "=" to sep
 		unsigned int seppos = cmdline.find(sep, parpos); // 	separator position
@@ -64,6 +64,7 @@
 			val += cmdline.at(iter); // build value of parameter
 			iter++;
 		}
+
 		use = true;
 		if (val.size() != 0) {
 			value = val;
@@ -87,7 +88,9 @@
 						for(int i=atoi(start.c_str())-1;i<atoi(end.c_str());i++){
 							valueset.insert(i);
 						}
-					}else valueset.insert(atoi(str_tmp.c_str())-1);
+					}else if(atoi(str_tmp.c_str())!=0)
+						valueset.insert(atoi(str_tmp.c_str())-1);
+
 					str_tmp="";
 				}
 			}
@@ -99,19 +102,40 @@
 	}
 }
 
+string Parameter::delfromcmdline(string cmdline){
+	if(use){
+		int val=value.size();
+		if(value=="None"||value=="all")
+			val=-1;
+		cmdline.replace(cmdline.find(name)-2,name.size()+val+3,"");
+	}
+	return cmdline;
+}
+
 //	Constructor, which gets info about all parameters from cmdline
 Parameters::Parameters(int argc,char* argv[]) {
-	string cmdline=get_cmd_line(argc,argv);
+	static string cmdline=get_cmd_line(argc,argv);
 	unsigned int seppos = cmdline.find(sep); // 	first separator's position
 	string filename = cmdline.substr(0, seppos);
+	cmdline.erase(0,seppos);//Erase file name
 	iout_fname = filename + ".iout";
 	out_fname = filename + ".out";
+	info = Parameter(cmdline, "info");
+	cmdline=info.delfromcmdline(cmdline);
 	datadims = Parameter(cmdline, "datadims");
+	cmdline=datadims.delfromcmdline(cmdline);
 	snpnames = Parameter(cmdline, "snpnames");
+	cmdline=snpnames.delfromcmdline(cmdline);
 	traitnames = Parameter(cmdline, "traitnames");
+	cmdline=traitnames.delfromcmdline(cmdline);
 	traits = Parameter(cmdline, "traits");
+	cmdline=traits.delfromcmdline(cmdline);
 	snps = Parameter(cmdline, "snps");
+	cmdline=snps.delfromcmdline(cmdline);
 	heritabilities = Parameter(cmdline, "heritabilities");
+	cmdline=heritabilities.delfromcmdline(cmdline);
 	chi = Parameter(cmdline, "chi");
+	cmdline=	chi.delfromcmdline(cmdline);
 	dataslim= Parameter(cmdline, "dataslim");
+	cmdline=	dataslim.delfromcmdline(cmdline);
 }

Modified: pkg/OmicABEL/src/reshuffle/Parameters.h
===================================================================
--- pkg/OmicABEL/src/reshuffle/Parameters.h	2013-03-05 11:52:43 UTC (rev 1114)
+++ pkg/OmicABEL/src/reshuffle/Parameters.h	2013-03-06 13:17:59 UTC (rev 1115)
@@ -2,7 +2,7 @@
  * Parameters.h
  *
  *  Created on: 28.02.2013
- *      Author: lima
+ *      Author: Sodbo
  */
 
 #ifndef PARAMETERS_H_
@@ -22,13 +22,15 @@
 	Parameter(string,string); 	//constructor
 	Parameter();		//default constructor
 	set<int> valueset;
+	string delfromcmdline(string);
 };
 
 ostream &operator <<(ostream &, Parameter);
 
 class Parameters {
 public:
-	string iout_fname;
+	Parameter info; // Write info about progeamm's run
+	string iout_fname; //iout_file_name
 	string out_fname;
 	Parameter datadims;
 	Parameter snpnames;
@@ -39,7 +41,7 @@
 	Parameter chi;
 	Parameter dataslim;
 	Parameters(int, char*[]);		//	Constructor from cmdline
-	string get_cmd_line(int,char*[]);
+	static string get_cmd_line(int,char*[]);
 
 };
 

Modified: pkg/OmicABEL/src/reshuffle/iout_file.cpp
===================================================================
--- pkg/OmicABEL/src/reshuffle/iout_file.cpp	2013-03-05 11:52:43 UTC (rev 1114)
+++ pkg/OmicABEL/src/reshuffle/iout_file.cpp	2013-03-06 13:17:59 UTC (rev 1115)
@@ -2,7 +2,7 @@
  * iout_file.cpp
  *
  *  Created on: 28.02.2013
- *      Author: lima
+ *      Author: Sodbo
  */
 #include "iout_file.h"
 

Modified: pkg/OmicABEL/src/reshuffle/iout_file.h
===================================================================
--- pkg/OmicABEL/src/reshuffle/iout_file.h	2013-03-05 11:52:43 UTC (rev 1114)
+++ pkg/OmicABEL/src/reshuffle/iout_file.h	2013-03-06 13:17:59 UTC (rev 1115)
@@ -2,7 +2,7 @@
  * iout_file.h
  *
  *  Created on: 28.02.2013
- *      Author: lima
+ *      Author: Sodbo
  */
 
 #ifndef IOUT_FILE_H_

Modified: pkg/OmicABEL/src/reshuffle/main.cpp
===================================================================
--- pkg/OmicABEL/src/reshuffle/main.cpp	2013-03-05 11:52:43 UTC (rev 1114)
+++ pkg/OmicABEL/src/reshuffle/main.cpp	2013-03-06 13:17:59 UTC (rev 1115)
@@ -2,7 +2,7 @@
  * main.cpp
  *
  *  Created on: 31.01.2013
- *      Author: Ñîäáî
+ *      Author: Sodbo
  */
 #include <iostream>
 #include <ctime>
@@ -10,18 +10,21 @@
 #include "Parameters.h"
 #include "Reshuffle.h"
 #include <iterator>
+//TODO Create Makefile
 
-
 using namespace std;
 
 int main(int argc, char* argv[]) {
 	cout << "Every day I'm [re]shuffling!" << endl;
 	Parameters Params(argc, argv);
-	cout << Params;
+	if(Params.info.use)
+		cout << Params;
 	iout_file iout_F(Params);
 	cout << "finish iout_file read " << double(clock()) / CLOCKS_PER_SEC << endl;
-	cout<<iout_F.header;
-	cout<<iout_F.labels;
+	if(Params.info.use){
+		cout<<iout_F.header;
+		cout<<iout_F.labels;
+	}
 	Reshuffle reshh(iout_F,Params);
 	reshh.run();
 	cout << "finish_reshuffling " << double(clock()) / CLOCKS_PER_SEC << endl;

Modified: pkg/OmicABEL/src/reshuffle/reshuffle.cpp
===================================================================
--- pkg/OmicABEL/src/reshuffle/reshuffle.cpp	2013-03-05 11:52:43 UTC (rev 1114)
+++ pkg/OmicABEL/src/reshuffle/reshuffle.cpp	2013-03-06 13:17:59 UTC (rev 1115)
@@ -4,6 +4,7 @@
  *  Created on: 01.03.2013
  *      Author: lima
  */
+
 #include "reshuffle.h"
 #include <dir.h>
 #include <ctime>



More information about the Genabel-commits mailing list