# Path: anoisetools/scripts/split.py
# class SequenceWriter(object):
# class AlreadyOpenError(BaseException):
# class SequenceSplitter(object):
#     def __init__(self, queue, path, sequence_format, barcode=None,
#             primer=None):
#     def __iter__(self):
#     def write(self):
#     def write_control(self):
# def load_barcodes(fp):
#     def vals():
#     def __init__(self, barcodes, make_dirs=False,
#             unmatched_name="unknown.sff", output_format='sff',
#             write_controls=False):
#     def __enter__(self):
#     def __exit__(self, *args):
#     def open(self):
#     def _default_queue(self):
#     def _get_primers(self, barcode):
#     def _get_queue(self, barcode, primer_re):
#     def _get_name(self, barcode, primer_re):
#     def close(self):
#     def run(self, sequences):
# def build_parser(subparsers):
# def main(parsed):


import unittest
from anoisetools.scripts import split


def _line_iterator(s):
    return iter(s.splitlines())

class ReadBarcodeTestCase(unittest.TestCase):

    def test_basic(self):
        s = "Barcode1,ACGTGA,ACGT"
        i = _line_iterator(s)
        actual = split.load_barcodes(i)
        self.assertEqual(1, len(actual))
        self.assertEqual(1, len(actual['ACGTGA']))
        self.assertEqual('Barcode1', actual['ACGTGA'][0][1])

    def test_extra_data(self):
        """
        Extra items in a row should be ignored
        """
        s = """Barcode1,ACGTGA,ACGT,Data from patient X
Barcode2,ACTGAA,ACGT,Data from patient Y"""
        i = _line_iterator(s)

# Path: anoisetools/scripts/split.py
# class SequenceWriter(object):
# class AlreadyOpenError(BaseException):
# class SequenceSplitter(object):
#     def __init__(self, queue, path, sequence_format, barcode=None,
#             primer=None):
#     def __iter__(self):
#     def write(self):
#     def write_control(self):
# def load_barcodes(fp):
#     def vals():
#     def __init__(self, barcodes, make_dirs=False,
#             unmatched_name="unknown.sff", output_format='sff',
#             write_controls=False):
#     def __enter__(self):
#     def __exit__(self, *args):
#     def open(self):
#     def _default_queue(self):
#     def _get_primers(self, barcode):
#     def _get_queue(self, barcode, primer_re):
#     def _get_name(self, barcode, primer_re):
#     def close(self):
#     def run(self, sequences):
# def build_parser(subparsers):
# def main(parsed):


# Path: anoisetools/test/scripts/test_split.py
import unittest
from anoisetools.scripts import split



def _line_iterator(s):
    return iter(s.splitlines())

class ReadBarcodeTestCase(unittest.TestCase):

    def test_basic(self):
        s = "Barcode1,ACGTGA,ACGT"
        i = _line_iterator(s)
        actual = split.load_barcodes(i)
        self.assertEqual(1, len(actual))
        self.assertEqual(1, len(actual['ACGTGA']))
        self.assertEqual('Barcode1', actual['ACGTGA'][0][1])

    def test_extra_data(self):
        """
        Extra items in a row should be ignored
        """
        s = """Barcode1,ACGTGA,ACGT,Data from patient X
Barcode2,ACTGAA,ACGT,Data from patient Y"""
        i = _line_iterator(s)

        actual = split.load_barcodes(i)