Skip to content

Commit

Permalink
Code Arrangement changes #2 (OpenMS#5406)
Browse files Browse the repository at this point in the history
Co-authored-by: Arraxx <[email protected]>
  • Loading branch information
Arraxx and Arraxx authored Jul 11, 2021
1 parent 60f38cd commit a146aed
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 26 deletions.
9 changes: 4 additions & 5 deletions src/openms/source/ANALYSIS/ID/ConsensusIDAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,13 @@ namespace OpenMS
number_of_runs_ = (number_of_runs != 0) ? number_of_runs : ids.size();

// prepare data here, so that it doesn't have to happen in each algorithm:
for (vector<PeptideIdentification>::iterator pep_it = ids.begin();
pep_it != ids.end(); ++pep_it)
for (PeptideIdentification& pep : ids)
{
pep_it->sort();
pep.sort();
if ((considered_hits_ > 0) &&
(pep_it->getHits().size() > considered_hits_))
(pep.getHits().size() > considered_hits_))
{
pep_it->getHits().resize(considered_hits_);
pep.getHits().resize(considered_hits_);
}
}
// make sure there are no duplicated hits (by sequence):
Expand Down
23 changes: 16 additions & 7 deletions src/openms/source/CHEMISTRY/AASequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,10 @@ namespace OpenMS
const AASequence& seq = *this;

String bs;
if (seq.empty()) return bs;

if (seq.empty())
{
return bs;
}
if (seq.hasNTerminalModification())
{
const ResidueModification& mod = *(seq.getNTerminalModification());
Expand All @@ -245,8 +247,10 @@ namespace OpenMS
if (std::find(fixed_modifications.begin(), fixed_modifications.end(), nterm_mod_name) == fixed_modifications.end())
{
double nominal_mass = mod.getDiffMonoMass();
if (!mass_delta) nominal_mass += Residue::getInternalToNTerm().getMonoWeight();

if (!mass_delta)
{
nominal_mass += Residue::getInternalToNTerm().getMonoWeight();
}
String sign = (mass_delta && nominal_mass > 0) ? "+" : ""; // the '-' will be printed automatically by conversion to string
if (integer_mass)
{
Expand All @@ -271,9 +275,14 @@ namespace OpenMS
if (std::find(fixed_modifications.begin(), fixed_modifications.end(), mod_name) == fixed_modifications.end())
{
double nominal_mass;
if (mass_delta) nominal_mass = mod.getDiffMonoMass();
else nominal_mass = r.getMonoWeight(Residue::Internal);

if (mass_delta)
{
nominal_mass = mod.getDiffMonoMass();
}
else
{
nominal_mass = r.getMonoWeight(Residue::Internal);
}
String sign = (mass_delta && nominal_mass > 0) ? "+" : "";
if (aa == "X")
{
Expand Down
15 changes: 8 additions & 7 deletions src/openms/source/FILTERING/ID/IDFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,10 @@ namespace OpenMS
const vector<ProteinIdentification::ProteinGroup>& groups,
vector<ProteinHit>& hits)
{
if (hits.empty()) return; // nothing to update

if (hits.empty())
{
return; // nothing to update
}
// we'll do lots of look-ups, so use a suitable data structure:
unordered_set<String> valid_accessions;
for (const auto& grp : groups)
Expand All @@ -496,15 +498,14 @@ namespace OpenMS
void IDFilter::keepBestPeptideHits(vector<PeptideIdentification>& peptides,
bool strict)
{
for (vector<PeptideIdentification>::iterator pep_it = peptides.begin();
pep_it != peptides.end(); ++pep_it)
for (PeptideIdentification& pep : peptides)
{
vector<PeptideHit>& hits = pep_it->getHits();
vector<PeptideHit>& hits = pep.getHits();
if (hits.size() > 1)
{
pep_it->sort();
pep.sort();
double top_score = hits[0].getScore();
bool higher_better = pep_it->isHigherScoreBetter();
bool higher_better = pep.isHigherScoreBetter();
struct HasGoodScore<PeptideHit> good_score(top_score, higher_better);
if (strict) // only one best score allowed
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,21 @@ namespace OpenMS
bool use_peptide_mass)
{
seeds.clear();
for (vector<PeptideIdentification>::iterator pep_it = peptides.begin();
pep_it != peptides.end(); ++pep_it)
for (PeptideIdentification& pep : peptides)
{
double mz;
if (!pep_it->getHits().empty() && use_peptide_mass)
if (!pep.getHits().empty() && use_peptide_mass)
{
pep_it->sort();
const PeptideHit& hit = pep_it->getHits().front();
pep.sort();
const PeptideHit& hit = pep.getHits().front();
Int charge = hit.getCharge();
mz = hit.getSequence().getMZ(charge);
}
else
{
mz = pep_it->getMZ();
mz = pep.getMZ();
}
DPosition<2> point(pep_it->getRT(), mz);
DPosition<2> point(pep.getRT(), mz);
seeds.push_back(point);
}
}
Expand Down

0 comments on commit a146aed

Please sign in to comment.