bpp-seq3  3.0.0
MaseTools.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_SEQ_IO_MASETOOLS_H
6 #define BPP_SEQ_IO_MASETOOLS_H
7 
8 #include <Bpp/Exceptions.h>
9 
10 #include "../Container/SequenceContainer.h"
11 #include "../Container/SequenceContainerTools.h"
12 #include "../Container/SiteContainer.h"
13 #include "../Container/SiteContainerTools.h"
14 
15 namespace bpp
16 {
27 class MaseTools
28 {
29 public:
37  static SiteSelection getSiteSet(const Comments& maseFileHeader, const std::string& setName);
38 
46  static SequenceSelection getSequenceSet(const Comments& maseFileHeader, const std::string& setName);
47 
60  template<class SiteType, class SequenceType>
61  static std::unique_ptr< TemplateVectorSiteContainer<SiteType, SequenceType>>
64  const std::string& setName)
65  {
66  SiteSelection ss = getSiteSet(sequences.getComments(), setName);
67  return SiteContainerTools::getSelectedPositions<SiteType, SequenceType>(sequences, ss);
68  }
69 
70 
83  template<class SequenceType, class HashType>
84  static std::unique_ptr< TemplateSequenceContainerInterface<SequenceType, HashType>>
87  const std::string& setName)
88  {
89  SequenceSelection ss = getSequenceSet(sequences.getGeneralComments(), setName);
90  return SequenceContainerTools::getSelectedSequences<SequenceType, HashType>(sequences, ss);
91  }
92 
93 
100  static std::map<std::string, size_t> getAvailableSiteSelections(const Comments& maseHeader);
101 
108  static std::map<std::string, size_t> getAvailableSequenceSelections(const Comments& maseHeader);
109 
120  static size_t getPhase(const Comments& maseFileHeader, const std::string& setName);
121 };
122 } // end of namespace bpp.
123 #endif // BPP_SEQ_IO_MASETOOLS_H
virtual const Comments & getComments() const =0
Get the comments.
Utilitary methods that deal with the Mase format.
Definition: MaseTools.h:28
static SiteSelection getSiteSet(const Comments &maseFileHeader, const std::string &setName)
Get a site selection from a Mase+ header file.
Definition: MaseTools.cpp:17
static std::unique_ptr< TemplateSequenceContainerInterface< SequenceType, HashType > > getSelectedSequences(const TemplateSequenceContainerInterface< SequenceType, HashType > &sequences, const std::string &setName)
Create a new container corresponding to a site set given in the mase+ format.
Definition: MaseTools.h:85
static std::map< std::string, size_t > getAvailableSequenceSelections(const Comments &maseHeader)
Get a list of all available sequences selections.
Definition: MaseTools.cpp:163
static std::map< std::string, size_t > getAvailableSiteSelections(const Comments &maseHeader)
Get a list of all available site selections.
Definition: MaseTools.cpp:116
static SequenceSelection getSequenceSet(const Comments &maseFileHeader, const std::string &setName)
Get a sequence selection from a Mase+ header file.
Definition: MaseTools.cpp:69
static std::unique_ptr< TemplateVectorSiteContainer< SiteType, SequenceType > > getSelectedSites(const TemplateSiteContainerInterface< SiteType, SequenceType, std::string > &sequences, const std::string &setName)
Create a new container corresponding to a site set given in the mase+ format.
Definition: MaseTools.h:62
static size_t getPhase(const Comments &maseFileHeader, const std::string &setName)
Get the phase of a given coding region from a mase+ header.
Definition: MaseTools.cpp:189
This alphabet is used to deal NumericAlphabet.
std::vector< size_t > SiteSelection
std::vector< size_t > SequenceSelection
std::vector< std::string > Comments
Declaration of Comments type.
Definition: Commentable.h:21