<commit_before>#!/usr/bin/env python3

import binary_utils
import os
import sys
import logging
import subprocess
import shutil

logger = logging.getLogger(__name__)


class Assembler:

    @classmethod
    def name(cls):
        return cls.__name__


    def __init__(self):
        self.assembler_wrapper = self._assembler_wrapper()
        self.assembler_bin = self._assembler_bin()
        self.cmd_line = None

    def _assembler_wrapper(self):
        """
        return the assembler wrapper path
        """
        raise NotImplementedError( "Should have implemented this method: '%s'" % self._assembler_wrapper.__name__ )


    def _assembler_bin(self):
        """
        return the assembler bin path
        """
        raise NotImplementedError( "Should have implemented this method: '%s'" % self._assembler_bin.__name__ )


    def build_command_line(self, fastq_file, workdir, read_correction='no', cpu=1, *args, **kwargs):
        """
        Build the command line to run (*args & **kwargs are potential parameters)
        The command must run in self.workdir with a number of cpu limited to self.cpu.
        It also has to take self.fastq_file as input file
        self.read_correction is a switch to take into account
        !!!! Important !!!!
        This method has to set the self.fasta_file which is the results of the assembly
        """

        raise NotImplementedError( "Should have implemented this method: '%s'" % self.build_command_line.__name__ )

    def run(self):
        """
        Check I/O and simply run the command
        """

        if self.cmd_line is None:
            logger.fatal('You have to call "build_command_line" method before "run" method')
            sys.exit("No command line available")

        if self.fastq_file is None or not os.path.isfile(self.fastq_file):
            logger.fatal('The input reads file does not exists:%s' % self.fastq_file)
            sys.exit("Can't assemble %s" % self.fastq_file)

        if self.workdir is None:
            logger.debug("Workdir is not set")
            sys.exit("Can't assemble %s" % self.fastq_file)

        elif os.path.isdir(self.workdir):
            logger.debug("Remove previous assembler working dir before assembling:%s" % self.workdir)
            shutil.rmtree(self.workdir)
        os.mkdir(self.workdir)

        subprocess.check_call(self.cmd_line, shell=True, bufsize=0)

        return self.fasta_file


class SGA(Assembler):<commit_msg>Log the command line on debug mode<commit_after>#!/usr/bin/env python3

import binary_utils
import os
import sys
import logging
import subprocess
import shutil

logger = logging.getLogger(__name__)


class Assembler:

    @classmethod
    def name(cls):
        return cls.__name__


    def __init__(self):
        self.assembler_wrapper = self._assembler_wrapper()
        self.assembler_bin = self._assembler_bin()
        self.cmd_line = None

    def _assembler_wrapper(self):
        """
        return the assembler wrapper path
        """
        raise NotImplementedError( "Should have implemented this method: '%s'" % self._assembler_wrapper.__name__ )


    def _assembler_bin(self):
        """
        return the assembler bin path
        """
        raise NotImplementedError( "Should have implemented this method: '%s'" % self._assembler_bin.__name__ )


    def build_command_line(self, fastq_file, workdir, read_correction='no', cpu=1, *args, **kwargs):
        """
        Build the command line to run (*args & **kwargs are potential parameters)
        The command must run in self.workdir with a number of cpu limited to self.cpu.
        It also has to take self.fastq_file as input file
        self.read_correction is a switch to take into account
        !!!! Important !!!!
        This method has to set the self.fasta_file which is the results of the assembly
        """

        raise NotImplementedError( "Should have implemented this method: '%s'" % self.build_command_line.__name__ )

    def run(self):
        """
        Check I/O and simply run the command
        """

        if self.cmd_line is None:
            logger.fatal('You have to call "build_command_line" method before "run" method')
            sys.exit("No command line available")

        if self.fastq_file is None or not os.path.isfile(self.fastq_file):
            logger.fatal('The input reads file does not exists:%s' % self.fastq_file)
            sys.exit("Can't assemble %s" % self.fastq_file)

        if self.workdir is None:
            logger.debug("Workdir is not set")
            sys.exit("Can't assemble %s" % self.fastq_file)

        elif os.path.isdir(self.workdir):
            logger.debug("Remove previous assembler working dir before assembling:%s" % self.workdir)
            shutil.rmtree(self.workdir)
        os.mkdir(self.workdir)

        logger.debug("CMD: %s" % self.cmd_line)
        subprocess.check_call(self.cmd_line, shell=True, bufsize=0)

        return self.fasta_file


class SGA(Assembler):
{'fraction_non_alphanumeric': 0.09290709290709291, 'fraction_numerical': 0.0011988011988011988, 'mean_word_length': 2.6196673897324656, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6484421', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1424, 'n_words': 434}