OpenStructure
Loading...
Searching...
No Matches
amino_acids.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// This file is part of the OpenStructure project <www.openstructure.org>
3//
4// Copyright (C) 2008-2020 by the OpenStructure authors
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License as published by the Free
8// Software Foundation; either version 3.0 of the License, or (at your option)
9// any later version.
10// This library is distributed in the hope that it will be useful, but WITHOUT
11// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this library; if not, write to the Free Software Foundation, Inc.,
17// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18//------------------------------------------------------------------------------
19#ifndef OST_CONOP_AMINO_ACIDS_HH
20#define OST_CONOP_AMINO_ACIDS_HH
21/*
22 Author: Marco Biasini
23 */
24#include <set>
25#include <ost/dllexport.hh>
28
30
31namespace ost { namespace conop {
32
33// convenience enum for standard set of 20 amino acids
34// Xxx signifies an unknown amino acid.
44
49
50// \brief from amino acid to residue name
52
54
56
58
60
62 using iterator_category = std::forward_iterator_tag;
63 using value_type = AminoAcid;
64 using difference_type = std::ptrdiff_t;
65 using pointer = AminoAcid*;
66 using reference = AminoAcid&;
67
68public:
69 AminoAcidSetIterator(unsigned int bits, int start):
70 bits_(bits), curr_(start)
71 {
72 }
74 {
75 this->Advance();
76 return *this;
77 }
78
80 {
81 return AminoAcid(curr_);
82 }
83
84 bool operator==(const AminoAcidSetIterator& rhs) const
85 {
86 return curr_==rhs.curr_;
87 }
88 bool operator!=(const AminoAcidSetIterator& rhs) const
89 {
90 return !this->operator==(rhs);
91 }
92private:
93 void Advance()
94 {
95 ++curr_;
96 while (curr_<=XXX && !(bits_ & (1 << curr_))) { ++curr_; }
97 }
98 unsigned int bits_;
99 int curr_;
100};
101
104public:
106
108
110
112
114
115 static std::vector<AminoAcidSet> CreateCompleteSet();
116
117 static std::vector<AminoAcidSet> CreateThreeStateSet();
118
119 static std::vector<AminoAcidSet> CreatePseudoSet();
120
122
124 void Add(AminoAcid amino_acid);
125
127 void Remove(AminoAcid amino_acid);
128
130 bool Contains(AminoAcid amino_acid) const;
131
133 bool Empty() const;
134
143
145 Iterator End() const;
146
147 bool operator==(const AminoAcidSet& rhs) const;
148
149 bool operator!=(const AminoAcidSet& rhs) const;
150
151 template <typename DS>
152 void Serialize(DS& ds)
153 {
154 ds & bits_;
155 }
156private:
157 unsigned int bits_;
158};
159
160DLLEXPORT_OST_CONOP std::ostream& operator<<(std::ostream& os,
161 const AminoAcidSet& aa_set);
162
163typedef std::vector<AminoAcidSet> AminoAcidAlphabet;
164
165}}
166
167#endif
Amino acid bit set.
void Remove(AminoAcid amino_acid)
void Add(AminoAcid amino_acid)
add another amino acid
static AminoAcidSet CreateSet(AminoAcid aa)
static AminoAcidSet CreatePolarSet()
static std::vector< AminoAcidSet > CreateCompleteSet()
static std::vector< AminoAcidSet > CreatePseudoSet()
static AminoAcidSet CreateApolarSet()
bool operator!=(const AminoAcidSet &rhs) const
AminoAcidSetIterator Iterator
Iterator End() const
iterator pointing to the end of the amino acids.
bool Empty() const
whether the set is empty
Iterator Begin() const
iterator pointing to the beginning of the amino acid set
static std::vector< AminoAcidSet > CreateThreeStateSet()
bool operator==(const AminoAcidSet &rhs) const
bool Contains(AminoAcid amino_acid) const
whether the set contains a given amino acid
static AminoAcidSet CreateAromaticSet()
bool operator!=(const AminoAcidSetIterator &rhs) const
bool operator==(const AminoAcidSetIterator &rhs) const
AminoAcidSetIterator & operator++()
AminoAcidSetIterator(unsigned int bits, int start)
#define DLLEXPORT_OST_CONOP
std::string String
Definition base.hh:54
std::vector< AminoAcidSet > AminoAcidAlphabet
DLLEXPORT_OST_CONOP String OneLetterCodeToResidueName(char olc)
DLLEXPORT_OST_CONOP AminoAcid OneLetterCodeToAminoAcid(char olc)
DLLEXPORT_OST_CONOP std::ostream & operator<<(std::ostream &os, const AminoAcidSet &aa_set)
DLLEXPORT_OST_CONOP String AminoAcidToResidueName(AminoAcid aa)
char DLLEXPORT_OST_CONOP ResidueNameToOneLetterCode(String rn)
DLLEXPORT_OST_CONOP AminoAcid ResidueToAminoAcid(const mol::ResidueHandle &r)
from residue name to amino acid.
AminoAcid DLLEXPORT_OST_CONOP ResidueNameToAminoAcid(String rn)
Definition base.dox:1