| OpenMS 2.5.0

ParentMolecule.h
Go to the documentation of this file.
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-2020.
6 //
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.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Hendrik Weisser $
32 // $Authors: Hendrik Weisser $
33 // --------------------------------------------------------------------------
34
35 #pragma once
36
37 #include <OpenMS/METADATA/ID/ScoredProcessingResult.h>
38
39 #include <boost/multi_index_container.hpp>
40 #include <boost/multi_index/ordered_index.hpp>
41 #include <boost/multi_index/member.hpp>
42
43 namespace OpenMS
44 {
45 namespace IdentificationDataInternal
46 {
49 struct ParentMolecule: public ScoredProcessingResult
50 {
51 String accession;
52
53 enum MoleculeType molecule_type;
54
55 // @TODO: if there are modifications in the sequence, "sequence.size()"
56 // etc. will be misleading!
57 String sequence;
58
59 String description;
60
61 double coverage;
62
63 bool is_decoy;
64
65 explicit ParentMolecule(
66 const String& accession,
67 MoleculeType molecule_type = MoleculeType::PROTEIN,
68 const String& sequence = "", const String& description = "",
69 double coverage = 0.0, bool is_decoy = false,
70 const AppliedProcessingSteps& steps_and_scores =
71 AppliedProcessingSteps()):
72 ScoredProcessingResult(steps_and_scores), accession(accession),
73 molecule_type(molecule_type), sequence(sequence),
74 description(description), coverage(coverage), is_decoy(is_decoy)
75 {
76 }
77
78 ParentMolecule(const ParentMolecule&) = default;
79
80 ParentMolecule& operator+=(const ParentMolecule& other)
81 {
82 ScoredProcessingResult::operator+=(other);
83 if (sequence.empty()) sequence = other.sequence;
84 if (description.empty()) description = other.description;
85 if (!is_decoy) is_decoy = other.is_decoy; // believe it when it's set
86 // @TODO: what about coverage? (not reliable if we're merging data)
87
88 return *this;
89 }
90 };
91
92 // parent molecules indexed by their accessions:
93 // @TODO: allow querying/iterating over proteins and RNAs separately
94 typedef boost::multi_index_container<
95 ParentMolecule,
96 boost::multi_index::indexed_by<
97 boost::multi_index::ordered_unique<boost::multi_index::member<
98 ParentMolecule, String, &ParentMolecule::accession>>>
99 > ParentMolecules;
100 typedef IteratorWrapper<ParentMolecules::iterator> ParentMoleculeRef;
101
102 }
103 }
OpenMS::IdentificationDataInternal::ParentMolecule::operator+=
ParentMolecule & operator+=(const ParentMolecule &other)
Definition: ParentMolecule.h:80
OpenMS::IdentificationDataInternal::ParentMolecule::ParentMolecule
ParentMolecule(const String &accession, MoleculeType molecule_type=MoleculeType::PROTEIN, const String &sequence="", const String &description="", double coverage=0.0, bool is_decoy=false, const AppliedProcessingSteps &steps_and_scores=AppliedProcessingSteps())
Definition: ParentMolecule.h:65
OpenMS::String
A more convenient string class.
Definition: String.h:58
ScoredProcessingResult.h
OpenMS::IdentificationDataInternal::ParentMolecule
Representation of a parent molecule that is identified only indirectly (e.g. a protein).
Definition: ParentMolecule.h:49
OpenMS::IdentificationDataInternal::PROTEIN
Definition: MetaData.h:65
OpenMS::IdentificationDataInternal::IteratorWrapper
Wrapper that adds operator< to iterators, so they can be used as (part of) keys in maps/sets or multi...
Definition: MetaData.h:43
OpenMS::IdentificationDataInternal::ParentMolecule::description
String description
Definition: ParentMolecule.h:59
OpenMS::IdentificationDataInternal::ParentMolecule::coverage
double coverage
sequence coverage as a fraction between 0 and 1
Definition: ParentMolecule.h:61
OpenMS::IdentificationDataInternal::AppliedProcessingSteps
boost::multi_index_container< AppliedProcessingStep, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::ordered_unique< boost::multi_index::member< AppliedProcessingStep, boost::optional< ProcessingStepRef >, &AppliedProcessingStep::processing_step_opt > > > > AppliedProcessingSteps
Definition: AppliedProcessingStep.h:116
OpenMS::IdentificationDataInternal::ParentMolecules
boost::multi_index_container< ParentMolecule, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::member< ParentMolecule, String, &ParentMolecule::accession > > > > ParentMolecules
Definition: ParentMolecule.h:99
OpenMS::IdentificationDataInternal::ScoredProcessingResult
Base class for ID data with scores and processing steps (and meta info)
Definition: ScoredProcessingResult.h:44
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::IdentificationDataInternal::ScoredProcessingResult::steps_and_scores
AppliedProcessingSteps steps_and_scores
Definition: ScoredProcessingResult.h:46
OpenMS::IdentificationDataInternal::ParentMoleculeRef
IteratorWrapper< ParentMolecules::iterator > ParentMoleculeRef
Definition: ParentMolecule.h:100
OpenMS::IdentificationDataInternal::ParentMolecule::sequence
String sequence
Definition: ParentMolecule.h:57
OpenMS::IdentificationDataInternal::ScoredProcessingResult::operator+=
ScoredProcessingResult & operator+=(const ScoredProcessingResult &other)
Merge in data from another object.
Definition: ScoredProcessingResult.h:107
OpenMS::IdentificationDataInternal::ParentMolecule::accession
String accession
Definition: ParentMolecule.h:51
OpenMS::IdentificationDataInternal::ParentMolecule::is_decoy
bool is_decoy
Definition: ParentMolecule.h:63
OpenMS::IdentificationDataInternal::ParentMolecule::molecule_type
enum MoleculeType molecule_type
Definition: ParentMolecule.h:53
OpenMS::IdentificationDataInternal::MoleculeType
MoleculeType
Definition: MetaData.h:63