# Spec AnchorGaps
Stores gaps as anchors of the first characters behind gaps.

Extends | Gaps
All Extended | Gaps
All Impl'd | AssignableConcept, ContainerConcept, DestructibleConcept
Defined in | <seqan/align.h>
Signature | `template <typename TSource, typename TGapAnchors = String<GapAnchor<unsigned> > > class Gaps<TSource, AnchorGaps<TGapAnchors> >;`

## Template Parameters

`TSource` | The type of the underlying sequence.
`TGapAnchors` | The type of the string of GapAnchor objects.

## Member Function Overview

- `Gaps::Gaps([other]);, Gaps::Gaps(source[, anchors]);, Gaps::Gaps(anchors);`
  Constructor

### Member Functions Inherited From AssignableConcept

- `operator=`

## Interface Function Overview

- `TPos positionGapToSeq(gaps, pos);`
  Convert from gap space in the global alignment to the sequence space on the reference.
- `TPos positionSeqToGap(gaps, pos);`
  Convert from sequence space on the reference to gap space in the global alignment.

### Interface Functions Inherited From Gaps

- `assignSource`
- `beginPosition`
- `clearClipping`
- `clearGaps`
- `clippedBeginPosition`
- `clippedEndPosition`
- `clipSemiGlobal`
- `copyClipping`
- `copyGaps`
- `countCharacters`
- `countGapExtensions`
- `countGapOpens`
- `countGaps`
- `countLeadingGaps`
- `countTrailingGaps`
- `endPosition`
- `insertGap`
- `insertGaps`
- `isCharacer`
- `isGap`
- `iter`
- `length`
- `removeGap`
- `removeGaps`
- `setBeginPosition`
- `setClippedBeginPosition`
- `setClippedEndPosition`
- `setEndPosition`
- `source`
- `toSourcePosition`
- `toViewPosition`
- `unclippedLength`

### Interface Functions Inherited From AssignableConcept

- `assign`
- `set`
- `move`

### Interface Functions Inherited From ContainerConcept

- `begin`
- `end`
- `length`
- `empty`
- `swap`
- `writeValue`
- `write`
- `getObjectId`
- `moveValue`
- `append`
- `appendValue`
- `shrinkToFit`
- `directionIterator`

## Interface Metafunction Overview

### Interface Metafunctions Inherited From ContainerConcept

- `DefaultGetIteratorSpec`
- `DefaultIteratorSpec`
- `Difference`
- `DirectionIterator`
- `GetValue`
- `Iterator`
- `Position`
- `Reference`
- `Size`
- `Value`

## Member Functions Detail

### `Gaps::Gaps([other]); Gaps::Gaps(source[, anchors]); Gaps::Gaps(anchors);`

Constructor

#### Parameters

`other` | Another AnchorGaps object to copy from.
`source` | The underlying sequence to construct the Gaps object from.
`anchors` | The string of anchors to construct with.

An AnchorGaps object has a default constructor, can be constructed from the underlying source, and/or a string of gap anchors.

#### Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

## Interface Functions Detail

### `TPos positionGapToSeq(gaps, pos);`

Convert from gap space in the global alignment to the sequence space on the reference.

#### Parameters

`gaps` | Contig AnchorGaps (e.g. from FragmentStore).
`pos` | Position in gap space.

#### Returns

`TPos` | Position in sequence space (Metafunction: Position).

See the example below to construct the Gaps object. Note that this construction is fast since it is only a thin wrapper around underlying objects.

#### Examples

Convert from gap space to positions pace when the contig required to be loaded. * Converts position aligned read with index `idx` in the aligned read store.

    typedef typename TFragmentStore::TContigStore                        TContigStore;
    typedef typename Value<TContigStore>::Type                           TContig;
    typedef typename TFragmentStore::TContigSeq                          TContigSeq;
    typedef Gaps<TContigSeq, AnchorGaps<typename TContig::TGapAnchors> > TContigGaps;

    typedef typename TFragmentStore::TAlignedReadStore                   TAlignedReadStore;
    typedef typename Value<TAlignedReadStore>::Type                      TAlignedRead;
    typedef typename TAlignedRead::TPos                                  TAlignedReadPos;

    unsigned contigId = alignedReadStore[idx].contigId;
    TContigGaps contigGaps(contigStore[contigId].seq, contigStore[contigId].gaps);
    TAlignedRead const & alignedRead = alignedReadStore[idx];
    // Translate end position from aligned read record to sequence space in reference.
    TAlignedReadPos endPos = positionGapToSeq(contigGaps, alignedRead.endPos);

