Пример #1
0
    def check_binaries(self):
        """Check the required binaries.
        There are six required binaries to perform the complete analysis (blat, gfserver,
        gfclient, fatotwobit, cutadapt, jellyfish). Each binary is checked whether
        the path provided in the configuration file has an executable file attached or
        if no path was provided that the binary is on the path. Cutadapt and Jellyfish
        are also tested using small set of hardcoded data.

        Args:
            None
        Returns:
            None
        Raises:
            None
        """

        binaries = ('blat', 
                    'gfserver', 
                    'gfclient', 
                    'fatotwobit', 
                    'cutadapt', 
                    'jellyfish')
        for binaryName in binaries:
            binaryPath = self.get_param(binaryName)
            if binaryPath is not None:
                binaryCheck = utils.which(binaryPath)  # Use the binary path specified in the config file.
            else:
                binaryCheck = utils.which(binaryName)  # Perform a which on the server to see if the binary is in the path.
                self.set_param(binary, binaryCheck)  # Store the result in the opts dictionary.
            if not binaryCheck:  # No binary found or specified. Throw an error.
                print 'Missing path/executable for', binaryName
                utils.log(self.loggingName, 'error', 'Missing path/executable for %s' % binaryName)
                sys.exit(1)
            utils.log(self.loggingName, 'info', '%s path = %s' % (binaryName, binaryCheck))
        utils.log(self.loggingName, 'info', 'All the required binaries have been checked successfully!')

        # Test cutadapt and jellyfish binaries
        testDir = os.path.join(self.paths['analysis'], 'bin_test')
        testFq = os.path.join(testDir, 'test.fq')
        if not os.path.exists(testDir):
            os.makedirs(testDir)

        fqFile = open(testFq, 'w')
        fqFile.write("@H91H9ADXX140327:1:2102:19465:23489/2\nCACCCCCACTGAAAAAGATGAGTATGCCTGCCGTGTGAACCATGTGACTTTACAATCTGCATATTGGGATTGTCAGGGAATGTTCTTAAAGATC\n+\n69EEEFBAFBFABCCFFBEFFFDDEEHHDGH@FEFEFCAGGCDEEEBGEEBCGBCCGDFGCBBECFFEBDCDCEDEEEAABCCAEC@>>BB?@C\n@H91H9ADXX140327:2:2212:12198:89759/2\nTCTTGTACTACACTGAATTCACCCCCACTGAAAAAGATGAGTATGCCTGCCGTGTGAACCATGTGACTTTACAATCTGCATATTGGGATTGTCAGGGA\n+\nA@C>C;?AB@BBACDBCAABBDDCDDCDEFCDDDDEBBFCEABCGDBDEEF>@GBGCEDGEDGCGFECAACFEGDFFGFECB@DFGCBABFAECEB?=")
        fqFile.close()

        cleanFq, returnCode = utils.test_cutadapt(testFq, self.get_param('cutadapt'), self.get_param('cutadapt_config_file'))
        if cleanFq:
            utils.log(self.loggingName, 'info', 'Test cutadapt ran successfully')
            jfish_prgm, rc = utils.test_jellyfish(self.get_param('jellyfish'), cleanFq, testDir)
            if returnCode != 0:
                utils.log(self.loggingName, 'error', '%s unable to run successfully, exit code %s. Check installation and correct version.' % (jfish_prgm, str(returnCode)))
                sys.exit(1)
            else:
                utils.log(self.loggingName, 'info', 'Test jellyfish ran successfully')
        else:
            utils.log(self.loggingName, 'error', 'Cutadapt failed to run, exit code %s. Check installation and version.' % str(returnCode))
            sys.exit(1)
        shutil.rmtree(testDir)  # Remove the test directory.
