[Genabel-commits] r1490 - in branches/ProbABEL-pvals/filevector: fvfutil fvlib

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Dec 19 22:56:04 CET 2013


Author: lckarssen
Date: 2013-12-19 22:56:04 +0100 (Thu, 19 Dec 2013)
New Revision: 1490

Modified:
   branches/ProbABEL-pvals/filevector/fvfutil/convert.cpp
   branches/ProbABEL-pvals/filevector/fvfutil/fv2text.cpp
   branches/ProbABEL-pvals/filevector/fvfutil/mergevars.cpp
   branches/ProbABEL-pvals/filevector/fvfutil/text2fvf.h
   branches/ProbABEL-pvals/filevector/fvfutil/text2fvf_main.cpp
   branches/ProbABEL-pvals/filevector/fvfutil/transpose_main.cpp
   branches/ProbABEL-pvals/filevector/fvfutil/usage.cpp
   branches/ProbABEL-pvals/filevector/fvlib/AbstractMatrix.cpp
   branches/ProbABEL-pvals/filevector/fvlib/AbstractMatrix.h
   branches/ProbABEL-pvals/filevector/fvlib/CastUtils.cpp
   branches/ProbABEL-pvals/filevector/fvlib/CastUtils.h
   branches/ProbABEL-pvals/filevector/fvlib/FileVector.cpp
   branches/ProbABEL-pvals/filevector/fvlib/FileVector.h
   branches/ProbABEL-pvals/filevector/fvlib/FilteredMatrix.cpp
   branches/ProbABEL-pvals/filevector/fvlib/FilteredMatrix.h
   branches/ProbABEL-pvals/filevector/fvlib/Logger.cpp
   branches/ProbABEL-pvals/filevector/fvlib/Logger.h
   branches/ProbABEL-pvals/filevector/fvlib/RealHandlerWrapper.cpp
   branches/ProbABEL-pvals/filevector/fvlib/RealHandlerWrapper.h
   branches/ProbABEL-pvals/filevector/fvlib/ReusableFileHandle.cpp
   branches/ProbABEL-pvals/filevector/fvlib/ReusableFileHandle.h
   branches/ProbABEL-pvals/filevector/fvlib/Transposer.cpp
   branches/ProbABEL-pvals/filevector/fvlib/Transposer.h
   branches/ProbABEL-pvals/filevector/fvlib/convert_util.cpp
   branches/ProbABEL-pvals/filevector/fvlib/convert_util.h
   branches/ProbABEL-pvals/filevector/fvlib/frutil.cpp
   branches/ProbABEL-pvals/filevector/fvlib/frutil.h
Log:
Merging filevector r1450 through r1489 into this branch.


Modified: branches/ProbABEL-pvals/filevector/fvfutil/convert.cpp
===================================================================
--- branches/ProbABEL-pvals/filevector/fvfutil/convert.cpp	2013-12-19 21:53:57 UTC (rev 1489)
+++ branches/ProbABEL-pvals/filevector/fvfutil/convert.cpp	2013-12-19 21:56:04 UTC (rev 1490)
@@ -1,5 +1,6 @@
 /*
-* This is utility to convert old format fvf files: split into data and metadata files.
+* This is utility to convert old format fvf files: split into data and
+* metadata files.
 */
 
 #include <iostream>
@@ -13,77 +14,90 @@
 
 int main(int argc, char * argv[])
 {
-	if ( argc<2 )
-  	{
-  		cout << "Please provide name of the file to convert"<< endl;
-  		exit ( 1 );
-  	}
+    if ( argc < 2 )
+    {
+        cout << "Please provide name of the file to convert" << endl;
+        exit(1);
+    }
     string filename = argv[1];
-    if(filename.find(".fvf")!=filename.length()-4)
-       errorLog << "filename should have .fvf extention" << errorExit;
+    if(filename.find(".fvf") != filename.length() - 4)
+        errorLog << "filename should have .fvf extention" << errorExit;
 
-    string dataFilename = filename.substr(0,filename.length()-4) + FILEVECTOR_DATA_FILE_SUFFIX;
-    string indexFilename = filename.substr(0,filename.length()-4) + FILEVECTOR_INDEX_FILE_SUFFIX;
+    string dataFilename = filename.substr(0, filename.length() - 4) +
+        FILEVECTOR_DATA_FILE_SUFFIX;
+    string indexFilename = filename.substr(0, filename.length() - 4) +
+        FILEVECTOR_INDEX_FILE_SUFFIX;
 
     dbg << "data:" << dataFilename << ", index:" << indexFilename << endl;
 
     FileHeader data_type;
-	struct stat filestatus;
+    struct stat filestatus;
 
-	stat( filename.c_str() , &filestatus);
+    stat( filename.c_str() , &filestatus);
 
 
-	if ( (unsigned int) filestatus.st_size < sizeof(data_type) )
-		errorLog << "File " << filename <<" is too short to contain an FVF-object." << endl << errorExit;
+    if ( (unsigned int) filestatus.st_size < sizeof(data_type) )
+        errorLog << "File " << filename
+                 << " is too short to contain an FVF-object."
+                 << endl << errorExit;
 
-	fstream dataFile;
-	ofstream new_data_file;
-	ofstream new_index_file;
+    fstream dataFile;
+    ofstream new_data_file;
+    ofstream new_index_file;
 
-	dataFile.open(filename.c_str(), ios::out | ios::in | ios::binary);
-	if (dataFile.fail()) {
-		errorLog << "Opening file "<< filename << "for write & read failed" << errorExit;
-	}
+    dataFile.open(filename.c_str(), ios::out | ios::in | ios::binary);
+    if (dataFile.fail()) {
+        errorLog << "Opening file " << filename
+                 << "for write & read failed" << errorExit;
+    }
 
-	dataFile.read((char*)&data_type,sizeof(data_type));
-	if (dataFile.fail()) {
-		errorLog << "Failed to read datainfo from file " << filename << errorExit;
-	}
+    dataFile.read((char*)&data_type, sizeof(data_type));
+    if (dataFile.fail()) {
+        errorLog << "Failed to read datainfo from file "
+                 << filename << errorExit;
+    }
 
-	unsigned long headerSize = sizeof(data_type) + sizeof(FixedChar)*(data_type.numVariables+data_type.numObservations);
+    unsigned long headerSize = sizeof(data_type) +
+        sizeof(FixedChar) * (data_type.numVariables + data_type.numObservations);
 
     new_data_file.open(dataFilename.c_str(), ios::out | ios::binary);
     if (new_data_file.fail())
-    	errorLog << "Creating new data file " << dataFilename << " for write failed" << endl << errorExit;
+    {
+        errorLog << "Creating new data file " << dataFilename
+                 << " for write failed" << endl << errorExit;
+    }
 
     new_index_file.open(indexFilename.c_str(), ios::out | ios::binary);
     if (new_index_file.fail())
-    	errorLog << "Creating new index file "<<indexFilename<<" for write failed"<< endl<< errorExit;
+    {
+        errorLog << "Creating new index file " << indexFilename
+                 << " for write failed" << endl << errorExit;
+    }
 
-     //copy header
+    //copy header
     int buf_len = headerSize;
     char * buffer = new (nothrow) char [buf_len];
     if (!buffer)
-		errorLog << "failed to get memory for buffer " << endl << errorExit;
-		
-     dataFile.seekg( 0 );
-     dataFile.read(buffer,buf_len);
-     new_index_file.write(buffer,buf_len);
+        errorLog << "failed to get memory for buffer " << endl << errorExit;
 
-     dbg << "index copied, copying data..." << endl;
+    dataFile.seekg( 0 );
+    dataFile.read(buffer,buf_len);
+    new_index_file.write(buffer,buf_len);
 
-     //copy data
-     while(!dataFile.eof())
-     {
-       dataFile.read(buffer,buf_len);
-       new_data_file.write(buffer,dataFile.gcount());
-     }
+    dbg << "index copied, copying data..." << endl;
 
-	 dbg << "DONE" << endl;
+    //copy data
+    while(!dataFile.eof())
+    {
+        dataFile.read(buffer, buf_len);
+        new_data_file.write(buffer, dataFile.gcount());
+    }
 
-     dataFile.close();
-     new_data_file.close();
-     new_index_file.close();
-     delete buffer;
+    dbg << "DONE" << endl;
 
+    dataFile.close();
+    new_data_file.close();
+    new_index_file.close();
+    delete[] buffer;
+
 }

Modified: branches/ProbABEL-pvals/filevector/fvfutil/fv2text.cpp
===================================================================
--- branches/ProbABEL-pvals/filevector/fvfutil/fv2text.cpp	2013-12-19 21:53:57 UTC (rev 1489)
+++ branches/ProbABEL-pvals/filevector/fvfutil/fv2text.cpp	2013-12-19 21:56:04 UTC (rev 1490)
@@ -12,7 +12,7 @@
 
 
 
-void info() 
+void info()
 {
     cout << "fv2text converts .fv* files to a text file" << endl;
     cout << "Usage: fv2text inputfile outfile.txt [--RMatrix]" << endl;
@@ -23,21 +23,21 @@
 
     char s[20];
     for(int i=0;i<length;i++){
-	sprintf(s,"%x ", ((unsigned char*)data)[i]);
-	    ret += string(s);
-    }    
+        sprintf(s,"%x ", ((unsigned char*)data)[i]);
+            ret += string(s);
+    }
 