Convert from gap space to position space when the contigs are not required. Converts position aligned read with index $idx$ in the aligned read store.

    typedef typename TFragmentStore::TContigStore                        TContigStore;
    typedef typename Value<TContigStore>::Type                           TContig;
    typedef Gaps<Nothing, AnchorGaps<typename TContig::TGapAnchors> > TContigGaps;

    typedef typename TFragmentStore::TAlignedReadStore                   TAlignedReadStore;
    typedef typename Value<TAlignedReadStore>::Type                      TAlignedRead;
    typedef typename TAlignedRead::TPos                                  TAlignedReadPos;

    unsigned contigId = alignedReadStore[idx].contigId;
    TContigGaps contigGaps(Nothing(), contigStore[contigId].gaps);
    TAlignedRead const & alignedRead = alignedReadStore[idx];
    // Translate end position from aligned read record to sequence space in reference.
    TAlignedReadPos endPos = positionGapToSeq(contigGaps, alignedRead.endPos);

#### Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

### `TPos positionSeqToGap(gaps, pos);`

Convert from sequence space on the reference to gap space in the global alignment.

#### Parameters

`gaps` | The AnchorGaps object to use for the translation.
`pos` | The gap space position to convert to sequence space.

#### Returns

`TPos` | The resulting position in sequence space (Metafunction: Position).

See the example below to construct the gaps object. Note that this construction is fast since it is only a thin wrapper around underlying objects.

#### Example

Convert from gap space to position space on contig $contigId$ when the contigs required to be loaded.

    typedef typename TFragmentStore::TContigStore                        TContigStore;
    typedef typename Value<TContigStore>::Type                           TContig;
    typedef typename TFragmentStore::TContigSeq                          TContigSeq;
    typedef Gaps<TContigSeq, AnchorGaps<typename TContig::TGapAnchors> > TContigGaps;

    TContigGaps contigGaps(contigStore[contigId].seq, contigStore[contigId].gaps);
    TAlignedReadPos pos = positionGapToSeq(contigGaps, 33);

Convert from gap space to position space on contig $contigId$ when the contigs are not required.

    typedef typename TFragmentStore::TContigStore                        TContigStore;
    typedef typename Value<TContigStore>::Type                           TContig;
    typedef Gaps<Nothing, AnchorGaps<typename TContig::TGapAnchors> > TContigGaps;

    TContigGaps contigGaps(Nothing(), contigStore[contigId].gaps);
    TAlignedReadPos endPos = positionGapToSeq(contigGaps, 33);

#### Data Races

If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.

