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
1
// --------------------------------------------------------------------------
2
// OpenMS -- Open-Source Mass Spectrometry
3
// --------------------------------------------------------------------------
4
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
7
// This software is released under a three-clause BSD license:
8
// * Redistributions of source code must retain the above copyright
9
// notice, this list of conditions and the following disclaimer.
10
// * Redistributions in binary form must reproduce the above copyright
11
// notice, this list of conditions and the following disclaimer in the
12
// documentation and/or other materials provided with the distribution.
13
// * Neither the name of any author or any participating institution
14
// may be used to endorse or promote products derived from this software
15
// without specific prior written permission.
16
// For a full list of authors, refer to the file AUTHORS.
17
// --------------------------------------------------------------------------
18
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
30
// --------------------------------------------------------------------------
24
31
// $Maintainer: Hendrik Weisser $
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);
41
SeedListGenerator::SeedListGenerator()
45
void SeedListGenerator::generateSeedList(const MSExperiment<> & experiment,
49
for (MSExperiment<>::ConstIterator exp_it = experiment.begin();
50
exp_it != experiment.end(); ++exp_it)
52
if (exp_it->getMSLevel() == 2) // MS2 spectrum -> look for precursor
54
MSExperiment<>::ConstIterator prec_it =
55
experiment.getPrecursorSpectrum(exp_it);
56
const vector<Precursor> & precursors = exp_it->getPrecursors();
57
DPosition<2> point(prec_it->getRT(), precursors[0].getMZ());
58
seeds.push_back(point);
63
void SeedListGenerator::generateSeedList(vector<PeptideIdentification> &
64
peptides, SeedList & seeds,
65
bool use_peptide_mass)
68
for (vector<PeptideIdentification>::iterator pep_it = peptides.begin();
69
pep_it != peptides.end(); ++pep_it)
72
if (!pep_it->getHits().empty() && use_peptide_mass)
75
const PeptideHit & hit = pep_it->getHits().front();
76
Int charge = hit.getCharge();
77
mz = hit.getSequence().getMonoWeight(Residue::Full, charge) /
82
mz = pep_it->getMetaValue("MZ");
84
DPosition<2> point(pep_it->getMetaValue("RT"), mz);
85
seeds.push_back(point);
89
void SeedListGenerator::generateSeedLists(const ConsensusMap & consensus,
90
Map<UInt64, SeedList> & seed_lists)
93
// iterate over all consensus features...
94
for (ConsensusMap::ConstIterator cons_it = consensus.begin();
95
cons_it != consensus.end(); ++cons_it)
97
DPosition<2> point(cons_it->getRT(), cons_it->getMZ());
98
// for each sub-map in the consensus map, add a seed at the position of
99
// this consensus feature:
100
for (ConsensusMap::FileDescriptions::ConstIterator file_it =
101
consensus.getFileDescriptions().begin(); file_it !=
102
consensus.getFileDescriptions().end(); ++file_it)
103
seed_lists[file_it->first].push_back(point);
104
// for each feature contained in the consensus feature, remove the seed of
105
// the corresponding map:
106
for (ConsensusFeature::HandleSetType::const_iterator feat_it =
107
cons_it->getFeatures().begin(); feat_it !=
108
cons_it->getFeatures().end(); ++feat_it)
110
seed_lists[feat_it->getMapIndex()].pop_back();
112
// this leaves seeds for maps where no feature was found near the
113
// consensus position
117
void SeedListGenerator::convertSeedList(const SeedList & seeds,
118
FeatureMap<> & features)
120
features.clear(true); // "true" should really be a default value here...
122
for (SeedList::const_iterator seed_it = seeds.begin();
123
seed_it != seeds.end(); ++seed_it, ++counter)
126
feature.setRT(seed_it->getX());
127
feature.setMZ(seed_it->getY());
128
feature.setUniqueId(counter);
129
features.push_back(feature);
131
// // assign unique ids:
132
// features.applyMemberFunction(&UniqueIdInterface::setUniqueId);
135
void SeedListGenerator::convertSeedList(const FeatureMap<> & features,
139
for (FeatureMap<>::ConstIterator feat_it = features.begin();
140
feat_it != features.end(); ++feat_it)
142
DPosition<2> point(feat_it->getRT(), feat_it->getMZ());
143
seeds.push_back(point);
145
147
} // namespace OpenMS