-    return ret;    
+    return ret;
 }*/
 
 
 int main(int argc, char* argv[])
 {
     argc--;
-    if (argc<2) 
+    if (argc<2)
     {
         info();
-	return 0;
+        return 0;
     }
 
     string inputFileName = string(argv[1]);
@@ -46,7 +46,7 @@
     bool isRMatrix;
 
     if (argc >= 3) {
-	isRMatrix = (strcmp(argv[3], "--RMatrix") == 0);
+        isRMatrix = (strcmp(argv[3], "--RMatrix") == 0);
     }
 
     cout << "Input file is '" << inputFileName << "'." << endl;
@@ -59,23 +59,23 @@
     unsigned long row, col;
 
     if (!isRMatrix) {
-	    out << "X ";
+            out << "X ";
     }
 
-    for (col=0; col<fv.getNumObservations(); col++){
-	    out << fv.readObservationName(col).name << " ";
+    for (col = 0; col < fv.getNumObservations(); col++){
+            out << fv.readObservationName(col).name << " ";
     }
 
     out << endl;
 
-    for (row=0; row<fv.getNumVariables(); row++){
-	    out << fv.readVariableName(row).name << " ";
-        for (col=0; col<fv.getNumObservations(); col++){
-    	    char data[2000];
-    	    fv.readElement(row, col, data);
-    	    string elem = bufToString(fv.getElementType(), data,string("NAN"));
-	        out << elem << " ";
-	    }
-	    out << endl;
+    for (row = 0; row < fv.getNumVariables(); row++){
+            out << fv.readVariableName(row).name << " ";
+        for (col = 0; col < fv.getNumObservations(); col++){
+            char data[2000];
+            fv.readElement(row, col, data);
+            string elem = bufToString(fv.getElementType(), data, string("NAN"));
+                out << elem << " ";
+            }
+            out << endl;
     }
 }

Modified: branches/ProbABEL-pvals/filevector/fvfutil/mergevars.cpp
===================================================================
--- branches/ProbABEL-pvals/filevector/fvfutil/mergevars.cpp	2013-12-19 21:53:57 UTC (rev 1489)
+++ branches/ProbABEL-pvals/filevector/fvfutil/mergevars.cpp	2013-12-19 21:56:04 UTC (rev 1490)
@@ -2,72 +2,95 @@
 
 int main(int argc, char * argv[])
 {
-	print_mergevars_welcome();
+    print_mergevars_welcome();
 
-	if (argc < 4) print_mergevars_usage(argv[0]);
+    if (argc < 4) print_mergevars_usage(argv[0]);
 
-	char * ifname1 = argv[1], * ifname2 = argv[2], * ofname = argv[3];
-	unsigned long cachesize = 64;
-	if (argc>4) cachesize = atoi(argv[4]);
-	if (cachesize < 0) errorLog << "cache size must be positive long integer" << endl << endl << errorExit;
-	dbg << "Options in effect:\n";
-	dbg << "\tINFILE1   = " << ifname1 << "\n";
-	dbg << "\tINFILE2   = " << ifname2 << "\n";
-	dbg << "\tOUTFILE   = " << ofname << "\n";
-	dbg << "\tcachesize = " << cachesize << " Mb\n\n";
+    char * ifname1 = argv[1], * ifname2 = argv[2], * ofname = argv[3];
+    unsigned long cachesize = 64;
+    if (argc > 4) cachesize = atoi(argv[4]);
+    if (cachesize < 0)
+    {
+        errorLog << "cache size must be positive long integer"
+                 << endl << endl << errorExit;
+    }
+    dbg << "Options in effect:\n";
+    dbg << "\tINFILE1   = " << ifname1 << "\n";
+    dbg << "\tINFILE2   = " << ifname2 << "\n";
+    dbg << "\tOUTFILE   = " << ofname << "\n";
+    dbg << "\tcachesize = " << cachesize << " Mb\n\n";
 
-	FileVector indata1(ifname1, cachesize);
-	FileVector indata2(ifname2, cachesize);
+    FileVector indata1(ifname1, cachesize);
+    FileVector indata2(ifname2, cachesize);
 
-// sanity checks: can we merge these files?
-// are dimensions compatible?
-	if (indata1.data_type.nobservations != indata2.data_type.nobservations)
-		errorLog << "can not merge files with different number of observations" << endl << endl << errorExit;
-	else
-		errorLog << "file dimensions are compatible\n";
-// are observation names the same?
-	unsigned long cmpfail = 0, i = 0;
-	while (!cmpfail && i<indata1.data_type.nobservations) {
-		cmpfail = strcmp(indata1.observationNames[i].name,indata2.observationNames[i].name);
-		i++;
-	}
-	if (cmpfail){
-		msg << "observation names are not the same in files '" << ifname1;
-		msg << "' and '" << ifname2 << "', observation # " << i <<", names are '";
-		msg << indata1.observationNames[i-1].name;
-		msg << "' and '" << indata2.observationNames[i-1].name;
-		msg << "' (only first shown); name will be taken from the first file\n";
-	} else {
-		msg << "observation names are the same in files '" << ifname1 << "' and '"<< ifname2 << "'\n\n";
-	}
-	unsigned long out_nvars = indata1.data_type.numVariables + indata2.data_type.numVariables;
-	unsigned long out_nobs = indata1.data_type.nobservations;
-	dbg << "initalizing FVF-file '" << ofname << "'...\n";
-	initializeEmptyFile(ofname, out_nvars, out_nobs, FLOAT, true);
-	dbg << "writing out the data ... \n";
+    // sanity checks: can we merge these files?
+    // are dimensions compatible?
+    if (indata1.data_type.nobservations != indata2.data_type.nobservations)
+    {
+        errorLog << "can not merge files with different number of observations"
+                 << endl << endl << errorExit;
+    }
+    else
+    {
+        errorLog << "file dimensions are compatible\n";
+    }
+    // are observation names the same?
+    unsigned long cmpfail = 0, i = 0;
+    while (!cmpfail && i<indata1.data_type.nobservations) {
+        cmpfail = strcmp(indata1.observationNames[i].name,
+                         indata2.observationNames[i].name);
+        i++;
+    }
+    if (cmpfail){
+        msg << "observation names are not the same in files '" << ifname1;
+        msg << "' and '" << ifname2 << "', observation # " << i
+            << ", names are '";
+        msg << indata1.observationNames[i-1].name;
+        msg << "' and '" << indata2.observationNames[i-1].name;
+        msg << "' (only first shown); name will be taken from the first file\n";
+    } else {
+        msg << "observation names are the same in files '" << ifname1
+            << "' and '"<< ifname2 << "'\n\n";
+    }
+    unsigned long out_nvars = indata1.data_type.numVariables +
+        indata2.data_type.numVariables;
+    unsigned long out_nobs = indata1.data_type.nobservations;
+    dbg << "initalizing FVF-file '" << ofname << "'...\n";
+    initializeEmptyFile(ofname, out_nvars, out_nobs, FLOAT, true);
+    dbg << "writing out the data ... \n";
 
-	FileVector outdata(ofname, cachesize);
+    FileVector outdata(ofname, cachesize);
 
-// copy observation names from the first object
-	for (i=0;i<indata1.data_type.nobservations;i++)
-	    outdata.observationNames[i] = indata1.observationNames[i];
+    // copy observation names from the first object
+    for (i = 0; i < indata1.data_type.nobservations; i++)
+    {
+        outdata.observationNames[i] = indata1.observationNames[i];
+    }
 
-// copy var names and data
-	float * tmpdat = new (nothrow) float [outdata.data_type.nobservations];
-	if (!tmpdat) errorLog << "can not allocate memory for tmpdat" << endl << endl << errorExit;
-	for (unsigned long i=0;i<indata1.data_type.numVariables;i++)
-	{
-		outdata.variableNames[i] = indata1.variableNames[i];
-		indata1.readVariable(i,tmpdat);
-		outdata.writeVariable(i,tmpdat);
-	}
+    // copy var names and data
+    float * tmpdat = new (nothrow) float [outdata.data_type.nobservations];
+    if (!tmpdat)
+    {
+        errorLog << "can not allocate memory for tmpdat"
+                 << endl << endl << errorExit;
+    }
 
-	for (i=indata1.data_type.numVariables;i<(indata1.data_type.numVariables+indata2.data_type.numVariables);i++)
-	{
-		outdata.variableNames[i] = indata2.variableNames[i-indata1.data_type.numVariables];
-		indata2.readVariable(i-indata1.data_type.numVariables,tmpdat);
-		outdata.writeVariable(i,tmpdat);
-	} 
+    for (unsigned long i = 0; i < indata1.data_type.numVariables; i++)
+    {
+        outdata.variableNames[i] = indata1.variableNames[i];
+        indata1.readVariable(i,tmpdat);
+        outdata.writeVariable(i,tmpdat);
+    }
 
-	return(1);
+    for (i = indata1.data_type.numVariables;
+         i < (indata1.data_type.numVariables + indata2.data_type.numVariables);
+         i++)
+    {
+        outdata.variableNames[i] =
+            indata2.variableNames[i-indata1.data_type.numVariables];
+        indata2.readVariable(i-indata1.data_type.numVariables, tmpdat);
+        outdata.writeVariable(i, tmpdat);
+    }
+
+    return(1);
 }

Modified: branches/ProbABEL-pvals/filevector/fvfutil/text2fvf.h
===================================================================
--- branches/ProbABEL-pvals/filevector/fvfutil/text2fvf.h	2013-12-19 21:53:57 UTC (rev 1489)
+++ branches/ProbABEL-pvals/filevector/fvfutil/text2fvf.h	2013-12-19 21:56:04 UTC (rev 1490)
@@ -11,8 +11,12 @@
 #define T2F_AUTHORS "Yurii Aulchenko"
 
 void text2fvf(
-    string program_name, string infilename, string outfilename, string rownamesfilename, string colnamesfilename,
-	int rownames, int colnames,	unsigned long skiprows, unsigned long skipcols, int transpose, int Rmatrix, unsigned short int type, bool quiet, string nanString
+    string program_name, string infilename, string outfilename,
+    string rownamesfilename, string colnamesfilename,
+    int rownames, int colnames,
+    unsigned long skiprows, unsigned long skipcols,
+    int transpose, int Rmatrix, unsigned short int type,
+    bool quiet, string nanString
 );
 
 

Modified: branches/ProbABEL-pvals/filevector/fvfutil/text2fvf_main.cpp
===================================================================
--- branches/ProbABEL-pvals/filevector/fvfutil/text2fvf_main.cpp	2013-12-19 21:53:57 UTC (rev 1489)
+++ branches/ProbABEL-pvals/filevector/fvfutil/text2fvf_main.cpp	2013-12-19 21:56:04 UTC (rev 1490)
@@ -69,10 +69,10 @@
                 colnamesfilename = string(optarg);
                 break;
             case 't':
-                transpose=1;
+                transpose = 1;
                 break;
             case 'R':
-                Rmatrix=1;
+                Rmatrix = 1;
                 break;
             case 'd':
                 cout << "optarg:" << optarg << flush;
@@ -100,13 +100,14 @@
         print_text2fvf_usage(program_name);
     }
 
-    string Pname = program_name, Iname = infilename, Oname = outfilename, RFname = rownamesfilename, CFname = colnamesfilename;
+    string Pname = program_name, Iname = infilename, Oname = outfilename,
+        RFname = rownamesfilename, CFname = colnamesfilename;
 
     text2fvf(Pname, Iname, Oname,
-                RFname, CFname,
-                rownames, colnames,
-                skiprows, skipcols,
-                transpose, Rmatrix, dataType, !!quiet, nanString);
+             RFname, CFname,
+             rownames, colnames,
+             skiprows, skipcols,
+             transpose, Rmatrix, dataType, !!quiet, nanString);
 
     return(0);
 }

