OpenMS
Loading...
Searching...
No Matches
RibonucleotideDB.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- 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
13#include <memory>
14#include <unordered_map>
15
16namespace OpenMS
17{
25 class OPENMS_DLLAPI RibonucleotideDB final
26 {
27 public:
29
31 typedef std::vector<std::unique_ptr<Ribonucleotide>>::const_iterator ConstIterator;
32
35
37 ~RibonucleotideDB() = default;
38
40 RibonucleotideDB(const RibonucleotideDB& other) = delete;
41
44
46 inline ConstIterator begin() const
47 {
48 return ribonucleotides_.begin();
49 }
50
52 inline ConstIterator end() const
53 {
54 return ribonucleotides_.end();
55 }
56
62 ConstRibonucleotidePtr getRibonucleotide(const std::string& code);
63
70
76 std::pair<ConstRibonucleotidePtr, ConstRibonucleotidePtr> getRibonucleotideAlternatives(const std::string& code);
77
78
79 protected:
82
84 void readFromFile_(const std::string& path);
85
87 void readFromJSON_(const std::string& path);
88
90 const std::unique_ptr<Ribonucleotide> parseRow_(const std::string& row, Size line_count);
91
93 std::vector<std::unique_ptr<Ribonucleotide>> ribonucleotides_;
94
96 std::unordered_map<std::string, Size> code_map_;
97
99 std::map<std::string, std::pair<ConstRibonucleotidePtr, ConstRibonucleotidePtr>> ambiguity_map_;
100
102 };
103}
Database of ribonucleotides (modified and unmodified)
Definition RibonucleotideDB.h:26
RibonucleotideDB()
default constructor
std::vector< std::unique_ptr< Ribonucleotide > > ribonucleotides_
list of known (modified) nucleotides
Definition RibonucleotideDB.h:93
std::vector< std::unique_ptr< Ribonucleotide > >::const_iterator ConstIterator
const iterator type definition
Definition RibonucleotideDB.h:31
RibonucleotideDB(const RibonucleotideDB &other)=delete
copy constructor not available
ConstRibonucleotidePtr getRibonucleotide(const std::string &code)
Get a ribonucleotide by its code (short name)
static RibonucleotideDB * getInstance()
replacement for constructor (singleton pattern)
ConstIterator end() const
Const iterator to end of database.
Definition RibonucleotideDB.h:52
void readFromJSON_(const std::string &path)
read from a newer version of Modomics that uses a JSON file
std::unordered_map< std::string, Size > code_map_
mapping of codes (short names) to indexes into ribonucleotides_
Definition RibonucleotideDB.h:96
RibonucleotideDB & operator=(const RibonucleotideDB &other)=delete
assignment operator not available
Size max_code_length_
Definition RibonucleotideDB.h:101
ConstIterator begin() const
Const iterator to beginning of database.
Definition RibonucleotideDB.h:46
ConstRibonucleotidePtr getRibonucleotidePrefix(const std::string &seq)
Get the ribonucleotide with the longest code that matches a prefix of seq.
void readFromFile_(const std::string &path)
read (modified) nucleotides from input file
const std::unique_ptr< Ribonucleotide > parseRow_(const std::string &row, Size line_count)
create a (modified) nucleotide from an input row
std::map< std::string, std::pair< ConstRibonucleotidePtr, ConstRibonucleotidePtr > > ambiguity_map_
mapping of ambiguity codes to the alternatives they represent
Definition RibonucleotideDB.h:99
~RibonucleotideDB()=default
destructor
std::pair< ConstRibonucleotidePtr, ConstRibonucleotidePtr > getRibonucleotideAlternatives(const std::string &code)
Get the alternatives for an ambiguous modification code.
Representation of a ribonucleotide (modified or unmodified)
Definition Ribonucleotide.h:28
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19