<commit_before>// ==========================================================================
//                 SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2010, <NAME>, 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 <NAME> 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 <NAME> 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.
//
// ==========================================================================

#ifndef SEQAN_HEADER_GRAPH_IMPL_FRAGMENT_H
#define SEQAN_HEADER_GRAPH_IMPL_FRAGMENT_H

namespace SEQAN_NAMESPACE_MAIN
{


//////////////////////////////////////////////////////////////////////////////
// Fragment Specs
//////////////////////////////////////////////////////////////////////////////

/**
.Spec.ExactFragment:
..cat:Alignments
..general:Class.Fragment
..summary:A type for ungapped, pairwise segment matches.
..signature:Fragment<TSize, ExactFragment<TSpec> > 
..param.TSize: The Size type of the underlying sequences.
...metafunction:Metafunction.Size
..param.TSpec:The specializing type for the graph.
...metafunction:Metafunction.Spec
..include:seqan/refinement.h
..see:Spec.ExactReversableFragment
*/
template<typename TSpec = Default>
struct ExactFragment;	



/**
.Spec.ExactReversableFragment:
..cat:Alignments
..general:Class.Fragment
..summary:A type for ungapped, pairwise segment matches that may be in reverse orientation.
..signature:Fragment<TSize, ExactReversableFragment<TSpec> > 
..param.TSize: The Size type of the underlying sequences.
...metafunction:Metafunction.Size
..param.TSpec:The specializing type for the graph.
...metafunction:Metafunction.Spec
..remarks:Compared to the @Spec.ExactFragment@ specialzing type of @Class.Fragment@, a @Spec.ExactReversableFragment@ stores an additional bool value to indicate whether a match is in reverse orientation or not.
..include:seqan/refinement.h
..see:Spec.ExactFragment
*/
template<typename TSpec = Default>
struct ExactReversableFragment;	


//////////////////////////////////////////////////////////////////////////////
// Default Fragment is the exact one
//////////////////////////////////////////////////////////////////////////////


/**
.Class.Fragment:
..cat:Alignments
..summary:A type for ungapped, pairwise segment matches.
..signature:Fragment<TSize, TSpec>
..param.TSize:The size type of the underlying sequences.
...metafunction:Metafunction.Size
..param.TSpec:The specializing type.
...metafunction:Metafunction.Spec
...XXdefault:@Spec.ExactFragment@
..include:seqan/refinement.h
*/


template<typename TSize = typename Size<String<char> >::Type, typename TSpec = ExactFragment<> >
class Fragment;


//////////////////////////////////////////////////////////////////////////////
// Size Metafunction
//////////////////////////////////////////////////////////////////////////////

template<typename TSize, typename TSpec>
struct Size<Fragment<TSize, TSpec> > {
	typedef TSize Type;
};


template<typename TSize, typename TSpec>
struct Size<Fragment<TSize, TSpec> const> {
	typedef TSize Type;
};


//////////////////////////////////////////////////////////////////////////////
// Exact Fragment
//////////////////////////////////////////////////////////////////////////////
	

template<typename TSize, typename TSpec>
class Fragment<TSize, ExactFragment<TSpec> > {
 public:
	 typedef typename Id<Fragment>::Type TId;
	 TId seqId1;
	 TSize begin1;
	 TId seqId2;
	 TSize begin2;
	 TSize len;
  