Modified: branches/ProbABEL-pvals/filevector/fvfutil/transpose_main.cpp
===================================================================
--- branches/ProbABEL-pvals/filevector/fvfutil/transpose_main.cpp	2013-12-19 21:53:57 UTC (rev 1489)
+++ branches/ProbABEL-pvals/filevector/fvfutil/transpose_main.cpp	2013-12-19 21:56:04 UTC (rev 1490)
@@ -1,6 +1,6 @@
 /*
-* This is utility to transpose FileVector files in binary format, so there will not be need in
-advanced text tools behaviour.
+* This is utility to transpose FileVector files in binary format, so there
+* will not be need in advanced text tools behaviour.
 */
 
 #include <iostream>
@@ -15,14 +15,13 @@
 
 int main(int argc, char * argv[])
 {
-	if ( argc<2 )
-  	{
-  		cout << "Please provide name of the file to transpose"<< endl;
-  		exit ( 1 );
-  	}
+    if (argc < 2)
+    {
+        cout << "Please provide name of the file to transpose" << endl;
+        exit(1);
+    }
     string filename = argv[1];
 
     Transposer tr;
     tr.process(filename);
 }
-

Modified: branches/ProbABEL-pvals/filevector/fvfutil/usage.cpp
===================================================================
--- branches/ProbABEL-pvals/filevector/fvfutil/usage.cpp	2013-12-19 21:53:57 UTC (rev 1489)
+++ branches/ProbABEL-pvals/filevector/fvfutil/usage.cpp	2013-12-19 21:56:04 UTC (rev 1490)
@@ -4,65 +4,97 @@
 
 void print_text2fvf_usage(char * progname)
 {
-        cout << "USAGE: " << progname << " -i INFILE -o OUTFILE [-r N2] [--colnames[=CFILE]] [-t] [-datatype=TYPE]" << endl;
-        cout << endl;
-        cout << "\t--infile=INFILE    : the name of the input file containing matrix in text format" << endl;
-        cout << "\t--outfile=OUTFILE  : name of the output file which will containing matrix in FVF format" << endl;
-        cout << "\t--skipcols=N1      : skip N1 first columns when reading from the input text file" << endl;
-        cout << "\t--rownames=N2      : row names are provided in the N2-th column of the text file" << endl;
-        cout << "\t--colnames[=CFILE] : column names are provided either as the first line of the text" << endl;
-        cout << "\t                     matrix text file (if no arguments supplied) or in a separate" << endl;
-        cout << "\t                     text file CFILE" << endl;
-        cout << "\t--transpose        : should the matrix be transposed" << endl;
-        cout << "\t--datatype=TYPE    : specify destination data type, default is DOUBLE" << endl;
+    cout << "USAGE: " << progname << " -i INFILE -o OUTFILE [-r N2] "
+         << "[--colnames[=CFILE]] [-t] [-datatype=TYPE]" << endl;
+    cout << endl;
+    cout << "\t--infile=INFILE    : the name of the input file "
+         << "containing matrix in text format" << endl;
+    cout << "\t--outfile=OUTFILE  : name of the output file which "
+         << "will containing matrix in FVF format" << endl;
+    cout << "\t--skipcols=N1      : skip N1 first columns when reading "
+         << "from the input text file" << endl;
+    cout << "\t--rownames=N2      : row names are provided in the N2-th "
+         << "column of the text file" << endl;
+    cout << "\t--colnames[=CFILE] : column names are provided either as "
+         << "the first line of the text" << endl;
+    cout << "\t                     matrix text file "
+         << "(if no arguments supplied) or in a separate" << endl;
+    cout << "\t                     text file CFILE" << endl;
+    cout << "\t--transpose        : should the matrix be transposed" << endl;
+    cout << "\t--datatype=TYPE    : specify destination data type, "
+         << "default is DOUBLE" << endl;
 
-        cout << endl;
-        cout << "The program will convert text matrix to FileVector (FVF) format."<< endl;
-        cout << "By default, the columns of the text matrix are considered as 'variables'"<< endl;
-        cout << "for which FVF will provide fast access. If you want it other way around,"<< endl;
-        cout << "please specify '-t' option."<< endl;
-        cout << ""<< endl;
-        cout << "EXAMPLES: " << progname << " -i test.mldose -o test.mldose.fvf -c 2 -r 1"<< endl;
-        cout << "          Text matrix file contains two starting columns, first of which"<< endl;
-        cout << "          contains subjects IDs."<< endl;
-        cout << "          Command will convert text matrix provided in 'test.mldose' to "<< endl;
-        cout << "          FVF-formated file 'test.mldose.fvf'. Columns will be stored as"<< endl;
-        cout << "          the fast-access FVF 'variables'"<< endl;
-        cout << ""<< endl;
-        cout << "          " << progname << " -i test.mldose -o test.mldose.fvf -c 2 -r 1 -t"<< endl;
-        cout << "          Same as above, but transposing the matrix. Rows will be stores as"<< endl;
-        cout << "          the fast-access FVF 'variables'"<< endl;
-        cout << ""<< endl;
-        cout << "          " << progname << " -i test.mldose -o test.mldose.fvf -c 2 -r 1 --colnames=test.snplist"<< endl;
-        cout << "          Same as example 1, but we tell that column names are stored in file"<< endl;
-        cout << "          'test.snplist' (mind the full format used: '--colnames=CFILE')"<< endl;
-        cout << ""<< endl;
-        exit(0);
+    cout << endl;
+    cout << "The program will convert text matrix to FileVector (FVF) format."
+         << endl;
+    cout << "By default, the columns of the text matrix are considered "
+         << "as 'variables'" << endl;
+    cout << "for which FVF will provide fast access. If you want it "
+         << "other way around," << endl;
+    cout << "please specify '-t' option." << endl;
+    cout << "" << endl;
+    cout << "EXAMPLES: " << progname << " -i test.mldose -o test.mldose.fvf "
+         << "-c 2 -r 1" << endl;
+    cout << "          Text matrix file contains two starting columns, "
+         << "first of which" << endl;
+    cout << "          contains subjects IDs." << endl;
+    cout << "          Command will convert text matrix provided "
+         << "in 'test.mldose' to " << endl;
+    cout << "          FVF-formated file 'test.mldose.fvf'. "
+         << "Columns will be stored as" << endl;
+    cout << "          the fast-access FVF 'variables'" << endl;
+    cout << "" << endl;
+    cout << "          " << progname << " -i test.mldose "
+         << "-o test.mldose.fvf -c 2 -r 1 -t" << endl;
+    cout << "          Same as above, but transposing the matrix. "
+         << "Rows will be stores as" << endl;
+    cout << "          the fast-access FVF 'variables'" << endl;
+    cout << "" << endl;
+    cout << "          " << progname << " -i test.mldose "
+         << "-o test.mldose.fvf -c 2 -r 1 --colnames=test.snplist" << endl;
+    cout << "          Same as example 1, but we tell that column names "
+         << "are stored in file" << endl;
+    cout << "          'test.snplist' (mind the full format "
+         << "used: '--colnames=CFILE')" << endl;
+    cout << "" << endl;
+    exit(0);
 }
 
