qiime/qiime — pull request #1025 by kylebittinger (2013-06-21 14:38:57+00:00)
Title: Fix spaces in Mothur taxonomy strings

This fixes a problem that we discovered while assigning taxonomy with Mothur on the QIIME 1.7 VM.

Problem
-----
Assigning taxonomy with Mothur on the QIIME 1.7 VM fails with a KeyError. A couple forum posts and at least one bug (closed) are related to this issue:

- https://groups.google.com/d/topic/qiime-forum/BFzZTXT2r4M/discussion
- https://groups.google.com/d/topic/qiime-forum/-eyC4Fwzt0w/discussion
- https://github.com/qiime/qiime/issues/1002
- https://github.com/qiime/qiime/issues/702

Output
-----
The traceback from QIIME and Mothur log file were similar to that described by Leah Reshef in the first forum post above.

Solution
-----
Mothur does not allow any spaces in the taxonomy string (see http://www.mothur.org/wiki/Taxonomy_outline). We now replace spaces with underscores and remove spaces surrounding the ";" taxon separators before giving the taxonomy string to Mothur.

Additionally, we avoid the KeyError if results are not produced by Mothur. Instead, we return a RuntimeError reporting that no output file was produced by Mothur.

Workaround
-----
This problem can also be solved by modifying the GreenGenes taxonomy files with a perl script. On the QIIME 1.7 VM, a user can run:

perl -pe's/; /;/g;s/ /_/g' ~/qiime_software/gg_otus-12_10-release/taxonomy/97_otu_taxonomy.txt > ~/qiime_software/gg_otus-12_10-release/taxonomy/97_otu_taxonomy_nospaces.txt

Then, the `97_otu_taxonomy_nospaces.txt` file can be used via the `--id_to_taxonomy_fp` option when running `assign_taxonomy.py`.