Пример #2
0
    def check_binaries(self):
        # Binaries required for operation: blat, gfserver, gfclient, fatotwobit, cutadapt, jellyfish
        binaries = ('blat', 'gfserver', 'gfclient', 'fatotwobit', 'cutadapt',
                    'jellyfish')

        for binary_name in binaries:
            binary_path = self.get_param(binary_name)
            binary_check = None
            if binary_path is not None:
                binary_check = utils.which(binary_path)
            else:
                binary_check = utils.which(binary_name)
                self.set_param(binary_name, binary_check)
            if not binary_check:
                print 'Missing path/executable for', binary_name
                sys.exit(2)
            utils.log(self.logging_name, 'debug',
                      '%s path = %s' % (binary_name, binary_check))

        utils.log(self.logging_name, 'debug',
                  'All the required binaries have been check successfully!')

        # Test cutadapt and jellyfish binaries
        test_dir = os.path.join(self.paths['analysis'], 'binary_test')
        test_fq = os.path.join(test_dir, 'test.fq')
        if not os.path.exists(test_dir):
            os.makedirs(test_dir)

        fq_file = open(test_fq, 'w')
        fq_file.write(
            "@H91H9ADXX140327:1:2102:19465:23489/2\nCACCCCCACTGAAAAAGATGAGTATGCCTGCCGTGTGAACCATGTGACTTTACAATCTGCATATTGGGATTGTCAGGGAATGTTCTTAAAGATC\n+\n69EEEFBAFBFABCCFFBEFFFDDEEHHDGH@FEFEFCAGGCDEEEBGEEBCGBCCGDFGCBBECFFEBDCDCEDEEEAABCCAEC@>>BB?@C\n@H91H9ADXX140327:2:2212:12198:89759/2\nTCTTGTACTACACTGAATTCACCCCCACTGAAAAAGATGAGTATGCCTGCCGTGTGAACCATGTGACTTTACAATCTGCATATTGGGATTGTCAGGGA\n+\nA@C>C;?AB@BBACDBCAABBDDCDDCDEFCDDDDEBBFCEABCGDBDEEF>@GBGCEDGEDGCGFECAACFEGDFFGFECB@DFGCBABFAECEB?="
        )
        fq_file.close()

        clean_fq, return_code = utils.test_cutadapt(
            test_fq, self.get_param('cutadapt'),
            self.get_param('cutadapt_config_file'))
        if clean_fq:
            utils.log(self.logging_name, 'info',
                      'Test cutadapt ran successfully')
            jfish_prgm, return_code = utils.test_jellyfish(
                self.opts['jellyfish'], clean_fq, test_dir)
            if return_code != 0:
                utils.log(
                    self.logging_name, 'error',
                    '%s unable to run successfully, exit code %s. Check installation and correct version.'
                    % (jfish_prgm, str(return_code)))
                sys.exit(2)
            else:
                utils.log(self.logging_name, 'info',
                          'Test jellyfish ran successfully')
        else:
            utils.log(
                self.logging_name, 'error',
                'Cutadapt failed to run, exit code %s. Check installation and version.'
                % str(return_code))
            sys.exit(2)
        shutil.rmtree(test_dir)
Пример #3
0
    def check_binaries(self):
        # Binaries required for operation: blat, gfserver, gfclient, fatotwobit, cutadapt, jellyfish
        binaries = ('blat',
                    'gfserver',
                    'gfclient',
                    'fatotwobit',
                    'cutadapt',
                    'jellyfish')

        for binary_name in binaries:
            binary_path = self.get_param(binary_name)
            binary_check = None
            if binary_path is not None:
                binary_check = utils.which(binary_path)
            else:
                binary_check = utils.which(binary_name)
                self.set_param(binary_name, binary_check)
            if not binary_check:
                print 'Missing path/executable for', binary_name
                sys.exit(2)
            utils.log(self.logging_name, 'debug', '%s path = %s' % (binary_name, binary_check))

        utils.log(self.logging_name, 'debug', 'All the required binaries have been check successfully!')

        # Test cutadapt and jellyfish binaries
        test_dir = os.path.join(self.paths['analysis'], 'binary_test')
        test_fq = os.path.join(test_dir, 'test.fq')
        if not os.path.exists(test_dir):
            os.makedirs(test_dir)

        fq_file = open(test_fq, 'w')
        fq_file.write("@H91H9ADXX140327:1:2102:19465:23489/2\nCACCCCCACTGAAAAAGATGAGTATGCCTGCCGTGTGAACCATGTGACTTTACAATCTGCATATTGGGATTGTCAGGGAATGTTCTTAAAGATC\n+\n69EEEFBAFBFABCCFFBEFFFDDEEHHDGH@FEFEFCAGGCDEEEBGEEBCGBCCGDFGCBBECFFEBDCDCEDEEEAABCCAEC@>>BB?@C\n@H91H9ADXX140327:2:2212:12198:89759/2\nTCTTGTACTACACTGAATTCACCCCCACTGAAAAAGATGAGTATGCCTGCCGTGTGAACCATGTGACTTTACAATCTGCATATTGGGATTGTCAGGGA\n+\nA@C>C;?AB@BBACDBCAABBDDCDDCDEFCDDDDEBBFCEABCGDBDEEF>@GBGCEDGEDGCGFECAACFEGDFFGFECB@DFGCBABFAECEB?=")
        fq_file.close()

        clean_fq, return_code = utils.test_cutadapt(test_fq, self.get_param('cutadapt'), self.get_param('cutadapt_config_file'))
        if clean_fq:
            utils.log(self.logging_name, 'info', 'Test cutadapt ran successfully')
            jfish_prgm, return_code = utils.test_jellyfish(self.opts['jellyfish'], clean_fq, test_dir)
            if return_code != 0:
                utils.log(self.logging_name, 'error', '%s unable to run successfully, exit code %s. Check installation and correct version.' % (jfish_prgm, str(return_code)))
                sys.exit(2)
            else:
                utils.log(self.logging_name, 'info', 'Test jellyfish ran successfully')
        else:
            utils.log(self.logging_name, 'error', 'Cutadapt failed to run, exit code %s. Check installation and version.' % str(return_code))
            sys.exit(2)
        shutil.rmtree(test_dir)
