# Path: dark/cigar.py
# (CINS_STR, CDEL_STR, CMATCH_STR, CEQUAL_STR, CDIFF_STR,
#  CHARD_CLIP_STR) = 'IDM=XH'
# def dna2cigar(s1, s2, concise=False):
# def makeCigar(reference, query, noEdgeInsertions=True):
# def cigarTuplesToOperations(tuples, includeHardClip=True):
# def softClippedOffset(offset, pairs, cigarOperations):
# def insertionOffset(offset, pairs, cigarOperations):


from unittest import TestCase
from pysam import CSOFT_CLIP, CHARD_CLIP, CMATCH, CINS
from dark.cigar import (
    CINS_STR, CDEL_STR, CMATCH_STR, CEQUAL_STR, CDIFF_STR,
    dna2cigar, makeCigar, cigarTuplesToOperations, softClippedOffset,
    insertionOffset)
        """
        self.assertEqual(
            [CHARD_CLIP, CHARD_CLIP, CINS, CINS, CMATCH, CMATCH, CMATCH],
            list(cigarTuplesToOperations(
                [(CHARD_CLIP, 2), (CINS, 2), (CMATCH, 3)])))

    def testSkipHardClipping(self):
        """
        It must be possible to have hard clipping operations skipped.
        """
        self.assertEqual(
            [CINS, CINS, CMATCH, CMATCH, CMATCH],
            list(cigarTuplesToOperations(
                [(CHARD_CLIP, 2), (CINS, 2), (CMATCH, 3)],
                includeHardClip=False)))


class TestSoftClippedOffset(TestCase):
    """
    Test the softClippedOffset function.
    """
    def testNoNonClippedBases(self):
        """
        If there are no preceding or following non-clipped bases, a ValueError
        must be raised.
        """
        error = (r'^Soft-clipped base with no following or preceding '
                 r'non-hard-clipped bases\.$')
        self.assertRaisesRegex(
            ValueError, error,

# Path: dark/cigar.py
# (CINS_STR, CDEL_STR, CMATCH_STR, CEQUAL_STR, CDIFF_STR,
#  CHARD_CLIP_STR) = 'IDM=XH'
# def dna2cigar(s1, s2, concise=False):
# def makeCigar(reference, query, noEdgeInsertions=True):
# def cigarTuplesToOperations(tuples, includeHardClip=True):
# def softClippedOffset(offset, pairs, cigarOperations):
# def insertionOffset(offset, pairs, cigarOperations):


# Path: test/test_cigar.py
from unittest import TestCase
from pysam import CSOFT_CLIP, CHARD_CLIP, CMATCH, CINS
from dark.cigar import (
    CINS_STR, CDEL_STR, CMATCH_STR, CEQUAL_STR, CDIFF_STR,
    dna2cigar, makeCigar, cigarTuplesToOperations, softClippedOffset,
    insertionOffset)

        """
        self.assertEqual(
            [CHARD_CLIP, CHARD_CLIP, CINS, CINS, CMATCH, CMATCH, CMATCH],
            list(cigarTuplesToOperations(
                [(CHARD_CLIP, 2), (CINS, 2), (CMATCH, 3)])))

    def testSkipHardClipping(self):
        """
        It must be possible to have hard clipping operations skipped.
        """
        self.assertEqual(
            [CINS, CINS, CMATCH, CMATCH, CMATCH],
            list(cigarTuplesToOperations(
                [(CHARD_CLIP, 2), (CINS, 2), (CMATCH, 3)],
                includeHardClip=False)))


class TestSoftClippedOffset(TestCase):
    """
    Test the softClippedOffset function.
    """
    def testNoNonClippedBases(self):
        """
        If there are no preceding or following non-clipped bases, a ValueError
        must be raised.
        """
        error = (r'^Soft-clipped base with no following or preceding '
                 r'non-hard-clipped bases\.$')
        self.assertRaisesRegex(
            ValueError, error,

            softClippedOffset, 0, ((0, None),), (CSOFT_CLIP,))