# Path: abstar/utils/pandaseq.py
# def pair_files(files, nextseq):
#     pairs = {}
#     for f in files:
#         if nextseq:
#             f_prefix = '_'.join(os.path.basename(f).split('_')[:-2])
#         else:
#             f_prefix = '_'.join(os.path.basename(f).split('_')[:-3])
#         if f_prefix in pairs:
#             pairs[f_prefix].append(f)
#         else:
#             pairs[f_prefix] = [f, ]
#     return pairs


from multiprocessing import cpu_count
from subprocess import Popen, PIPE
from Bio import SeqIO
from .utils.pandaseq import pair_files
from abutils.utils.log import get_logger
from abutils.utils.pipeline import list_files, make_dir
import os
import sys
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
# and associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#


from __future__ import absolute_import, division, print_function, unicode_literals






logger = get_logger('preprocess')


def quality_trim(input_directory=None, output_directory=None,
        quality_cutoff=20, length_cutoff=50,
        quality_type='sanger', compress_output=True, file_pairs=None,

# Path: abstar/utils/pandaseq.py
# def pair_files(files, nextseq):
#     pairs = {}
#     for f in files:
#         if nextseq:
#             f_prefix = '_'.join(os.path.basename(f).split('_')[:-2])
#         else:
#             f_prefix = '_'.join(os.path.basename(f).split('_')[:-3])
#         if f_prefix in pairs:
#             pairs[f_prefix].append(f)
#         else:
#             pairs[f_prefix] = [f, ]
#     return pairs


# Path: abstar/preprocess.py
from multiprocessing import cpu_count
from subprocess import Popen, PIPE
from Bio import SeqIO
from .utils.pandaseq import pair_files
from abutils.utils.log import get_logger
from abutils.utils.pipeline import list_files, make_dir
import os
import sys

# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
# and associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#


from __future__ import absolute_import, division, print_function, unicode_literals






logger = get_logger('preprocess')


def quality_trim(input_directory=None, output_directory=None,
        quality_cutoff=20, length_cutoff=50,
        quality_type='sanger', compress_output=True, file_pairs=None,

        singles_directory=None, nextseq=False, paired_reads=True,