OpenMS  3.0.0
ParentMatch.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-2022.
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 
38 
39 namespace OpenMS
40 {
41  namespace IdentificationDataInternal
42  {
46  {
47  // in extraordinary cases (e.g. database searches that allow insertions/
48  // deletions), the length of the identified molecule may differ from the
49  // length of the subsequence in the parent; therefore, store "end_pos":
51 
52  // String instead of char so modified residues can be represented:
53  String left_neighbor, right_neighbor; // neighboring sequence elements
54 
55  static constexpr Size UNKNOWN_POSITION = Size(-1);
56  static constexpr char UNKNOWN_NEIGHBOR = 'X';
57  static constexpr char LEFT_TERMINUS = '[';
58  static constexpr char RIGHT_TERMINUS = ']';
59 
66  {
67  }
68 
69  bool operator<(const ParentMatch& other) const
70  {
71  // positions determine neighbors - no need to compare those:
72  return (std::tie(start_pos, end_pos) <
73  std::tie(other.start_pos, other.end_pos));
74  }
75 
76  bool operator==(const ParentMatch& other) const
77  {
78  // positions determine neighbors - no need to compare those:
79  return (std::tie(start_pos, end_pos) ==
80  std::tie(other.start_pos, other.end_pos));
81  }
82 
83  bool hasValidPositions(Size molecule_length = 0, Size parent_length = 0) const
84  {
86  {
87  return false;
88  }
89  if (end_pos < start_pos) return false;
90  if (molecule_length && (end_pos - start_pos + 1 != molecule_length))
91  {
92  return false;
93  }
94  if (parent_length && (end_pos >= parent_length)) return false;
95  return true;
96  }
97  };
98 
100  typedef std::map<ParentSequenceRef,
101  std::set<ParentMatch>> ParentMatches;
102 
103  }
104 }
OpenMS::IdentificationDataInternal::ParentMatch::operator<
bool operator<(const ParentMatch &other) const
Definition: ParentMatch.h:69
OpenMS::IdentificationDataInternal::ParentMatch::RIGHT_TERMINUS
static constexpr char RIGHT_TERMINUS
Definition: ParentMatch.h:58
OpenMS::IdentificationDataInternal::ParentMatch::end_pos
Size end_pos
Definition: ParentMatch.h:50
OpenMS::IdentificationDataInternal::ParentMatch::left_neighbor
String left_neighbor
Definition: ParentMatch.h:53
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::IdentificationDataInternal::ParentMatch::start_pos
Size start_pos
Definition: ParentMatch.h:50
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::IdentificationDataInternal::ParentMatches
std::map< ParentSequenceRef, std::set< ParentMatch > > ParentMatches
mapping: parent sequence -> match information
Definition: ParentMatch.h:101
OpenMS::IdentificationDataInternal::ParentMatch::UNKNOWN_NEIGHBOR
static constexpr char UNKNOWN_NEIGHBOR
Definition: ParentMatch.h:56
ParentSequence.h
OpenMS::IdentificationDataInternal::ParentMatch::LEFT_TERMINUS
static constexpr char LEFT_TERMINUS
Definition: ParentMatch.h:57
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::MetaInfoInterface
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:60
OpenMS::IdentificationDataInternal::ParentSequenceRef
IteratorWrapper< ParentSequences::iterator > ParentSequenceRef
Definition: ParentSequence.h:121
OpenMS::IdentificationDataInternal::ParentMatch::ParentMatch
ParentMatch(Size start_pos=UNKNOWN_POSITION, Size end_pos=UNKNOWN_POSITION, String left_neighbor=UNKNOWN_NEIGHBOR, String right_neighbor=UNKNOWN_NEIGHBOR)
Definition: ParentMatch.h:60
OpenMS::IdentificationDataInternal::ParentMatch::operator==
bool operator==(const ParentMatch &other) const
Definition: ParentMatch.h:76
OpenMS::IdentificationDataInternal::ParentMatch::right_neighbor
String right_neighbor
Definition: ParentMatch.h:53
OpenMS::IdentificationDataInternal::ParentMatch
Meta data for the association between an identified molecule (e.g. peptide) and a parent sequence (e....
Definition: ParentMatch.h:45
OpenMS::IdentificationDataInternal::ParentMatch::UNKNOWN_POSITION
static constexpr Size UNKNOWN_POSITION
Definition: ParentMatch.h:55
OpenMS::IdentificationDataInternal::ParentMatch::hasValidPositions
bool hasValidPositions(Size molecule_length=0, Size parent_length=0) const
Definition: ParentMatch.h:83