# 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)
            softClippedOffset(2,
                              ((0, 10), (1, None), (2, None)),
                              (CMATCH, CSOFT_CLIP, CSOFT_CLIP)))

    def testMatchTwoAfterThenHardClips(self):
        """
        Test that a soft-clipped base two sites after a non-soft-clipped site
        returns the correct offset, including when there are also hard clips.
        """
        self.assertEqual(
            12,
            softClippedOffset(
                2,
                ((0, 10), (1, None), (2, None), (3, None), (4, None)),
                (CMATCH, CSOFT_CLIP, CSOFT_CLIP, CHARD_CLIP, CHARD_CLIP)))


class TestInsertionOffset(TestCase):
    """
    Test the insertionOffset function.
    """
    def testNoNonInsertionBases(self):
        """
        If there are no preceding or following non-inserted bases, a ValueError
        must be raised.
        """
        error = (r'^Inserted base with no following or preceding reference '
                 r'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)

            softClippedOffset(2,
                              ((0, 10), (1, None), (2, None)),
                              (CMATCH, CSOFT_CLIP, CSOFT_CLIP)))

    def testMatchTwoAfterThenHardClips(self):
        """
        Test that a soft-clipped base two sites after a non-soft-clipped site
        returns the correct offset, including when there are also hard clips.
        """
        self.assertEqual(
            12,
            softClippedOffset(
                2,
                ((0, 10), (1, None), (2, None), (3, None), (4, None)),
                (CMATCH, CSOFT_CLIP, CSOFT_CLIP, CHARD_CLIP, CHARD_CLIP)))


class TestInsertionOffset(TestCase):
    """
    Test the insertionOffset function.
    """
    def testNoNonInsertionBases(self):
        """
        If there are no preceding or following non-inserted bases, a ValueError
        must be raised.
        """
        error = (r'^Inserted base with no following or preceding reference '
                 r'bases\.$')
        self.assertRaisesRegex(
            ValueError, error,

            insertionOffset, 0, ((0, None),), (CINS,))