Пример #1
0
    def test_detect_and_output_transporters_via_signalp_when_no_sigpeps(self):
        """
        Test optional transporter prediction is generated even if
        abortion of script due to no signal peptides
        """

        test_fas_no_sigpep = os.path.join(self.tmp_dir, 'test_no_sigpep.fas')
        tmp_dir_to_test_removal = os.path.join(self.tmp_dir, 'intermediate_tmp_2')
        os.mkdir(tmp_dir_to_test_removal)
        rename_mappings = {'KGQ972831Candidaalbicans': 'KGQ972831Candidaalbicans'}

        with self.assertRaises(SystemExit):
            _, _, _ = utils.signalp(test_fas_no_sigpep,
                                    tmp_dir_to_test_removal,
                                    rename_mappings,
                                    'actual',
                                    trans=2)
        self.assertFalse(os.path.exists(tmp_dir_to_test_removal))

        expected_transporters = os.path.join(self.tmp_dir,
                                             'expected_no_sigpep_transporters.fas')

        actual_transporters = 'actual_predicted_transporters.fas'
        self.assertTrue(actual_transporters)
        self.compare_files(actual_transporters, expected_transporters)
Пример #2
0
    def test_signalp_func(self):
        """
        Test that the signalp function correctly parses signalp output
        """

        expected_accessions_with_sig_pep = ['PM50_trimmed_paired_qual32_contig_10408',
                                            'R1qual32.paired_(paired)_contig_1567',
                                            'PM50_trimmed_paired_qual32_contig_16575',
                                            'PM50_trimmed_paired_qual32_contig_18412',
                                            'PM50_trimmed_paired_qual32_contig_12144',
                                            'R1qual32.paired_(paired)_contig_2534']

        expected_mature_seq_fp = os.path.join(self.tmp_dir, 'expected_signalp_mature_seqs.fasta')

        expected_full_sequences_with_sigpep_fp = os.path.join(self.tmp_dir,
                                                              'expected_signalp_full_seqs_with_sigpep.fasta')

        actual_mature_seqs_fp, \
        actual_accessions_with_sig_pep, \
        actual_full_sequences_with_sigpep_fp = utils.signalp(self.test_fas, '', '', '')

        self.assertEqual(actual_accessions_with_sig_pep, expected_accessions_with_sig_pep)

        self.compare_files(actual_full_sequences_with_sigpep_fp,
                           expected_full_sequences_with_sigpep_fp)

        self.compare_files(actual_mature_seqs_fp, expected_mature_seq_fp)
Пример #3
0
    def test_pipe_aborts_in_signalp_step_when_no_sigpeps(self):
        """
        Test execution abortion if there are no signal peptides detected
        """

        test_fas_no_sigpep = os.path.join(self.tmp_dir, 'test_no_sigpep.fas')
        tmp_dir_to_test_removal = os.path.join(self.tmp_dir, 'intermediate_tmp')
        os.mkdir(tmp_dir_to_test_removal)

        with self.assertRaises(SystemExit):
            _, _, _ = utils.signalp(test_fas_no_sigpep,
                                    tmp_dir_to_test_removal,
                                    '',
                                    '')

        self.assertFalse(os.path.exists(tmp_dir_to_test_removal))
