Imported Upstream version 0.12.7
[bowtie.git] / SeqAn-1.1 / seqan / sequence / segment_infix.h
1  /*==========================================================================
2                 SeqAn - The Library for Sequence Analysis
3                           http://www.seqan.de 
4  ============================================================================
5   Copyright (C) 2007
6
7   This library is free software; you can redistribute it and/or
8   modify it under the terms of the GNU Lesser General Public
9   License as published by the Free Software Foundation; either
10   version 3 of the License, or (at your option) any later version.
11
12   This library is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   Lesser General Public License for more details.
16
17  ============================================================================
18   $Id: segment_infix.h,v 1.1 2008/08/25 16:20:04 langmead Exp $
19  ==========================================================================*/
20
21 #ifndef SEQAN_HEADER_SEGMENT_INFIX_H
22 #define SEQAN_HEADER_SEGMENT_INFIX_H
23
24
25 namespace SEQAN_NAMESPACE_MAIN
26 {
27
28 //////////////////////////////////////////////////////////////////////////////
29 // InfixSegment
30 //////////////////////////////////////////////////////////////////////////////
31
32
33 /**
34 .Spec.InfixSegment:
35 ..cat:Segments
36 ..summary:An arbitrary segment.
37 ..general:Class.Segment
38 ..signature:Segment<THost, InfixSegment>
39 ..param.THost:Type of the whole sequence.
40 ...text:Instances of $Segment<THost, InfixSegment>$ are infixes of $THost$ objects.
41 ...remarks:Use @Metafunction.Host@ to get the host type for a given class.
42 ..remarks.note:Since the appropriate segment type depends on the host sequence type, 
43         it is recommended to use the metafunction @Metafunction.Infix@ instead of explicitely 
44         choose a specialization of @Class.Segment@.
45 ..see:Metafunction.Infix
46 */
47
48 template <typename THost_>
49 class Segment<THost_, InfixSegment>
50 {
51 protected:
52         typedef typename Host<Segment>::Type THost;
53
54         typename _Pointer<THost>::Type data_host;
55         typename Position<THost>::Type data_begin_position;
56         typename Position<THost>::Type data_end_position;
57
58
59 //____________________________________________________________________________
60
61 public:
62
63 /**
64 .Memfunc.InfixSegment#Segment:
65 ..class:Spec.InfixSegment
66 ..summary:Constructor
67 ..signature:Segment<THost, InfixSegment> ()
68 ..signature:Segment<THost, InfixSegment> (infix)
69 ..signature:Segment<THost, InfixSegment> (host [, begin, end])
70 ..param.infix:Other infix object. (copy constructor)
71 ..param.host:The whole sequence.
72 ..param.begin:Position/iterator in $host$ of the first item in segment.
73 ...type:Metafunction.Position.$Position<THost>::Type$
74 ...type:Metafunction.Iterator.$Iterator<THost>::Type$
75 ..param.end:Position/iterator behind the end of the segment.
76 ...type:Metafunction.Position.$Position<THost>::Type$
77 ...type:Metafunction.Iterator.$Iterator<THost>::Type$
78 ..remarks:
79 ...text:A Segment object cannot work without a host. If the object is default constructed,
80 the host must be set by @Function.setHost@ before the segment can be used.
81 ...text:If a segment object is constructed by the copy constructor, the
82 members of the new constructed object are set to the same values as the members in the
83 source object; the host object is not modified.
84 Note that this is a special case, since all other copy operations result in changes 
85 of the host object.
86 ...text:$begin$ and $end$ must be valid positions/iterators in $host$.
87 If $begin$ und $end$ are omitted, the infix segment corresponding to
88 the first character of $host$ is constructed.
89 This is the same segment that is returned by @Function.goBegin@.
90 */
91         Segment():
92                 data_begin_position(0),
93                 data_end_position(0)
94         {
95 SEQAN_CHECKPOINT
96         }
97
98         Segment(typename _Parameter<THost>::Type _host):
99                 data_host(_toPointer(_host)),
100                 data_begin_position(0),
101                 data_end_position(1)
102         {
103 SEQAN_CHECKPOINT
104         }
105
106         Segment(typename _Parameter<THost>::Type _host, typename Position<THost>::Type _begin_index, typename Position<THost>::Type _end_index):
107                 data_host(_toPointer(_host)),
108                 data_begin_position(_begin_index),
109                 data_end_position(_end_index)
110         {
111 SEQAN_CHECKPOINT
112         }
113 /*
114         Segment(typename _Parameter<THost>::Type _host, typename Iterator<THost, Rooted>::Type _begin, typename Iterator<THost, Rooted>::Type _end):
115                 data_host(_toPointer(_host)),
116                 data_begin_position(position(_begin)),
117                 data_end_position(position(_end))
118         {
119 SEQAN_CHECKPOINT
120         }
121 */
122         Segment(typename _Parameter<THost>::Type _host, typename Iterator<THost, Standard>::Type _begin, typename Iterator<THost, Standard>::Type _end):
123                 data_host(_toPointer(_host)),
124                 data_begin_position(position(_begin, _host)),
125                 data_end_position(position(_end, _host))
126         {
127 SEQAN_CHECKPOINT
128         }
129         template <typename THost2, typename TSpec2>
130         Segment(Segment<THost2, TSpec2> const & _other):
131                 data_host(_toPointer(host(_other))),
132                 data_begin_position(beginPosition(_other)),
133                 data_end_position(endPosition(_other))
134         {
135 SEQAN_CHECKPOINT
136         }
137
138         ~ Segment() 
139         {
140 SEQAN_CHECKPOINT
141         }
142
143         template <typename TSource>
144         inline Segment & 
145         operator = (TSource const & source)
146         {
147                 assign(*this, source);
148                 return *this;
149         }
150         inline Segment & 
151         operator = (Segment const & source)
152         {
153                 assign(*this, source);
154                 return *this;
155         }
156 //____________________________________________________________________________
157
158 public:
159
160 ///Function.host.param.object.type:Class.Segment
161
162         friend inline typename _Parameter<THost>::Type 
163         host(Segment & me)
164         {
165 SEQAN_CHECKPOINT
166                 return _toParameter<THost>(me.data_host);
167         }
168
169         friend inline typename _Parameter<THost>::Type 
170         host(Segment const & me)
171         {
172 SEQAN_CHECKPOINT
173                 return _toParameter<THost>(me.data_host);
174         }
175
176 //____________________________________________________________________________
177
178 /**
179 .Function.setHost:
180 ..summary:Sets the host of an object.
181 ..cat:Dependent Objects
182 ..signature:setHost(object, host)
183 ..param.object:The object that will get a new host.
184 ...type:Class.Segment
185 ..param.host:The new host.
186 ..remarks:After this operation, $object$ depends on $host$.
187 ...text:Note that setting the host can invalidate $object$.
188 For example, if one changes the host of a @Class.Segment@ object, it is possible
189 that begin- and end-position of the segment does not fit into the new host sequence.
190 ..see:Function.host
191 */
192         friend inline void 
193         setHost(Segment & me, typename _Parameter<THost>::Type _host)
194         {
195 SEQAN_CHECKPOINT
196                 me.data_host = _toPointer(_host);
197         }
198
199 //____________________________________________________________________________
200
201         template <typename TPos>
202         inline typename Reference<Segment>::Type
203         operator [] (TPos pos)
204         {
205 SEQAN_CHECKPOINT
206                 return value(*this, pos);
207         }
208
209         template <typename TPos>
210         inline typename Reference<Segment const>::Type 
211         operator [] (TPos pos) const
212         {
213 SEQAN_CHECKPOINT
214                 return value(*this, pos);
215         }
216
217 //____________________________________________________________________________
218
219 ///.Function.begin.param.object.type:Class.Segment
220
221         friend inline typename Iterator<Segment, Standard>::Type 
222         begin(Segment & me,
223                 Standard)
224         {
225 SEQAN_CHECKPOINT
226                 return begin(host(me), Standard()) + me.data_begin_position;
227         }
228         friend inline typename Iterator<Segment const, Standard>::Type 
229         begin(Segment const & me,
230                 Standard)
231         {
232 SEQAN_CHECKPOINT
233                 return begin(host(me), Standard()) + me.data_begin_position;
234         }
235
236 //____________________________________________________________________________
237
238 ///.Function.beginPosition.param.object.type:Class.Segment
239
240         friend inline typename Position<Segment>::Type 
241         beginPosition(Segment & me)
242         {
243 SEQAN_CHECKPOINT
244                 return me.data_begin_position;
245         }
246         friend inline typename Position<Segment const>::Type 
247         beginPosition(Segment const & me)
248         {
249 SEQAN_CHECKPOINT
250                 return me.data_begin_position;
251         }
252
253 //____________________________________________________________________________
254
255 /**
256 .Function.setBegin:
257 ..summary:Sets begin of object in host.
258 ..cat:Dependent Objects
259 ..signature:setBegin(object, new_begin)
260 ..param.object:An object.
261 ...type:Spec.InfixSegment
262 ...type:Spec.SuffixSegment
263 ..param.new_begin:iterator to the new first item in $host(object)$ that belongs of $object$.
264 ...type:Metafunction.Iterator
265 ..see:Function.begin
266 ..see:Function.beginPosition
267 */
268         template <typename TIterator>
269         friend inline void 
270         setBegin(Segment & me, TIterator new_begin)
271         {
272 SEQAN_CHECKPOINT
273                 me.data_begin_position = new_begin - begin(host(me));//, Standard());
274         }
275
276
277 //____________________________________________________________________________
278
279 /**
280 .Function.setBeginPosition:
281 ..summary:Sets begin position of object in host.
282 ..cat:Dependent Objects
283 ..signature:setBeginPosition(object, new_begin)
284 ..param.object:An object.
285 ...type:Spec.InfixSegment
286 ...type:Spec.SuffixSegment
287 ..param.new_begin:position of the new first item in $host(object)$ that belongs of $object$.
288 ...type:Metafunction.Position
289 ..see:Function.begin
290 ..see:Function.beginPosition
291 ..see:Function.setBegin
292 */
293
294         template <typename TPosition>
295         friend inline void 
296         setBeginPosition(Segment & me, TPosition new_begin)
297         {
298 SEQAN_CHECKPOINT
299                 me.data_begin_position = new_begin;
300         }
301
302 //____________________________________________________________________________
303
304 ///.Function.begin.param.object.type:Class.Segment
305
306         friend inline typename Iterator<Segment, Standard>::Type 
307         end(Segment & me,
308                 Standard)
309         {
310 SEQAN_CHECKPOINT
311                 return begin(host(me), Standard()) + me.data_end_position;
312         }
313         friend inline typename Iterator<Segment const, Standard>::Type 
314         end(Segment const & me,
315                 Standard)
316         {
317 SEQAN_CHECKPOINT
318                 return begin(host(me), Standard()) + me.data_end_position;
319         }
320
321 //____________________________________________________________________________
322
323 ///.Function.endPosition.param.object.type:Class.Segment
324
325         friend inline typename Position<Segment>::Type 
326         endPosition(Segment & me)
327         {
328 SEQAN_CHECKPOINT
329                 return me.data_end_position;
330         }
331         friend inline typename Position<Segment>::Type 
332         endPosition(Segment const & me)
333         {
334 SEQAN_CHECKPOINT
335                 return me.data_end_position;
336         }
337
338 //____________________________________________________________________________
339
340 /**
341 .Function.setEnd:
342 ..summary:Sets end of object in host.
343 ..cat:Dependent Objects
344 ..signature:setEnd(object, new_end)
345 ..param.object:An object.
346 ...type:Spec.InfixSegment
347 ...type:Spec.PrefixSegment
348 ..param.new_end:Iterator behind the last item in $host(object)$ belongs of $object$.
349 ...type:Metafunction.Iterator
350 ..see:Function.end
351 ..see:Function.endPosition
352 ..see:Function.setBegin
353 */
354
355         template <typename TIterator>
356         friend inline void 
357         setEnd(Segment & me, TIterator new_end)
358         {
359 SEQAN_CHECKPOINT
360                 me.data_end_position = new_end - begin(host(me));//, Standard());
361         }
362
363 /* //unnoetig
364         friend inline void 
365         setEnd(Segment & me)
366         {
367 SEQAN_CHECKPOINT
368                 setEnd(me, end(host(me)));
369         }
370 */
371 //____________________________________________________________________________
372
373
374 /**
375 .Function.setEndPosition:
376 ..summary:Sets begin position of object in host.
377 ..cat:Dependent Objects
378 ..signature:setEndPosition(object, new_end)
379 ..param.object:An object.
380 ...type:Spec.InfixSegment
381 ...type:Spec.PrefixSegment
382 ..param.new_end:position behind the last item in $host(object)$ that belongs of $object$.
383 ...type:Metafunction.Position
384 ..see:Function.end
385 ..see:Function.endPosition
386 ..see:Function.setBeginPosition
387 ..see:Function.setEnd
388 */
389
390         template <typename TPosition>
391         friend inline void 
392         setEndPosition(Segment & me, TPosition new_end)
393         {
394 SEQAN_CHECKPOINT
395                 me.data_end_position = new_end;
396         }
397
398 //____________________________________________________________________________
399
400         friend inline void 
401         _setLength(
402                 Segment & me, 
403                 typename Size<THost>::Type new_length)
404         {
405 SEQAN_CHECKPOINT
406                 me.data_end_position = me.data_begin_position + new_length;
407         }
408
409 //____________________________________________________________________________
410
411 };
412
413 //////////////////////////////////////////////////////////////////////////////
414
415 /**
416 .Metafunction.Infix:
417 ..summary:Infix sequence type.
418 ..signature:Infix<T>::Type
419 ..param.T:A sequence type.
420 ...type:Class.String
421 ..returns.param.Type:The infix type.
422 ..see:Spec.InfixSegment
423 */
424
425 template <typename THost>
426 struct Infix
427 {
428         typedef Segment<THost, InfixSegment> Type;
429 };
430
431 template <typename THost, typename TSpec>
432 struct Infix< Segment<THost, TSpec> >
433 {
434         typedef Segment<THost, InfixSegment> Type;
435 };
436
437 template <typename THost, typename TSpec>
438 struct Infix< Segment<THost, TSpec> const >:
439         Infix< Segment<THost, TSpec> > {};
440
441 //////////////////////////////////////////////////////////////////////////////
442
443 template <typename THost, typename TPosition1, typename TPosition2>
444 inline void
445 set(Segment<THost, InfixSegment> & me,
446         THost & host_,
447         TPosition1 begin_,
448         TPosition2 end_)
449 {
450 SEQAN_CHECKPOINT
451         setHost(me, host_);
452         setBegin(me, begin_);
453         setEnd(me, end_);
454 }
455 //____________________________________________________________________________
456
457 template <typename THost>
458 inline void
459 set(Segment<THost, InfixSegment> & me,
460         THost & host_)
461 {
462 SEQAN_CHECKPOINT
463         setHost(me, host_);
464         setBegin(me, begin(host_, Standard()));
465         setEnd(me, end(host_, Standard()));
466 }
467 template <typename THost>
468 inline void
469 set(Segment<THost, InfixSegment> & me,
470         THost const & host_)
471 {
472 SEQAN_CHECKPOINT
473         setHost(me, host_);
474         setBegin(me, begin(host_, Standard()));
475         setEnd(me, end(host_, Standard()));
476 }
477
478 //____________________________________________________________________________
479
480 template <typename THost, typename TSpec>
481 inline void
482 set(Segment<THost, InfixSegment> & me,
483         Segment<THost, TSpec> & source)
484 {
485 SEQAN_CHECKPOINT
486         setHost(me, host(source));
487         setBeginPosition(me, beginPosition(source));
488         setEndPosition(me, endPosition(source));
489 }
490 template <typename THost, typename TSpec>
491 inline void
492 set(Segment<THost, InfixSegment> & me,
493         Segment<THost, TSpec> const & source)
494 {
495 SEQAN_CHECKPOINT
496         setHost(me, host(source));
497         setBeginPosition(me, beginPosition(source));
498         setEndPosition(me, endPosition(source));
499 }
500
501 //////////////////////////////////////////////////////////////////////////////
502
503 template <typename THost>
504 inline bool
505 atBegin(Segment<THost, InfixSegment> & segment)
506 {
507 SEQAN_CHECKPOINT
508         return (beginPosition(segment) == endPosition(segment));
509 }
510 template <typename THost>
511 inline bool
512 atBegin(Segment<THost, InfixSegment> const & segment)
513 {
514 SEQAN_CHECKPOINT
515         return (beginPosition(segment) == endPosition(segment));
516 }
517
518 //////////////////////////////////////////////////////////////////////////////
519
520 template <typename THost>
521 inline bool
522 atEnd(Segment<THost, InfixSegment> & segment)
523 {
524 SEQAN_CHECKPOINT
525         return (endPosition(segment) - beginPosition(segment)) > length(host(segment));
526 }
527 template <typename THost>
528 inline bool
529 atEnd(Segment<THost, InfixSegment> const & segment)
530 {
531 SEQAN_CHECKPOINT
532         return (endPosition(segment) - beginPosition(segment)) > length(host(segment));
533 }
534
535
536 //////////////////////////////////////////////////////////////////////////////
537
538 template <typename THost>
539 inline void
540 goBegin(Segment<THost, InfixSegment> & segment)
541 {
542 SEQAN_CHECKPOINT
543         setBeginPosition(segment, 0);
544         setEndPosition(segment, 1);
545 }
546 template <typename THost, typename THost2>
547 inline void
548 goBegin(Segment<THost, InfixSegment> & segment,
549                 THost2 &)
550 {
551         goBegin(segment);
552 }
553 template <typename THost, typename THost2>
554 inline void
555 goBegin(Segment<THost, InfixSegment> & segment,
556                 THost2 const &)
557 {
558         goBegin(segment);
559 }
560
561 //////////////////////////////////////////////////////////////////////////////
562
563
564 template <typename THost>
565 inline void
566 goEnd(Segment<THost, InfixSegment> & segment)
567 {
568 SEQAN_CHECKPOINT
569         setBeginPosition(segment, 0);
570         setEndPosition(segment, length(host(segment)));
571 }
572 template <typename THost, typename THost2>
573 inline void
574 goEnd(Segment<THost, InfixSegment> & segment,
575           THost2 &)
576 {
577         goEnd(segment);
578 }
579 template <typename THost, typename THost2>
580 inline void
581 goEnd(Segment<THost, InfixSegment> & segment,
582           THost2 const &)
583 {
584         goEnd(segment);
585 }
586
587 //////////////////////////////////////////////////////////////////////////////
588
589 template <typename THost>
590 inline Segment<THost, InfixSegment> &
591 operator ++(Segment<THost, InfixSegment> & segment)
592 {
593 SEQAN_CHECKPOINT
594         if (endPosition(segment) == length(host(segment)))
595         {
596                 setEndPosition(segment, endPosition(segment) - beginPosition(segment) + 1);
597                 setBeginPosition(segment, 0);
598         }
599         else
600         {
601                 setBeginPosition(segment, beginPosition(segment) + 1);
602                 setEndPosition(segment, endPosition(segment) + 1);
603         }
604         return segment;
605 }
606
607 //////////////////////////////////////////////////////////////////////////////
608
609 template <typename THost>
610 inline Segment<THost, InfixSegment> &
611 operator --(Segment<THost, InfixSegment> & segment)
612 {
613 SEQAN_CHECKPOINT
614         if (!beginPosition(segment))
615         {
616                 typename Size<THost>::Type host_length = length(host(segment));
617
618                 setBeginPosition(segment, host_length - endPosition(segment) + beginPosition(segment) + 1);
619                 setEndPosition(segment, host_length);
620         }
621         else
622         {
623                 setBeginPosition(segment, beginPosition(segment) - 1);
624                 setEndPosition(segment, endPosition(segment) - 1);
625         }
626         return segment;
627 }
628
629 //////////////////////////////////////////////////////////////////////////////
630
631 template <typename THost, typename TSpec, typename TPos>
632 inline typename Reference< Segment<THost, TSpec> >::Type 
633 value(Segment<THost, TSpec> & me, 
634           TPos pos)
635 {
636 SEQAN_CHECKPOINT
637         return *(begin(me, Standard()) + pos);
638 }
639
640 template <typename THost, typename TSpec, typename TPos>
641 inline typename Reference< Segment<THost, TSpec> const >::Type 
642 value(Segment<THost, TSpec> const & me, 
643           TPos pos)
644 {
645 SEQAN_CHECKPOINT
646         return *(begin(me, Standard()) + pos);
647 }
648
649 //////////////////////////////////////////////////////////////////////////////
650
651 /**
652 .Function.infix:
653 ..cat:Containers
654 ..summary:Creates infix object.
655 ..signature:infix(host, begin, end)
656 ..param.host:The complete sequence.
657 ...type:Class.String
658 ...type:Adaption.char array
659 ..param.begin:Position or iterator of the first element of the segment.
660 ...type:Metafunction.Position
661 ...type:Metafunction.Iterator
662 ..param.end:Position or iterator behind the last element of the segment.
663 ...remarks:$end$ must have the same type as $begin$.
664 ..returns:The infix of $host$ between $begin$ and $end-1$.
665 ...remarks:The type of the infix is given by @Metafunction.Infix@.
666 ..remarks:Notational sugar.
667 ..see:Spec.InfixSegment
668 */
669
670 template <typename T, typename TPosBegin, typename TPosEnd>
671 inline typename Infix<T>::Type
672 infix(T & t, TPosBegin pos_begin, TPosEnd pos_end)
673 {
674 SEQAN_CHECKPOINT
675         return typename Infix<T>::Type(t, pos_begin, pos_end);
676 }
677
678 template <typename T, typename TPosBegin, typename TPosEnd>
679 inline typename Infix<T *>::Type
680 infix(T * t, TPosBegin pos_begin, TPosEnd pos_end)
681 {
682 SEQAN_CHECKPOINT
683         return typename Infix<T *>::Type (t, pos_begin, pos_end);
684 }
685
686 template <typename T, typename TSpec, typename TPosBegin, typename TPosEnd>
687 inline typename Infix<Segment<T, TSpec> >::Type
688 infix(Segment<T, TSpec> & t, TPosBegin pos_begin, TPosEnd pos_end)
689 {
690 SEQAN_CHECKPOINT
691         return typename Infix<Segment<T, TSpec> >::Type (
692                 host(t), 
693                 beginPosition(t) + pos_begin, 
694                 beginPosition(t) + pos_end);
695 }
696
697 template <typename T, typename TSpec, typename TPosBegin, typename TPosEnd>
698 inline typename Infix<Segment<T, TSpec> const>::Type
699 infix(Segment<T, TSpec> const & t, TPosBegin pos_begin, TPosEnd pos_end)
700 {
701 SEQAN_CHECKPOINT
702         return typename Infix<Segment<T, TSpec> const>::Type (
703                 host(t), 
704                 beginPosition(t) + pos_begin, 
705                 beginPosition(t) + pos_end);
706 }
707
708 //////////////////////////////////////////////////////////////////////////////
709
710 /**
711 .Function.infixWithLength:
712 ..cat:Containers
713 ..summary:Creates infix object.
714 ..signature:infixWithLength(host, begin, length)
715 ..param.host:The complete sequence.
716 ...type:Class.String
717 ...type:Adaption.char array
718 ..param.begin:Position or iterator of the first element of the segment.
719 ...type:Metafunction.Position
720 ...type:Metafunction.Iterator
721 ..param.length:Length of the returned infix.
722 ..returns:The infix of $host$ between $begin$ and $begin+length-1$.
723 ...remarks:The type of the infix is given by @Metafunction.Infix@.
724 ..remarks:Notational sugar.
725 ..see:Spec.InfixSegment
726 */
727
728 template <typename T, typename TPosBegin, typename TSize>
729 inline typename Infix<T>::Type
730 infixWithLength(T & t, TPosBegin pos_begin, TSize length)
731 {
732 SEQAN_CHECKPOINT
733         return typename Infix<T>::Type(t, pos_begin, pos_begin + length);
734 }
735
736 template <typename T, typename TPosBegin, typename TSize>
737 inline typename Infix<T *>::Type
738 infixWithLength(T * t, TPosBegin pos_begin, TSize length)
739 {
740 SEQAN_CHECKPOINT
741         return typename Infix<T *>::Type (t, pos_begin, pos_begin + length);
742 }
743
744 template <typename T, typename TSpec, typename TPosBegin, typename TSize>
745 inline typename Infix<Segment<T, TSpec> >::Type
746 infixWithLength(Segment<T, TSpec> & t, TPosBegin pos_begin, TSize length)
747 {
748 SEQAN_CHECKPOINT
749         return typename Infix<Segment<T, TSpec> >::Type (
750                 host(t), 
751                 beginPosition(t) + pos_begin, 
752                 beginPosition(t) + pos_begin + length);
753 }
754
755 template <typename T, typename TSpec, typename TPosBegin, typename TSize>
756 inline typename Infix<Segment<T, TSpec> const>::Type
757 infixWithLength(Segment<T, TSpec> const & t, TPosBegin pos_begin, TSize length)
758 {
759 SEQAN_CHECKPOINT
760         return typename Infix<Segment<T, TSpec> const>::Type (
761                 host(t), 
762                 beginPosition(t) + pos_begin, 
763                 beginPosition(t) + pos_begin + length);
764 }
765
766 //////////////////////////////////////////////////////////////////////////////
767 //setBegin
768
769
770 template <typename TIterator>
771 inline void 
772 setBegin(TIterator new_begin)
773 {
774 SEQAN_CHECKPOINT
775         setBegin(container(new_begin), hostIterator(new_begin));
776 }
777
778
779 //////////////////////////////////////////////////////////////////////////////
780 //setEnd
781
782 template <typename TIterator>
783 inline void 
784 setEnd(TIterator new_end)
785 {
786 SEQAN_CHECKPOINT
787         setEnd(container(new_end), new_end);
788 }
789
790 //////////////////////////////////////////////////////////////////////////////
791
792 } //namespace SEQAN_NAMESPACE_MAIN
793
794 #endif //#ifndef SEQAN_HEADER_...