#### Dox Sources

    /*!
     * @class AnchorGaps
     *
     * @extends Gaps
     *
     * @headerfile <seqan/align.h>
     *
     * @brief Stores gaps as anchors of the first characters behind gaps.
     *
     * @signature template <typename TSource, typename TGapAnchors =
     *            String<GapAnchor<unsigned> > > class Gaps<TSource,
     *            AnchorGaps<TGapAnchors> >;
     *
     * @tparam TSource The type of the underlying sequence.
     * @tparam TGapAnchors The type of the string of @link GapAnchor @endlink
     *                     objects.
     *
     * @fn AnchorGaps::Gaps
     *
     * @brief Constructor
     *
     * @signature Gaps::Gaps([other]);
     * @signature Gaps::Gaps(source[, anchors]);
     * @signature Gaps::Gaps(anchors);
     *
     * @param[in] other Another @link AnchorGaps @endlink object to copy from.
     * @param[in] source The underlying sequence to construct the Gaps object from.
     * @param[in] anchors The string of anchors to construct with.
     *
     * An AnchorGaps object has a default constructor, can be constructed from the
     * underlying source, and/or a string of gap anchors.
     *
     * @fn AnchorGaps#positionGapsToSeq
     *
     * @brief Convert from gap space in the global alignment to the sequence space
     *        on the reference.
     *
     * @signature TPos positionGapToSeq(gaps, pos);
     *
     * @param[in] gaps Contig AnchorGaps (e.g. from FragmentStore).
     * @param[in] pos Position in gap space.
     *
     * @return TPos Position in sequence space (Metafunction: @link
     *              ContainerConcept#Position @endlink).
     *
     * See the example below to construct the Gaps object. Note that this
     * construction is fast since it is only a thin wrapper around underlying
     * objects.
     *
     * @section Examples
     *
     * Convert from gap space to positions pace when the contig required to be
     * loaded. * Converts position aligned read with index <tt>idx</tt> in the
     * aligned read store.
     *
     * @code{.cpp}
     * typedef typename TFragmentStore::TContigStore                        TContigStore;
     * typedef typename Value<TContigStore>::Type                           TContig;
     * typedef typename TFragmentStore::TContigSeq                          TContigSeq;
     * typedef Gaps<TContigSeq, AnchorGaps<typename TContig::TGapAnchors> > TContigGaps;
     *
     * typedef typename TFragmentStore::TAlignedReadStore                   TAlignedReadStore;
     * typedef typename Value<TAlignedReadStore>::Type                      TAlignedRead;
     * typedef typename TAlignedRead::TPos                                  TAlignedReadPos;
     *
     * unsigned contigId = alignedReadStore[idx].contigId;
     * TContigGaps contigGaps(contigStore[contigId].seq, contigStore[contigId].gaps);
     * TAlignedRead const & alignedRead = alignedReadStore[idx];
     * // Translate end position from aligned read record to sequence space in reference.
     * TAlignedReadPos endPos = positionGapToSeq(contigGaps, alignedRead.endPos);
     * @endcode
     *
     *
     * Convert from gap space to position space when the contigs are not required.
     * Converts position aligned read with index $idx$ in the aligned read store.
     *
     * @code{.cpp}
     * typedef typename TFragmentStore::TContigStore                        TContigStore;
     * typedef typename Value<TContigStore>::Type                           TContig;
     * typedef Gaps<Nothing, AnchorGaps<typename TContig::TGapAnchors> > TContigGaps;
     *
     * typedef typename TFragmentStore::TAlignedReadStore                   TAlignedReadStore;
     * typedef typename Value<TAlignedReadStore>::Type                      TAlignedRead;
     * typedef typename TAlignedRead::TPos                                  TAlignedReadPos;
     *
     * unsigned contigId = alignedReadStore[idx].contigId;
     * TContigGaps contigGaps(Nothing(), contigStore[contigId].gaps);
     * TAlignedRead const & alignedRead = alignedReadStore[idx];
     * // Translate end position from aligned read record to sequence space in reference.
     * TAlignedReadPos endPos = positionGapToSeq(contigGaps, alignedRead.endPos);
     * @endcode
     *
     *
     * @fn AnchorGaps#positionSeqToGap
     *
     * @brief Convert from sequence space on the reference to gap space in the
     *        global alignment.
     *
     * @signature TPos positionSeqToGap(gaps, pos);
     *
     * @param[in] gaps The AnchorGaps object to use for the translation.
     * @param[in] pos The gap space position to convert to sequence space.
     *
     * @return TPos The resulting position in sequence space (Metafunction: @link
     *              ContainerConcept#Position @endlink).
     *
     * See the example below to construct the gaps object. Note that this
     * construction is fast since it is only a thin wrapper around underlying
     * objects.
     *
     * @section Example
     *
     * Convert from gap space to position space on contig $contigId$ when the
     * contigs required to be loaded.
     *
     * @code{.cpp}
     * typedef typename TFragmentStore::TContigStore                        TContigStore;
     * typedef typename Value<TContigStore>::Type                           TContig;
     * typedef typename TFragmentStore::TContigSeq                          TContigSeq;
     * typedef Gaps<TContigSeq, AnchorGaps<typename TContig::TGapAnchors> > TContigGaps;
     *
     * TContigGaps contigGaps(contigStore[contigId].seq, contigStore[contigId].gaps);
     * TAlignedReadPos pos = positionGapToSeq(contigGaps, 33);
     * @endcode
     *
     *
     * Convert from gap space to position space on contig $contigId$ when the
     * contigs are not required.
     *
     * @code{.cpp}
     * typedef typename TFragmentStore::TContigStore                        TContigStore;
     * typedef typename Value<TContigStore>::Type                           TContig;
     * typedef Gaps<Nothing, AnchorGaps<typename TContig::TGapAnchors> > TContigGaps;
     *
     * TContigGaps contigGaps(Nothing(), contigStore[contigId].gaps);
     * TAlignedReadPos endPos = positionGapToSeq(contigGaps, 33);
     * @endcode
     */