1 // ==========================================================================
2 //                 SeqAn - The Library for Sequence Analysis
3 // ==========================================================================
4 // Copyright (c) 2006-2010, 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: David Weese <david.weese@fu-berlin.de>
33 // ==========================================================================
34 
35 #ifndef SEQAN_HEADER_INDEX_BASE_H
36 #define SEQAN_HEADER_INDEX_BASE_H
37 
38 //#define SEQAN_TEST_INDEX
39 
40 namespace SEQAN_NAMESPACE_MAIN
41 {
42 
43 //////////////////////////////////////////////////////////////////////////////
44 // needful forward declarations
45 
46 	// suffix array construction specs
47 	struct Skew3;
48 	struct Skew7;
49 	struct LarssonSadakane;
50 	struct ManberMyers;
51 	struct SAQSort;
52 	struct QGramAlg;
53 
54 	// lcp table construction algorithms
55 	struct Kasai;
56 	struct KasaiOriginal;	// original, but more space-consuming algorithm
57 
58 	// enhanced suffix array construction algorithms
59 	struct Childtab;
60 	struct Bwt;
61 
62 /**
63 .Tag.Index Find Algorithm
64 ..summary:Tag to specify the index search algorithm.
65 ..remarks:These tag can be used to specify the @Function.find@ algorithm
66 for @Class.Index@ based substring searches.
67 ..cat:Index
68 
69 ..tag.EsaFindMlr:Binary search with mlr-heuristic.
70 ...remarks:Exact string matching using a suffix array binary search with the mlr-heuristic.
71 
72 ..tag.EsaFindLcpe:Binary search using lcp values.
73 ...remarks:Exact string matching using a suffix array binary search and a lcp-interval tree.
74 
75 ..tag.FinderSTree:Suffix tree search.
76 ...remarks:Exact string matching using a suffix tree.
77 
78 ..see:Class.Finder
79 ..see:Spec.IndexEsa
80 ..see:Spec.IndexQGram
81 ..include:seqan/index.h
82 */
83 
84 	// finder tags
85     struct FinderMlr_;     // simple Suffix Array finder with mlr-heuristic
86     struct FinderLcpe_;    // Suffix Array finder using an enhanced LCP-Table
87     struct FinderSTree_;    // Suffix Array finder using an enhanced LCP-Table
88 
89     typedef Tag<FinderMlr_> const EsaFindMlr;
90     typedef Tag<FinderLcpe_> const EsaFindLcpe;
91     typedef Tag<FinderSTree_> const FinderSTree;
92 
93 	template <typename TSpec = void>
94 	struct IndexEsa {};
95 
96 
97 //////////////////////////////////////////////////////////////////////////////
98 /**
99 .Metafunction.DefaultIndexSpec:
100 ..cat:Index
101 ..summary:Default @Class.Index@ specialization type.
102 ..signature:DefaultIndexSpec<TText>::Type
103 ..param.TText:The given text type.
104 ..returns:Can be @Spec.IndexEsa@ or $IndexQGram$, etc.
105 ..remarks:Currently @Spec.IndexEsa@ is default if $TText$ is a @Class.String@.
106 ..include:seqan/index.h
107 */
108     template < typename TObject >
109     struct DefaultIndexSpec {
110         typedef IndexEsa<> Type;
111     };
112 
113 //////////////////////////////////////////////////////////////////////////////
114 /**
115 .Metafunction.DefaultIndexStringSpec:
116 ..cat:Index
117 ..summary:Default @Class.String@ specialization type of the @Metafunction.Fibre@ of an @Class.Index@.
118 ..signature:DefaultIndexStringSpec<TIndex>::Type
119 ..param.TIndex:An @Class.Index@ Type.
120 ..returns:If the underlying text is a @Class.String@ or a set of Strings (see @Class.StringSet@) the String's spec. type is returned.
121 ..remarks:Most of the @Class.Index@ fibres are strings. The @Class.String@ specialization type is chosen by this meta-function.
122 ..include:seqan/index.h
123 */
124     template < typename TIndex >
125     struct DefaultIndexStringSpec {
126         typedef Alloc<> Type;
127     };
128 
129     template < typename TValue, typename TSpec >
130     struct DefaultIndexStringSpec< String<TValue, External<TSpec> > > {
131         typedef External<TSpec> Type;
132     };
133 
134 	template < typename TString, typename TSpec >
135 	struct DefaultIndexStringSpec< StringSet<TString, TSpec> >:
136 		DefaultIndexStringSpec<TString> {};
137 
138 
139 //////////////////////////////////////////////////////////////////////////////
140 /**
141 .Class.Index:
142 ..summary:Contains preprocessing data of a fixed text. Allows fast dictionary look-up and advanced computations.
143 ..cat:Index
144 ..signature:Index<TText[, TSpec]>
145 ..param.TText:The text type.
146 ...type:Class.String
147 ...type:Class.StringSet
148 ...metafunction:Metafunction.Host
149 ..param.TSpec:The index type.
150 ...default:The result of @Metafunction.DefaultIndexSpec@
151 ...metafunction:Metafunction.Spec
152 ..remarks:An index contains various arrays or objects, also called fibres (see @Metafunction.Fibre@).
153 ..remarks:These fibres are created on demand depending on the requirements of an algorithm.
154 ..include:seqan/index.h
155 */
156 
157 ///.Function.setHaystack.param.haystack.type:Class.Index
158 
159 	// index as a haystack
160 	template <
161         typename TObject,
162         typename TSpec = typename DefaultIndexSpec<TObject>::Type >
163 	class Index;
164 
165 	template <typename TObject, typename TSpec>
166 	struct Host< Index<TObject, TSpec> > {
167 		typedef TObject Type;
168 	};
169 
170 	template <typename TObject, typename TSpec>
171 	struct Spec< Index<TObject, TSpec> > {
172 		typedef TSpec Type;
173 	};
174 
175 
176 //////////////////////////////////////////////////////////////////////////////
177 /**
178 .Metafunction.Fibre:
179 ..summary:Type of a specific index member (fibre).
180 ..signature:Fibre<TIndex, TSpec>::Type
181 ..cat:Index
182 ..param.TIndex:The index type.
183 ...type:Class.Index
184 ..param.TSpec:Tag to specify the fibre.
185 ..returns:Fibre type.
186 ..remarks:An @Class.Index@ can be seen as a bundle consisting of various fibres. In most cases this type is $String<Size<TIndex>::Type>$.
187 The fibre interface was designed to unify the access to the members of different index data structures.
188 To get a reference or the type of a specific fibre use @Function.getFibre@ or @Metafunction.Fibre@.
189 ..remarks:A @Metafunction.Fibre@ need not to be a real container. It can also be view (see @Tag.ESA Index Fibres.EsaRawText@).
190 ..include:seqan/index.h
191 */
192 	// meta function to get the type of a bundle fibre
193 	template < typename TIndex, typename TSpec >
194 	struct Fibre {
195 		typedef String< typename Size<TIndex>::Type > Type;
196 	};
197 
198 	template < typename TIndex, typename TSpec >
199 	struct Fibre<TIndex const, TSpec> {
200 		typedef typename Fibre<TIndex, TSpec>::Type const Type;
201 	};
202 
203 	struct FibreRecord {
204 		unsigned	id;
205 		void*		ptr;
206 		bool		owner;
207 	};
208 
209 	// less function to search in sorted list for fibre id
210 	struct FibreLess: public ::std::binary_function<FibreRecord, unsigned, bool>
211 	{	// functor for operator>
212 		inline bool operator()(FibreRecord const & _Left, unsigned const Right_) const
213 		{	// apply operator> to operands
214 			return (_Left.id < Right_);
215 		}
216 	};
217 
218 //////////////////////////////////////////////////////////////////////////////
219 /**
220 .Metafunction.DefaultIndexCreator:
221 ..cat:Index
222 ..summary:Default algorithm to create a demanded and not yet existing @Metafunction.Fibre@.
223 ..signature:DefaultIndexCreator<TIndex, TFibre>::Type
224 ..param.TIndex:An @Class.Index@ Type.
225 ..param.TFibre:A tag specifying the fibre (e.g. @Tag.ESA Index Fibres.EsaSA@).
226 ..returns:A tag specifying the default algorithm to create the fibre with.
227 ..include:seqan/index.h
228 */
229     // standard algorithm for indices creation
230     template < typename TIndex, typename TFibre >
231 	struct DefaultIndexCreator {
232 		typedef Default Type;
233 	};
234 
235 
236 //////////////////////////////////////////////////////////////////////////////
237 
238 	template <
239 		typename TSA,
240 		typename TText,
241         typename TAlgSpec >
242     struct SACreatorRandomAccess_
243     {
244         typedef typename AllowsFastRandomAccess<TSA>::Type   TRandomSA;
245         typedef typename AllowsFastRandomAccess<TText>::Type TRandomText;
246         typedef typename And<TRandomText,TRandomSA>::Type Type;
247     };
248 
249 	template <
250         typename TLCP,
251 		typename TText,
252 		typename TSA,
253         typename TAlgSpec >
254     struct LcpCreatorRandomAccess_
255     {
256         typedef typename AllowsFastRandomAccess<TText>::Type TRandomText;
257         typedef typename AllowsFastRandomAccess<TLCP>::Type  TRandomLCP;
258         typedef typename AllowsFastRandomAccess<TSA>::Type   TRandomSA;
259         typedef typename And<TRandomLCP, typename And<TRandomText,TRandomSA>::Type>::Type Type;
260     };
261 
262 
263 //////////////////////////////////////////////////////////////////////////////
264 /**
265 	.Class.Bundle:
266 	..summary:General purpose container of various members.
267 	..signature:Bundle<TValue, TSize>
268 	..param.TValue:The value type, that is the type of the items/characters stored in the string.
269 	...remarks:Use @Metafunction.Value@ to get the value type for a given class.
270 	..param.TSpec:The specializing type.
271 	...default:$Alloc<>$, see @Spec.Alloc String@.
272 */
273 /*
274 	template < typename TSpec = void >
275 	struct Bundle {
276 		typedef ::std::vector<FibreRecord>	TFibreRecords;
277 		TFibreRecords						fibres;
278 	};
279 
280 	template < typename TBundleSpec, typename TFibreSpec >
281 	inline FibreRecord& getRecord(Bundle<TBundleSpec> &bundle, TFibreSpec const) {
282 		unsigned id = (unsigned)ClassIdentifier_<TFibreSpec>::getID();
283 
284 		typename Bundle<TBundleSpec>::TFibreRecords::iterator first = lower_bound(bundle.fibres.begin(), bundle.fibres.end(), id, FibreLess());
285 		if (!first->id != id) {
286 			FibreRecord rec;
287 			rec.id = id;
288 			rec.ptr = NULL;
289 			rec.owner = true;
290 			bundle.fibres.insert(first, rec);
291 		} else
292 			return *first;
293 	}
294 
295 	template < typename TBundleSpec, typename TFibreSpec >
296 	inline typename Fibre<Bundle<TBundleSpec>, TFibreSpec>::Type & getFibre(Bundle<TBundleSpec> &bundle, TFibreSpec const) {
297 		typedef typename Fibre<Bundle<TBundleSpec>, TFibreSpec>::Type Type;
298 		unsigned id = (unsigned)ClassIdentifier_<TFibreSpec>::getID();
299 
300 		FibreRecord &rec = getRecord(bundle, TFibreSpec());
301 		if (!rec.ptr)
302 			rec.ptr = new Type();
303 		return *reinterpret_cast<Type*>(rec.ptr);
304 	}
305 
306 	template < typename TBundleSpec, typename TFibreSpec >
307 	inline typename Fibre<Bundle<TBundleSpec>, TFibreSpec>::Type const & getFibre(Bundle<TBundleSpec> const &bundle, TFibreSpec const) {
308 		typedef typename Fibre<Bundle<TBundleSpec>, TFibreSpec>::Type Type;
309 		unsigned id = (unsigned)ClassIdentifier_<TFibreSpec>::getID();
310 
311 		FibreRecord &rec = getRecord(bundle, TFibreSpec());
312 		return *reinterpret_cast<Type*>(rec.ptr);
313 	}
314 */
315 
316 //////////////////////////////////////////////////////////////////////////////
317 // various fibre specs for enhanced suffix arrays
318 
319 	struct FibreText_;		// Original text. Can be a String or a StringSet
320 	struct FibreRawText_;	// Concatenation of the strings above
321 	struct FibreSA_;		// suffix array (of raw text with virtual $-delimiters) with Pair entries
322 	struct FibreRawSA_;	// suffix array with integer entries
323 	struct FibreSae_;		// suffix array reordered in a b-tree
324 	struct FibreLcp_;		// lcp table of raw text
325 	struct FibreLcpe_;		// lcp interval tree
326 	struct FibreChildtab_;	// childtab (Kurtz et al.) of raw text
327 	struct FibreBwt_;		// burrows wheeler table of raw text
328 
329 	typedef Tag<FibreText_> const		FibreText;
330 	typedef Tag<FibreRawText_> const	FibreRawText;
331 	typedef Tag<FibreSA_> const		FibreSA;
332 	typedef Tag<FibreRawSA_> const		FibreRawSA;
333 	typedef Tag<FibreSae_> const		FibreSae;
334 	typedef Tag<FibreLcp_> const		FibreLcp;
335 	typedef Tag<FibreLcpe_> const		FibreLcpe;
336 	typedef Tag<FibreChildtab_> const	FibreChildtab;
337 	typedef Tag<FibreBwt_> const		FibreBwt;
338 
339 //////////////////////////////////////////////////////////////////////////////
340 
341 /**
342 .Metafunction.SAValue:
343 ..cat:Index
344 ..summary:The default alphabet type of a suffix array, i.e. the type to store a position of a string or string set.
345 ..signature:SAValue<TObject>::Type
346 ..param.TObject:A string, string set, or index type.
347 ...type:Class.String
348 ...type:Class.StringSet
349 ...type:Class.Index
350 ..returns:A type to store a position.
351 ...text:If $TObject$ is a @Class.String@, it is a single integer value. By default this is the @Metafunction.Size@ type of $TObject$.
352 ...text:If $TObject$ is a @Class.StringSet@, it could be a single integer too (called global position, see @Spec.ConcatDirect@) or a @Class.Pair@ (called local position, see @Spec.Owner@).
353 Currently SeqAn defaults to a local position for @Class.StringSet@ classes (index_base.h):
354 ...code:template < typename TString, typename TSpec >
355 struct SAValue< StringSet<TString, TSpec> > {
356 	typedef Pair<
357 		typename Size< StringSet<TString, TSpec> >::Type,
358 		typename SAValue<TString>::Type,
359 		Compressed
360 	> Type;
361 };
362 ..remarks.note:SAValue is the return type of various function, e.g. @Function.position@ for the @Class.Index@ @Class.Finder@ class, @Function.getOccurrence@, @Function.getOccurrences@ etc.
363 You should always use the type of this meta-function to store the return values.
364 If you want to write algorithms for both variants (local and global positions) you
365 should use the functions @Function.posLocalize@, @Function.posGlobalize@, @Function.getSeqNo@ and @Function.getSeqOffset@.
366 ..remarks.note:If $TObject$ is an @Class.Index@, @Metafunction.Position@ returns the same value as $SAValue$. You can change the position type of an index by overloading $SAValue$, not @Metafunction.Position@.
367 ..include:seqan/index.h
368 */
369 	template <typename TObject>
370 	struct SAValue:
371 		Size<TObject> {};
372 
373 	template <typename TObject>
374 	struct SAValue<TObject const>:
375 		SAValue<TObject> {};
376 
377 	// to speed up sequence number computation
378 	// we use a pair of seqNo and localPosition
379 	template < typename TString, typename TSpec >
380 	struct SAValue< StringSet<TString, TSpec> > {
381 		typedef Pair<
382 			typename Size< StringSet<TString, TSpec> >::Type,
383 			typename SAValue<TString>::Type,
384 			Compressed
385 		> Type;
386 	};
387 
388 /*
389 	template < typename TString, typename TSpec >
390 	struct SAValue< StringSet<TString, TSpec> > {
391 		typedef Pair<
392 			typename Size< StringSet<TString, TSpec> >::Type,
393 			typename SAValue<TString>::Type,
394 			BitCompressed<2,30>						// max. 4 sequences
395 		> Type;										// max. 2^30 characters each
396 	};
397 */
398 	template < typename TText, typename TSpec >
399 	struct SAValue< Index<TText, TSpec> >:
400 		SAValue<TText> {};
401 
402 	template < typename TObject, typename TSpec >
403 	struct DefaultIndexStringSpec< Index<TObject, TSpec> >:
404 		DefaultIndexStringSpec<TObject> {};
405 
406 //////////////////////////////////////////////////////////////////////////////
407 // value and size type of an index
408 
409 	template < typename TText, typename TSpec >
410     struct Value< Index<TText, TSpec> > {
411 		typedef typename Value<
412 			typename Fibre< Index<TText, TSpec>, FibreRawText>::Type
413 		>::Type Type;
414     };
415 
416 	template < typename TText, typename TSpec >
417     struct Size< Index<TText, TSpec> > {
418 		typedef typename Size<
419 			typename Fibre< Index<TText, TSpec>, FibreRawText>::Type
420 		>::Type Type;
421     };
422 
423 	template < typename TText, typename TSpec >
424 	struct Position< Index<TText, TSpec> >:
425 		SAValue< Index<TText, TSpec> > {};
426 
427 //////////////////////////////////////////////////////////////////////////////
428 // infix of an index
429 
430 	template < typename TText, typename TSpec >
431     struct Infix< Index<TText, TSpec> >:
432 		public Infix<TText> {};
433 
434 	template < typename TText, typename TSpec >
435     struct Infix< Index<TText, TSpec> const >:
436 		public Infix<TText> {};
437 
438 //////////////////////////////////////////////////////////////////////////////
439 // default table type
440 
441 	template < typename TObject, typename TSpec, typename TFibre >
442 	struct Fibre< Index<TObject, TSpec>, Tag<TFibre> const > {
443 		typedef String<
444 			typename Size< Index<TObject, TSpec> >::Type,
445 			typename DefaultIndexStringSpec< Index<TObject, TSpec> >::Type
446 		> Type;
447 	};
448 
449 //////////////////////////////////////////////////////////////////////////////
450 // original text
451 
452 	template < typename TText, typename TSpec >
453 	struct Fibre< Index<TText, TSpec>, FibreText> {
454 		typedef TText Type;
455 	};
456 
457 //////////////////////////////////////////////////////////////////////////////
458 // concatenated text
459 
460 	template < typename TText, typename TSpec >
461 	struct Fibre< Index<TText, TSpec>, FibreRawText> {
462 		typedef typename Concatenator<TText>::Type Type;
463 	};
464 
465 //////////////////////////////////////////////////////////////////////////////
466 // suffix array type
467 
468 	template < typename TText, typename TSpec >
469 	struct Fibre< Index<TText, TSpec>, FibreSA> {
470 		typedef String<
471 			typename SAValue< Index<TText, TSpec> >::Type,
472 			typename DefaultIndexStringSpec< Index<TText, TSpec> >::Type
473 		> Type;
474 	};
475 
476 //////////////////////////////////////////////////////////////////////////////
477 // globalize functor
478 
479 	template <typename InType, typename TLimitsString, typename Result = typename Value<TLimitsString>::Type>
480 	struct FunctorGlobalize : public ::std::unary_function<InType,Result>
481 	{
482 		TLimitsString const *limits;
483 		FunctorGlobalize() {}
484 		FunctorGlobalize(TLimitsString const &_limits) : limits(&_limits) {}
485 
486 		inline Result operator()(InType const &x) const
487 		{
488 			return posGlobalize(x, *limits);
489 		}
490     };
491 
492 	template <typename InType, typename Result>
493 	struct FunctorGlobalize<InType, Nothing, Result> : public ::std::unary_function<InType,InType>
494 	{
495 		FunctorGlobalize() {}
496 		FunctorGlobalize(Nothing const &) {}
497 
498         inline InType operator()(InType const &x) const
499         {
500 			return x;
501 		}
502     };
503 
504 //////////////////////////////////////////////////////////////////////////////
505 // raw suffix array contains integer offsets relative to raw text
506 /*
507 	template < typename TString, typename TSpec >
508 	struct Fibre< Index<TString, TSpec>, FibreRawSA>:
509 		public Fibre< Index<TString, TSpec> const, FibreSA> {};
510 
511 	template < typename TString, typename TSSetSpec, typename TSpec >
512 	struct Fibre< Index<StringSet<TString, TSSetSpec>, TSpec>, FibreRawSA>
513 	{
514 		typedef Index< StringSet<TString, TSSetSpec>, TSpec> TIndex;
515 		typedef ModifiedString<
516 			typename Fibre<TIndex, FibreSA>::Type,
517 			ModView< FunctorGlobalize<
518 				typename Value< typename Fibre<TIndex, FibreSA>::Type >::Type,
519 				typename StringSetLimits<TString>::Type >
520 			>
521 		> Type;
522 	};
523 */
524 	template < typename TText, typename TSpec >
525 	struct Fibre< Index<TText, TSpec>, FibreRawSA>
526 	{
527 		typedef Index<TText, TSpec> TIndex;
528 		typedef ModifiedString<
529 			typename Fibre<TIndex, FibreSA>::Type,
530 			ModView< FunctorGlobalize<
531 				typename Value< typename Fibre<TIndex, FibreSA>::Type >::Type,
532 				typename StringSetLimits<TText>::Type >
533 			>
534 		> Type;
535 	};
536 
537 //////////////////////////////////////////////////////////////////////////////
538 // default burrows-wheeler table
539 
540 	template < typename TText, typename TSpec >
541 	struct Fibre< Index<TText, TSpec>, FibreBwt> {
542 		typedef String <
543 			typename Value< Index<TText, TSpec> >::Type,
544 			typename DefaultIndexStringSpec< Index<TText, TSpec> >::Type
545 		> Type;
546 	};
547 
548 
549 //////////////////////////////////////////////////////////////////////////////
550 // default fibre creators
551 
552 	template < typename TText, typename TSpec >
553 	struct DefaultIndexCreator<Index<TText, TSpec>, FibreSA> {
554         typedef Skew7 Type;							// standard suffix array creator is skew7
555     };
556 
557 	template < typename TText, typename TSpec >
558 	struct DefaultIndexCreator<Index<TText, TSpec>, FibreLcp> {
559         typedef Kasai Type;
560     };
561 
562 	template < typename TText, typename TSpec >
563 	struct DefaultIndexCreator<Index<TText, TSpec>, FibreBwt> {
564         typedef Bwt Type;
565     };
566 
567 	template < typename TText, typename TSpec >
568 	struct DefaultIndexCreator<Index<TText, TSpec>, FibreChildtab> {
569         typedef Childtab Type;
570     };
571 
572 
573 //////////////////////////////////////////////////////////////////////////////
574 // fibre interface to access the enhanced suffix array tables
575 
576 /**
577 .Function.getFibre:
578 ..summary:Returns a specific @Metafunction.Fibre@ of an @Class.Index@ object.
579 ..cat:Index
580 ..signature:getFibre(index, fibre_tag)
581 ..param.index:The @Class.Index@ object holding the fibre.
582 ...type:Class.Index
583 ..param.fibre_tag:A tag that identifies the @Metafunction.Fibre@ (e.g. @Tag.ESA Index Fibres.EsaSA@).
584 ..returns:A reference to the @Metafunction.Fibre@ object.
585 ..include:seqan/index.h
586 */
587 
588 	template <typename TText, typename TSpec>
589 	inline Holder<TText> & _dataHost(Index<TText, TSpec> &index) {
590 		return index.text;
591 	}
592 	template <typename TText, typename TSpec>
593 	inline Holder<TText> const & _dataHost(Index<TText, TSpec> const &index) {
594 		return index.text;
595 	}
596 
597 //////////////////////////////////////////////////////////////////////////////
598 
599 	template <typename TText, typename TSpec>
600 	inline typename Fibre<Index<TText, TSpec>, FibreText>::Type &
601 	getFibre(Index<TText, TSpec> &index, FibreText) {
602 		return value(index.text);
603 	}
604 	template <typename TText, typename TSpec>
605 	inline typename Fibre<Index<TText, TSpec> const, FibreText>::Type &
606 	getFibre(Index<TText, TSpec> const &index, FibreText) {
607 		return value(index.text);
608 	}
609 
610 //////////////////////////////////////////////////////////////////////////////
611 
612 	template <typename TText, typename TSpec>
613 	inline typename Fibre<Index<TText, TSpec>, FibreRawText>::Type &
614 	getFibre(Index<TText, TSpec> &index, FibreRawText) {
615 		return concat(value(index.text));
616 	}
617 	template <typename TText, typename TSpec>
618 	inline typename Fibre<Index<TText, TSpec> const, FibreRawText>::Type &
619 	getFibre(Index<TText, TSpec> const &index, FibreRawText) {
620 		return concat(value(index.text));
621 	}
622 
623 //////////////////////////////////////////////////////////////////////////////
624 
625 	template <typename TText, typename TSpec>
626 	inline typename Fibre<Index<TText, TSpec>, FibreSA>::Type &
627 	getFibre(Index<TText, TSpec> &index, FibreSA) {
628 		return index.sa;
629 	}
630 	template <typename TText, typename TSpec>
631 	inline typename Fibre<Index<TText, TSpec> const, FibreSA>::Type &
632 	getFibre(Index<TText, TSpec> const &index, FibreSA) {
633 		return index.sa;
634 	}
635 
636 //////////////////////////////////////////////////////////////////////////////
637 /*
638 	template <typename TText, typename TSpec>
639 	inline typename Fibre<Index<TText, TSpec>, FibreRawSA>::Type const &
640 	getFibre(Index<TText, TSpec> &index, FibreRawSA) {
641 		return indexSA(index);
642 	}
643 
644 	template <typename TString, typename TSSetSpec, typename TSpec>
645 	inline typename Fibre<Index<StringSet<TString, TSSetSpec>, TSpec>, FibreRawSA>::Type
646 	getFibre(Index<StringSet<TString, TSSetSpec>, TSpec> &index, FibreRawSA)
647 	{
648 		typedef Index< StringSet<TString, TSSetSpec>, TSpec> TIndex;
649 
650 		typedef FunctorGlobalize<
651 			typename Value< typename Fibre<TIndex, FibreSA>::Type >::Type,
652 			typename StringSetLimits<StringSet<TString, TSSetSpec> >::Type
653 		> TFunctor;
654 
655 		typedef ModifiedString<
656 			typename Fibre<Index<StringSet<TString, TSSetSpec>, TSpec>, FibreSA>::Type,
657 			ModView< TFunctor >
658 		> ModString;
659 
660 		return ModString(indexSA(index), TFunctor(stringSetLimits(indexText(index))));
661 	}
662 */
663 
664 	template <typename TText, typename TSpec>
665 	inline typename Fibre<Index<TText, TSpec>, FibreRawSA>::Type
666 	getFibre(Index<TText, TSpec> &index, FibreRawSA)
667 	{
668 		typedef Index<TText, TSpec> TIndex;
669 
670 		typedef FunctorGlobalize<
671 			typename Value< typename Fibre<TIndex, FibreSA>::Type >::Type,
672 			typename StringSetLimits<TText>::Type
673 		> TFunctor;
674 
675 		typedef ModifiedString<
676 			typename Fibre<Index<TText, TSpec>, FibreSA>::Type,
677 			ModView< TFunctor >
678 		> ModString;
679 
680 		return ModString(indexSA(index), TFunctor(stringSetLimits(indexText(index))));
681 	}
682 //////////////////////////////////////////////////////////////////////////////
683 
684 	template <typename TText, typename TSpec>
685 	inline typename Fibre<Index<TText, TSpec>, FibreLcp>::Type &
686 	getFibre(Index<TText, TSpec> &index, FibreLcp) {
687 		return index.lcp;
688 	}
689 	template <typename TText, typename TSpec>
690 	inline typename Fibre<Index<TText, TSpec> const, FibreLcp>::Type &
691 	getFibre(Index<TText, TSpec> const &index, FibreLcp) {
692 		return index.lcp;
693 	}
694 
695 //////////////////////////////////////////////////////////////////////////////
696 
697 	template <typename TText, typename TSpec>
698 	inline typename Fibre<Index<TText, TSpec>, FibreLcpe>::Type &
699 	getFibre(Index<TText, TSpec> &index, FibreLcpe) {
700 		return index.lcpe;
701 	}
702 	template <typename TText, typename TSpec>
703 	inline typename Fibre<Index<TText, TSpec> const, FibreLcpe>::Type &
704 	getFibre(Index<TText, TSpec> const &index, FibreLcpe) {
705 		return index.lcpe;
706 	}
707 
708 //////////////////////////////////////////////////////////////////////////////
709 
710 	template <typename TText, typename TSpec>
711 	inline typename Fibre<Index<TText, TSpec>, FibreChildtab>::Type &
712 	getFibre(Index<TText, TSpec> &index, FibreChildtab) {
713 		return index.childtab;
714 	}
715 	template <typename TText, typename TSpec>
716 	inline typename Fibre<Index<TText, TSpec> const, FibreChildtab>::Type &
717 	getFibre(Index<TText, TSpec> const &index, FibreChildtab) {
718 		return index.childtab;
719 	}
720 
721 //////////////////////////////////////////////////////////////////////////////
722 
723 	template <typename TText, typename TSpec>
724 	inline typename Fibre<Index<TText, TSpec>, FibreBwt>::Type &
725 	getFibre(Index<TText, TSpec> &index, FibreBwt) {
726 		return index.bwt;
727 	}
728 	template <typename TText, typename TSpec>
729 	inline typename Fibre<Index<TText, TSpec> const, FibreBwt>::Type &
730 	getFibre(Index<TText, TSpec> const &index, FibreBwt) {
731 		return index.bwt;
732 	}
733 
734 //////////////////////////////////////////////////////////////////////////////
735 ///.Function.length.param.object.type:Class.Index
736 
737 	template <typename TText, typename TSpec>
738 	inline typename Size<Index<TText, TSpec> >::Type
739 	length(Index<TText, TSpec> const &index) {
740 		return length(indexRawText(index));
741 	}
742 
743 //////////////////////////////////////////////////////////////////////////////
744 
745 	template <typename TText, typename TSpec>
746 	inline typename Size<TText>::Type
747 	countSequences(Index<TText, TSpec> const &index) {
748 		return countSequences(indexText(index));
749 	}
750 
751 //////////////////////////////////////////////////////////////////////////////
752 
753 	template <typename TText, typename TSpec>
754 	struct GetSequenceByNo< Index<TText, TSpec> >
755 	{
756 		typedef typename GetSequenceByNo<TText>::Type Type;
757 	};
758 
759 	template <typename TText, typename TSpec>
760 	struct GetSequenceByNo< Index<TText, TSpec> const>
761 	{
762 		typedef typename GetSequenceByNo<TText const>::Type Type;
763 	};
764 
765 //////////////////////////////////////////////////////////////////////////////
766 
767 	template <typename TSeqNo, typename TText, typename TSpec>
768 	inline typename GetSequenceByNo< Index<TText, TSpec> >::Type
769 	getSequenceByNo(TSeqNo seqNo, Index<TText, TSpec> &index)
770 	{
771 		return getSequenceByNo(seqNo, indexText(index));
772 	}
773 
774 	template <typename TSeqNo, typename TText, typename TSpec>
775 	inline typename GetSequenceByNo< Index<TText, TSpec> const>::Type
776 	getSequenceByNo(TSeqNo seqNo, Index<TText, TSpec> const &index)
777 	{
778 		return getSequenceByNo(seqNo, indexText(index));
779 	}
780 
781 //////////////////////////////////////////////////////////////////////////////
782 
783 	template <typename TSeqNo, typename TText, typename TSpec>
784 	inline typename Size<Index<TText, TSpec> >::Type
785 	sequenceLength(TSeqNo seqNo, Index<TText, TSpec> const &index) {
786 		return sequenceLength(seqNo, indexText(index));
787 	}
788 
789 //////////////////////////////////////////////////////////////////////////////
790 
791 	template <typename TPos, typename TText, typename TSpec>
792 	inline typename Size<Index<TText, TSpec> >::Type
793 	suffixLength(TPos pos, Index<TText, TSpec> const &index) {
794 		return sequenceLength(getSeqNo(pos, stringSetLimits(index)), index) - getSeqOffset(pos, stringSetLimits(index));
795 	}
796 
797 
798 //////////////////////////////////////////////////////////////////////////////
799 /**
800 .Function.textAt:
801 ..summary:Shortcut for $value(indexText(..), ..)$.
802 ..cat:Index
803 ..signature:textAt(position, index)
804 ..param.position:A position in the array on which the value should be accessed.
805 ..param.index:The @Class.Index@ object holding the fibre.
806 ...type:Spec.IndexEsa
807 ..returns:A reference or proxy to the value.
808 ..include:seqan/index.h
809 */
810 
811 	template <typename TPos, typename TIndex>
812 	inline typename Reference<typename Fibre<TIndex, FibreRawText>::Type>::Type
813 	textAt(TPos i, TIndex &index) {
814 		return value(getFibre(index, FibreRawText()), i);
815 	}
816 	template <typename TPos, typename TString, typename TSSetSpec, typename TSpec>
817 	inline typename Reference<typename Fibre< Index< StringSet<TString, TSSetSpec>, TSpec>, FibreRawText>::Type>::Type
818 	textAt(TPos i, Index< StringSet<TString, TSSetSpec>, TSpec> &index) {
819 		return value(getFibre(index, FibreRawText()), posGlobalize(i, stringSetLimits(index)));
820 	}
821 	template <typename TPos, typename TString, typename TSpec>
822 	inline typename Reference<typename Fibre< Index< StringSet<TString, Owner<Default> >, TSpec>, FibreRawText>::Type>::Type
823 	textAt(TPos i, Index< StringSet<TString, Owner<Default> >, TSpec> &index) {
824 		Pair <
825 			typename Size< StringSet<TString, Owner<Default> > >::Type,
826 			typename Size< TString >::Type > locPos;
827 		posLocalize(locPos, i, stringSetLimits(index));
828 		return value(value(getFibre(index, FibreText()), getValueI1(locPos)), getValueI2(locPos));
829 	}
830 
831 //////////////////////////////////////////////////////////////////////////////
832 // infix
833 
834 	template <typename TText, typename TSpec, typename TPosBegin, typename TPosEnd>
835 	inline typename Infix<TText>::Type
836 	infix(Index<TText, TSpec> &index, TPosBegin pos_begin, TPosEnd pos_end)
837 	{
838 		return infix(indexText(index), pos_begin, pos_end);
839 	}
840 
841 	template <typename TText, typename TSpec, typename TPosBegin, typename TPosEnd>
842 	inline typename Infix<TText>::Type
843 	infix(Index<TText, TSpec> const &index, TPosBegin pos_begin, TPosEnd pos_end)
844 	{
845 		return infix(indexText(index), pos_begin, pos_end);
846 	}
847 
848 //////////////////////////////////////////////////////////////////////////////
849 /**
850 .Function.rawtextAt:
851 ..summary:Shortcut for $value(indexRawText(..), ..)$.
852 ..cat:Index
853 ..signature:rawtextAt(position, index)
854 ..param.position:A position in the array on which the value should be accessed.
855 ..param.index:The @Class.Index@ object holding the fibre.
856 ...type:Spec.IndexEsa
857 ..returns:A reference or proxy to the value.
858 ..include:seqan/index.h
859 */
860 
861 	template <typename TPos, typename TIndex>
862 	inline typename Reference<typename Fibre<TIndex, FibreRawText>::Type>::Type rawtextAt(TPos i, TIndex &index) {
863 		return value(getFibre(index, FibreRawText()), i);
864 	}
865 	template <typename TPos, typename TIndex>
866 	inline typename Reference<typename Fibre<TIndex const, FibreRawText>::Type>::Type rawtextAt(TPos i, TIndex const &index) {
867 		return value(getFibre(index, FibreRawText()), i);
868 	}
869 
870 //////////////////////////////////////////////////////////////////////////////
871 /**
872 .Function.saAt:
873 ..summary:Shortcut for $value(indexSA(..), ..)$.
874 ..cat:Index
875 ..signature:saAt(position, index)
876 ..param.position:A position in the array on which the value should be accessed.
877 ..param.index:The @Class.Index@ object holding the fibre.
878 ...type:Spec.IndexEsa
879 ..returns:A reference or proxy to the value.
880 ..include:seqan/index.h
881 */
882 
883 	template <typename TPos, typename TIndex>
884 	inline typename Reference<typename Fibre<TIndex, FibreSA>::Type>::Type saAt(TPos i, TIndex &index) {
885 		return value(getFibre(index, FibreSA()), i);
886 	}
887 	template <typename TPos, typename TIndex>
888 	inline typename Reference<typename Fibre<TIndex const, FibreSA>::Type>::Type saAt(TPos i, TIndex const &index) {
889 		return value(getFibre(index, FibreSA()), i);
890 	}
891 
892 //////////////////////////////////////////////////////////////////////////////
893 /**
894 .Function.rawsaAt:
895 ..summary:Shortcut for $value(indexRawSA(..), ..)$.
896 ..cat:Index
897 ..signature:saAt(position, index)
898 ..param.position:A position in the array on which the value should be accessed.
899 ..param.index:The @Class.Index@ object holding the fibre.
900 ...type:Spec.IndexEsa
901 ..returns:A reference or proxy to the value.
902 ..include:seqan/index.h
903 */
904 
905 	template <typename TPos, typename TIndex>
906 	inline typename Value<typename Fibre<TIndex const, FibreRawSA>::Type>::Type rawsaAt(TPos i, TIndex const &index) {
907 		return posGlobalize(saAt(i, index), stringSetLimits(indexText(index)));
908 	}
909 
910 
911 //////////////////////////////////////////////////////////////////////////////
912 /**
913 .Function.lcpAt:
914 ..summary:Shortcut for $value(indexLcp(..), ..)$.
915 ..cat:Index
916 ..signature:lcpAt(position, index)
917 ..param.position:A position in the array on which the value should be accessed.
918 ..param.index:The @Class.Index@ object holding the fibre.
919 ...type:Spec.IndexEsa
920 ..returns:A reference or proxy to the value.
921 ..include:seqan/index.h
922 */
923 
924 	template <typename TPos, typename TIndex>
925 	inline typename Reference<typename Fibre<TIndex, FibreLcp>::Type>::Type lcpAt(TPos i, TIndex &index) {
926 		return value(getFibre(index, FibreLcp()), i);
927 	}
928 	template <typename TPos, typename TIndex>
929 	inline typename Reference<typename Fibre<TIndex const, FibreLcp>::Type>::Type lcpAt(TPos i, TIndex const &index) {
930 		return value(getFibre(index, FibreLcp()), i);
931 	}
932 
933 //////////////////////////////////////////////////////////////////////////////
934 /**
935 .Function.lcpeAt:
936 ..summary:Shortcut for $value(indexLcpe(..), ..)$.
937 ..cat:Index
938 ..signature:lcpeAt(position, index)
939 ..param.position:A position in the array on which the value should be accessed.
940 ..param.index:The @Class.Index@ object holding the fibre.
941 ...type:Spec.IndexEsa
942 ..returns:A reference or proxy to the value.
943 ..include:seqan/index.h
944 */
945 
946 	template <typename TPos, typename TIndex>
947 	inline typename Reference<typename Fibre<TIndex, FibreLcpe>::Type>::Type lcpeAt(TPos i, TIndex &index) {
948 		return value(getFibre(index, FibreLcpe()), i);
949 	}
950 	template <typename TPos, typename TIndex>
951 	inline typename Reference<typename Fibre<TIndex const, FibreLcpe>::Type>::Type lcpeAt(TPos i, TIndex const &index) {
952 		return value(getFibre(index, FibreLcpe()), i);
953 	}
954 
955 //////////////////////////////////////////////////////////////////////////////
956 /**
957 .Function.childAt:
958 ..summary:Shortcut for $value(indexChildtab(..), ..)$.
959 ..cat:Index
960 ..signature:childAt(position, index)
961 ..param.position:A position in the array on which the value should be accessed.
962 ..param.index:The @Class.Index@ object holding the fibre.
963 ...type:Spec.IndexEsa
964 ..returns:A reference or proxy to the value.
965 ..include:seqan/index.h
966 */
967 
968 	template <typename TPos, typename TIndex>
969 	inline typename Reference<typename Fibre<TIndex, FibreChildtab>::Type>::Type childAt(TPos i, TIndex &index) {
970 		return value(getFibre(index, FibreChildtab()), i);
971 	}
972 	template <typename TPos, typename TIndex>
973 	inline typename Reference<typename Fibre<TIndex const, FibreChildtab>::Type>::Type childAt(TPos i, TIndex const &index) {
974 		return value(getFibre(index, FibreChildtab()), i);
975 	}
976 
977 //////////////////////////////////////////////////////////////////////////////
978 /**
979 .Function.bwtAt:
980 ..summary:Shortcut for $value(indexBwt(..), ..)$.
981 ..cat:Index
982 ..signature:bwtAt(position, index)
983 ..param.position:A position in the array on which the value should be accessed.
984 ..param.index:The @Class.Index@ object holding the fibre.
985 ...type:Spec.IndexEsa
986 ..returns:A reference or proxy to the value.
987 ..include:seqan/index.h
988 */
989 
990 	template <typename TPos, typename TIndex>
991 	inline typename Reference<typename Fibre<TIndex, FibreBwt>::Type>::Type bwtAt(TPos i, TIndex &index) {
992 		return value(getFibre(index, FibreBwt()), i);
993 	}
994 	template <typename TPos, typename TIndex>
995 	inline typename Reference<typename Fibre<TIndex const, FibreBwt>::Type>::Type bwtAt(TPos i, TIndex const &index) {
996 		return value(getFibre(index, FibreBwt()), i);
997 	}
998 
999 //////////////////////////////////////////////////////////////////////////////
1000 // interface for infinity/invalid values
1001 
1002 	template <typename TValue>
1003 	inline void _setSizeInval(TValue &v) {
1004 		v = MaxValue<TValue>::VALUE;
1005 	}
1006 
1007 	template <typename TValue>
1008 	inline bool _isSizeInval(TValue const &v) {
1009 		return v == MaxValue<TValue>::VALUE;
1010 	}
1011 
1012 //////////////////////////////////////////////////////////////////////////////
1013 /**
1014 .Function.indexText:
1015 ..summary:Shortcut for $getFibre(.., EsaText)$.
1016 ..cat:Index
1017 ..signature:indexText(index)
1018 ..param.index:The @Class.Index@ object holding the fibre.
1019 ...type:Spec.IndexEsa
1020 ..returns:A reference to the @Tag.ESA Index Fibres.EsaText@ fibre (original text).
1021 ..include:seqan/index.h
1022 */
1023 
1024 	template <typename TText, typename TSpec>
1025 	inline typename Fibre<Index<TText, TSpec>, FibreText>::Type & indexText(Index<TText, TSpec> &index) { return getFibre(index, FibreText()); }
1026 	template <typename TText, typename TSpec>
1027 	inline typename Fibre<Index<TText, TSpec> const, FibreText>::Type & indexText(Index<TText, TSpec> const &index) { return getFibre(index, FibreText()); }
1028 
1029 //////////////////////////////////////////////////////////////////////////////
1030 
1031 	template <typename TText, typename TSpec>
1032 	inline typename StringSetLimits<TText const>::Type
1033 	stringSetLimits(Index<TText, TSpec> &) {
1034 		return Nothing();
1035 	}
1036 
1037 	template <typename TText, typename TSpec>
1038 	inline typename StringSetLimits<TText const>::Type
1039 	stringSetLimits(Index<TText, TSpec> const &) {
1040 		return Nothing();
1041 	}
1042 
1043 	template <typename TString, typename TSSetSpec, typename TSpec>
1044 	inline typename StringSetLimits< StringSet<TString, TSSetSpec> const >::Type &
1045 	stringSetLimits(Index<StringSet<TString, TSSetSpec>, TSpec> &index) {
1046 		return stringSetLimits(indexText(index));
1047 	}
1048 
1049 	template <typename TString, typename TSSetSpec, typename TSpec>
1050 	inline typename StringSetLimits< StringSet<TString, TSSetSpec> const >::Type &
1051 	stringSetLimits(Index<StringSet<TString, TSSetSpec>, TSpec> const &index) {
1052 		return stringSetLimits(indexText(index));
1053 	}
1054 
1055 //////////////////////////////////////////////////////////////////////////////
1056 /**
1057 .Function.indexRawText:
1058 ..summary:Shortcut for $getFibre(.., EsaRawText)$.
1059 ..cat:Index
1060 ..signature:indexRawText(index)
1061 ..param.index:The @Class.Index@ object holding the fibre.
1062 ...type:Spec.IndexEsa
1063 ..returns:A reference to the @Tag.ESA Index Fibres.EsaRawText@ fibre (concatenated input text).
1064 ..include:seqan/index.h
1065 */
1066 
1067 	template <typename TText, typename TSpec>
1068 	inline typename Fibre<Index<TText, TSpec>, FibreRawText>::Type & indexRawText(Index<TText, TSpec> &index) { return getFibre(index, FibreRawText()); }
1069 	template <typename TText, typename TSpec>
1070 	inline typename Fibre<Index<TText, TSpec> const, FibreRawText>::Type & indexRawText(Index<TText, TSpec> const &index) { return getFibre(index, FibreRawText()); }
1071 
1072 //////////////////////////////////////////////////////////////////////////////
1073 /**
1074 .Function.indexSA:
1075 ..summary:Shortcut for $getFibre(.., EsaSA)$.
1076 ..cat:Index
1077 ..signature:indexSA(index)
1078 ..param.index:The @Class.Index@ object holding the fibre.
1079 ...type:Spec.IndexEsa
1080 ..returns:A reference to the @Tag.ESA Index Fibres.EsaSA@ fibre (suffix array).
1081 ..include:seqan/index.h
1082 */
1083 
1084 	template <typename TText, typename TSpec>
1085 	inline typename Fibre<Index<TText, TSpec>, FibreSA>::Type & indexSA(Index<TText, TSpec> &index) { return getFibre(index, FibreSA()); }
1086 	template <typename TText, typename TSpec>
1087 	inline typename Fibre<Index<TText, TSpec> const, FibreSA>::Type & indexSA(Index<TText, TSpec> const &index) { return getFibre(index, FibreSA()); }
1088 
1089 //////////////////////////////////////////////////////////////////////////////
1090 /**
1091 .Function.indexRawSA:
1092 ..summary:Shortcut for $getFibre(.., EsaRawSA)$.
1093 ..cat:Index
1094 ..signature:indexRawSA(index)
1095 ..param.index:The @Class.Index@ object holding the fibre.
1096 ...type:Spec.IndexEsa
1097 ..returns:A reference to the @Tag.ESA Index Fibres.EsaRawSA@ fibre (suffix array).
1098 ..include:seqan/index.h
1099 */
1100 /*
1101 	template <typename TText, typename TSpec>
1102 	inline typename Fibre<Index<TText, TSpec>, FibreRawSA>::Type const & indexRawSA(Index<TText, TSpec> &index) { return getFibre(index, FibreRawSA()); }
1103 	template <typename TText, typename TSpec>
1104 	inline typename Fibre<Index<TText, TSpec> const, FibreRawSA>::Type const & indexRawSA(Index<TText, TSpec> const &index) { return getFibre(index, FibreRawSA()); }
1105 */
1106 	template <typename TText, typename TSpec>
1107 	inline typename Fibre<Index<TText, TSpec>, FibreRawSA>::Type indexRawSA(Index<TText, TSpec> &index) { return getFibre(index, FibreRawSA()); }
1108 	template <typename TText, typename TSpec>
1109 	inline typename Fibre<Index<TText, TSpec> const, FibreRawSA>::Type indexRawSA(Index<TText, TSpec> const &index) { return getFibre(index, FibreRawSA()); }
1110 
1111 //////////////////////////////////////////////////////////////////////////////
1112 /**
1113 .Function.indexLcp:
1114 ..summary:Shortcut for $getFibre(.., EsaLcp)$.
1115 ..cat:Index
1116 ..signature:indexLcp(index)
1117 ..param.index:The @Class.Index@ object holding the fibre.
1118 ...type:Spec.IndexEsa
1119 ..returns:A reference to the @Tag.ESA Index Fibres.EsaLcp@ fibre (lcp table).
1120 ..include:seqan/index.h
1121 */
1122 
1123 	template <typename TText, typename TSpec>
1124 	inline typename Fibre<Index<TText, TSpec>, FibreLcp>::Type & indexLcp(Index<TText, TSpec> &index) { return getFibre(index, FibreLcp()); }
1125 	template <typename TText, typename TSpec>
1126 	inline typename Fibre<Index<TText, TSpec> const, FibreLcp>::Type & indexLcp(Index<TText, TSpec> const &index) { return getFibre(index, FibreLcp()); }
1127 
1128 //////////////////////////////////////////////////////////////////////////////
1129 /**
1130 .Function.indexLcpe:
1131 ..summary:Shortcut for $getFibre(.., EsaLcpe)$.
1132 ..cat:Index
1133 ..signature:indexLcpe(index)
1134 ..param.index:The @Class.Index@ object holding the fibre.
1135 ...type:Spec.IndexEsa
1136 ..returns:A reference to the @Tag.ESA Index Fibres.EsaLcpe@ fibre (enhanced lcp table).
1137 ..include:seqan/index.h
1138 */
1139 
1140 	template <typename TText, typename TSpec>
1141 	inline typename Fibre<Index<TText, TSpec>, FibreLcpe>::Type & indexLcpe(Index<TText, TSpec> &index) { return getFibre(index, FibreLcpe()); }
1142 	template <typename TText, typename TSpec>
1143 	inline typename Fibre<Index<TText, TSpec> const, FibreLcpe>::Type & indexLcpe(Index<TText, TSpec> const &index) { return getFibre(index, FibreLcpe()); }
1144 
1145 //////////////////////////////////////////////////////////////////////////////
1146 /**
1147 .Function.indexBwt:
1148 ..summary:Shortcut for $getFibre(.., EsaBwt)$.
1149 ..cat:Index
1150 ..signature:indexBwt(index)
1151 ..param.index:The @Class.Index@ object holding the fibre.
1152 ...type:Spec.IndexEsa
1153 ..returns:A reference to the @Tag.ESA Index Fibres.EsaBwt@ fibre (Burrows-Wheeler table).
1154 ..include:seqan/index.h
1155 */
1156 
1157 	template <typename TText, typename TSpec>
1158 	inline typename Fibre<Index<TText, TSpec>, FibreBwt>::Type & indexBwt(Index<TText, TSpec> &index) { return getFibre(index, FibreBwt()); }
1159 	template <typename TText, typename TSpec>
1160 	inline typename Fibre<Index<TText, TSpec> const, FibreBwt>::Type & indexBwt(Index<TText, TSpec> const &index) { return getFibre(index, FibreBwt()); }
1161 
1162 //////////////////////////////////////////////////////////////////////////////
1163 /**
1164 .Function.indexChildtab:
1165 ..summary:Shortcut for $getFibre(.., EsaChildtab)$.
1166 ..cat:Index
1167 ..signature:indexChildtab(index)
1168 ..param.index:The @Class.Index@ object holding the fibre.
1169 ...type:Spec.IndexEsa
1170 ..returns:A reference to the @Tag.ESA Index Fibres.EsaChildtab@ fibre (child table).
1171 ..include:seqan/index.h
1172 */
1173 
1174 	template <typename TText, typename TSpec>
1175 	inline typename Fibre<Index<TText, TSpec>, FibreChildtab>::Type & indexChildtab(Index<TText, TSpec> &index) { return getFibre(index, FibreChildtab()); }
1176 	template <typename TText, typename TSpec>
1177 	inline typename Fibre<Index<TText, TSpec> const, FibreChildtab>::Type & indexChildtab(Index<TText, TSpec> const &index) { return getFibre(index, FibreChildtab()); }
1178 
1179 }
1180 
1181 #endif
1182