#include #include #include #include #include #include "arrays.h" #include "maths.h" #define PROGRAM_NAME "PASTE" #define VERSION "1.0" #define BUILD_DATE "7 October 96" imatrix read_data(fstream& f,int& N,int& P,int& G); main(int argc, char *argv[]) //argc is the number of command lines args (0 is progname) { int NN,PP,GG,n,p,g; int COL=0,GROUP=0,k,l,i; NN=PP=GG=0; cerr << PROGRAM_NAME << " version " << VERSION << " built on " << BUILD_DATE << endl; if(argc < 3) { cerr << "\n----------------------------------------------------------\n"; cerr << "Use this program by giving the command "<< endl; cerr << argv[0] << " ... " << endl; cerr << "This program will paste these data files together into\n"; cerr << "one large GELSTATS datafile\n"; cerr << "See the documentation about how groups are numbered.\n"; cerr << "\n----------------------------------------------------------\n"; exit( 0); } fstream fin; //Read the files from the command line for(i=1;i> n >> p >>g; PP+=p; if(NN==0) NN=n; else { if (NN != n) { cerr << "Sorry: not all your data sets have the same number of bands\n"; cerr << "File " << argv[i] << " has " << n << " bands while previous files\n"; cerr << "had "<> N >> P >> G; imatrix data(N+1,P); for(i=0;i> data[i][j]; if(f.eof()) { cerr << "Problem in read_data(): can't seem to read enough data" << endl; cerr << "EOF occurred before entire data array was read." << endl; exit(37); } } } /* cout << "Here's the data I've just read\n"; cout << "\n\n-----------------------------------------------\n"; for(i=0;i 1) { cerr << "Problem: your data file contains values other that 0 and 1\n"; cerr << "For example, data["<< i << "][" << j << "] = " << data[i][j] << endl; cerr << "Check this.\n"; exit(7); } } } /// Check to make sure labels for groups in first row of data array are okay. for(j=0;j<(P);j++) { if(data[0][j] <0 || data[0][j] >(G)-1) { cerr << "Problem: your data file mentions more groups than expected\n"; cerr << "With G = " << G << " only the values 0,...," << (G-1) << " should appear in\n"; cerr << "the first row of data. But I found data[0][" << j << "]=" << data[0][j] << endl; cerr << "You'd better fix it before running the program on this data\n"; exit(7); } } return data; }