+
 void print_text2fvf_welcome()
 {
-        cout << "\ntext2fvf v. " << T2F_VERSION << " (" << T2F_RELEASEDATE << ")"<< endl;
-        cout << "(C) " << T2F_AUTHORS << endl;
-        cout << "based on FileVector v. " << FV_VERSION << " (" << FV_RELEASEDATE << ")"<< endl;
-        cout << "(C) " << FV_AUTHORS << endl;
+    cout << "\ntext2fvf v. " << T2F_VERSION
+         << " (" << T2F_RELEASEDATE
+         << ")" << endl;
+    cout << "(C) " << T2F_AUTHORS << endl;
+    cout << "based on FileVector v. " << FV_VERSION
+         << " (" << FV_RELEASEDATE
+         << ")" << endl;
+    cout << "(C) " << FV_AUTHORS << endl;
 }
 
+
 void print_mergevars_usage(char * progname)
 {
-        cout << "USAGE: " << progname << " INFILE1 INFILE2 OUTFILE [cachesize]" << ""<< endl;
-        cout << ""<< endl;
-        cout << "\tINFILE1, INFILE2 : two files in FVF-format"<< endl;
-        cout << "\tOUTFILE          : name of file where merged data will be written to"<< endl;
-        cout << "\tcachesize        : size (Mb) of cache to be used (optional)"<< endl;
-        cout << ""<< endl;
-        exit(0);
+    cout << "USAGE: " << progname
+         << " INFILE1 INFILE2 OUTFILE [cachesize]" << endl;
+    cout << "" << endl;
+    cout << "\tINFILE1, INFILE2 : two files in FVF-format" << endl;
+    cout << "\tOUTFILE          : name of file where merged data "
+         << "will be written to" << endl;
+    cout << "\tcachesize        : size (Mb) of cache to be used "
+         << "(optional)" << endl;
+    cout << "" << endl;
+    exit(0);
 }
 
