# fn() reAlignment
Perform realignment on a FragmentStore object.

Defined in | <seqan/realign.h>
Signature | `void reAlignment(store, contigID, realignmentMethod, bandwidth, includeReference[, windowBegin, windowEnd][, debug][, printTiming]);`

## Parameters

`store` | The FragmentStore to perform realignment for.
`realignmentMethod` | The realignment algorithm to use, `1` for affine gap costs, `0` for linear gap costs, affine gap costs are recommended, `unsigned`.
`contigID` | Identifier of the contig to realign, `unsigned`
`bandwidth` | Bandwidth to use in the pairwise DP alignment algorithms `unsigned`.
`includeReference` | A `bool`, if `true` then the reference will be included as a pseudo-read to increase stability in case of indels. See section "Including the Reference" for details.
`windowBegin` | Optional `unsigned` window begin for windowed alignment, default: `0`, i.e. no windowing. Also see section "Windowed Realignment" below.
`windowEnd` | Optional `unsigned` window end for windowed alignment, default: `0`, i.e. no windowing. Also see section "Windowed Realignment" below.
`debug` | Optional `bool` to enable verbose logging, default: `false`.
`printTiming` | Optional `bool` to enable printing of times, default: `false`.

## Detailed Description

This function implements a variant of the Anson-Myers algorithm to refine the multi-read alignments. The algorithm works in a round-robin fashion:

First, the profile sequence is created for the multi-read alignment. The algorithm then works in round.

In each round, each read alignment is selected, removed from the profile and then aligned against the profile using a DP algorithm. For this alignment, a region of `bandwidth / 2` positions around the previous alignment locus is chosen and aligned using a bandwidth of `bandwidth` in the DP alignment algorithm. The profile is then updated with the resulting pairwise alignment. This is iterated until the global alignment score does not improve.

In the end, the reference sequence of the given contig is replaced by the consensus of the multi-read alignment.

### Including the Reference

You can choose to include the reference sequence of the selected contig as a pseudo-read. In this case, the reference sequence of the selected contig will be added as an additional read and also a read alignment will be created for it. The appended pseudo-read will have the highest read ID in the store.

### Windowed Realignment

Sometimes, it is useful to just realign a part of the fragment store. This can be done by using the parameters `windowBegin` and `windowEnd`. This refers to view positions in the current multi-read alignment. Set both to `0` (also the default) to disalbe windowed realignment.

### References

- Anson, Eric L., and Eugene W. Myers. "ReAligner: a program for refining DNA sequence multi-alignments." Journal of Computational Biology 4.3 (1997): 369-383.

## Data Races

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

#### Dox Sources

    /*!
     * @fn reAlignment
     *
     * @headerfile <seqan/realign.h>
     *
     * @brief Perform realignment on a @link FragmentStore @endlink object.
     *
     * @signature void reAlignment(store, contigID, realignmentMethod, bandwidth,
     *            includeReference[, windowBegin, windowEnd][, debug][,
     *            printTiming]);
     *
     * @param[in,out] store The @link FragmentStore @endlink to perform realignment
     *                      for.
     * @param[in] realignmentMethod The realignment algorithm to use, <tt>1</tt> for
     *                              affine gap costs, <tt>0</tt> for linear gap
     *                              costs, affine gap costs are recommended,
     *                              <tt>unsigned</tt>.
     * @param[in] contigID Identifier of the contig to realign, <tt>unsigned</tt>
     * @param[in] bandwidth Bandwidth to use in the pairwise DP alignment algorithms
     *                      <tt>unsigned</tt>.
     * @param[in] includeReference A <tt>bool</tt>, if <tt>true</tt> then the
     *                             reference will be included as a pseudo-read to
     *                             increase stability in case of indels. See section
     *                             "Including the Reference" for details.
     * @param[in] windowBegin Optional <tt>unsigned</tt> window begin for windowed
     *                        alignment, default: <tt>0</tt>, i.e. no windowing.
     *                        Also see section "Windowed Realignment" below.
     * @param[in] windowEnd Optional <tt>unsigned</tt> window end for windowed
     *                      alignment, default: <tt>0</tt>, i.e. no windowing. Also
     *                      see section "Windowed Realignment" below.
     * @param[in] debug Optional <tt>bool</tt> to enable verbose logging, default:
     *                  <tt>false</tt>.
     * @param[in] printTiming Optional <tt>bool</tt> to enable printing of times,
     *                        default: <tt>false</tt>.
     *
     * This function implements a variant of the Anson-Myers algorithm to refine the
     * multi-read alignments. The algorithm works in a round-robin fashion:
     *
     * First, the profile sequence is created for the multi-read alignment. The
     * algorithm then works in round.
     *
     * In each round, each read alignment is selected, removed from the profile and
     * then aligned against the profile using a DP algorithm. For this alignment, a
     * region of <tt>bandwidth / 2</tt> positions around the previous alignment
     * locus is chosen and aligned using a bandwidth of <tt>bandwidth</tt> in the DP
     * alignment algorithm. The profile is then updated with the resulting pairwise
     * alignment. This is iterated until the global alignment score does not
     * improve.
     *
     * In the end, the reference sequence of the given contig is replaced by the
     * consensus of the multi-read alignment.
     *
     * @section Including the Reference
     *
     * You can choose to include the reference sequence of the selected contig as a
     * pseudo-read. In this case, the reference sequence of the selected contig will
     * be added as an additional read and also a read alignment will be created for
     * it. The appended pseudo-read will have the highest read ID in the store.
     *
     * @section Windowed Realignment
     *
     * Sometimes, it is useful to just realign a part of the fragment store. This
     * can be done by using the parameters <tt>windowBegin</tt> and
     * <tt>windowEnd</tt>. This refers to view positions in the current multi-read
     * alignment. Set both to <tt>0</tt> (also the default) to disalbe windowed
     * realignment.
     *
     * @section References
     *
     * <ul><li>Anson, Eric L., and Eugene W. Myers. "ReAligner: a program for
     * refining DNA sequence multi-alignments." Journal of Computational Biology 4.3
     * (1997): 369-383.</li></ul>
     */