-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProteinChain.cpp
More file actions
28 lines (25 loc) · 803 Bytes
/
ProteinChain.cpp
File metadata and controls
28 lines (25 loc) · 803 Bytes
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
#include "ProteinChain.h"
ProteinChain::ProteinChain(std::vector<std::string>&& chainInfo) {
if (chainInfo.size() == 0) {
return;
}
chainID = chainInfo[0].substr(21, 1).at(0);
auto idx = std::stoi(chainInfo.front().substr(22, 4));
std::vector<std::string> localResInfo;
for (auto&& line : chainInfo) {
auto thisIdx = std::stoi(line.substr(22, 4));
if (thisIdx != idx) {
auto& newRes = residues.emplace_back(std::move(localResInfo));
seq += newRes.getOneAA();
localResInfo.clear();
idx = thisIdx;
continue;
}
localResInfo.emplace_back(std::move(line));
}
//Handles the last case
if (localResInfo.size() > 0) {
residues.emplace_back(std::move(localResInfo));
}
length = residues.back().getResIdx() - residues.front().getResIdx() + 1;
}