Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Commit

Permalink
resolve issue 1682
Browse files Browse the repository at this point in the history
  • Loading branch information
ekopylova committed Oct 2, 2014
1 parent 760c9e0 commit 82c28cc
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
2 changes: 1 addition & 1 deletion qiime/workflow/upstream.py
Expand Up @@ -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']
Expand Down
@@ -0,0 +1,2 @@
pick_otus:otu_picking_method usearch_ref
pick_otus:suppress_reference_chimera_detection True
12 changes: 11 additions & 1 deletion scripts/pick_closed_reference_otus.py
Expand Up @@ -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 "
Expand All @@ -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'] = ""

Expand Down
55 changes: 54 additions & 1 deletion tests/test_workflow/test_upstream.py
Expand Up @@ -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([])
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 82c28cc

Please sign in to comment.