Class
ModifiedStringAllows you to generate modified versions of a string in a non-inplace way.
Allows you to generate modified versions of a string in a non-inplace way.
Implements | SequenceConcept |
---|---|
All Subcl's | ModCyclicShapeModifiedString, ModReverseString, ModViewModifiedString |
All Impl'd | AssignableConcept, ContainerConcept, DestructibleConcept, ForwardContainerConcept, RandomAccessContainerConcept, ReversibleContainerConcept, SequenceConcept |
Defined in | <seqan/modifier.h> |
Signature |
template <typename THost[, typename TSpec]>
class ModifiedString;
|
Member Function Overview
Member Functions Inherited From AssignableConcept
Member Functions Inherited From RandomAccessContainerConcept
Interface Function Overview
Interface Functions Inherited From AssignableConcept
Interface Functions Inherited From ContainerConcept
Interface Functions Inherited From RandomAccessContainerConcept
Interface Functions Inherited From SequenceConcept
Interface Metafunction Overview
Interface Metafunctions Inherited From ContainerConcept
DefaultGetIteratorSpec
DefaultIteratorSpec
Difference
GetValue
Iterator
Position
Reference
Size
Value
Interface Metafunctions Inherited From SequenceConcept
Detailed Description
THost can also be a modified string, so you can create nest modified strings to create custom combinations.
Examples
Using ModReverseString
#include <seqan/basic.h> #include <seqan/sequence.h> #include <seqan/file.h> // for I/O #include <seqan/modifier.h> using namespace seqan; int main() { String<Dna> seq = "TATACGCGAAAA"; ModifiedString< String<Dna>, ModReverse > myModifier(seq); std::cout << seq << std::endl; std::cout << myModifier << std::endl; replace(seq, 8, 12, "TTTT"); std::cout << std::endl; std::cout << seq << std::endl; std::cout << myModifier << std::endl; return 0; }
The output is als follows:
TATACGCGAAAA AAAAGCGCATAT TATACGCGTTTT TTTTGCGCATAT
Using a custom functor for ModViewString
#include <iostream> #include <seqan/file.h> #include <seqan/modifier.h> using namespace seqan; // A user-defined modifier that transforms all characters to upper case. struct MyFunctor : public std::unary_function<char,char> { inline char operator()(char x) const { if (('a' <= x) && (x <= 'z')) return (x + ('A' - 'a')); return x; } }; int main () { // Construct a String and a ModifiedString over it. String<char> myString = "A man, a plan, a canal-Panama"; ModifiedString<String<char>, ModView<MyFunctor> > myModifier(myString); // Print the result and demonstrate that the changes to myString are also // visible through myModifier. std::cout << myString << "\n" << myModifier << "\n"; replace(myString, 9, 9, "master "); std::cout << myString << "\n" << myModifier << "\n"; return 0; }
The output is as follows:
A man, a plan, a canal-Panama A MAN, A PLAN, A CANAL-PANAMA A man, a master plan, a canal-Panama A MAN, A MASTER PLAN, A CANAL-PANAMA
Using nested modified strings.
#include <iostream> #include <seqan/file.h> #include <seqan/modifier.h> using namespace seqan; int main () { // A nested modifier. typedef ModifiedString<String<Dna>, ModComplementDna> TMyComplement; typedef ModifiedString<TMyComplement, ModReverse> TMyReverseComplement; // The original string. String<Dna> myString = "attacgg"; // A reverse complemented string. TMyReverseComplement myReverseComplement(myString); std::cout << myString << "\n" << myReverseComplement << "\n"; replace(myString, 1, 1, "cgt"); std::cout << myString << "\n" << myReverseComplement << "\n" << DnaStringReverseComplement(myString) << "\n"; return 0; }
The output is as follows:
ATTACGG CCGTAAT ACGTTTACGG CCGTAAACGT CCGTAAACGT