Skip to content
Snippets Groups Projects
Commit 727603c1 authored by Olivier Langella's avatar Olivier Langella
Browse files

reading Xtandem files seems to work!

parent 2ff5d8a9
No related branches found
No related tags found
No related merge requests found
......@@ -54,11 +54,19 @@ ProteinMatch * IdentificationGroup::getProteinMatch(const QString accession) {
if (accession.isEmpty()) {
throw pappso::PappsoException(QObject::tr("Error protein match not found : accession is empty"));
}
for (ProteinMatch * p_protein_match : _protein_match_list) {
if (p_protein_match->getProteinXtpSp().get()->getAccession() == accession) {
return p_protein_match;
auto it_cache = _cache_accession_protein_match.find(accession);
if (it_cache == _cache_accession_protein_match.end()) {
//accession not found in cache
for (ProteinMatch * p_protein_match : _protein_match_list) {
if (p_protein_match->getProteinXtpSp().get()->getAccession() == accession) {
_cache_accession_protein_match.insert(std::pair<QString, ProteinMatch *>(accession, p_protein_match));
return p_protein_match;
}
}
}
else {
return it_cache->second;
}
return nullptr;
}
void IdentificationGroup::addProteinMatch(ProteinMatch * protein_match) {
......@@ -66,20 +74,13 @@ void IdentificationGroup::addProteinMatch(ProteinMatch * protein_match) {
if (accession.isEmpty()) {
throw pappso::PappsoException(QObject::tr("Error adding protein match : accession is empty"));
}
bool push = true;
for (ProteinMatch * p_protein_match : _protein_match_list) {
if (p_protein_match == protein_match) {
push = false;
}
else {
if(p_protein_match->getProteinXtpSp().get()->getAccession() == accession) {
throw pappso::PappsoException(QObject::tr("Error adding protein match : accession %1 already registered").arg(accession));
}
}
}
if (push) {
auto it_cache = _cache_already_added_protein_match.find(protein_match);
if (it_cache == _cache_already_added_protein_match.end()) {
//accession not found in cache
_cache_already_added_protein_match.insert(protein_match);
_protein_match_list.push_back(protein_match);
}
}
bool IdentificationGroup::contains (const MsRun * p_msrun) const {
......
......@@ -31,6 +31,7 @@
#ifndef IDENTIFICATIONGROUP_H
#define IDENTIFICATIONGROUP_H
#include <set>
class Project;
......@@ -92,6 +93,9 @@ private :
std::vector<ProteinMatch *> _protein_match_list;
std::vector<MsRunSp> _ms_run_list;
std::map<QString, ProteinMatch *> _cache_accession_protein_match;
std::set<ProteinMatch *> _cache_already_added_protein_match;
};
#endif // IDENTIFICATIONGROUP_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment