Class CyclicShape
A pattern of zeros and ones to mark "don't care"-positions in a text.

All Subcl's FixedCyclicShape, GenericCyclicShape
Defined in <seqan/modifier.h>
Signature template <typename TShapeSpec> class CyclicShape<TShapeSpec>;

Template Parameters

TShapeSpec The specializing type. Default is GenericShape, another option is FixedShape.
TSize Size type of the CyclicShape

Interface Function Overview

Interface Metafunction Overview

Member Variable Overview

Detailed Description

CyclicShapes store a pattern like 11010100110 that mark care (match) positions and don't-care positions. Unlike Shape, the CyclicShape does not perform hashing of q-grams. It is instead useful to modify a text in such a way that zero position are ignored. The pattern is applied repeatedly on the whole text, as the example shows.

Note that CyclicShapes can start and end with zero characters, which is not allowed in Shape.

Examples

#include <seqan/modifier.h>
#include <seqan/stream.h>

using namespace seqan;

int main(int argc, char const ** argv)
{
    // create a (generic) CyclicShape
    typedef CyclicShape<GenericShape> TShape;
    TShape shape;
    stringToCyclicShape(shape, "1110010");

    // print cyclic Shape
    CharString out;
    cyclicShapeToString(out, shape);
    std::cout << "shape: " << out << std::endl;

    // determine weight and span
    std::cout << "weight: " << weight(shape);
    std::cout << ", span: " << shape.span << std::endl;

    // modify a text to leave out characters
    CharString str = "this is an original string";
    ModifiedString<CharString, ModCyclicShape<TShape> > modStr(str, shape);

    // modStr can be used like a normal String
    std::cout << str << " => " << modStr << std::endl;
    std::cout << "length: " << length(str) << " => " << length(modStr) << std::endl;

    return 0;
}

The output is as follows:

shape: 1110010
weight: 4, span: 7
this is an original string => thii anrgin tri
length: 26 => 15

See Also

Interface Functions Detail

void carePositions(positions, cyclicShape);

Determine the indices of care positions in the range [0,span)

Template Parameters

TString String or array. Value type should be an integral size type.
TSpec Specialization of CyclicShape.

Parameters

cyclicShape CyclicShape object.
positions The resulting String to store the care-positions in. Type TString.

This function can be used to convert CyclicShape.diffs, which stores the distances between care positions, to a positions string directly containing the care positions. See the example:

        std::cout << std::endl << "relative care positions: ";
        for (unsigned i = 0; i < weight(shape); ++i)
            std::cout << (int)shape.diffs[i] << ",";    // output: 1,1,3,2,4,

        std::cout << std::endl << "absolute care positions: ";
        String<int> carePos;
        carePositions(carePos, shape);

        for (unsigned i = 0; i < weight(shape); ++i)
            std::cout << carePos[i] << ",";             // output: 2,3,4,7,9,
        std::cout << std::endl;

Data Races

Thread safety unknown!

void cyclicShapeToString(bitmap, cyclicShape);

Print a given cyclic shape as a sequence of '1' (care position) and '0' (don't-care position).

Parameters

cyclicShape CyclicShape object. Types: CyclicShape
bitmap The resulting sequence object. Type: String, e.g. CharString

Data Races

Thread safety unknown!

See Also

void cyclicShapeToSuffixLengths(TString suffLengths, cyclicShape);

Calculates the number of characters of modified Strings shorter than the Shape's span.

Template Parameters

TString String type or array with an integral value type, i.e. unsigned or int.

Parameters

cyclicShape CyclicShape object.
suffLengths String to be filled. Must be resized beforehands. Fixed length arrays also work.

Given a CyclicShape, this function calculates a how many characters a String of length x contains after the CyclicShape is applied to it. This is done for all 0 <= x < span. suffLengths therefore must be resized to the shape's span beforehands. The resizing is not done in this function so that it can be applied to arrays, too.

Data Races

Thread safety unknown!

TSize weight(const & cyclicShape);

Return the weight of a CyclicShape

Template Parameters

TSpec Specialisation of the CyclicShape.
TSize Size type of CyclicShape

Parameters

cyclicShape CyclicShape object

Returns

weight of the CyclicShape (number of care positions)

Data Races

Thread safety unknown!

Interface Metafunctions Detail

Size<CyclicShape<TSpec> >::Type;

Size type for parameters used in CyclicShape.

Template Parameters

TSpec The CyclicShape specialization.

Returns

TReturn Currently the return type unsigned char.

Remarks

Member Variables Detail

TSize CyclicShape::loffset

left offset (number of leading zeros) of the CyclicShape.

TSize CyclicShape::span

span of the CyclicShape.