OpenMS
ParentSequence.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Hendrik Weisser $
6 // $Authors: Hendrik Weisser $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
12 
13 #include <boost/multi_index_container.hpp>
14 #include <boost/multi_index/ordered_index.hpp>
15 #include <boost/multi_index/member.hpp>
16 
17 namespace OpenMS
18 {
19  namespace IdentificationDataInternal
20  {
24  {
26 
28 
29  // @TODO: if there are modifications in the sequence, "sequence.size()"
30  // etc. will be misleading!
32 
34 
35  double coverage;
36 
37  bool is_decoy;
38 
39  explicit ParentSequence(
40  const String& accession,
42  const String& sequence = "", const String& description = "",
43  double coverage = 0.0, bool is_decoy = false,
48  {
49  }
50 
51  ParentSequence(const ParentSequence&) = default;
52 
54  {
56  if (sequence.empty())
57  {
58  sequence = other.sequence;
59  }
60  else if (!other.sequence.empty() && sequence != other.sequence) // differ and none is empty
61  {
62  throw Exception::InvalidValue(__FILE__, __LINE__,
63  OPENMS_PRETTY_FUNCTION,
64  "Trying to overwrite ParentSequence sequence '" + sequence + "' with conflicting value.",
65  other.sequence);
66  }
67 
68  if (description.empty())
69  {
70  description = other.description;
71  }
72  else if (!other.description.empty() && description != other.description) // differ and none is empty
73  {
74  throw Exception::InvalidValue(__FILE__, __LINE__,
75  OPENMS_PRETTY_FUNCTION,
76  "Trying to overwrite ParentSequence description '" + description + "' with conflicting value.",
77  other.description);
78  }
79 
80  if (!is_decoy) is_decoy = other.is_decoy; // believe it when it's set
81  // @TODO: what about coverage? (not reliable if we're merging data)
82 
83  return *this;
84  }
85  };
86 
87  // parent sequences indexed by their accessions:
88  // @TODO: allow querying/iterating over proteins and RNAs separately
89  typedef boost::multi_index_container<
90  ParentSequence,
91  boost::multi_index::indexed_by<
92  boost::multi_index::ordered_unique<boost::multi_index::member<
93  ParentSequence, String, &ParentSequence::accession>>>
96 
97  }
98 }
Invalid value exception.
Definition: Exception.h:305
A more convenient string class.
Definition: String.h:34
boost::multi_index_container< AppliedProcessingStep, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::ordered_unique< boost::multi_index::member< AppliedProcessingStep, std::optional< ProcessingStepRef >, &AppliedProcessingStep::processing_step_opt > > > > AppliedProcessingSteps
Definition: AppliedProcessingStep.h:107
MoleculeType
Definition: MetaData.h:40
@ PROTEIN
Definition: MetaData.h:41
boost::multi_index_container< ParentSequence, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::member< ParentSequence, String, &ParentSequence::accession > > > > ParentSequences
Definition: ParentSequence.h:94
IteratorWrapper< ParentSequences::iterator > ParentSequenceRef
Definition: ParentSequence.h:95
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Wrapper that adds operator< to iterators, so they can be used as (part of) keys in maps/sets or multi...
Definition: MetaData.h:20
Representation of a parent sequence that is identified only indirectly (e.g. a protein).
Definition: ParentSequence.h:24
ParentSequence & merge(const ParentSequence &other)
Definition: ParentSequence.h:53
ParentSequence(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: ParentSequence.h:39
bool is_decoy
Definition: ParentSequence.h:37
String sequence
Definition: ParentSequence.h:31
String description
Definition: ParentSequence.h:33
double coverage
sequence coverage as a fraction between 0 and 1
Definition: ParentSequence.h:35
String accession
Definition: ParentSequence.h:25
enum MoleculeType molecule_type
Definition: ParentSequence.h:27
ParentSequence(const ParentSequence &)=default
Base class for ID data with scores and processing steps (and meta info)
Definition: ScoredProcessingResult.h:19
AppliedProcessingSteps steps_and_scores
Definition: ScoredProcessingResult.h:20
ScoredProcessingResult & merge(const ScoredProcessingResult &other)
Merge in data from another object.
Definition: ScoredProcessingResult.h:81