-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreadFileTestUtils.cpp
69 lines (57 loc) · 1.25 KB
/
readFileTestUtils.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream>
#include <string>
#include <fstream>
#include <list>
#include <cstdlib>
#include <vector>
#include "readFileTestUtils.h"
using namespace std;
void printFromFile(string filename)
{
// Connecting file to stream
ifstream fin;
fin.open(filename.c_str());
if (fin.fail())
{
cout << "Input file opening failed.";
exit(1);
}
// Loop reading to screen
string line;
while (! fin.eof())
{
getline(fin, line);
cout << line << endl;
}
}
void printFromData(double **dataMatrix, int numOfMeas, int numOfGenes, vector<string>& measIDs, vector<string>& geneIDs)
{
cout << "///\t";
// Writes all gene-IDs
vector<string>::const_iterator it;
for (it = geneIDs.begin(); it != geneIDs.end(); ++it)
{
cout << *it << "\t";
}
cout << endl;
// Writes all measurment-IDs and data
it = measIDs.begin();
for (int i=0; i < numOfMeas; i++)
{
cout << *it << "\t";
for (int j=0; j < numOfGenes; j++)
{
cout << dataMatrix[i][j] << "\t";
}
++it;
cout << endl;
}
}
void printStringVector(vector<string>& strList)
{
vector<string>::const_iterator iterator;
for (iterator = strList.begin(); iterator != strList.end(); ++iterator)
{
cout << *iterator << endl;
}
}