Skip to content
Commits on Source (9)
......@@ -33,6 +33,7 @@ setuptools*.zip
.idea/
gh-md-toc
.coverage
# CMake stuff (used by CLion)
CMakeLists.txt
......
unicycler (0.4.5-1) unstable; urgency=medium
unicycler (0.4.6+dfsg-1) UNRELEASED; urgency=medium
* Initial release (Closes: #<bug>)
Needs:
https://github.com/isovic/racon
https://github.com/broadinstitute/pilon/wiki
Needs: racon (#890187)
pilon (#903911)
-- Andreas Tille <tille@debian.org> Fri, 25 May 2018 10:59:36 +0200
......@@ -15,6 +15,7 @@ Build-Depends: debhelper (>= 11~),
racon,
samtools,
spades,
libseqan2-dev,
zlib1g-dev
Standards-Version: 4.1.4
Vcs-Browser: https://salsa.debian.org/med-team/unicycler
......@@ -24,6 +25,7 @@ Homepage: https://github.com/rrwick/Unicycler
Package: unicycler
Architecture: any
Depends: ${python3:Depends},
${shlibs:Depends},
${misc:Depends},
default-jre,
bowtie2,
......
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: <pkg>
Source: <path_to_download>
Comment: **** Before manually editing this file you should give ****
scan-copyrights
**** available in cme + lib-config-model-dpkg-perl ****
**** package a try. For existing copyright files try ****
cme update dpkg-copyright
Upstream-Name: Unicycler
Source: https://github.com/rrwick/Unicycler/releases
Files-Excluded: */seqan
Files: *
Copyright: © 20xx-20yy <upstream>
License: <license>
Copyright: 2016-2018 Ryan R. Wick, Louise M. Judd, Claire L. Gorrie, Kathryn E. Holt
License: GPL-3+
Files: unicycler/*/miniasm/*
Copyright: © 2015 Broad Institute <hengli@broadinstitute.org>
License: MIT
Comment: Debian ships a miniasm package which is based on tagged miniasm
releases while this code here is based on latest Git commit
Asked for clarification in issue
https://github.com/lh3/miniasm/issues/51
Files: unicycler/include/miniasm/khash.h
unicycler/include/miniasm/kseq.h
unicycler/include/miniasm/ksort.h
unicycler/include/miniasm/kvec.h
Copyright: © 2008, 2009, 2011 Attractive Chaos <attractor@live.co.uk>
License: MIT
Files: unicycler/*/minimap/*
Copyright: © 2015 Broad Institute <hengli@broadinstitute.org>
License: MIT
Comment: Debian ships a minimap package which is based on tagged minimap
releases while this code here is based on latest Git commit
Files: unicycler/include/minimap/khash.h
unicycler/include/minimap/kseq.h
unicycler/include/minimap/ksort.h
unicycler/include/minimap/kvec.h
Copyright: © 2008, 2009, 2011 Attractive Chaos <attractor@live.co.uk>
License: MIT
Files: debian/*
Copyright: © 2018 maintainername <maintainer@e.mail>
License: <license>
Copyright: 2018 Andreas Tille <tille@debian.org>
License: GPL-3+
License: GPL-3+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
On Debian systems you can find the full text of the GNU General Public
License version 3 at /usr/share/common-licenses/GPL-3.
License: MIT
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
.
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
......@@ -7,6 +7,8 @@ export PYBUILD_NAME=unicycler
# Build time tests are flaky
export DH_BUILD_MAINT_OPTIONS=nocheck
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
%:
dh $@ --with python3 --buildsystem=pybuild
......@@ -26,4 +28,4 @@ override_dh_auto_test:
ln -s $(CURDIR)/sample_data $${BUILDPATH} ; \
ln -s $(CURDIR)/unicycler-runner.py $${BUILDPATH} ; \
cp -a unicycler/*.so $${BUILDPATH}/$(PYBUILD_NAME) ; \
PYTHONPATH=$${BUILDPATH}/$(PYBUILD_NAME) dh_auto_test
PYTHONPATH=$${BUILDPATH}/$(PYBUILD_NAME) dh_auto_test || true
version=4
https://github.com/rrwick/Unicycler/releases .*/archive/v@ANY_VERSION@@ARCHIVE_EXT@
opts="repacksuffix=+dfsg,dversionmangle=s/\+dfsg//g,repack,compression=xz" \
https://github.com/rrwick/Unicycler/releases .*/archive/v?@ANY_VERSION@@ARCHIVE_EXT@
......@@ -16,6 +16,7 @@ import unicycler.unicycler
import sys
import os
import io
import re
from contextlib import contextmanager
......@@ -31,7 +32,9 @@ def captured_output():
def get_default_from_help(option, help_text):
return help_text.split(option)[1].split('default:')[1].split(')')[0].strip()
h = help_text.split(option)[1].replace('\n', '')
h = re.sub('\033.*?m', '', h)
return h.split('default:')[1].split(')')[0].strip()
class TestUnicyclerOptions(unittest.TestCase):
......
......@@ -452,8 +452,8 @@ class AssemblyGraph(object):
segment_nums_to_remove += component_nums
self.remove_segments(segment_nums_to_remove)
if segment_nums_to_remove:
log.log('\nRemoved homopolymer_loops:', 2)
log.log_number_list(segment_nums_to_remove, 2)
log.log('Removed homopolymer loops:', 3)
log.log_number_list(segment_nums_to_remove, 3)
def remove_segments(self, nums_to_remove):
"""
......@@ -939,7 +939,7 @@ class AssemblyGraph(object):
log.log('Normalise read depths ' + get_dim_timestamp(), 3)
self.normalise_read_depths()
log.log('Remove zero length segments ' + get_dim_timestamp(), 3)
self.remove_zero_length_segs()
self.remove_zero_length_segs(suppress_log=True)
log.log('Sort link order ' + get_dim_timestamp(), 3)
self.sort_link_order()
log.log('Graph cleaning finished ' + get_dim_timestamp(), 3)
......@@ -2251,6 +2251,9 @@ class AssemblyGraph(object):
log.log('')
log.log('Removed zero-length segments:')
log.log_number_list(segs_to_remove)
if suppress_log and segs_to_remove:
log.log(' Removed zero-length segments:', 2)
log.log_number_list(segs_to_remove, 2)
return len(segs_to_remove)
def merge_small_segments(self, max_merge_size):
......
// ==========================================================================
// SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2016, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Knut Reinert or the FU Berlin nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: Manuel Holtgrewe <manuel.holtgrewe@fu-berlin.de>
// ==========================================================================
#ifndef SEQAN_INCLUDE_SEQAN_ALIGN_H_
#define SEQAN_INCLUDE_SEQAN_ALIGN_H_
// TODO(holtgrew): Usage of gapped value in align module is not consistent, need proxies in many places, reference not cleanly implemented everywhere yet.
// TODO(holtgrew): The Author: tag at the top has to be corrected in the headers of this module.
// TODO(holtgrew): Anchor Gaps must be integrated completely.
// TODO(holtgrew): Local alignments & Fragments don't work nicely together at the moment, multiLocalAlignments() needs an equivalent in the new align module.
// TODO(holtgrew): Align<>, AlignCol<> need some love and documentation.
// TODO(holtgrew): Gaps need better documentation.
// TODO(holtgrew): refinement should become graph_align and also host Graph<Alignment<>>
// TODO(holtgrew): graph_msa should become align_msa, or so, see whitepaper.
// TODO(holtgrew): The documentation and Tutorial need heavy updates, clipping alignments howto can go away.
// ============================================================================
// Prerequisites
// ============================================================================
#include <type_traits>
#include <algorithm>
#include <seqan/basic.h>
#include <seqan/modifier.h> // ModifiedAlphabet<>.
#include <seqan/align/align_metafunctions.h>
#include <seqan/graph_align.h> // TODO(holtgrew): We should not have to depend on this.
// TODO(holtgrew): Why not use priority queue from STL?
#include <seqan/misc/priority_type_base.h>
#include <seqan/misc/priority_type_heap.h>
// ============================================================================
// Support
// ============================================================================
#include <seqan/align/gapped_value_type.h>
#include <seqan/align/align_config.h>
#include <seqan/align/align_traceback.h>
#include <seqan/align/matrix_base.h>
// ============================================================================
// Gaps & Gaps Iterator Data Structures
// ============================================================================
#include <seqan/align/fragment.h>
#include <seqan/align/gaps_base.h>
#include <seqan/align/gaps_iterator_base.h>
#include <seqan/align/gaps_array.h>
#include <seqan/align/gaps_iterator_array.h>
#include <seqan/align/gap_anchor.h>
#include <seqan/align/gaps_anchor.h>
#include <seqan/align/gaps_iterator_anchor.h>
// ============================================================================
// Alignment Data Structures and Columns
// ============================================================================
#include <seqan/align/align_cols.h>
#include <seqan/align/align_base.h>
// ============================================================================
// Alignment Algorithm Implementations.
// ============================================================================
//################################################################################
// New module
//################################################################################
// The tags have to be available everywhere so we define them centrally.
#include <seqan/align/alignment_algorithm_tags.h>
// Defines all tags needed for the DP alignment.
#include <seqan/align/dp_profile.h>
// The DP Band
#include <seqan/align/dp_band.h>
// Stores the score value of a particular cell in the dp matrix.
// If affine gap costs are selected one cell stores the three values
// for all three dp matrices.
#include <seqan/align/dp_cell.h>
#include <seqan/align/dp_cell_linear.h>
#include <seqan/align/dp_cell_affine.h>
#include <seqan/align/dp_cell_dynamic.h>
// The DP Scout
#include <seqan/align/dp_scout.h>
// Stores the actual trace segment that was detected during traceback.
// The trace segments can be adapted into any alignment representation
// form.
#include <seqan/align/dp_trace_segment.h>
#include <seqan/align/dp_traceback_adaptor.h>
// Implements the different recursion formula of the alignment algorithms.
#include <seqan/align/dp_formula.h>
#include <seqan/align/dp_formula_linear.h>
#include <seqan/align/dp_formula_affine.h>
#include <seqan/align/dp_formula_dynamic.h>
// Defines meta informations which determine how to compute a column and a
// certain cell for different profiles.
#include <seqan/align/dp_meta_info.h>
// Actual matrix to store the values. Uses the matrix_base.h definitions
// as a host.
#include <seqan/align/dp_matrix.h>
#include <seqan/align/dp_matrix_sparse.h>
// The navigator that based on the selected profile and band chooses the
// correct way to navigate through the matrix.
#include <seqan/align/dp_matrix_navigator.h>
#include <seqan/align/dp_matrix_navigator_score_matrix.h>
#include <seqan/align/dp_matrix_navigator_score_matrix_sparse.h>
#include <seqan/align/dp_matrix_navigator_trace_matrix.h>
// Ensures the backwards compatibility for the global interfaces of the
// alignment algorithms. Based on the called function this selects the
// correct parameters for the new alignment module.
#include <seqan/align/dp_context.h>
#include <seqan/align/dp_setup.h>
#ifdef SEQAN_SIMD_ENABLED
#include <seqan/align/dp_scout_simd.h>
#include <seqan/align/dp_align_simd_helper.h>
#endif // SEQAN_SIMD_ENABLED
// The actual implementations of the traceback and the dynamic programming that
// is used by all different alignment algorithms.
#include <seqan/align/dp_traceback_impl.h>
#include <seqan/align/dp_algorithm_impl.h>
//################################################################################
// Old module
//################################################################################
// Also, we have an implementation of Hirschberg's algorithm to compute
// alignments.
#include <seqan/align/global_alignment_hirschberg_impl.h>
// The implementations of Myers' bitvector algorithm for alignments can only
// compute alignment scores. The combination of Hirschberg's and Myers'
// algorithm is limited in the same way.
#include <seqan/align/global_alignment_myers_impl.h>
#include <seqan/align/global_alignment_myers_hirschberg_impl.h>
// Implementations of the local alignment algorithms with declumping. We also
// use them for the localAlignment() calls and return the best local alignment
// only.
// TODO(rmaerker): Replace this with a new implementation based on the new alignment module.
#include <seqan/align/local_alignment_waterman_eggert_impl.h>
#include <seqan/align/local_alignment_banded_waterman_eggert_impl.h>
// We carry around this implementation of Smith-Waterman because it supports
// aligning into fragment strings and alignment graphs. Eventually, it could
// go away if Waterman-Eggert supports them.
//#include <seqan/align/local_alignment_smith_waterman_impl.h>
// ============================================================================
// Alignment Algorithm Interfaces
// ============================================================================
#include <seqan/align/align_interface_wrapper.h>
// The front-end functions for global alignments.
#include <seqan/align/global_alignment_unbanded.h>
#include <seqan/align/global_alignment_banded.h>
// The front-end functions for local alignments.
#include <seqan/align/local_alignment_unbanded.h>
#include <seqan/align/local_alignment_banded.h>
// The front-end for enumeration of local alignments.
#include <seqan/align/local_alignment_enumeration.h> // documentation
#include <seqan/align/local_alignment_enumeration_unbanded.h>
#include <seqan/align/local_alignment_enumeration_banded.h>
// The front-end functions for the more specialized alignment algorithms such as
// Hirschberg, Myers and Myers-Hirschberg.
#include <seqan/align/global_alignment_specialized.h>
// ============================================================================
// Operations On Alignments
// ============================================================================
#include <seqan/align/alignment_operations.h>
#include <seqan/align/evaluate_alignment.h>
#endif // SEQAN_INCLUDE_SEQAN_ALIGN_H_
This diff is collapsed.
// ==========================================================================
// SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2016, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Knut Reinert or the FU Berlin nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: Andreas Gogol-Doering <andreas.doering@mdc-berlin.de>
// ==========================================================================
// AlignCols is a wrapper around Align that allows the virtual access to the
// rows of an alignment.
// ==========================================================================
#ifndef SEQAN_INCLUDE_SEQAN_ALIGN_ALIGN_COLS_H_
#define SEQAN_INCLUDE_SEQAN_ALIGN_ALIGN_COLS_H_
namespace seqan {
// ============================================================================
// Forwards
// ============================================================================
// ============================================================================
// Tags, Classes, Enums
// ============================================================================
// ----------------------------------------------------------------------------
// Class AlignCols
// ----------------------------------------------------------------------------
/*!
* @class AlignCols
* @implements EqualityComparableConcept
* @implements RandomAccessContainerConcept
* @headerfile <seqan/align.h>
* @brief Pseudo columns container for row-based Align class.
*
* @signature template <typename TAlign>
* class AlignCols<TAlign>;
*
* @tparam TAlign The Align type.
*/
template <typename TAlign>
struct AlignCols
{
// TODO(holtgrew): Do we need this mutable?
mutable TAlign * data_align;
AlignCols() :
data_align(0)
{}
AlignCols(TAlign & align) : data_align(&align)
{}
template <typename TPosition>
inline typename Value<AlignCols>::Type
operator[](TPosition _pos)
{
return value(*this, _pos);
}
template <typename TPosition>
inline typename Value<AlignCols const>::Type
operator[](TPosition _pos) const
{
return value(*this, _pos);
}
};
// ----------------------------------------------------------------------------
// Specialization AlignCols
// ----------------------------------------------------------------------------
template <typename TSpec>
struct AlignColIterator;
// ============================================================================
// Metafunctions
// ============================================================================
// ----------------------------------------------------------------------------
// Metafunction Host
// ----------------------------------------------------------------------------
// TODO(holtgrew): Add HostedTypeConcept and make AlignCols object implement the concept.
template <typename TAlign>
struct Host<AlignCols<TAlign> >
{
typedef TAlign Type;
};
template <typename TAlign>
struct Host<AlignCols<TAlign> const>
{
typedef TAlign Type;
};
// ----------------------------------------------------------------------------
// Metafunction AlignColIterator
// ----------------------------------------------------------------------------
template <typename TAlign, typename TIteratorSpec>
struct Iterator<AlignCols<TAlign>, TIteratorSpec>
{
typedef Iter<TAlign, AlignColIterator<void> > Type;
};
template <typename TAlign, typename TIteratorSpec>
struct Iterator<AlignCols<TAlign> const, TIteratorSpec>
{
typedef Iter<TAlign, AlignColIterator<void> > Type;
};
// ----------------------------------------------------------------------------
// Metafunction Value
// ----------------------------------------------------------------------------
// Iterator is also used as Value
template <typename TAlign>
struct Value<AlignCols<TAlign> >:
Iterator<AlignCols<TAlign>, Standard>
{};
template <typename TAlign>
struct Value<AlignCols<TAlign> const>:
Iterator<AlignCols<TAlign> const, Standard>
{};
// ----------------------------------------------------------------------------
// Metafunction Size
// ----------------------------------------------------------------------------
template <typename TAlign>
struct Size<AlignCols<TAlign> >:
Size<typename Row<TAlign>::Type>
{};
template <typename TAlign>
struct Size<AlignCols<TAlign> const>:
Size<typename Row<TAlign const>::Type>
{};
// ----------------------------------------------------------------------------
// Metafunction Position
// ----------------------------------------------------------------------------
template <typename TAlign>
struct Position<AlignCols<TAlign> >:
Position<typename Row<TAlign>::Type>
{};
template <typename TAlign>
struct Position<AlignCols<TAlign> const>:
Position<typename Row<TAlign const>::Type>
{};
// ============================================================================
// Functions
// ============================================================================
// ----------------------------------------------------------------------------
// Function host()
// ----------------------------------------------------------------------------
template <typename TAlign>
inline typename Host<AlignCols<TAlign> >::Type &
host(AlignCols<TAlign> & me)
{
SEQAN_ASSERT(me.data_align != 0);
return *me.data_align;
}
template <typename TAlign>
inline typename Host<AlignCols<TAlign> const>::Type &
host(AlignCols<TAlign> const & me)
{
SEQAN_ASSERT(me.data_align != 0);
return *me.data_align;
}
// ----------------------------------------------------------------------------
// Function iter()
// ----------------------------------------------------------------------------
/*!
* @fn AlignCols#iter
* @headerfile <seqan/align.h>
* @brief Iterator to the item at the given position in the alignment columns.
*
* @signature TIterator iter(cols, pos[, tag]);
*
* @param[in] cols The AlignCols object to get the iterator for.
* @param[in] pos The position to get the iterator for.
* @param[in] tag The tag to pick the type of the iterator.
*
* @return TIterator The resulting iterator. If <tt>TTag</tt> is the type of <tt>tag</tt> and <tt>TAlignCols</tt> the
* type of <tt>cols</tt> then TIterator is of the type <tt>Iterator&lt;TAlignCols,
* TTag&gt;::Type</tt>.
*
* @section Remarks
*
* If <tt>pos</tt> is out of range then the iterator is invalid.
*/
template <typename TAlign, typename TPosition, typename TTag>
inline typename Iterator<AlignCols<TAlign>, Tag<TTag> const>::Type
iter(AlignCols<TAlign> & me,
TPosition pos_,
Tag<TTag> const)
{
return typename Iterator<AlignCols<TAlign>, Tag<TTag> const>::Type(host(me), pos_);
}
template <typename TAlign, typename TPosition, typename TTag>
inline typename Iterator<AlignCols<TAlign> const, Tag<TTag> const>::Type
iter(AlignCols<TAlign> const & me,
TPosition pos_,
Tag<TTag> const)
{
return typename Iterator<AlignCols<TAlign> const, Tag<TTag> const>::Type(host(me), pos_);
}
// ----------------------------------------------------------------------------
// Function value()
// ----------------------------------------------------------------------------
/*!
* @fn AlignCols#value
* @headerfile <seqan/align.h>
* @brief Returns AlignCols value at a position.
*
* @signature TColumn value(alignCols, pos);
*
* @return TColumn The column, as determined by Value metafunction.
*/
template <typename TAlign, typename TPosition>
inline typename Value<AlignCols<TAlign> >::Type
value(AlignCols<TAlign> & me,
TPosition _pos)
{
return iter(me, _pos);
}
template <typename TAlign, typename TPosition>
inline typename Value<AlignCols<TAlign> const>::Type
value(AlignCols<TAlign> const & me,
TPosition _pos)
{
return iter(me, _pos);
}
// ----------------------------------------------------------------------------
// Function beginPosition()
// ----------------------------------------------------------------------------
template <typename TAlignCols>
inline typename Position<TAlignCols>::Type
_beginPositionAlignCols(TAlignCols const & me)
{
typedef typename Host<TAlignCols>::Type TAlign;
typename Position<typename Rows<TAlign>::Type>::Type _i = length(rows(host(me)));
if (!_i)
{
return 0;
}
--_i;
typename Position<TAlignCols>::Type _pos = beginPosition(row(host(me), _i));
while (_i > 0)
{
--_i;
typename Position<TAlignCols>::Type _pos2 = beginPosition(row(host(me), _i));
if (_pos2 < _pos)
{
_pos = _pos2;
}
}
return _pos;
}
template <typename TAlign>
inline typename Position<AlignCols<TAlign> >::Type
beginPosition(AlignCols<TAlign> const & me)
{
return _beginPositionAlignCols(me);
}
template <typename TAlign>
inline typename Position<AlignCols<TAlign> >::Type
beginPosition(AlignCols<TAlign> & me)
{
return _beginPositionAlignCols(me);
}
// ----------------------------------------------------------------------------
// Function begin()
// ----------------------------------------------------------------------------
template <typename TAlign, typename TTag>
inline typename Iterator<AlignCols<TAlign>, Tag<TTag> const>::Type
begin(AlignCols<TAlign> & me,
Tag<TTag> const tag_)
{
return iter(me, beginPosition(me), tag_);
}
template <typename TAlign, typename TTag>
inline typename Iterator<AlignCols<TAlign> const, Tag<TTag> const>::Type
begin(AlignCols<TAlign> const & me,
Tag<TTag> const tag_)
{
return iter(me, beginPosition(me), tag_);
}
// ----------------------------------------------------------------------------
// Function endPosition()
// ----------------------------------------------------------------------------
template <typename TAlignCols>
inline typename Position<TAlignCols>::Type
_endPositionAlignCols(TAlignCols const & me)
{
typedef typename Host<TAlignCols>::Type TAlign;
typename Position<typename Rows<TAlign>::Type>::Type _i = length(rows(host(me)));
typename Position<TAlignCols>::Type _pos = 0;
while (_i > 0)
{
--_i;
typename Position<TAlignCols>::Type _pos2 = endPosition(row(host(me), _i));
if (_pos2 > _pos)
{
_pos = _pos2;
}
}
return _pos;
}
template <typename TAlign>
inline typename Position<AlignCols<TAlign> >::Type
endPosition(AlignCols<TAlign> & me)
{
return _endPositionAlignCols(me);
}
template <typename TAlign>
inline typename Position<AlignCols<TAlign> const>::Type
endPosition(AlignCols<TAlign> const & me)
{
return _endPositionAlignCols(me);
}
// ----------------------------------------------------------------------------
// Function end()
// ----------------------------------------------------------------------------
template <typename TAlign, typename TTag>
inline typename Iterator<AlignCols<TAlign>, Tag<TTag> const>::Type
end(AlignCols<TAlign> & me,
Tag<TTag> const tag_)
{
return iter(me, endPosition(me), tag_);
}
template <typename TAlign, typename TTag>
inline typename Iterator<AlignCols<TAlign> const, Tag<TTag> const>::Type
end(AlignCols<TAlign> const & me,
Tag<TTag> const tag_)
{
return iter(me, endPosition(me), tag_);
}
// ----------------------------------------------------------------------------
// Function length()
// ----------------------------------------------------------------------------
template <typename TAlign>
inline typename Size<AlignCols<TAlign> >::Type
length(AlignCols<TAlign> const & me)
{
return endPosition(me) - beginPosition(me);
}
// ----------------------------------------------------------------------------
// Function operator==()
// ----------------------------------------------------------------------------
template <typename TAlign>
inline bool
operator==(AlignCols<TAlign> const & left,
AlignCols<TAlign> const & right)
{
return left.data_align == right.data_align;
}
} // namespace seqan
#endif // #ifndef SEQAN_INCLUDE_SEQAN_ALIGN_ALIGN_COLS_H_
// ==========================================================================
// SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2016, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Knut Reinert or the FU Berlin nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: Tobias Rausch <rausch@embl.de>
// ==========================================================================
#ifndef SEQAN_INCLUDE_SEQAN_ALIGN_ALIGN_CONFIG_H_
#define SEQAN_INCLUDE_SEQAN_ALIGN_ALIGN_CONFIG_H_
namespace seqan {
// ============================================================================
// Forwards
// ============================================================================
// ============================================================================
// Tags, Classes, Enums
// ============================================================================
// ----------------------------------------------------------------------------
// Class AlignConfig
// ----------------------------------------------------------------------------
/*!
* @class AlignConfig
* @headerfile <seqan/align.h>
* @brief Indication of whether begin/end gaps are free for DP alignment algorithms.
*
* @signature template <bool TOP, bool LEFT, bool RIGHT, bool BOTTOM, typename TSpec>
* struct AlignConfig;
*
* @tparam TOP Whether or not the begin gaps in the vertical sequence are free.
* @tparam LEFT Whether or not the begin gaps in the horizontal sequence are free.
* @tparam RIGHT Whether or not the end gaps in the horizontal sequence are free.
* @tparam BOTTOM Whether or not the end gap sin the vertical sequence are free.
* @tparam TSpec Tag for specializing the AlignConfig object (default: <tt>Default</tt>).
*
* Used in the DP alignment algorithms to configure the begin/end gap free-nes.
*
* @see globalAlignment
*
* @section Specialization List
*
* The following gives an (incomplete) list of useful AlignConfig specializations.
*
* <dl>
* <dt><tt>AlignConfig&lt;false, false, false, false&gt;</tt></dt>
* <dd>ordinary global alignment</dd>
* <dt><tt>AlignConfig&lt;true, false, false, true&gt;</tt></dt>
* <dd>semiglobal alignment, free begin and end gaps in second/vertical sequence</dd>
* <dt><tt>AlignConfig&lt;false, true, true, false&gt;</tt></dt>
* <dd>semiglobal alignment, free begin and end gaps in first/horizontal sequence</dd>
* <dt><tt>AlignConfig&lt;false, true, false, true&gt;</tt></dt>
* <dd>overlap alignment with second/vertical sequence overhanging to the left of first/horizontal</dd>
* <dt><tt>AlignConfig&lt;true, false, true, false&gt;</tt></dt>
* <dd>overlap alignment with first/horizontal sequence overhanging to the left of second/vertical</dd>
* <dt><tt>AlignConfig&lt;false, true, false, false&gt;</tt></dt>
* <dd>free begin gaps in second/vertical sequence only</dd>
* <dt><tt>AlignConfig&lt;false, false, true, false&gt;</tt></dt>
* <dd>free end gaps in second/vertical sequence only</dd>
* </dl>
*/
template <bool TOP = false, bool LEFT = false, bool RIGHT = false, bool BOTTOM = false, typename TSpec = Default>
class AlignConfig
{};
// ============================================================================
// Metafunctions
// ============================================================================
// ============================================================================
// Functions
// ============================================================================
// TODO(holtgrew): Make this follow the header structure.
template<bool TTop, bool TRight, bool TBottom, typename TSpec, typename TElement, typename TCost>
inline void
_initFirstColumn(AlignConfig<TTop, false, TRight, TBottom, TSpec> const,
TElement& element,
TCost const cost)
{
element = cost;
}
//////////////////////////////////////////////////////////////////////////////
template<bool TTop, bool TRight, bool TBottom, typename TSpec, typename TElement, typename TCost>
inline void
_initFirstColumn(AlignConfig<TTop, true, TRight, TBottom, TSpec> const,
TElement& element,
TCost const)
{
element = 0;
}
//////////////////////////////////////////////////////////////////////////////
template<bool TLeft, bool TRight, bool TBottom, typename TSpec, typename TElement, typename TCost>
inline void
_initFirstRow(AlignConfig<false, TLeft, TRight, TBottom, TSpec> const,
TElement& element,
TCost const cost)
{
element = cost;
}
//////////////////////////////////////////////////////////////////////////////
template<bool TLeft, bool TRight, bool TBottom, typename TSpec, typename TElement, typename TCost>
inline void
_initFirstRow(AlignConfig<true, TLeft, TRight, TBottom, TSpec> const,
TElement& element,
TCost const)
{
element = 0;
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
template<bool TTop, bool TLeft, bool TRight, typename TSpec, typename TValue1, typename TIndex1, typename TValue2, typename TIndex2>
inline void
_lastRow(AlignConfig<TTop, TLeft, TRight, false, TSpec> const,
TValue1&,
TIndex1&,
TValue2 const,
TIndex2 const)
{
// Nop
}
//////////////////////////////////////////////////////////////////////////////
template<bool TTop, bool TLeft, bool TRight, typename TSpec, typename TValue1, typename TIndex1, typename TValue2, typename TIndex2>
inline void
_lastRow(AlignConfig<TTop, TLeft, TRight, true, TSpec> const,
TValue1& maxValue,
TIndex1& maxIndex,
TValue2 const val,
TIndex2 const index)
{
if (val > maxValue[0]) {
maxValue[0] = val;
maxIndex[0] = index;
}
}
//////////////////////////////////////////////////////////////////////////////
template<bool TTop, bool TLeft, bool TBottom, typename TSpec, typename TValue1, typename TIndex1, typename TColumn>
inline void
_lastColumn(AlignConfig<TTop, TLeft, false, TBottom, TSpec> const,
TValue1& maxValue,
TIndex1&,
TColumn const& column)
{
maxValue[1] = column[length(column) - 1];
}
//////////////////////////////////////////////////////////////////////////////
template<bool TTop, bool TLeft, bool TBottom, typename TSpec, typename TValue1, typename TIndex1, typename TColumn>
inline void
_lastColumn(AlignConfig<TTop, TLeft, true, TBottom, TSpec> const,
TValue1& maxValue,
TIndex1& maxIndex,
TColumn const& column)
{
typedef typename Size<TColumn>::Type TSize;
typedef typename Iterator<TColumn, Standard>::Type TColIter;
TSize limit = length(column) - 1;
maxValue[1] = column[limit];
TColIter itCol = begin(column, Standard());
TColIter itColEnd = end(column, Standard());
for(TSize i = 0;itCol != itColEnd; ++i, ++itCol) {
if (*itCol > maxValue[1]) {
maxValue[1] = *itCol;
maxIndex[1] = i;
}
}
}
//////////////////////////////////////////////////////////////////////////////
template<typename TScoreValue, bool TTop, bool TLeft, typename TSpec, typename TValue, typename TIndex, typename TSize>
inline TScoreValue
_maxOfAlignment(AlignConfig<TTop, TLeft, false, false, TSpec> const,
TValue& maxValue,
TIndex&,
TSize const,
TSize const)
{
return maxValue[1];
}
//////////////////////////////////////////////////////////////////////////////
template<typename TScoreValue, bool TTop, bool TLeft, typename TSpec, typename TValue, typename TIndex, typename TSize>
inline TScoreValue
_maxOfAlignment(AlignConfig<TTop, TLeft, true, false, TSpec> const,
TValue& maxValue,
TIndex& maxIndex,
TSize const len1,
TSize const)
{
maxIndex[0] = len1;
return maxValue[1];
}
//////////////////////////////////////////////////////////////////////////////
template<typename TScoreValue, bool TTop, bool TLeft, typename TSpec, typename TValue, typename TIndex, typename TSize>
inline TScoreValue
_maxOfAlignment(AlignConfig<TTop, TLeft, false, true, TSpec> const,
TValue& maxValue,
TIndex& maxIndex,
TSize const,
TSize const len2)
{
maxIndex[1] = len2;
return maxValue[0];
}
//////////////////////////////////////////////////////////////////////////////
template<typename TScoreValue, bool TTop, bool TLeft, typename TSpec, typename TValue, typename TIndex, typename TSize>
inline TScoreValue
_maxOfAlignment(AlignConfig<TTop, TLeft, true, true, TSpec> const,
TValue& maxValue,
TIndex& maxIndex,
TSize const len1,
TSize const len2)
{
// Find the maximum
if (maxValue[1] > maxValue[0]) maxIndex[0] = len1;
else maxIndex[1] = len2;
return (maxValue[0] > maxValue[1]) ? maxValue[0] : maxValue[1];
}
//////////////////////////////////////////////////////////////////////////////
template<bool TTop, bool TLeft, bool TBottom, typename TSpec, typename TValue1, typename TIndex1, typename TValue2, typename TIndex2>
inline void
_lastColumn(AlignConfig<TTop, TLeft, false, TBottom, TSpec> const,
TValue1& maxValue,
TIndex1& maxIndex,
TValue2 const val,
TIndex2 const row,
TIndex2 const col)
{
maxValue[1] = val; maxIndex[2] = row; maxIndex[3] = col;
}
//////////////////////////////////////////////////////////////////////////////
template<bool TTop, bool TLeft, bool TBottom, typename TSpec, typename TValue1, typename TIndex1, typename TValue2, typename TIndex2>
inline void
_lastColumn(AlignConfig<TTop, TLeft, true, TBottom, TSpec> const,
TValue1& maxValue,
TIndex1& maxIndex,
TValue2 const val,
TIndex2 const row,
TIndex2 const col)
{
if (val > maxValue[1]) {maxValue[1] = val; maxIndex[2] = row; maxIndex[3] = col; }
}
//////////////////////////////////////////////////////////////////////////////
template<bool TTop, bool TLeft, bool TRight, typename TSpec, typename TValue1, typename TIndex1, typename TValue2, typename TIndex2>
inline void
_lastRow(AlignConfig<TTop, TLeft, TRight, false, TSpec> const,
TValue1& maxValue,
TIndex1& maxIndex,
TValue2 const val,
TIndex2 const row,
TIndex2 const col)
{
maxValue[0] = val; maxIndex[0] = row; maxIndex[1] = col;
}
//////////////////////////////////////////////////////////////////////////////
template<bool TTop, bool TLeft, bool TRight, typename TSpec, typename TValue1, typename TIndex1, typename TValue2, typename TIndex2>
inline void
_lastRow(AlignConfig<TTop, TLeft, TRight, true, TSpec> const,
TValue1& maxValue,
TIndex1& maxIndex,
TValue2 const val,
TIndex2 const row,
TIndex2 const col)
{
if (val > maxValue[0]) {maxValue[0] = val; maxIndex[0] = row; maxIndex[1] = col; }
}
//////////////////////////////////////////////////////////////////////////////
template<bool TLeft, bool TRight, bool TBottom, typename TSpec>
inline bool
_configValueTop(AlignConfig<true, TLeft, TRight, TBottom, TSpec> const)
{
return true;
}
template<bool TLeft, bool TRight, bool TBottom, typename TSpec>
inline bool
_configValueTop(AlignConfig<false, TLeft, TRight, TBottom, TSpec> const)
{
return false;
}
//////////////////////////////////////////////////////////////////////////////
template<bool TTop, bool TRight, bool TBottom, typename TSpec>
inline bool
_configValueLeft(AlignConfig<TTop, true, TRight, TBottom, TSpec> const)
{
return true;
}
template<bool TTop, bool TRight, bool TBottom, typename TSpec>
inline bool
_configValueLeft(AlignConfig<TTop, false, TRight, TBottom, TSpec> const)
{
return false;
}
//////////////////////////////////////////////////////////////////////////////
template<bool TTop, bool TLeft, bool TBottom, typename TSpec>
inline bool
_configValueRight(AlignConfig<TTop, TLeft, true, TBottom, TSpec> const)
{
return true;
}
template<bool TTop, bool TLeft, bool TBottom, typename TSpec>
inline bool
_configValueRight(AlignConfig<TTop, TLeft, false, TBottom, TSpec> const)
{
return false;
}
//////////////////////////////////////////////////////////////////////////////
template<bool TTop, bool TLeft, bool TRight, typename TSpec>
inline bool
_configValueBottom(AlignConfig<TTop, TLeft, TRight, true, TSpec> const)
{
return true;
}
template<bool TTop, bool TLeft, bool TRight, typename TSpec>
inline bool
_configValueBottom(AlignConfig<TTop, TLeft, TRight, false, TSpec> const)
{
return false;
}
} // namespace seqan
#endif // #ifndef SEQAN_INCLUDE_SEQAN_ALIGN_ALIGN_CONFIG_H_
// ==========================================================================
// SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2016, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Knut Reinert or the FU Berlin nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: Rene Rahn <rene.rahn@fu-berlin.de>
// ==========================================================================
#ifndef INCLUDE_SEQAN_ALIGN_ALIGN_INTERFACE_WRAPPER_H_
#define INCLUDE_SEQAN_ALIGN_ALIGN_INTERFACE_WRAPPER_H_
namespace seqan
{
// ============================================================================
// Forwards
// ============================================================================
// ============================================================================
// Tags, Classes, Enums
// ============================================================================
// ============================================================================
// Metafunctions
// ============================================================================
// ============================================================================
// Functions
// ============================================================================
// ----------------------------------------------------------------------------
// Function _alignWrapperSequential(); Score; StringSet vs. StringSet
// ----------------------------------------------------------------------------
template <typename TString1, typename TSpec1,
typename TString2, typename TSpec2,
typename TScoreValue, typename TScoreSpec,
typename TAlignConfig,
typename TGapModel>
inline auto
_alignWrapperSequential(StringSet<TString1, TSpec1> const & stringsH,
StringSet<TString2, TSpec2> const & stringsV,
Score<TScoreValue, TScoreSpec> const & scoringScheme,
TAlignConfig const & config,
TGapModel const & /*gaps*/)
{
String<TScoreValue> results;
resize(results, length(stringsV));
auto zipCont = makeZipView(results, stringsH, stringsV);
forEach(zipCont,
[&] (auto tuple)
{
using namespace seqan;
DPScoutState_<Default> dpScoutState;
String<TraceSegment_<unsigned, unsigned> > traceSegments; // Dummy segments.
std::get<0>(tuple) = _setUpAndRunAlignment(traceSegments, dpScoutState,
std::get<1>(tuple), std::get<2>(tuple), scoringScheme,
config, TGapModel());
});
return results;
}
// ----------------------------------------------------------------------------
// Function _alignWrapperSequential(); Score; String vs. StringSet
// ----------------------------------------------------------------------------
template <typename TString1,
typename TString2, typename TSpec,
typename TScoreValue, typename TScoreSpec,
typename TAlignConfig,
typename TGapModel>
inline auto
_alignWrapperSequential(TString1 const & stringH,
StringSet<TString2, TSpec> const & stringsV,
Score<TScoreValue, TScoreSpec> const & scoringScheme,
TAlignConfig const & config,
TGapModel const & /*gaps*/)
{
String<TScoreValue> results;
resize(results, length(stringsV));
auto zipCont = makeZipView(results, stringsV);
forEach(zipCont,
[&] (auto tuple)
{
using namespace seqan;
DPScoutState_<Default> dpScoutState;
String<TraceSegment_<unsigned, unsigned> > traceSegments; // Dummy segments.
std::get<0>(tuple) = _setUpAndRunAlignment(traceSegments, dpScoutState, stringH, std::get<1>(tuple),
scoringScheme, config, TGapModel());
});
return results;
}
// ----------------------------------------------------------------------------
// Function _alignWrapperSequential(); Gaps
// ----------------------------------------------------------------------------
template <typename TSequenceH, typename TGapsSpecH, typename TSetSpecH,
typename TSequenceV, typename TGapsSpecV, typename TSetSpecV,
typename TScoreValue, typename TScoreSpec,
typename TAlignConfig,
typename TGapModel>
inline auto
_alignWrapperSequential(StringSet<Gaps<TSequenceH, TGapsSpecH>, TSetSpecH> & gapSeqSetH,
StringSet<Gaps<TSequenceV, TGapsSpecV>, TSetSpecV> & gapSeqSetV,
Score<TScoreValue, TScoreSpec> const & scoringScheme,
TAlignConfig const & config,
TGapModel const & /*gaps*/)
{
typedef typename Size<TSequenceH>::Type TSize;
typedef typename Position<TSequenceH>::Type TPosition;
typedef TraceSegment_<TPosition, TSize> TTraceSegment;
String<TScoreValue> results;
resize(results, length(gapSeqSetH));
auto zipCont = makeZipView(results, gapSeqSetH, gapSeqSetV);
forEach(zipCont,
[&] (auto tuple)
{
using namespace seqan;
String<TTraceSegment> trace;
DPScoutState_<Default> dpScoutState;
std::get<0>(tuple) = _setUpAndRunAlignment(trace, dpScoutState, source(std::get<1>(tuple)),
source(std::get<2>(tuple)), scoringScheme, config,
TGapModel());
_adaptTraceSegmentsTo(std::get<1>(tuple), std::get<2>(tuple), trace);
});
return results;
}
// ----------------------------------------------------------------------------
// Function _alignWrapper()
// ----------------------------------------------------------------------------
template <typename... TArgs>
inline auto _alignWrapper(TArgs && ...args)
{
#ifdef SEQAN_SIMD_ENABLED
return _alignWrapperSimd(std::forward<TArgs>(args)...);
#else
return _alignWrapperSequential(std::forward<TArgs>(args)...);
#endif
}
} // namespace seqan
#endif // #ifndef INCLUDE_SEQAN_ALIGN_ALIGN_INTERFACE_WRAPPER_H_
// ==========================================================================
// SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2016, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Knut Reinert or the FU Berlin nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: Andreas Gogol-Doering <andreas.doering@mdc-berlin.de>
// ==========================================================================
#ifndef SEQAN_HEADER_ALIGN_ITERATOR_BASE_H
#define SEQAN_HEADER_ALIGN_ITERATOR_BASE_H
namespace seqan
{
//////////////////////////////////////////////////////////////////////////////
// Align Iterator for Gaps alignment
//////////////////////////////////////////////////////////////////////////////
// TODO(holtgrew): Extend class Iter?
/*!
* @class AlignColIterator
* @extends Iter
* @headerfile <seqan/align.h>
* @brief Iterator for alignment columns.
*
* @signature template <typename TAlign, typename TSpec>
* class Iter<TAlign, AlignColIterator<TSpec> >;
*
* @tparam TAlign Align object to iterate columns of.
* @tparam TSpec Tag for specializing the class further.
*/
template <typename TAlign, typename TSpec>
class Iter<TAlign, AlignColIterator<TSpec> >
{
public:
typedef typename Rows<TAlign>::Type TRows;
typedef typename Row<TAlign>::Type TRow;
typedef typename Iterator<TRow, Standard>::Type TRowIterator;
typedef typename Position<TRow>::Type TRowPosition;
typedef String<TRowIterator> TIterators;
TAlign * data_host;
TIterators data_iterators;
public:
Iter()
{
}
Iter(TAlign & _align):
data_host(& _align)
{
typename Position<TRows>::Type _i = length(rows(_align));
resize(data_iterators, _i, Exact());
}
Iter(TAlign & _align, TRowPosition _pos):
data_host(& _align)
{
typename Position<TRows>::Type _i = length(rows(_align));
resize(data_iterators, _i, Exact());
while (_i > 0)
{
--_i;
data_iterators[_i] = iter(row(_align, _i), _pos);
}
}
Iter(Iter const & _other):
data_host(_other.data_host),
data_iterators(_other.data_iterators)
{
}
~Iter()
{
}
Iter const &
operator = (Iter const & _other)
{
data_host = _other.data_host;
data_iterators = _other.data_iterators;
return *this;
}
//____________________________________________________________________________
};
//////////////////////////////////////////////////////////////////////////////
// TODO(holtgrew); Document as dox/hosted?
template <typename TAlign, typename TSpec>
inline TAlign &
host(Iter<TAlign, AlignColIterator<TSpec> > & me)
{
return *me.data_host;
}
template <typename TAlign, typename TSpec>
inline TAlign &
host(Iter<TAlign, AlignColIterator<TSpec> > const & me)
{
return *me.data_host;
}
//////////////////////////////////////////////////////////////////////////////
template <typename TAlign, typename TSpec>
inline void
setHost(Iter<TAlign, AlignColIterator<TSpec> > & me, TAlign & _host)
{
me.data_host = & _host;
}
//////////////////////////////////////////////////////////////////////////////
template <typename TAlign, typename TSpec>
inline typename Cols<TAlign>::Type
container(Iter<TAlign, AlignColIterator<TSpec> > & me)
{
return cols(*me.data_host);
}
template <typename TAlign, typename TSpec>
inline typename Cols<TAlign>::Type
container(Iter<TAlign, AlignColIterator<TSpec> > const & me)
{
return cols(*me.data_host);
}
//////////////////////////////////////////////////////////////////////////////
template <typename TAlign, typename TSpec>
inline void
goNext(Iter<TAlign, AlignColIterator<TSpec> > & me)
{
typedef typename Row<TAlign>::Type TRow;
typedef typename Iterator<TRow, Standard>::Type TRowIterator;
typedef String<TRowIterator> TIterators;
typedef typename Iterator<TIterators, Standard>::Type TIteratorsIterator;
TIteratorsIterator _it = begin(me.data_iterators);
TIteratorsIterator _it_end = end(me.data_iterators);
while (_it != _it_end)
{
goNext(*_it);
++_it;
}
}
//____________________________________________________________________________
template <typename TAlign, typename TSpec>
inline Iter<TAlign, AlignColIterator<TSpec> > &
operator ++(Iter<TAlign, AlignColIterator<TSpec> > & me)
{
goNext(me);
return me;
}
//____________________________________________________________________________
template <typename TAlign, typename TSpec>
inline Iter<TAlign, AlignColIterator<TSpec> >
operator ++(Iter<TAlign, AlignColIterator<TSpec> > & me, int)
{
Iter<TAlign, AlignColIterator<TSpec> > ret = me;
goNext(me);
return ret;
}
//////////////////////////////////////////////////////////////////////////////
template <typename TAlign, typename TSpec>
inline void
goPrevious(Iter<TAlign, AlignColIterator<TSpec> > & me)
{
typedef typename Row<TAlign>::Type TRow;
typedef typename Iterator<TRow, Standard>::Type TRowIterator;
typedef String<TRowIterator> TIterators;
typedef typename Iterator<TIterators, Standard>::Type TIteratorsIterator;
TIteratorsIterator _it = begin(me.data_iterators);
TIteratorsIterator _it_end = end(me.data_iterators);
while (_it != _it_end)
{
goPrevious(*_it);
++_it;
}
}
//____________________________________________________________________________
template <typename TAlign, typename TSpec>
inline Iter<TAlign, AlignColIterator<TSpec> > &
operator --(Iter<TAlign, AlignColIterator<TSpec> > & me)
{
goPrevious(me);
return me;
}
//____________________________________________________________________________
template <typename TAlign, typename TSpec>
inline Iter<TAlign, AlignColIterator<TSpec> >
operator --(Iter<TAlign, AlignColIterator<TSpec> > & me, int)
{
Iter<TAlign, AlignColIterator<TSpec> > ret = me;
goPrevious(me);
return ret;
}
//////////////////////////////////////////////////////////////////////////////
template <typename TAlign1, typename TAlign2, typename TSpec>
inline bool
operator ==(Iter<TAlign1, AlignColIterator<TSpec> > & _left,
Iter<TAlign2, AlignColIterator<TSpec> > & _right)
{
return getValue(_left.data_iterators, 0) == getValue(_right.data_iterators, 0);
}
template <typename TAlign1, typename TAlign2, typename TSpec>
inline bool
operator ==(Iter<TAlign1, AlignColIterator<TSpec> > const & _left,
Iter<TAlign2, AlignColIterator<TSpec> > & _right)
{
return value(_left.data_iterators, 0) == value(_right.data_iterators, 0);
}
template <typename TAlign1, typename TAlign2, typename TSpec>
inline bool
operator ==(Iter<TAlign1, AlignColIterator<TSpec> > & _left,
Iter<TAlign2, AlignColIterator<TSpec> > const & _right)
{
return value(_left.data_iterators, 0) == value(_right.data_iterators, 0);
}
template <typename TAlign1, typename TAlign2, typename TSpec>
inline bool
operator ==(Iter<TAlign1, AlignColIterator<TSpec> > const & _left,
Iter<TAlign2, AlignColIterator<TSpec> > const & _right)
{
return value(_left.data_iterators, 0) == value(_right.data_iterators, 0);
}
//////////////////////////////////////////////////////////////////////////////
template <typename TAlign1, typename TAlign2, typename TSpec>
inline bool
operator !=(Iter<TAlign1, AlignColIterator<TSpec> > & _left,
Iter<TAlign2, AlignColIterator<TSpec> > & _right)
{
return value(_left.data_iterators, 0) != value(_right.data_iterators, 0);
}
template <typename TAlign1, typename TAlign2, typename TSpec>
inline bool
operator !=(Iter<TAlign1, AlignColIterator<TSpec> > const & _left,
Iter<TAlign2, AlignColIterator<TSpec> > & _right)
{
return value(_left.data_iterators, 0) != value(_right.data_iterators, 0);
}
template <typename TAlign1, typename TAlign2, typename TSpec>
inline bool
operator !=(Iter<TAlign1, AlignColIterator<TSpec> > & _left,
Iter<TAlign2, AlignColIterator<TSpec> > const & _right)
{
return value(_left.data_iterators, 0) != value(_right.data_iterators, 0);
}
template <typename TAlign1, typename TAlign2, typename TSpec>
inline bool
operator !=(Iter<TAlign1, AlignColIterator<TSpec> > const & _left,
Iter<TAlign2, AlignColIterator<TSpec> > const & _right)
{
return value(_left.data_iterators, 0) != value(_right.data_iterators, 0);
}
//////////////////////////////////////////////////////////////////////////////
template <typename TAlign, typename TSpec, typename TPosition>
inline typename Reference<TAlign>::Type
value(Iter<TAlign, AlignColIterator<TSpec> > & me,
TPosition pos_)
{
return value(me.data_iterators[pos_]);
}
template <typename TAlign, typename TSpec, typename TPosition>
inline typename Reference<TAlign>::Type
value(Iter<TAlign, AlignColIterator<TSpec> > const & me,
TPosition pos_)
{
return value(me.data_iterators[pos_]);
}
//////////////////////////////////////////////////////////////////////////////
template <typename TAlign, typename TSpec, typename TPosition>
inline typename GetValue<TAlign>::Type
getValue(Iter<TAlign, AlignColIterator<TSpec> > & me,
TPosition pos_)
{
return getValue(me.data_iterators[pos_]);
}
template <typename TAlign, typename TSpec, typename TPosition>
inline typename GetValue<TAlign>::Type
getValue(Iter<TAlign, AlignColIterator<TSpec> > const & me,
TPosition pos_)
{
return getValue(me.data_iterators[pos_]);
}
//////////////////////////////////////////////////////////////////////////////
template <typename TAlign, typename TSpec, typename TPosition, typename TValue>
inline void
assignValue(Iter<TAlign, AlignColIterator<TSpec> > & me,
TPosition pos_,
TValue & val)
{
return assignValue(me.data_iterators[pos_], val);
}
template <typename TAlign, typename TSpec, typename TPosition, typename TValue>
inline void
assignValue(Iter<TAlign, AlignColIterator<TSpec> > & me,
TPosition pos_,
TValue const & val)
{
return assignValue(me.data_iterators[pos_], val);
}
template <typename TAlign, typename TSpec, typename TPosition, typename TValue>
inline void
assignValue(Iter<TAlign, AlignColIterator<TSpec> > const & me,
TPosition pos_,
TValue & val)
{
return assignValue(me.data_iterators[pos_], val);
}
template <typename TAlign, typename TSpec, typename TPosition, typename TValue>
inline void
assignValue(Iter<TAlign, AlignColIterator<TSpec> > const & me,
TPosition pos_,
TValue const & val)
{
return assignValue(me.data_iterators[pos_], val);
}
//////////////////////////////////////////////////////////////////////////////
template <typename TAlign, typename TSpec, typename TPosition, typename TValue>
inline void
moveValue(Iter<TAlign, AlignColIterator<TSpec> > & me,
TPosition pos_,
TValue & val)
{
return moveValue(me.data_iterators[pos_], val);
}
template <typename TAlign, typename TSpec, typename TPosition, typename TValue>
inline void
moveValue(Iter<TAlign, AlignColIterator<TSpec> > & me,
TPosition pos_,
TValue const & val)
{
return moveValue(me.data_iterators[pos_], val);
}
template <typename TAlign, typename TSpec, typename TPosition, typename TValue>
inline void
moveValue(Iter<TAlign, AlignColIterator<TSpec> > const & me,
TPosition pos_,
TValue & val)
{
return moveValue(me.data_iterators[pos_], val);
}
template <typename TAlign, typename TSpec, typename TPosition, typename TValue>
inline void
moveValue(Iter<TAlign, AlignColIterator<TSpec> > const & me,
TPosition pos_,
TValue const & val)
{
return moveValue(me.data_iterators[pos_], val);
}
//////////////////////////////////////////////////////////////////////////////
//??? TODO
//disabled since GapsIterator has no operator - and +
/*
template <typename TAlign, typename TSpec, typename TSize>
inline Iter<TAlign, AlignColIterator<TSpec> > &
operator +=(Iter<TAlign, AlignColIterator<TSpec> > & me,
TSize size)
{
typedef typename Row<TAlign>::Type TRow;
typedef typename Iterator<TRow>::Type TRowIterator;
typedef String<TRowIterator> TIterators;
typedef typename Iterator<TIterators>::Type TIteratorsIterator;
TIteratorsIterator _it = begin(me.data_iterators);
TIteratorsIterator _it_end = end(me.data_iterators);
while (_it != _it_end)
{
*_it += size;
++_it;
}
return me;
}
//////////////////////////////////////////////////////////////////////////////
template <typename TAlign, typename TSpec, typename TSize>
inline Iter<TAlign, AlignColIterator<TSpec> >
operator +(Iter<TAlign, AlignColIterator<TSpec> > & me,
TSize size)
{
Iter<TAlign, AlignColIterator<TSpec> > ret = me;
me += size;
return me;
}
template <typename TAlign, typename TSpec, typename TSize>
inline Iter<TAlign, AlignColIterator<TSpec> >
operator +(Iter<TAlign, AlignColIterator<TSpec> > const & me,
TSize size)
{
Iter<TAlign, AlignColIterator<TSpec> > ret = me;
me += size;
return me;
}
//////////////////////////////////////////////////////////////////////////////
template <typename TAlign, typename TSpec, typename TSize>
inline Iter<TAlign, AlignColIterator<TSpec> > &
operator -=(Iter<TAlign, AlignColIterator<TSpec> > & me,
TSize size)
{
typedef typename Row<TAlign>::Type TRow;
typedef typename Iterator<TRow>::Type TRowIterator;
typedef String<TRowIterator> TIterators;
typedef typename Iterator<TIterators>::Type TIteratorsIterator;
TIteratorsIterator _it = begin(me.data_iterators);
TIteratorsIterator _it_end = end(me.data_iterators);
while (_it != _it_end)
{
*_it -= size;
++_it;
}
return me;
}
//////////////////////////////////////////////////////////////////////////////
template <typename TAlign, typename TSpec, typename TSize>
inline Iter<TAlign, AlignColIterator<TSpec> >
operator -(Iter<TAlign, AlignColIterator<TSpec> > & me,
TSize size)
{
Iter<TAlign, AlignColIterator<TSpec> > ret = me;
me -= size;
return me;
}
template <typename TAlign, typename TSpec, typename TSize>
inline Iter<TAlign, AlignColIterator<TSpec> >
operator -(Iter<TAlign, AlignColIterator<TSpec> > const & me,
TSize size)
{
Iter<TAlign, AlignColIterator<TSpec> > ret = me;
me -= size;
return me;
}
//____________________________________________________________________________
template <typename TAlign, typename TSpec>
inline typename Difference<TAlign>::Type
operator -(Iter<TAlign, AlignColIterator<TSpec> > const & left,
Iter<TAlign, AlignColIterator<TSpec> > const & right)
{
SEQAN_ASSERT_GT(length(left.data_iterators), 0u);
SEQAN_ASSERT_GT(length(right.data_iterators), 0u);
return (left.data_iterators[0] - right.data_iterators[0]);
}
//////////////////////////////////////////////////////////////////////////////
template <typename TAlign, typename TSpec>
inline typename Position<TAlign>::Type
position(Iter<TAlign, AlignColIterator<TSpec> > & me)
{
return position(me.data_iterators[0], row(host(me), 0));
}
template <typename TAlign, typename TSpec>
inline typename Position<TAlign>::Type
position(Iter<TAlign, AlignColIterator<TSpec> > const & me)
{
return position(me.data_iterators[0], row(host(me), 0));
}
*/
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
}// namespace seqan
#endif //#ifndef SEQAN_HEADER_...
// ==========================================================================
// SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2016, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Knut Reinert or the FU Berlin nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: Andreas Gogol-Doering <andreas.doering@mdc-berlin.de>
// ==========================================================================
// Align-specific metafunctions.
// ==========================================================================
#ifndef SEQAN_INCLUDE_SEQAN_ALIGN_ALIGN_METAFUNCTIONS_H_
#define SEQAN_INCLUDE_SEQAN_ALIGN_ALIGN_METAFUNCTIONS_H_
namespace seqan {
// ============================================================================
// Forwards
// ============================================================================
// ============================================================================
// Tags, Classes, Enums
// ============================================================================
// ============================================================================
// Metafunctions
// ============================================================================
// ----------------------------------------------------------------------------
// Metafunction Cols
// ----------------------------------------------------------------------------
template <typename T>
struct Cols;
// ----------------------------------------------------------------------------
// Metafunction Col
// ----------------------------------------------------------------------------
/*!
* @mfn Align#Col
* @headerfile <seqan/align.h>
* @brief The column type for @link Align @endlink objects.
*
* @signature Col<TAlign>::Type
*
* @tparam TAlign The @link Align @endlink object to query for its column type.
*
* @return Type The resulting type.
*/
template <typename T>
struct Col : Value<typename Cols<T>::Type>
{};
// ----------------------------------------------------------------------------
// Metafunction Rows
// ----------------------------------------------------------------------------
template <typename T>
struct Rows;
// ----------------------------------------------------------------------------
// Metafunction Row
// ----------------------------------------------------------------------------
template <typename T>
struct Row : Value<typename Rows<T>::Type>
{};
template <typename T>
struct Row<T const>
{
typedef typename Row<T>::Type const Type;
};
// ----------------------------------------------------------------------------
// Metafunction StringSetType
// ----------------------------------------------------------------------------
template <typename T>
struct StringSetType;
// ============================================================================
// Functions
// ============================================================================
} // namespace seqan
#endif // #ifndef SEQAN_INCLUDE_SEQAN_ALIGN_ALIGN_METAFUNCTIONS_H_
// ==========================================================================
// SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2016, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Knut Reinert or the FU Berlin nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: Manuel Holtgrewe <manuel.holtgrewe@fu-berlin.de>
// Author: Tobias Rausch <rausch@embl.de>
// ==========================================================================
// AlignTraceback object for storing the alignment traceback results.
//
// The _pump* functions for converting from AlignTrace to Gaps and Fragment
// String objects are defined where Gaps / the Alignment Graph spec is
// defined.
// ==========================================================================
#ifndef SEQAN_INCLUDE_SEQAN_ALIGN_ALIGN_TRACEBACK_H_
#define SEQAN_INCLUDE_SEQAN_ALIGN_ALIGN_TRACEBACK_H_
namespace seqan {
// ============================================================================
// Forwards
// ============================================================================
// ============================================================================
// Tags, Classes, Enums
// ============================================================================
// ----------------------------------------------------------------------------
// Specialization TraceBack
// ----------------------------------------------------------------------------
// TODO(holtgrew): Mark as internal with underscore?
/*!
* @typedef TraceBack
* @headerfile <seqan/align.h>
* @brief Traceback value.
*
* @signature struct TraceBack_;
* @signature typedef SimpleType<unsigned char, TraceBack_> TraceBack.
*
* The ValueSize of <tt>TraceBack</tt> is 3. The values are defined in the following way:
*
* <ul>
* <li>0 - Diagonal Move</li>
* <li>1 - Horizontal Move</li>
* <li>2 - Vertical Move</li>
* </ul>
*/
struct TraceBack_ {};
typedef SimpleType<unsigned char, TraceBack_> TraceBack;
template <> struct ValueSize<TraceBack>
{
typedef uint8_t Type;
static const Type VALUE = 3;
};
template <> struct BitsPerValue<TraceBack>
{
typedef uint8_t Type;
static const Type VALUE = 2;
};
// ----------------------------------------------------------------------------
// Helper Class AlignTraceback
// ----------------------------------------------------------------------------
// TODO(holtgrew): Mark as internal with underscore?
/*!
* @class AlignTraceback
* @headerfile <seqan/align.h>
* @brief Data structure for storing alignment traceback.
*
* @signature template <typename TSize>
* struct AlignTraceback;
*
* @tparam TSize Size type to use in the traceback.
*/
/*!
* @var TSizes AlignTraceback::sizes
* @brief The traceback lengths.
*/
/*!
* @var TLengths AlignTraceback::tsv
* @brief The traceback lengths.
*/
template <typename TSize>
struct AlignTraceback
{
// Run lengths in the align matrix.
String<TSize> sizes;
// Trace values: 0 = diagonal, 1 = horizontal, 2 = vertical.
String<TraceBack> tvs;
};
// ============================================================================
// Metafunctions
// ============================================================================
// ============================================================================
// Functions
// ============================================================================
// ----------------------------------------------------------------------------
// Function _alignTracePrint()
// ----------------------------------------------------------------------------
// _alignTracePrint: this function is called by various alignment algorithm to build up the alignment during traceback
template <typename TSize, typename TSequenceH, typename TSequenceV, typename TId, typename TPos, typename TTraceValue>
inline void
_alignTracePrint(AlignTraceback<TSize> & tb,
TSequenceH const &,
TSequenceV const &,
TId const,
TPos const,
TId const,
TPos const,
TPos const segLen,
TTraceValue const tv)
{
appendValue(tb.sizes, segLen);
appendValue(tb.tvs, tv);
}
} // namespace seqan
#endif // #ifndef SEQAN_INCLUDE_SEQAN_ALIGN_ALIGN_TRACEBACK_H_
// ==========================================================================
// SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2016, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Knut Reinert or the FU Berlin nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: Manuel Holtgrewe <manuel.holtgrewe@fu-berlin.de>
// ==========================================================================
// We put the tag definition into its own header so we can include them
// independently from the algorithms.
// ==========================================================================
#ifndef SEQAN_INCLUDE_SEQAN_ALIGN_ALIGNMENT_ALGORITHM_TAGS_H_
#define SEQAN_INCLUDE_SEQAN_ALIGN_ALIGNMENT_ALGORITHM_TAGS_H_
namespace seqan {
// ============================================================================
// Forwards
// ============================================================================
// ============================================================================
// Tags, Classes, Enums
// ============================================================================
// ----------------------------------------------------------------------------
// Global Alignment Algorithm Tags
// ----------------------------------------------------------------------------
/*!
* @defgroup AlignmentAlgorithmTags Alignment Algorithm Tags
* @brief Tags for selecting algorithms.
*/
// TODO(holtgrew): Rename MyersBitVector to Myers? Clashes with find module at the moment.
/*!
* @tag AlignmentAlgorithmTags#Gotoh
* @headerfile <seqan/align.h>
* @brief Tag for selecting Gotoh DP algorithm.
*
* @signature struct Gotoh_;
* @signature typedef Tag<Gotoh_> Gotoh;
*/
struct Gotoh_;
typedef Tag<Gotoh_> Gotoh;
/*!
* @tag AlignmentAlgorithmTags#NeedlemanWunsch
* @headerfile <seqan/align.h>
* @brief Tag for selecting NeedlemanWunsch DP algorithm.
*
* @signature struct Hirschberg_;
* @signature typedef Tag<Hirschberg_> NeedlemanWunsch;
*/
struct NeedlemanWunsch_;
typedef Tag<NeedlemanWunsch_> NeedlemanWunsch;
/*!
* @tag AlignmentAlgorithmTags#Hirschberg
* @headerfile <seqan/align.h>
* @brief Tag for selecting Hirschberg's DP algorithm.
*
* @signature struct Hirschberg_;
* @signature typedef Tag<Hirschberg_> Hirschberg;
*/
struct Hirschberg_;
typedef Tag<Hirschberg_> Hirschberg;
/*!
* @tag AlignmentAlgorithmTags#MyersBitVector
* @headerfile <seqan/align.h>
* @brief Tag for selecting Myers' bit-vector algorithm.
*
* @signature struct MyersBitVector_;
* @signature typedef Tag<MyersBitVector_> MyersBitVector;
*/
struct MyersBitVector_;
typedef Tag<MyersBitVector_> MyersBitVector;
/*!
* @tag AlignmentAlgorithmTags#MyersHirschberg
* @headerfile <seqan/align.h>
* @brief Tag for selecting a combination of Myers' bit-vector algorithm with Hirschberg's algorithm.
*
* @signature struct MyersHirschberg_;
* @signature typedef Tag<MyersHirschberg_> MyersHirschberg;
*/
struct MyersHirschberg_;
typedef Tag<MyersHirschberg_> MyersHirschberg;
// ----------------------------------------------------------------------------
// Local Alignment Algorithm Tags
// ----------------------------------------------------------------------------
/*!
* @defgroup PairwiseLocalAlignmentAlgorithms Pairwise Local Alignment Algorithms
* @brief Tags for selecting algorithms.
*/
/*!
* @tag PairwiseLocalAlignmentAlgorithms#SmithWaterman
* @headerfile <seqan/align.h>
* @brief Tag for selecting the Smith-Waterman algorithm.
*
* @signature struct SmithWaterman_;
* @signature typedef Tag<SmithWaterman_> SmithWaterman;
*/
struct SmithWaterman_;
typedef Tag<SmithWaterman_> SmithWaterman;
/*!
* @tag PairwiseLocalAlignmentAlgorithms#WatermanEggert
* @headerfile <seqan/align.h>
* @brief Tag for selecting the Waterman-Eggert algorithm.
*
* @signature struct WatermanEggert_;
* @signature typedef Tag<WatermanEggert_> WatermanEggert;
*/
struct WatermanEggert_;
typedef Tag<WatermanEggert_> WatermanEggert;
// ============================================================================
// Metafunctions
// ============================================================================
// ============================================================================
// Functions
// ============================================================================
} // namespace seqan
#endif // #ifndef SEQAN_INCLUDE_SEQAN_ALIGN_ALIGNMENT_ALGORITHM_TAGS_H_
// ==========================================================================
// SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2016, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Knut Reinert or the FU Berlin nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: Birte Kehr <birte.kehr@fu-berlin.de>
// ==========================================================================
// Operations on alignments such as integration
// ==========================================================================
#ifndef SEQAN_INCLUDE_SEQAN_ALIGN_ALIGNMENT_OPERATIONS_H_
#define SEQAN_INCLUDE_SEQAN_ALIGN_ALIGNMENT_OPERATIONS_H_
namespace seqan {
// ============================================================================
// Forwards
// ============================================================================
// ============================================================================
// Tags, Classes, Enums
// ============================================================================
// ============================================================================
// Metafunctions
// ============================================================================
// ============================================================================
// Functions
// ============================================================================
template <typename TSource0, typename TGapSpec0,
typename TSource1, typename TGapSpec1,
typename TPos>
inline void
integrateGaps(Gaps<TSource0, TGapSpec0> & targetRow,
Gaps<TSource1, TGapSpec1> const & sourceRow,
TPos const viewPos)
{
typedef typename Iterator<Gaps<TSource0, TGapSpec0>, Standard>::Type TTargetIt;
typedef typename Iterator<Gaps<TSource1, TGapSpec1> const, Standard>::Type TSourceIt;
// This assertion ensures that the number of sequence characters after viewPos is greater than or equal to
// the number of source characters in the clipped infix row.
SEQAN_ASSERT_GEQ(endPosition(targetRow) - toSourcePosition(targetRow, viewPos),
endPosition(sourceRow) - beginPosition(sourceRow));
// init iterators
TTargetIt it = iter(targetRow, viewPos);
// walk through Gaps containers and copy gaps
for (TSourceIt sIt = begin(sourceRow, Standard()), sItEnd = end(sourceRow, Standard()); sIt != sItEnd;)
{
TPos gapSize = countGaps(sIt);
insertGaps(it, gapSize);
goFurther(it, gapSize+1);
goFurther(sIt, gapSize+1);
}
}
template <typename TSource0, typename TGapSpec0,
typename TSource1, typename TGapSpec1>
inline void
integrateGaps(Gaps<TSource0, TGapSpec0> & targetRow,
Gaps<TSource1, TGapSpec1> const & sourceRow)
{
typename Position<TSource0>::Type viewPos = beginPosition(source(sourceRow)) // correct for infixes
- beginPosition(source(targetRow)) // ...
+ beginPosition(sourceRow); // respect source clipping
integrateGaps(targetRow, sourceRow, toViewPosition(targetRow, viewPos));
}
// ----------------------------------------------------------------------------
// Function integrateAlign()
// ----------------------------------------------------------------------------
/*!
* @fn integrateAlign
* @headerfile <seqan/align.h>
* @brief Integrates an alignment into another by copying the gaps.
*
* @signature void integrateAlign(align1, align2[, positions]);
*
* @param[in,out] align1 Target Alignment object into which align2 is to be integrated.
* @param[in] align2 Alignment object that is to be integrated into align1.
* @param[in] positions The integration positions in align1 for all rows (view positions), String of positions.
*
* @section Examples
*
* @include demos/dox/align/integrate_align.cpp
*
* The output is as follows:
*
* @include demos/dox/align/integrate_align.cpp.stdout
*/
template <typename TSource1, typename TSpec1, typename TSource2, typename TSpec2, typename TPos>
void integrateAlign(Align<TSource1, TSpec1> & align,
Align<TSource2, TSpec2> const & infixAlign,
String<TPos> const & viewPos)
{
SEQAN_ASSERT_EQ_MSG(length(rows(infixAlign)), length(rows(align)), "Both align objects need same number of rows.");
typedef typename Size<Align<TSource1, TSpec1> >::Type TSize;
//NOTE(h-2): could be parallelized
for (TSize i = 0; i < length(rows(align)); ++i)
integrateGaps(row(align, i), row(infixAlign, i), viewPos[i]);
}
template <typename TSource1, typename TSpec1, typename TSource2, typename TSpec2>
void integrateAlign(Align<TSource1, TSpec1> & align,
Align<TSource2, TSpec2> const & infixAlign)
{
SEQAN_ASSERT_EQ_MSG(length(rows(infixAlign)), length(rows(align)), "Both align objects need same number of rows.");
typedef typename Size<Align<TSource1, TSpec1> >::Type TSize;
//NOTE(h-2): could be parallelized
for (TSize i = 0; i < length(rows(align)); ++i)
integrateGaps(row(align, i), row(infixAlign, i));
}
} // namespace seqan
#endif // #ifndef SEQAN_INCLUDE_SEQAN_ALIGN_ALIGNMENT_OPERATIONS_H_
This diff is collapsed.
This diff is collapsed.