# Path: crumbs/seq/seq.py
# class SeqItem(_SeqItem):
#     def __new__(cls, name, lines, annotations=None):
# def get_title(seq):
# def get_description(seq):
# def get_name(seq):
# def get_file_format(seq):
# def _break():
# def _is_fastq_plus_line(line, seq_name):
# def _get_seqitem_quals(seq):
# def get_str_seq(seq):
# def get_length(seq):
# def _get_seqitem_qualities(seqwrap):
# def get_int_qualities(seq):
# def _int_quals_to_str_quals(int_quals, out_format):
# def get_str_qualities(seq, out_format=None):
# def get_annotations(seq):
# def _copy_seqrecord(seqrec, seq=None, name=None, id_=None):
# def _copy_seqitem(seqwrapper, seq=None, name=None):
# def copy_seq(seqwrapper, seq=None, name=None):
# def _slice_seqitem(seqwrap, start, stop):
# def slice_seq(seq, start=None, stop=None):
# def assing_kind_to_seqs(kind, seqs, file_format):
# SANGER_QUALS = {chr(i): i - 33 for i in range(33, 127)}
# ILLUMINA_QUALS = {chr(i): i - 64 for i in range(64, 127)}
# SANGER_STRS = {i - 33: chr(i)  for i in range(33, 127)}
# ILLUMINA_STRS = {i - 64: chr(i) for i in range(64, 127)}
# 
# Path: crumbs/utils/tags.py
# SEQITEM = 'seqitem'
# 
# ILLUMINA_QUALITY = 'fastq-illumina'


import unittest
from crumbs.seq.seq import (get_length, get_str_seq, get_int_qualities,
                            get_str_qualities, slice_seq, copy_seq, SeqItem,
                            SeqWrapper)
from crumbs.utils.tags import SEQITEM, ILLUMINA_QUALITY
    def test_slice(self):
        # with fasta
        seq = SeqItem(name='s1', lines=['>s1\n', 'ACTGGTAC\n'])
        seq = SeqWrapper(SEQITEM, seq, 'fasta')
        expected_seq = SeqItem(name='s1', lines=['>s1\n', 'CTGG\n'])
        expected_seq = SeqWrapper(SEQITEM, expected_seq, 'fasta')
        assert slice_seq(seq, 1, 5) == expected_seq

        # with fastq
        seq = SeqItem(name='seq',
                      lines=['@seq\n', 'aata\n', '+\n', '!?!?\n'])
        seq = SeqWrapper(SEQITEM, seq, 'fastq')
        seq = slice_seq(seq, 1, 3)
        assert list(get_int_qualities(seq)) == [30, 0]
        assert get_str_seq(seq) == 'at'
        assert seq.object.lines == ['@seq\n', 'at\n', '+\n', '?!\n']

        # with multiline fastq
        seq = SeqItem(name='seq', lines=['@seq\n', 'aaatcaaa\n', '+\n',
                                         '@AAABBBB\n'])
        seq = SeqWrapper(SEQITEM, seq, 'fastq-illumina')
        seq_ = slice_seq(seq, 1, 5)
        assert list(get_int_qualities(seq_)) == [1, 1, 1, 2]
        assert get_str_seq(seq_) == get_str_seq(seq)[1: 5]

        # It tests the stop is None
        seq = SeqItem('seq', ['>seq\n', 'aCTG'])
        seq = SeqWrapper(SEQITEM, seq, 'fasta')
        assert get_str_seq(slice_seq(seq, 1, None)) == 'aCTG'[1:]


# Path: crumbs/seq/seq.py
# class SeqItem(_SeqItem):
#     def __new__(cls, name, lines, annotations=None):
# def get_title(seq):
# def get_description(seq):
# def get_name(seq):
# def get_file_format(seq):
# def _break():
# def _is_fastq_plus_line(line, seq_name):
# def _get_seqitem_quals(seq):
# def get_str_seq(seq):
# def get_length(seq):
# def _get_seqitem_qualities(seqwrap):
# def get_int_qualities(seq):
# def _int_quals_to_str_quals(int_quals, out_format):
# def get_str_qualities(seq, out_format=None):
# def get_annotations(seq):
# def _copy_seqrecord(seqrec, seq=None, name=None, id_=None):
# def _copy_seqitem(seqwrapper, seq=None, name=None):
# def copy_seq(seqwrapper, seq=None, name=None):
# def _slice_seqitem(seqwrap, start, stop):
# def slice_seq(seq, start=None, stop=None):
# def assing_kind_to_seqs(kind, seqs, file_format):
# SANGER_QUALS = {chr(i): i - 33 for i in range(33, 127)}
# ILLUMINA_QUALS = {chr(i): i - 64 for i in range(64, 127)}
# SANGER_STRS = {i - 33: chr(i)  for i in range(33, 127)}
# ILLUMINA_STRS = {i - 64: chr(i) for i in range(64, 127)}
# 
# Path: crumbs/utils/tags.py
# SEQITEM = 'seqitem'
# 
# ILLUMINA_QUALITY = 'fastq-illumina'


# Path: test/seq/test_seq.py
import unittest
from crumbs.seq.seq import (get_length, get_str_seq, get_int_qualities,
                            get_str_qualities, slice_seq, copy_seq, SeqItem,
                            SeqWrapper)
from crumbs.utils.tags import SEQITEM, ILLUMINA_QUALITY

    def test_slice(self):
        # with fasta
        seq = SeqItem(name='s1', lines=['>s1\n', 'ACTGGTAC\n'])
        seq = SeqWrapper(SEQITEM, seq, 'fasta')
        expected_seq = SeqItem(name='s1', lines=['>s1\n', 'CTGG\n'])
        expected_seq = SeqWrapper(SEQITEM, expected_seq, 'fasta')
        assert slice_seq(seq, 1, 5) == expected_seq

        # with fastq
        seq = SeqItem(name='seq',
                      lines=['@seq\n', 'aata\n', '+\n', '!?!?\n'])
        seq = SeqWrapper(SEQITEM, seq, 'fastq')
        seq = slice_seq(seq, 1, 3)
        assert list(get_int_qualities(seq)) == [30, 0]
        assert get_str_seq(seq) == 'at'
        assert seq.object.lines == ['@seq\n', 'at\n', '+\n', '?!\n']

        # with multiline fastq
        seq = SeqItem(name='seq', lines=['@seq\n', 'aaatcaaa\n', '+\n',
                                         '@AAABBBB\n'])
        seq = SeqWrapper(SEQITEM, seq, 'fastq-illumina')
        seq_ = slice_seq(seq, 1, 5)
        assert list(get_int_qualities(seq_)) == [1, 1, 1, 2]
        assert get_str_seq(seq_) == get_str_seq(seq)[1: 5]

        # It tests the stop is None
        seq = SeqItem('seq', ['>seq\n', 'aCTG'])
        seq = SeqWrapper(SEQITEM, seq, 'fasta')
        assert get_str_seq(slice_seq(seq, 1, None)) == 'aCTG'[1:]


        assert get_str_seq(slice_seq(seq, None, 1)) == 'aCTG'[:1]