Пример #1
0
    def __call__(self, seq_path, result_path=None, log_path=None):
        """Returns dict mapping {seq_id:(taxonomy, confidence)} for
        each seq.

        Parameters:
        seq_path: path to file of sequences
        result_path: path to file of results. If specified, dumps the
            result to the desired path instead of returning it.
        log_path: path to log, which should include dump of params.
        """

        if log_path:
            self.writeLog(log_path)

        reference_sequences_fp = self.Params['reference_sequences_fp']
        assert reference_sequences_fp, \
            "Must provide reference_sequences_fp when calling an RtaxTaxonAssigner."

        id_to_taxonomy_fp = self.Params['id_to_taxonomy_fp']
        assert id_to_taxonomy_fp, \
            "Must provide id_to_taxonomy_fp when calling an RtaxTaxonAssigner."

        # delimiter = self.Params['delimiter']
        read_1_seqs_fp = self.Params['read_1_seqs_fp']
        assert read_1_seqs_fp, \
            "Must provide read_1_seqs_fp when calling an RtaxTaxonAssigner."

        # following params may all be null

        read_2_seqs_fp = self.Params['read_2_seqs_fp']
        single_ok = self.Params['single_ok']
        no_single_ok_generic = self.Params['no_single_ok_generic']
        header_id_regex = self.Params['header_id_regex']
        assert header_id_regex, \
            "Must not provide empty header_id_regex when calling an RtaxTaxonAssigner; leave unset"\
            "to use default if in doubt."

        read_id_regex = self.Params['read_id_regex']
        amplicon_id_regex = self.Params['amplicon_id_regex']

        # seq_file = open(seq_path, 'r')

        results = rtax.assign_taxonomy(
            seq_path,
            reference_sequences_fp,
            id_to_taxonomy_fp,
            read_1_seqs_fp,
            read_2_seqs_fp,
            single_ok=single_ok,
            no_single_ok_generic=no_single_ok_generic,
            header_id_regex=header_id_regex,
            read_id_regex=read_id_regex,
            amplicon_id_regex=amplicon_id_regex,
            output_fp=result_path,
            log_path=log_path,
            base_tmp_dir=get_qiime_temp_dir())

        return results
Пример #2
0
    def __call__(self, seq_path, result_path=None, log_path=None):
        """Returns dict mapping {seq_id:(taxonomy, confidence)} for
        each seq.

        Parameters:
        seq_path: path to file of sequences
        result_path: path to file of results. If specified, dumps the
            result to the desired path instead of returning it.
        log_path: path to log, which should include dump of params.
        """

        if log_path:
            self.writeLog(log_path)

        reference_sequences_fp = self.Params['reference_sequences_fp']
        assert reference_sequences_fp, \
            "Must provide reference_sequences_fp when calling an RtaxTaxonAssigner."

        id_to_taxonomy_fp = self.Params['id_to_taxonomy_fp']
        assert id_to_taxonomy_fp, \
            "Must provide id_to_taxonomy_fp when calling an RtaxTaxonAssigner."

        # delimiter = self.Params['delimiter']
        read_1_seqs_fp = self.Params['read_1_seqs_fp']
        assert read_1_seqs_fp, \
            "Must provide read_1_seqs_fp when calling an RtaxTaxonAssigner."

        # following params may all be null

        read_2_seqs_fp = self.Params['read_2_seqs_fp']
        single_ok = self.Params['single_ok']
        no_single_ok_generic = self.Params['no_single_ok_generic']
        header_id_regex = self.Params['header_id_regex']
        assert header_id_regex, \
            "Must not provide empty header_id_regex when calling an RtaxTaxonAssigner; leave unset"\
            "to use default if in doubt."

        read_id_regex = self.Params['read_id_regex']
        amplicon_id_regex = self.Params['amplicon_id_regex']

        # seq_file = open(seq_path, 'r')

        results = rtax.assign_taxonomy(
            seq_path, reference_sequences_fp, id_to_taxonomy_fp,
            read_1_seqs_fp, read_2_seqs_fp, single_ok=single_ok, no_single_ok_generic=no_single_ok_generic,
            header_id_regex=header_id_regex, read_id_regex=read_id_regex,
            amplicon_id_regex=amplicon_id_regex, output_fp=result_path,
            log_path=log_path, base_tmp_dir=get_qiime_temp_dir())

        return results
Пример #3
0
 def test_single_end_classification(self):
     self._paths_to_clean_up += cleanAll(self.read_1_seqs_fp)
     result = assign_taxonomy(self.input_seqs_fp, self.reference_seqs_fp, self.id_to_taxonomy_fp, self.read_1_seqs_fp, None ,header_id_regex="\\S+\\s+(\\S+?)\/")
     self.assertEqual(result, rtax_expected_result_single)
Пример #4
0
 def test_paired_end_classification_with_fallback(self):
     self._paths_to_clean_up += cleanAll(self.read_1_seqs_fp)
     self._paths_to_clean_up += cleanAll(self.read_2_seqs_fp)
     result = assign_taxonomy(self.input_seqs_fp, self.reference_seqs_fp, self.id_to_taxonomy_fp, self.read_1_seqs_fp, self.read_2_seqs_fp,single_ok=True,header_id_regex="\\S+\\s+(\\S+?)\/")
     self.assertEqual(result, rtax_expected_result_paired_with_fallback)