bpp-seq3  3.0.0
SequenceWithQualityTools.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_SEQUENCEWITHQUALITYTOOLS_H
6 #define BPP_SEQ_SEQUENCEWITHQUALITYTOOLS_H
7 
8 
9 #include "SequenceTools.h"
10 #include "SequenceWithQuality.h"
11 
12 namespace bpp
13 {
27 {
28 private:
29  static DNA DNA_;
30  static RNA RNA_;
34 
35 public:
44  static void subseq(const SequenceWithQuality& sequence, size_t begin, size_t end, SequenceWithQuality& output)
45  {
46  if (end < begin || end >= sequence.size())
47  throw Exception("SequenceWithQualityTools::subseq. Invalid coordinates begin=" + TextTools::toString(begin) + ", end=" + TextTools::toString(end) + " for a sequence of size " + TextTools::toString(sequence.size()) + ".");
48  std::vector<int> content(end - begin + 1);
49  std::vector<int> scores(end - begin + 1);
50  for (size_t i = 0; i <= end - begin; ++i)
51  {
52  content[i] = sequence[begin + i];
53  scores[i] = sequence.getQuality(begin + i);
54  }
55  output.append(content, scores);
56  }
57 
66  static std::unique_ptr<SequenceWithQuality> subseq(const SequenceWithQuality& sequence, size_t begin, size_t end)
67  {
68  auto alphaPtr = sequence.getAlphabet();
69  auto seq = std::make_unique<SequenceWithQuality>(alphaPtr);
70  seq->setName(sequence.getName());
71  seq->setComments(sequence.getComments());
72  subseq(sequence, begin, end, *seq);
73  return seq;
74  }
75 
76 
90  static std::unique_ptr<SequenceWithQuality> concatenate(
91  const SequenceWithQuality& seqwq1,
92  const SequenceWithQuality& seqwq2);
93 
103  static std::unique_ptr<SequenceWithQuality> complement(
104  const SequenceWithQuality& sequence);
105 
115  static std::unique_ptr<SequenceWithQuality> transcript(
116  const SequenceWithQuality& sequence);
117 
127  static std::unique_ptr<SequenceWithQuality> reverseTranscript(
128  const SequenceWithQuality& sequence);
129 
140  static std::unique_ptr<SequenceWithQuality> invert(
141  const SequenceWithQuality& sequence);
142 
149  static std::unique_ptr<SequenceWithQuality> removeGaps(const SequenceWithQuality& seq);
150 };
151 }
152 #endif // BPP_SEQ_SEQUENCEWITHQUALITYTOOLS_H
const std::string & getName() const override
Get the name of this sequence.
Definition: CoreSequence.h:170
virtual std::shared_ptr< const Alphabet > getAlphabet() const =0
Get the alphabet associated to the list.
virtual size_t size() const =0
Get the number of elements in the list.
This alphabet is used to deal with DNA sequences.
Definition: DNA.h:26
Replication between to nucleic acids.
This alphabet is used to deal with RNA sequences.
Definition: RNA.h:25
The SequenceWithQualityTools static class.
static std::unique_ptr< SequenceWithQuality > transcript(const SequenceWithQuality &sequence)
Get the transcription sequence of a DNA sequence.
static std::unique_ptr< SequenceWithQuality > invert(const SequenceWithQuality &sequence)
Inverse a sequence from 5'->3' to 3'->5' and vice-versa.
static NucleicAcidsReplication RNARep_
static NucleicAcidsReplication transc_
static void subseq(const SequenceWithQuality &sequence, size_t begin, size_t end, SequenceWithQuality &output)
Get a sub-sequence.
static std::unique_ptr< SequenceWithQuality > subseq(const SequenceWithQuality &sequence, size_t begin, size_t end)
Get a sub-sequence.
static NucleicAcidsReplication DNARep_
static std::unique_ptr< SequenceWithQuality > removeGaps(const SequenceWithQuality &seq)
Remove gaps from a SequenceWithQuality.
static std::unique_ptr< SequenceWithQuality > complement(const SequenceWithQuality &sequence)
Get the complementary sequence of a nucleotide sequence.
static std::unique_ptr< SequenceWithQuality > reverseTranscript(const SequenceWithQuality &sequence)
Get the reverse-transcription sequence of a RNA sequence.
static std::unique_ptr< SequenceWithQuality > concatenate(const SequenceWithQuality &seqwq1, const SequenceWithQuality &seqwq2)
Concatenate two sequences.
A SequenceWithAnnotation class with quality scores attached.
int getQuality(size_t pos) const
Get the quality score.
virtual void append(const std::vector< int > &content, const std::vector< int > &qualities)
Append content with quality.
const Comments & getComments() const override
Get the comments.
Definition: Commentable.h:79
std::string toString(T t)
This alphabet is used to deal NumericAlphabet.