	 Fragment()	 {}


/**
.Memfunc.Fragment#Fragment:
..class:Class.Fragment
..summary:Constructor.
..signature:Fragment<TSize,TSpec>(seqId1, beg1, seqId2, beg2, len)
..param.seqId1:The id of the first sequence.
...type:Metafunction.Id
..param.beg1:The TSize begin position on the first sequence.
..param.seqId2:The id of the second sequence.
...type:Metafunction.Id
..param.beg2:The TSize begin position on the second sequence.
..param.len:The TSize length of the segment match.
*/
	 Fragment(TId sqId1, TSize beg1, TId sqId2, TSize beg2, TSize l) :
	 seqId1(sqId1), begin1(beg1), seqId2(sqId2), begin2(beg2), len(l) 
	 {
		 SEQAN_CHECKPOINT
	 }

};


//////////////////////////////////////////////////////////////////////////////
// Exact Fragment that is a forward or reverse match
//////////////////////////////////////////////////////////////////////////////
	

template<typename TSize, typename TSpec>
class Fragment<TSize, ExactReversableFragment<TSpec> > {
 public:
	 typedef typename Id<Fragment>::Type TId_;
	 TId_ seqId1;
	 TSize begin1;
	 TId_ seqId2;
	 TSize begin2;
	 TSize len;
	 bool reversed;
  
	 Fragment()	 {}

	 Fragment(TId_ sqId1, TSize beg1, TId_ sqId2, TSize beg2, TSize l) :
	 seqId1(sqId1), begin1(beg1), seqId2(sqId2), begin2(beg2), len(l), reversed(false) 
	 {
		 SEQAN_CHECKPOINT
	 }
/**
.Memfunc.Fragment#Fragment:
..class:Spec.ExactReversableFragment
..signature:Fragment<TSize,ExactReversableFragment<TSpec> >(seqId1, beg1, seqId2, beg2, len, reversed)
..param.reversed:True if the segments match in reverse orientation, false otherwise.
*/
	
