diff --git a/qiime/workflow/upstream.py b/qiime/workflow/upstream.py index 6d434aceb0..4298125158 100644 --- a/qiime/workflow/upstream.py +++ b/qiime/workflow/upstream.py @@ -332,7 +332,7 @@ def run_pick_closed_reference_otus( # confirm that a valid otu picking method was supplied before doing # any work reference_otu_picking_methods = ['blast', 'uclust_ref', 'usearch61_ref', - 'sortmerna'] + 'usearch_ref', 'sortmerna'] try: otu_picking_method = params['pick_otus']['otu_picking_method'] diff --git a/qiime_test_data/pick_closed_reference_otus/usearch5.2_params.txt b/qiime_test_data/pick_closed_reference_otus/usearch5.2_params.txt new file mode 100644 index 0000000000..a87778ed14 --- /dev/null +++ b/qiime_test_data/pick_closed_reference_otus/usearch5.2_params.txt @@ -0,0 +1,2 @@ +pick_otus:otu_picking_method usearch_ref +pick_otus:suppress_reference_chimera_detection True diff --git a/scripts/pick_closed_reference_otus.py b/scripts/pick_closed_reference_otus.py index fe8869bde6..d372c39494 100755 --- a/scripts/pick_closed_reference_otus.py +++ b/scripts/pick_closed_reference_otus.py @@ -50,6 +50,15 @@ "Pick OTUs, assign taxonomy, and create an OTU table against a reference set of OTUs using usearch_ref. ALWAYS SPECIFY ABSOLUTE FILE PATHS (absolute path represented here as $PWD, but will generally look something like /home/ubuntu/my_analysis/).", "%prog -i $PWD/seqs.fna -r $PWD/refseqs.fna -o $PWD/otus_usearch/ -p $PWD/usearch_params.txt -t $PWD/taxa.txt")) +script_info['script_usage'].append( + ("", + "Pick OTUs using usearch_ref, assign taxonomy, and create an OTU table " + "against a reference set of OTUs using usearch_ref. ALWAYS SPECIFY ABSOLUTE " + "FILE PATHS (absolute path represented here as $PWD, but will generally look " + "something like /home/ubuntu/my_analysis/).", + "%prog -i $PWD/seqs.fna -r $PWD/refseqs.fna -o $PWD/otus_usearch_ref/ " + "-p $PWD/usearch5.2_params.txt -t $PWD/taxa.txt")) + script_info['script_usage'].append( ("", "Pick OTUs, assign taxonomy, and create an OTU table against a " @@ -64,7 +73,8 @@ '$PWD/otus/', '$PWD/otus_w_tax/', '$PWD/otus_usearch/', - '$PWD/otus_sortmerna/'] + '$PWD/otus_sortmerna/', + '$PWD/otus_usearch_ref/'] script_info['output_description'] = "" diff --git a/tests/test_workflow/test_upstream.py b/tests/test_workflow/test_upstream.py index 614e6c6a0a..0ad4d5ca66 100755 --- a/tests/test_workflow/test_upstream.py +++ b/tests/test_workflow/test_upstream.py @@ -44,7 +44,7 @@ def setUp(self): self.test_out = mkdtemp(dir=tmp_dir, prefix='core_qiime_analyses_test_', suffix='') - self.dirs_to_remove.append(self.test_out) + self.dirs_to_remove.append("self.test_out") self.qiime_config = load_qiime_config() self.params = parse_qiime_parameters([]) @@ -159,6 +159,59 @@ def test_run_pick_closed_reference_otus_parallel(self): log_fp = glob(join(self.test_out, 'log*.txt'))[0] self.assertTrue(getsize(log_fp) > 0) + def test_run_pick_closed_reference_otus_usearch(self): + """run_pick_closed_reference_otus generates expected results + using usearch_ref""" + + self.params['pick_otus']['otu_picking_method'] = "usearch_ref" + self.params['pick_otus']['suppress_reference_chimera_detection'] = "" + + run_pick_closed_reference_otus( + self.test_data['seqs'][0], + self.test_data['refseqs'][0], + self.test_out, + self.test_data['refseqs_tax'][0], + call_commands_serially, + self.params, + self.qiime_config, + parallel=False, + status_update_callback=no_status_updates) + + input_file_basename = splitext(split(self.test_data['seqs'][0])[1])[0] + otu_map_fp = join(self.test_out, 'usearch_ref_picked_otus', + '%s_otus.txt' % input_file_basename) + otu_table_fp = join(self.test_out, 'otu_table.biom') + otu_table = load_table(otu_table_fp) + expected_sample_ids = ['f1', 'f2', 'f3', 'f4', 'p1', 'p2', 't1', 't2'] + self.assertItemsEqual(otu_table.ids(), expected_sample_ids) + + # Number of OTUs matches manually confirmed result + otu_map_lines = list(open(otu_map_fp)) + num_otus = len(otu_map_lines) + otu_map_otu_ids = [o.split()[0] for o in otu_map_lines] + self.assertEqual(num_otus, 2) + + # parse the otu table + otu_table = load_table(otu_table_fp) + expected_sample_ids = ['f1', 'f2', 'f3', 'f4', 'p1', 'p2', 't1', 't2'] + # sample IDs are as expected + self.assertItemsEqual(otu_table.ids(), expected_sample_ids) + # otu ids are as expected + self.assertItemsEqual(otu_table.ids(axis='observation'), + otu_map_otu_ids) + + # expected number of sequences in OTU table + number_seqs_in_otu_table = sum([v.sum() + for v in otu_table.iter_data()]) + self.assertEqual(number_seqs_in_otu_table, 116) + + # One tax assignment per otu + self.assertEqual(len(otu_table.metadata(axis='observation')), 2) + + # Check that the log file is created and has size > 0 + log_fp = glob(join(self.test_out, 'log*.txt'))[0] + self.assertTrue(getsize(log_fp) > 0) + def test_run_pick_closed_reference_otus_sortmerna(self): """run_pick_closed_reference_otus generates expected results using sortmerna