1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// OpenMS Mass Spectrometry Framework
6
// --------------------------------------------------------------------------
7
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
// --------------------------------------------------------------------------
24
// $Maintainer: Hendrik Weisser $
25
// $Authors: Hendrik Weisser $
26
// --------------------------------------------------------------------------
28
#include <OpenMS/TRANSFORMATIONS/FEATUREFINDER/SeedListGenerator.h>
34
SeedListGenerator::SeedListGenerator()
39
void SeedListGenerator::generateSeedList(const MSExperiment<>& experiment,
43
for (MSExperiment<>::ConstIterator exp_it = experiment.begin();
44
exp_it != experiment.end(); ++exp_it)
46
if (exp_it->getMSLevel() == 2) // MS2 spectrum -> look for precursor
48
MSExperiment<>::ConstIterator prec_it =
49
experiment.getPrecursorSpectrum(exp_it);
50
const vector<Precursor>& precursors = exp_it->getPrecursors();
51
DPosition<2> point(prec_it->getRT(), precursors[0].getMZ());
52
seeds.push_back(point);
58
void SeedListGenerator::generateSeedList(vector<PeptideIdentification>&
59
peptides, SeedList& seeds,
60
bool use_peptide_mass)
63
for (vector<PeptideIdentification>::iterator pep_it = peptides.begin();
64
pep_it != peptides.end(); ++pep_it)
67
if (!pep_it->getHits().empty() && use_peptide_mass)
70
const PeptideHit& hit = pep_it->getHits().front();
71
Int charge = hit.getCharge();
72
mz = hit.getSequence().getMonoWeight(Residue::Full, charge) /
77
mz = pep_it->getMetaValue("MZ");
79
DPosition<2> point(pep_it->getMetaValue("RT"), mz);
80
seeds.push_back(point);
85
void SeedListGenerator::generateSeedLists(const ConsensusMap& consensus,
86
Map<UInt64, SeedList>& seed_lists)
89
// iterate over all consensus features...
90
for (ConsensusMap::ConstIterator cons_it = consensus.begin();
91
cons_it != consensus.end(); ++cons_it)
93
DPosition<2> point(cons_it->getRT(), cons_it->getMZ());
94
// for each sub-map in the consensus map, add a seed at the position of
95
// this consensus feature:
96
for (ConsensusMap::FileDescriptions::ConstIterator file_it =
97
consensus.getFileDescriptions().begin(); file_it !=
98
consensus.getFileDescriptions().end(); ++file_it)
99
seed_lists[file_it->first].push_back(point);
100
// for each feature contained in the consensus feature, remove the seed of
101
// the corresponding map:
102
for (ConsensusFeature::HandleSetType::const_iterator feat_it =
103
cons_it->getFeatures().begin(); feat_it !=
104
cons_it->getFeatures().end(); ++feat_it)
106
seed_lists[feat_it->getMapIndex()].pop_back();
108
// this leaves seeds for maps where no feature was found near the
109
// consensus position
114
void SeedListGenerator::convertSeedList(const SeedList& seeds,
115
FeatureMap<>& features)
117
features.clear(true); // "true" should really be a default value here...
119
for (SeedList::const_iterator seed_it = seeds.begin();
120
seed_it != seeds.end(); ++seed_it, ++counter)
123
feature.setRT(seed_it->getX());
124
feature.setMZ(seed_it->getY());
125
feature.setUniqueId(counter);
126
features.push_back(feature);
128
// // assign unique ids:
129
// features.applyMemberFunction(&UniqueIdInterface::setUniqueId);
133
void SeedListGenerator::convertSeedList(const FeatureMap<>& features,
137
for (FeatureMap<>::ConstIterator feat_it = features.begin();
138
feat_it != features.end(); ++feat_it)
140
DPosition<2> point(feat_it->getRT(), feat_it->getMZ());
141
seeds.push_back(point);
145
} // namespace OpenMS