+
 void print_mergevars_welcome()
 {
-        cout << "\nmergevars v. " << MERGEVARS_VERSION << " (" << MERGEVARS_RELEASEDATE << ")"<< endl;
-        cout << "(C) " << MERGEVARS_AUTHORS << "\n"<< endl;
-        cout << "based on FileVector v. " << FV_VERSION << " (" << FV_RELEASEDATE << ")"<< endl;
-        cout << "(C) " << FV_AUTHORS << "\n"<< endl;
+    cout << "\nmergevars v. " << MERGEVARS_VERSION
+         << " (" << MERGEVARS_RELEASEDATE << ")" << endl;
+    cout << "(C) " << MERGEVARS_AUTHORS << "\n" << endl;
+    cout << "based on FileVector v. " << FV_VERSION
+         << " (" << FV_RELEASEDATE << ")" << endl;
+    cout << "(C) " << FV_AUTHORS << "\n" << endl;
 }

Modified: branches/ProbABEL-pvals/filevector/fvlib/AbstractMatrix.cpp
===================================================================
--- branches/ProbABEL-pvals/filevector/fvlib/AbstractMatrix.cpp	2013-12-19 21:53:57 UTC (rev 1489)
+++ branches/ProbABEL-pvals/filevector/fvlib/AbstractMatrix.cpp	2013-12-19 21:56:04 UTC (rev 1490)
@@ -3,18 +3,18 @@
 set<string> AbstractMatrix::fileNamesOpenForWriting;
 
 void AbstractMatrix::checkOpenForWriting(const string fileName){
-    deepDbg << "checkOpenForWriting("<< fileName << ")" << endl;
-    if (AbstractMatrix::fileNamesOpenForWriting.find(fileName) != fileNamesOpenForWriting.end()) {
+    deepDbg << "checkOpenForWriting(" << fileName << ")" << endl;
+    if (AbstractMatrix::fileNamesOpenForWriting.find(fileName) !=
+        fileNamesOpenForWriting.end()) {
         errorLog << "File " << fileName << " is already opened." <<  endl;
         throw 1;
     } else {
         AbstractMatrix::fileNamesOpenForWriting.insert(fileName);
     }
 }
+
+
 void AbstractMatrix::closeForWriting(const string fileName){
-    fmDbg << "closeForWriting("<< fileName << ")" << endl;
+    fmDbg << "closeForWriting(" << fileName << ")" << endl;
     AbstractMatrix::fileNamesOpenForWriting.erase(fileName);
 }
-
-
-

Modified: branches/ProbABEL-pvals/filevector/fvlib/AbstractMatrix.h
===================================================================
--- branches/ProbABEL-pvals/filevector/fvlib/AbstractMatrix.h	2013-12-19 21:53:57 UTC (rev 1489)
+++ branches/ProbABEL-pvals/filevector/fvlib/AbstractMatrix.h	2013-12-19 21:56:04 UTC (rev 1490)
@@ -14,48 +14,52 @@
 // See filteredMatrix.h for detailed comments
 
 class AbstractMatrix {
-public:
+ public:
     virtual ~AbstractMatrix(){};
 
     template <class DT>
-    void writeVariableAs(unsigned long varIdx, DT * outvec)
+        void writeVariableAs(unsigned long varIdx, DT * outvec)
     {
         char* tmp = new (nothrow) char [getNumObservations()*getElementSize()];
-        if(!tmp)
+        if (!tmp)
             errorLog << "writeVariableAs allocation error" << errorExit;
-        for(unsigned long int i = 0; i< getNumObservations();i++){
-            performCast(&tmp[i*getElementSize()],outvec[i],getElementType(), warningIsShown);
+        for (unsigned long int i = 0; i < getNumObservations(); i++){
+            performCast(&tmp[i * getElementSize()], outvec[i], getElementType(),
+                        warningIsShown);
         }
         writeVariable(varIdx, tmp);
         delete[] tmp;
     }
 
     template <class DT>
-    void addVariableAs(DT * outvec, string varname)
+        void addVariableAs(DT * outvec, string varname)
     {
         char* tmp = new (nothrow) char [getNumObservations()*getElementSize()];
-        if(!tmp)
+        if (!tmp)
             errorLog << "add_variable_as allocation error" << errorExit;
-        for(unsigned long int i = 0; i< getNumObservations();i++){
-            performCast(&tmp[i*getElementSize()],outvec[i],getElementType(), warningIsShown);
+        for (unsigned long int i = 0; i < getNumObservations(); i++){
+            performCast(&tmp[i * getElementSize()], outvec[i], getElementType(),
+                        warningIsShown);
         }
-        addVariable (tmp, varname);
+        addVariable (tmp,  varname);
         delete[] tmp;
     }
 
     template<class DT>
-    void readVariableAs(unsigned long varIdx, DT * outvec)
+        void readVariableAs(unsigned long varIdx, DT * outvec)
     {
-       char * tmp = new (nothrow) char[getNumObservations()*getElementSize()];
-       readVariable(varIdx, tmp);
-       for(unsigned long int i = 0; i< getNumObservations();i++) {
-            performCast(outvec[i],&tmp[i*getElementSize()],getElementType(),warningIsShown);
-       }
-       delete[] tmp;
+        char * tmp = new (nothrow) char[getNumObservations()*getElementSize()];
+        readVariable(varIdx, tmp);
+        for (unsigned long int i = 0; i < getNumObservations(); i++) {
+            performCast(outvec[i], &tmp[i*getElementSize()], getElementType(),
+                        warningIsShown);
+        }
+        delete[] tmp;
     }
 
     template<class DT>
-    void readElementAs(unsigned long varNumber, unsigned long obsNumber, DT & element){
+        void readElementAs(unsigned long varNumber, unsigned long obsNumber,
+                           DT & element){
         char *ret= new char [getElementSize()];
         readElement(varNumber, obsNumber, ret);
         performCast(element, ret, getElementType(), warningIsShown);
@@ -63,14 +67,16 @@
     }
 
     template <class DT>
-    void writeElementAs(unsigned long varNumber, unsigned long obsNumber, DT& element){
-       deepDbg << "AbstractMatrix.writeElementAs(" << varNumber << "," << obsNumber << "," << element <<")";
-       deepDbg << "Alloc getElementSize() = " << getElementSize() << endl;
-       char *ret = new char [getElementSize()];
-       deepDbg << "Perform cast" << endl;
-       performCast(ret, element, getElementType(), warningIsShown);
-       writeElement(varNumber, obsNumber, ret);
-       delete [] ret;
+        void writeElementAs(unsigned long varNumber, unsigned long obsNumber,
+                            DT& element){
+        deepDbg << "AbstractMatrix.writeElementAs(" << varNumber << ","
+                << obsNumber << "," << element <<")";
+        deepDbg << "Alloc getElementSize() = " << getElementSize() << endl;
+        char *ret = new char [getElementSize()];
+        deepDbg << "Perform cast" << endl;
+        performCast(ret, element, getElementType(), warningIsShown);
+        writeElement(varNumber, obsNumber, ret);
+        delete [] ret;
     }
 
     virtual string getFileName() = 0;
@@ -78,18 +84,23 @@
     virtual unsigned long getNumVariables() = 0;
     virtual unsigned long getNumObservations() = 0;
 
-	virtual void saveAs( string newFilename ) = 0;
-	virtual void saveVariablesAs( string newFilename, unsigned long nvars, unsigned long * varindexes) = 0;
-   	virtual void saveObservationsAs( string newFilename, unsigned long nobss, unsigned long * obsindexes) = 0;
+    virtual void saveAs(string newFilename) = 0;
+    virtual void saveVariablesAs(string newFilename, unsigned long nvars,
+                                 unsigned long * varindexes) = 0;
+    virtual void saveObservationsAs(string newFilename, unsigned long nobss,
+                                    unsigned long * obsindexes) = 0;
 
-    virtual void saveAs(string newFilename, unsigned long nvars, unsigned long nobss, unsigned long * varindexes, unsigned long * obsindexes) = 0;
-    virtual void saveAsText(string newFilename, bool saveVarNames, bool saveObsNames, string nanString) = 0;
+    virtual void saveAs(string newFilename, unsigned long nvars,
+                        unsigned long nobss, unsigned long * varindexes,
+                        unsigned long * obsindexes) = 0;
+    virtual void saveAsText(string newFilename, bool saveVarNames,
+                            bool saveObsNames, string nanString) = 0;
 
     virtual void readObservation(unsigned long obsIdx, void * outvec) = 0;
     virtual void writeObservation(unsigned long obsIdx, void * invec) = 0;
 
-    virtual void writeVariableName(unsigned long varIdx, FixedChar newname) = 0;  // todo loooong future -- control that name is unique
-    virtual void writeObservationName(unsigned long obsIdx, FixedChar newname)= 0;  //todo loooong future -- control that name is unique!
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/genabel -r 1490


More information about the Genabel-commits mailing list