Пример #4
0
    def check_binaries(self):
        """Check the required binaries.
        There are six required binaries to perform the complete analysis (blat, gfserver,
        gfclient, fatotwobit, cutadapt, jellyfish). Each binary is checked whether
        the path provided in the configuration file has an executable file attached or
        if no path was provided that the binary is on the path. Cutadapt and Jellyfish
        are also tested using small set of hardcoded data.

        Args:
            None
        Returns:
            None
        Raises:
            None
        """

        binaries = ('blat', 'gfserver', 'gfclient', 'fatotwobit', 'cutadapt',
                    'jellyfish')
        for binaryName in binaries:
            binaryPath = self.get_param(binaryName)
            if binaryPath is not None:
                binaryCheck = utils.which(
                    binaryPath
                )  # Use the binary path specified in the config file.
            else:
                binaryCheck = utils.which(
                    binaryName
                )  # Perform a which on the server to see if the binary is in the path.
                self.set_param(
                    binaryName,
                    binaryCheck)  # Store the result in the opts dictionary.
            if not binaryCheck:  # No binary found or specified. Throw an error.
                print 'Missing path/executable for', binaryName
                utils.log(self.loggingName, 'error',
                          'Missing path/executable for %s' % binaryName)
                sys.exit(1)
            utils.log(self.loggingName, 'info',
                      '%s path = %s' % (binaryName, binaryCheck))
        utils.log(self.loggingName, 'info',
                  'All the required binaries have been checked successfully!')

        # Test cutadapt and jellyfish binaries
        testDir = os.path.join(self.paths['analysis'], 'bin_test')
        testFq = os.path.join(testDir, 'test.fq')
        if not os.path.exists(testDir):
            os.makedirs(testDir)

        fqFile = open(testFq, 'w')
        fqFile.write(
            "@H91H9ADXX140327:1:2102:19465:23489/2\nCACCCCCACTGAAAAAGATGAGTATGCCTGCCGTGTGAACCATGTGACTTTACAATCTGCATATTGGGATTGTCAGGGAATGTTCTTAAAGATC\n+\n69EEEFBAFBFABCCFFBEFFFDDEEHHDGH@FEFEFCAGGCDEEEBGEEBCGBCCGDFGCBBECFFEBDCDCEDEEEAABCCAEC@>>BB?@C\n@H91H9ADXX140327:2:2212:12198:89759/2\nTCTTGTACTACACTGAATTCACCCCCACTGAAAAAGATGAGTATGCCTGCCGTGTGAACCATGTGACTTTACAATCTGCATATTGGGATTGTCAGGGA\n+\nA@C>C;?AB@BBACDBCAABBDDCDDCDEFCDDDDEBBFCEABCGDBDEEF>@GBGCEDGEDGCGFECAACFEGDFFGFECB@DFGCBABFAECEB?="
        )
        fqFile.close()

        cleanFq, returnCode = utils.test_cutadapt(
            testFq, self.get_param('cutadapt'),
            self.get_param('cutadapt_config_file'))
        if cleanFq:
            utils.log(self.loggingName, 'info',
                      'Test cutadapt ran successfully')
            jfish_prgm, rc = utils.test_jellyfish(self.get_param('jellyfish'),
                                                  cleanFq, testDir)
            if returnCode != 0:
                utils.log(
                    self.loggingName, 'error',
                    '%s unable to run successfully, exit code %s. Check installation and correct version.'
                    % (jfish_prgm, str(returnCode)))
                sys.exit(1)
            else:
                utils.log(self.loggingName, 'info',
                          'Test jellyfish ran successfully')
        else:
            utils.log(
                self.loggingName, 'error',
                'Cutadapt failed to run, exit code %s. Check installation and version.'
                % str(returnCode))
            sys.exit(1)
        shutil.rmtree(testDir)  # Remove the test directory.