1 // ==========================================================================
2 //                 SeqAn - The Library for Sequence Analysis
3 // ==========================================================================
4 // Copyright (c) 2006-2018, Knut Reinert, FU Berlin
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 //
10 //     * Redistributions of source code must retain the above copyright
11 //       notice, this list of conditions and the following disclaimer.
12 //     * Redistributions in binary form must reproduce the above copyright
13 //       notice, this list of conditions and the following disclaimer in the
14 //       documentation and/or other materials provided with the distribution.
15 //     * Neither the name of Knut Reinert or the FU Berlin nor the names of
16 //       its contributors may be used to endorse or promote products derived
17 //       from this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
23 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
29 // DAMAGE.
30 //
31 // ==========================================================================
32 // Author: Rene Rahn <rene.rahn@fu-berlin.de>
33 // ==========================================================================
34 
35 #ifndef INCLUDE_SEQAN_JOURNALED_SET_JOURNALED_SET_JOIN_H_
36 #define INCLUDE_SEQAN_JOURNALED_SET_JOURNALED_SET_JOIN_H_
37 
38 namespace seqan {
39 
40 // ============================================================================
41 // Forwards
42 // ============================================================================
43 
44 // ============================================================================
45 // Tags, Classes, Enums
46 // ============================================================================
47 
48 // ============================================================================
49 // Metafunctions
50 // ============================================================================
51 
52 // ============================================================================
53 // Functions
54 // ============================================================================
55 
56 /*!
57  * @fn JournaledSet#join
58  * @brief Joins a @link JournaledString @endlink to a @link JournaledSet @endlink by computing and journaling
59  *        differences to the global reference sequence.
60  *
61  * @signature void join(stringSet, pos, joinConfig);
62  *
63  * @param[in,out] stringSet  The JournaledSet to join to.
64  * @param[in]     pos        The position of the JournaledString within the string set.
65  * @param[in]     joinConfig A @link JoinConfig @endlink object that specifies the method and the method's strategy
66  *                           to compute the differences.
67  */
68 
69 // ----------------------------------------------------------------------------
70 // Function join()                                                [GlobalAlign]
71 // ----------------------------------------------------------------------------
72 
73 template <typename TString, typename TPosition, typename TSpec>
74 inline void
join(StringSet<TString,Owner<JournaledSet>> & journalSet,TPosition journalIdx,JoinConfig<GlobalAlign<TSpec>> const & joinConfig)75 join(StringSet<TString, Owner<JournaledSet> > & journalSet,
76      TPosition journalIdx,
77      JoinConfig<GlobalAlign<TSpec> > const & joinConfig)
78 {
79    SEQAN_ASSERT_LT(journalIdx, static_cast<TPosition>(length(journalSet)));
80    if (empty(host(journalSet)))
81    {
82        std::cerr << "No reference set! Join aborted!" << std::endl;
83    }
84    _joinInternal(value(journalSet, journalIdx), journalSet, joinConfig);
85 }
86 
87 // ----------------------------------------------------------------------------
88 // Function join                                                  [GlobalChain]
89 // ----------------------------------------------------------------------------
90 
91 template <typename TString, typename TPosition, typename TSpec>
92 inline void
join(StringSet<TString,Owner<JournaledSet>> & journalSet,TPosition journalIdx,JoinConfig<GlobalChain<TSpec>> const & joinConfig)93 join(StringSet<TString, Owner<JournaledSet> > & journalSet,
94      TPosition journalIdx,
95      JoinConfig<GlobalChain<TSpec> > const & joinConfig)
96 {
97    SEQAN_ASSERT_LT(journalIdx, static_cast<TPosition>(length(journalSet)));
98 
99    if (empty(host(journalSet)))
100    {
101        std::cerr << "No reference set! Join aborted!" << std::endl;
102    }
103    _joinInternal(value(journalSet, journalIdx), journalSet, joinConfig);
104 }
105 
106 
107 // ----------------------------------------------------------------------------
108 // Function join                                                  [Simple Join]
109 // ----------------------------------------------------------------------------
110 
111 template <typename TString, typename TPosition, typename TSpec>
112 inline void
join(StringSet<TString,Owner<JournaledSet>> & journalSet,TPosition journalIdx,TSpec const &)113 join(StringSet<TString, Owner<JournaledSet> > & journalSet,
114      TPosition journalIdx,
115      TSpec const &)
116 {
117    join(journalSet, journalIdx, JoinConfig<GlobalAlign<JournaledManhatten> >());
118 }
119 
120 template <typename TString, typename TPosition>
121 inline void
join(StringSet<TString,Owner<JournaledSet>> & journalSet,TPosition journalIdx)122 join(StringSet<TString, Owner<JournaledSet> > & journalSet,
123      TPosition journalIdx)
124 {
125    join(journalSet, journalIdx, JoinConfig<GlobalAlign<JournaledManhatten> >());
126 }
127 
128 }  // namespace seqan
129 
130 #endif  // #ifndef INCLUDE_SEQAN_JOURNALED_SET_JOURNALED_SET_JOIN_H_
131