-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblastinfo.cpp
More file actions
46 lines (40 loc) · 1.1 KB
/
blastinfo.cpp
File metadata and controls
46 lines (40 loc) · 1.1 KB
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
#include <unordered_map>
#include <tuple>
#include <string>
#include <sstream>
#include <fstream>
#include <iostream>
#include "boost/multi_array.hpp"
#include "Network.h"
#include "blastinfo.h"
BLASTDict* loadBLASTInfo(Network* net1, Network* net2, string filename){
ifstream infile(filename);
if(!infile.good()){
throw LineReadException("Failed to load BLAST info! Check filename.");
}
int net1Size = net1->nodeToNodeName.size();
int net2Size = net2->nodeToNodeName.size();
BLASTDict* toReturn = new BLASTDict(boost::extents[net1Size][net2Size]);
for(int i = 0; i < net1Size; i++){
for(int j = 0; j < net2Size; j++){
(*toReturn)[i][j] = 0.0;
}
}
string line;
unsigned int count = 0;
while(getline(infile,line)){
istringstream iss(line);
double blastScore;
string a, b;
node u, v;
if (!(iss >> a >> b >> blastScore)){
throw LineReadException(string("Parse error in network: ") + filename +
string("on line: ") + line + "\n");
}
u = net1->nodeNameToNode[a];
v = net2->nodeNameToNode[b];
(*toReturn)[u][v] = blastScore;
count++;
}
return toReturn;
}