Пример #4
0
def main(argv):
    """
    Main execution of the program in the proper order
    input: argv from arg parser
    """

    utils.check_dependencies(check_run=argv.check, verbose=argv.verbose)

    input_file = argv.input_file

    if argv.run_name is False:
        basename = os.path.basename(input_file)
        run_name = os.path.splitext(basename)[0]
    else:
        run_name = argv.run_name

    tmp_dir = os.path.join(os.getcwd(), 'intermediate_outputs_' + run_name)

    try:
        os.makedirs(tmp_dir)
    except OSError:
        if os.path.exists(tmp_dir):
            warnings.warn('\n\nintermediate output dir: {0} exists '
                          'overwriting contents\n'.format(tmp_dir))
        else:
            raise OSError('Error creating intermediate '
                          'output dir: {0}'.format(tmp_dir))

    rename_mappings, formatted_fasta_fp = utils.format_fasta(
        input_file, tmp_dir, verbose=argv.verbose)

    mature_seqs_fp, \
    accessions_with_sig_pep, \
    full_sequences_with_sigpep_fp = utils.signalp(formatted_fasta_fp,
                                                  tmp_dir,
                                                  rename_mappings,
                                                  run_name,
                                                  trans=argv.trans,
                                                  verbose=argv.verbose)

    if argv.trans:
        utils.detect_and_output_transporters(formatted_fasta_fp,
                                             rename_mappings,
                                             tmp_dir,
                                             run_name,
                                             mature_seqs=mature_seqs_fp,
                                             verbose=argv.verbose,
                                             tm_threshold=argv.trans)

    accesions_no_tm_in_mature_seq = utils.tmhmm(mature_seqs_fp,
                                                verbose=argv.verbose)

    secreted_accessions = utils.targetp(full_sequences_with_sigpep_fp,
                                        plant=False,
                                        verbose=argv.verbose)

    extracellular_accessions = utils.wolfpsort(formatted_fasta_fp,
                                               verbose=argv.verbose)

    if argv.permissive:
        conservative_flag = False
    else:
        conservative_flag = True

    secretome_accessions = utils.secretome(accessions_with_sig_pep,
                                           accesions_no_tm_in_mature_seq,
                                           secreted_accessions,
                                           extracellular_accessions,
                                           conservative=conservative_flag,
                                           verbose=argv.verbose)

    utils.generate_output(formatted_fasta_fp,
                          secretome_accessions,
                          rename_mappings,
                          run_name,
                          conservative=conservative_flag,
                          verbose=argv.verbose)

    if not argv.nocleanup:
        shutil.rmtree(tmp_dir)
Пример #5
0
def main(argv):
    """
    Main execution of the program in the proper order
    input: argv from arg parser
    """


    utils.check_dependencies(check_run=argv.check,
                             verbose=argv.verbose)

    input_file = argv.input_file

    if argv.run_name is False:
        basename = os.path.basename(input_file)
        run_name = os.path.splitext(basename)[0]
    else:
        run_name = argv.run_name

    tmp_dir = os.path.join(os.getcwd(), 'intermediate_outputs_'+run_name)

    try:
        os.makedirs(tmp_dir)
    except OSError:
        if os.path.exists(tmp_dir):
            warnings.warn('\n\nintermediate output dir: {0} exists '
                          'overwriting contents\n'.format(tmp_dir))
        else:
            raise OSError('Error creating intermediate '
                          'output dir: {0}'.format(tmp_dir))



    rename_mappings, formatted_fasta_fp = utils.format_fasta(input_file,
                                                             tmp_dir,
                                                             verbose=argv.verbose)

    mature_seqs_fp, \
    accessions_with_sig_pep, \
    full_sequences_with_sigpep_fp = utils.signalp(formatted_fasta_fp,
                                                  tmp_dir,
                                                  rename_mappings,
                                                  run_name,
                                                  trans=argv.trans,
                                                  verbose=argv.verbose)

    if argv.trans:
        utils.detect_and_output_transporters(formatted_fasta_fp,
                                             rename_mappings,
                                             tmp_dir,
                                             run_name,
                                             mature_seqs=mature_seqs_fp,
                                             verbose=argv.verbose,
                                             tm_threshold=argv.trans)


    accesions_no_tm_in_mature_seq = utils.tmhmm(mature_seqs_fp,
                                                verbose=argv.verbose)

    secreted_accessions = utils.targetp(full_sequences_with_sigpep_fp,
                                        plant=False,
                                        verbose=argv.verbose)


    extracellular_accessions = utils.wolfpsort(formatted_fasta_fp,
                                               verbose=argv.verbose)

    if argv.permissive:
        conservative_flag = False
    else:
        conservative_flag = True

    secretome_accessions = utils.secretome(accessions_with_sig_pep,
                                           accesions_no_tm_in_mature_seq,
                                           secreted_accessions,
                                           extracellular_accessions,
                                           conservative=conservative_flag,
                                           verbose=argv.verbose)

    utils.generate_output(formatted_fasta_fp,
                          secretome_accessions,
                          rename_mappings,
                          run_name,
                          conservative=conservative_flag,
                          verbose=argv.verbose)


    if not argv.nocleanup:
        shutil.rmtree(tmp_dir)