Loading...
Searching...
No Matches
aastringcodec.h
Go to the documentation of this file.
/**
* \file pappsomspp/amino_acid/aastringcodec.h
* \date 09/05/2023
* \author Olivier Langella
* \brief code and decodefrom amino acid string to integer
*/
/*******************************************************************************
* Copyright (c) 2023 Olivier Langella <Olivier.Langella@u-psud.fr>.
*
* This file is part of PAPPSOms-tools.
*
* PAPPSOms-tools is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAPPSOms-tools is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PAPPSOms-tools. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#pragma once
#include "pappsomspp/export-import-config.h"
#include "pappsomspp/core/amino_acid/aacode.h"
namespace pappso
{
class AaStringCodec;
/** \brief shared pointer on a Protein object
*/
typedef std::shared_ptr<const AaStringCodec> AaStringCodecSp;
struct CodeToMass
{
uint32_t code = 0;
double mass = 0;
};
/**
* @brief code and decode amino acid string sequence to unique integer
*/
class PMSPP_LIB_DECL AaStringCodec
{
public:
/**
* Default constructor
*/
AaStringCodec(const AaCode &aaCode);
/**
* Copy constructor
*
* @param other TODO
*/
AaStringCodec(const AaStringCodec &other);
/**
* Destructor
*/
~AaStringCodec();
/** @brief get the maximum code number for a given peptide size
*/
std::size_t getLimitMax(std::size_t size) const;
/** @brief get integer from amino acide suite string
*/
uint32_t code(const QString &aa_str) const;
/** @brief get the lowest common denominator integer from amino acide suite
* string
*/
uint32_t codeLlc(const QString &aa_str) const;
/** @brief get the lowest common denominator integer from amino acide code
* vector
*/
uint32_t codeLlc(std::vector<uint8_t>::const_iterator it_begin,
std::size_t size) const;
QString decode(uint32_t code) const;
QStringList decode(const std::vector<uint32_t> &code_list) const;
double getMass(uint32_t code) const;
/** @brief generates all possible combination of llc code mass
* llc : the lowest common code denominator for a given aa formula
*
* generate from peptide size =1 to peptide size
*/
std::vector<CodeToMass>
generateLlcCodeListUpToMaxPeptideSize(std::size_t size) const;
/** @brief generates all possible combination of llc code mass
* llc : the lowest common code denominator for a given aa formula
*
* generate only for this peptide size
*/
std::vector<CodeToMass>
generateLlcCodeListByMaxPeptideSize(std::size_t size) const;
/** @brief tell if a code only contains a list of amino acid
*
* @param code the code to valid
* @param aa_ok list of required amino acids
*/
bool codeOnlyContains(uint32_t code, const std::vector<uint8_t> &aa_ok) const;
/** @brief tell if a unique code only contains one amino acid 1 or n times
*
* @param code the code to valid
* @param aa_ok the amino acid the code must contains
* @param times the number of aa_ok presence in code
*/
bool
uniqueCodeContainsAminoAcid(uint32_t code, uint8_t aa_ok, int times) const;
const AaCode &getAaCode() const;
private:
/** @brief recursive method to generate models
*/
void recGenerateModel(std::vector<CodeToMass> &glist,
std::vector<uint8_t> &model,
std::size_t position) const;
CodeToMass generateCodeMassFromModel(const std::vector<uint8_t> &model) const;
private:
uint32_t m_base = 0;
const AaCode &m_aaCode;
std::vector<uint32_t> m_units;
};
} // namespace pappso
aacode.h
pappso::AaCode
collection of integer code for each amino acid 0 => null 1 to 20 => amino acid sorted by there mass (...
Definition aacode.h:44
pappso::AaStringCodec
code and decode amino acid string sequence to unique integer
Definition aastringcodec.h:52
pappso::AaStringCodec::getLimitMax
std::size_t getLimitMax(std::size_t size) const
get the maximum code number for a given peptide size
Definition aastringcodec.cpp:253
pappso::AaStringCodec::getMass
double getMass(uint32_t code) const
Definition aastringcodec.cpp:147
pappso::AaStringCodec::getAaCode
const AaCode & getAaCode() const
Definition aastringcodec.cpp:299
pappso::AaStringCodec::decode
QString decode(uint32_t code) const
Definition aastringcodec.cpp:119
pappso::AaStringCodec::codeLlc
uint32_t codeLlc(const QString &aa_str) const
get the lowest common denominator integer from amino acide suite string
Definition aastringcodec.cpp:72
pappso::AaStringCodec::recGenerateModel
void recGenerateModel(std::vector< CodeToMass > &glist, std::vector< uint8_t > &model, std::size_t position) const
recursive method to generate models
Definition aastringcodec.cpp:207
pappso::AaStringCodec::m_units
std::vector< uint32_t > m_units
Definition aastringcodec.h:148
pappso::AaStringCodec::uniqueCodeContainsAminoAcid
bool uniqueCodeContainsAminoAcid(uint32_t code, uint8_t aa_ok, int times) const
tell if a unique code only contains one amino acid 1 or n times
Definition aastringcodec.cpp:279
pappso::AaStringCodec::m_base
uint32_t m_base
Definition aastringcodec.h:146
pappso::AaStringCodec::code
uint32_t code(const QString &aa_str) const
get integer from amino acide suite string
Definition aastringcodec.cpp:58
pappso::AaStringCodec::m_aaCode
const AaCode & m_aaCode
Definition aastringcodec.h:147
pappso::AaStringCodec::generateCodeMassFromModel
CodeToMass generateCodeMassFromModel(const std::vector< uint8_t > &model) const
Definition aastringcodec.cpp:235
pappso::AaStringCodec::AaStringCodec
AaStringCodec(const AaCode &aaCode)
Definition aastringcodec.cpp:33
pappso::AaStringCodec::generateLlcCodeListByMaxPeptideSize
std::vector< CodeToMass > generateLlcCodeListByMaxPeptideSize(std::size_t size) const
generates all possible combination of llc code mass llc : the lowest common code denominator for a gi...
Definition aastringcodec.cpp:190
pappso::AaStringCodec::codeOnlyContains
bool codeOnlyContains(uint32_t code, const std::vector< uint8_t > &aa_ok) const
tell if a code only contains a list of amino acid
Definition aastringcodec.cpp:265
pappso::AaStringCodec::generateLlcCodeListUpToMaxPeptideSize
std::vector< CodeToMass > generateLlcCodeListUpToMaxPeptideSize(std::size_t size) const
generates all possible combination of llc code mass llc : the lowest common code denominator for a gi...
Definition aastringcodec.cpp:162
export-import-config.h
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition export-import-config.h:14
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::AaStringCodecSp
std::shared_ptr< const AaStringCodec > AaStringCodecSp
shared pointer on a Protein object
Definition aastringcodec.h:41
pappso::CodeToMass
Definition aastringcodec.h:44
pappso::CodeToMass::code
uint32_t code
Definition aastringcodec.h:45
pappso::CodeToMass::mass
double mass
Definition aastringcodec.h:46