 	 Fragment(TId_ sqId1, TSize beg1, TId_ sqId2, TSize beg2, TSize l, bool rev) :
	 seqId1(sqId1), begin1(beg1), seqId2(sqId2), begin2(beg2), len(l), reversed(rev) 
	 {
		 SEQAN_CHECKPOINT
	 }
};


//////////////////////////////////////////////////////////////////////////////

/**
.Function.label:
..class:Class.Fragment
..signature:label(f,str,seqId)
..param.f:A fragment.
...type:Class.Fragment
..param.str:The string set underlying the fragment.
..param.seqId:The id of the sequence for which the label should be retrieved.
...remarks:
*/
template<typename TSize, typename TSpec, typename TStringSet, typename TVal>
inline typename Infix<typename Value<TStringSet>::Type>::Type
label(Fragment<TSize, TSpec> const& f,
      TStringSet& str,
      TVal const seqId)
{
	SEQAN_CHECKPOINT
	typedef typename Id<Fragment<TSize, TSpec> >::Type TId;<commit_msg>`operator<()` and `operator==()` for fragments.<commit_after>// ==========================================================================
//                 SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2010, <NAME>, 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 <NAME> 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.
//
// ==========================================================================

#ifndef SEQAN_HEADER_GRAPH_IMPL_FRAGMENT_H
#define SEQAN_HEADER_GRAPH_IMPL_FRAGMENT_H

namespace SEQAN_NAMESPACE_MAIN
{


//////////////////////////////////////////////////////////////////////////////
// Fragment Specs
//////////////////////////////////////////////////////////////////////////////

/**
.Spec.ExactFragment:
..cat:Alignments
..general:Class.Fragment
..summary:A type for ungapped, pairwise segment matches.
..signature:Fragment<TSize, ExactFragment<TSpec> > 
..param.TSize: The Size type of the underlying sequences.
...metafunction:Metafunction.Size
..param.TSpec:The specializing type for the graph.
...metafunction:Metafunction.Spec
..include:seqan/refinement.h
..see:Spec.ExactReversableFragment
*/
template<typename TSpec = Default>
struct ExactFragment;	



/**
.Spec.ExactReversableFragment:
..cat:Alignments
..general:Class.Fragment
..summary:A type for ungapped, pairwise segment matches that may be in reverse orientation.
..signature:Fragment<TSize, ExactReversableFragment<TSpec> > 
..param.TSize: The Size type of the underlying sequences.
...metafunction:Metafunction.Size
..param.TSpec:The specializing type for the graph.
...metafunction:Metafunction.Spec
..remarks:Compared to the @Spec.ExactFragment@ specialzing type of @Class.Fragment@, a @Spec.ExactReversableFragment@ stores an additional bool value to indicate whether a match is in reverse orientation or not.
..include:seqan/refinement.h
..see:Spec.ExactFragment
*/
template<typename TSpec = Default>
struct ExactReversableFragment;	


//////////////////////////////////////////////////////////////////////////////
// Default Fragment is the exact one
//////////////////////////////////////////////////////////////////////////////


/**
.Class.Fragment:
..cat:Alignments
..summary:A type for ungapped, pairwise segment matches.
..signature:Fragment<TSize, TSpec>
..param.TSize:The size type of the underlying sequences.
...metafunction:Metafunction.Size
..param.TSpec:The specializing type.
...metafunction:Metafunction.Spec
...XXdefault:@Spec.ExactFragment@
..include:seqan/refinement.h
*/


template<typename TSize = typename Size<String<char> >::Type, typename TSpec = ExactFragment<> >
class Fragment;


//////////////////////////////////////////////////////////////////////////////
// Size Metafunction
//////////////////////////////////////////////////////////////////////////////

template<typename TSize, typename TSpec>
struct Size<Fragment<TSize, TSpec> > {
	typedef TSize Type;
};


template<typename TSize, typename TSpec>
struct Size<Fragment<TSize, TSpec> const> {
	typedef TSize Type;
};


//////////////////////////////////////////////////////////////////////////////
// Exact Fragment
//////////////////////////////////////////////////////////////////////////////
	

template<typename TSize, typename TSpec>
class Fragment<TSize, ExactFragment<TSpec> > {
 public:
	 typedef typename Id<Fragment>::Type TId;
	 TId seqId1;
	 TSize begin1;
	 TId seqId2;
	 TSize begin2;
	 TSize len;
  
	 Fragment()	 {}


/**
.Memfunc.Fragment#Fragment:
..class:Class.Fragment
..summary:Constructor.
..signature:Fragment<TSize,TSpec>(seqId1, beg1, seqId2, beg2, len)
..param.seqId1:The id of the first sequence.
...type:Metafunction.Id
..param.beg1:The TSize begin position on the first sequence.
..param.seqId2:The id of the second sequence.
...type:Metafunction.Id
..param.beg2:The TSize begin position on the second sequence.
..param.len:The TSize length of the segment match.
*/
	 Fragment(TId sqId1, TSize beg1, TId sqId2, TSize beg2, TSize l) :
	 seqId1(sqId1), begin1(beg1), seqId2(sqId2), begin2(beg2), len(l) 
	 {
		 SEQAN_CHECKPOINT
	 }

};

template<typename TSize, typename TSpec>
inline bool
operator==(Fragment<TSize, ExactFragment<TSpec> > const & left,
           Fragment<TSize, ExactFragment<TSpec> > const & right)
{
    return (left.seqId1 == right.seqId1 &&
            left.begin1 == right.begin1 &&
            left.seqId2 == right.seqId2 &&
            left.begin2 == right.begin2 &&
            left.len == right.len);
}

template<typename TSize, typename TSpec>
inline bool
operator<(Fragment<TSize, ExactFragment<TSpec> > const & left,
          Fragment<TSize, ExactFragment<TSpec> > const & right)
{
    if (left.seqId1 < right.seqId1)
        return true;
    if (left.seqId1 > right.seqId1)
        return false;
    if (left.begin1 < right.begin1)
        return true;
    if (left.begin1 > right.begin1)
        return false;
    if (left.seqId2 < right.seqId2)
        return true;
    if (left.seqId2 > right.seqId2)
        return false;
    if (left.begin2 < right.begin2)
        return true;
    if (left.begin2 > right.begin2)
        return false;
    if (left.len < right.len)
        return true;
    // if (left.len > right.len)
    //     return false;
    return false;
}

//////////////////////////////////////////////////////////////////////////////
// Exact Fragment that is a forward or reverse match
//////////////////////////////////////////////////////////////////////////////
	

template<typename TSize, typename TSpec>
class Fragment<TSize, ExactReversableFragment<TSpec> > {
 public:
	 typedef typename Id<Fragment>::Type TId_;
	 TId_ seqId1;
	 TSize begin1;
	 TId_ seqId2;
	 TSize begin2;
	 TSize len;
	 bool reversed;
  
	 Fragment()	 {}

	 Fragment(TId_ sqId1, TSize beg1, TId_ sqId2, TSize beg2, TSize l) :
	 seqId1(sqId1), begin1(beg1), seqId2(sqId2), begin2(beg2), len(l), reversed(false) 
	 {
		 SEQAN_CHECKPOINT
	 }
/**
.Memfunc.Fragment#Fragment:
..class:Spec.ExactReversableFragment
..signature:Fragment<TSize,ExactReversableFragment<TSpec> >(seqId1, beg1, seqId2, beg2, len, reversed)
..param.reversed:True if the segments match in reverse orientation, false otherwise.
*/
	
 	 Fragment(TId_ sqId1, TSize beg1, TId_ sqId2, TSize beg2, TSize l, bool rev) :
	 seqId1(sqId1), begin1(beg1), seqId2(sqId2), begin2(beg2), len(l), reversed(rev) 
	 {
		 SEQAN_CHECKPOINT
	 }
};

template<typename TSize, typename TSpec>
inline bool
operator==(Fragment<TSize, ExactReversableFragment<TSpec> > const & left,
           Fragment<TSize, ExactReversableFragment<TSpec> > const & right)
{
    return (left.seqId1 == right.seqId1 &&
            left.begin1 == right.begin1 &&
            left.seqId2 == right.seqId2 &&
            left.begin2 == right.begin2 &&
            left.len == right.len &&
            left.reversed == right.reversed);
}

template<typename TSize, typename TSpec>
inline bool
operator<(Fragment<TSize, ExactReversableFragment<TSpec> > const & left,
          Fragment<TSize, ExactReversableFragment<TSpec> > const & right)
{
    if (left.seqId1 < right.seqId1)
        return true;
    if (left.seqId1 > right.seqId1)
        return false;
    if (left.begin1 < right.begin1)
        return true;
    if (left.begin1 > right.begin1)
        return false;
    if (left.seqId2 < right.seqId2)
        return true;
    if (left.seqId2 > right.seqId2)
        return false;
    if (left.begin2 < right.begin2)
        return true;
    if (left.begin2 > right.begin2)
        return false;
    if (left.len < right.len)
        return true;
    if (left.len > right.len)
        return false;
    if (left.reversed < right.reversed)
        return true;
    // if (left.reversed > right.reversed)
    //     return false;
    return false;
}

//////////////////////////////////////////////////////////////////////////////

/**
.Function.label:
..class:Class.Fragment
..signature:label(f,str,seqId)
..param.f:A fragment.
...type:Class.Fragment
..param.str:The string set underlying the fragment.
..param.seqId:The id of the sequence for which the label should be retrieved.
...remarks:
*/
template<typename TSize, typename TSpec, typename TStringSet, typename TVal>
inline typename Infix<typename Value<TStringSet>::Type>::Type
label(Fragment<TSize, TSpec> const& f,
      TStringSet& str,
      TVal const seqId)
{
	SEQAN_CHECKPOINT
	typedef typename Id<Fragment<TSize, TSpec> >::Type TId;
{'fraction_non_alphanumeric': 0.21939900220443206, 'fraction_numerical': 0.010210001160227404, 'mean_word_length': 2.5260789527510736, 'pattern_counts': {'":': 0, '<': 110, '<?xml version=': 0, '>': 107, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4151273', 'n_tokens_mistral': 5006, 'n_tokens_neox': 4641, 'n_words': 1464}