-
Notifications
You must be signed in to change notification settings - Fork 4
/
sfs.cpp
30 lines (29 loc) · 936 Bytes
/
sfs.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
#include "sfs.hpp"
// TODO: if we split the .sfs into more files, we can load it using more threads
// (but for SVs having a single file shouldn't be the bottleneck)
unordered_map<string, vector<SFS>> parse_sfsfile(const string &sfs_path) {
spdlog::info("Loading SFSs from {}..", sfs_path);
unordered_map<string, vector<SFS>> SFSs;
int total = 0;
string line;
ifstream inf(sfs_path);
if (inf.is_open()) {
string info[4];
string read_name;
while (getline(inf, line)) {
stringstream ssin(line);
int i = 0;
while (ssin.good() && i < 4)
ssin >> info[i++];
if (info[0].compare("*") != 0) {
read_name = info[0];
SFSs[read_name] = vector<SFS>();
}
SFSs[read_name].push_back(
SFS(read_name, stoi(info[1]), stoi(info[2]), stoi(info[3])));
++total;
}
}
spdlog::info("Loaded {} SFSs from {} reads.", total, SFSs.size());
return SFSs;
}