# Path: q2_types/plugin_setup.py

# 
# Path: q2_types/per_sample_sequences/_format.py
# class FastqGzFormat(model.BinaryFileFormat):
#     """
#     A gzipped fastq file.
# 
#     """
# 
#     def _check_n_records(self, n=None):
#         with gzip.open(str(self), mode='rt', encoding='ascii') as fh:
#             zipper = itertools.zip_longest(*[fh] * 4)
#             if n is None:
#                 file_ = enumerate(zipper)
#             else:
#                 file_ = zip(range(1, n), zipper)
#             for i, record in file_:
#                 header, seq, sep, qual = record
# 
#                 if not header.startswith('@'):
#                     raise ValidationError('Header on line %d is not FASTQ, '
#                                           'records may be misaligned' %
#                                           (i * 4 + 1))
# 
#                 if seq is None or seq == '\n':
#                     raise ValidationError('Missing sequence for record '
#                                           'beginning on line %d'
#                                           % (i * 4 + 1))
#                 elif not seq.isupper():
#                     raise ValidationError('Lowercase case sequence on line %d'
#                                           % (i * 4 + 2))
# 
#                 if sep is None:
#                     raise ValidationError('Missing separator for record '
#                                           'beginning on line %d'
#                                           % (i * 4 + 1))
#                 elif not sep.startswith('+'):
#                     raise ValidationError('Invalid separator on line %d'
#                                           % (i * 4 + 3))
# 
#                 if qual is None:
#                     raise ValidationError('Missing quality for record '
#                                           'beginning on line %d'
#                                           % (i * 4 + 1))
#                 elif len(qual) != len(seq):
#                     raise ValidationError('Quality score length doesn\'t '
#                                           'match sequence length for record '
#                                           'beginning on line %d'
#                                           % (i * 4 + 1))
# 
#     def _validate_(self, level):
#         with self.open() as fh:
#             if fh.peek(2)[:2] != b'\x1f\x8b':
#                 raise ValidationError('File is uncompressed')
# 
#         record_count_map = {'min': 5, 'max': None}
#         self._check_n_records(record_count_map[level])


import qiime2.plugin.model as model
from ..plugin_setup import plugin
from q2_types.per_sample_sequences import FastqGzFormat
# ----------------------------------------------------------------------------
# Copyright (c) 2016-2021, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------




# MultiplexedSingleEndBarcodeInSequenceDirFmt &
# MultiplexedPairedEndBarcodeInSequenceDirFmt represent multiplexed sequences
# that contain inline barcode information:
# AGGACTAGGTAGATC => barcode: AGGA ; biological sequence: CTAGGTAGATC

MultiplexedSingleEndBarcodeInSequenceDirFmt = model.SingleFileDirectoryFormat(
    'MultiplexedSingleEndBarcodeInSequenceDirFmt', 'forward.fastq.gz',
    FastqGzFormat)


class MultiplexedPairedEndBarcodeInSequenceDirFmt(model.DirectoryFormat):
    forward_sequences = model.File('forward.fastq.gz', format=FastqGzFormat)

# Path: q2_types/plugin_setup.py

# 
# Path: q2_types/per_sample_sequences/_format.py
# class FastqGzFormat(model.BinaryFileFormat):
#     """
#     A gzipped fastq file.
# 
#     """
# 
#     def _check_n_records(self, n=None):
#         with gzip.open(str(self), mode='rt', encoding='ascii') as fh:
#             zipper = itertools.zip_longest(*[fh] * 4)
#             if n is None:
#                 file_ = enumerate(zipper)
#             else:
#                 file_ = zip(range(1, n), zipper)
#             for i, record in file_:
#                 header, seq, sep, qual = record
# 
#                 if not header.startswith('@'):
#                     raise ValidationError('Header on line %d is not FASTQ, '
#                                           'records may be misaligned' %
#                                           (i * 4 + 1))
# 
#                 if seq is None or seq == '\n':
#                     raise ValidationError('Missing sequence for record '
#                                           'beginning on line %d'
#                                           % (i * 4 + 1))
#                 elif not seq.isupper():
#                     raise ValidationError('Lowercase case sequence on line %d'
#                                           % (i * 4 + 2))
# 
#                 if sep is None:
#                     raise ValidationError('Missing separator for record '
#                                           'beginning on line %d'
#                                           % (i * 4 + 1))
#                 elif not sep.startswith('+'):
#                     raise ValidationError('Invalid separator on line %d'
#                                           % (i * 4 + 3))
# 
#                 if qual is None:
#                     raise ValidationError('Missing quality for record '
#                                           'beginning on line %d'
#                                           % (i * 4 + 1))
#                 elif len(qual) != len(seq):
#                     raise ValidationError('Quality score length doesn\'t '
#                                           'match sequence length for record '
#                                           'beginning on line %d'
#                                           % (i * 4 + 1))
# 
#     def _validate_(self, level):
#         with self.open() as fh:
#             if fh.peek(2)[:2] != b'\x1f\x8b':
#                 raise ValidationError('File is uncompressed')
# 
#         record_count_map = {'min': 5, 'max': None}
#         self._check_n_records(record_count_map[level])


# Path: q2_types/multiplexed_sequences/_format.py
import qiime2.plugin.model as model
from ..plugin_setup import plugin
from q2_types.per_sample_sequences import FastqGzFormat

# ----------------------------------------------------------------------------
# Copyright (c) 2016-2021, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------




# MultiplexedSingleEndBarcodeInSequenceDirFmt &
# MultiplexedPairedEndBarcodeInSequenceDirFmt represent multiplexed sequences
# that contain inline barcode information:
# AGGACTAGGTAGATC => barcode: AGGA ; biological sequence: CTAGGTAGATC

MultiplexedSingleEndBarcodeInSequenceDirFmt = model.SingleFileDirectoryFormat(
    'MultiplexedSingleEndBarcodeInSequenceDirFmt', 'forward.fastq.gz',
    FastqGzFormat)


class MultiplexedPairedEndBarcodeInSequenceDirFmt(model.DirectoryFormat):
    forward_sequences = model.File('forward.fastq.gz', format=FastqGzFormat)

    reverse_sequences = model.File('reverse.fastq.gz', format=FastqGzFormat)