broadinstitute/viral-ngs — pull request #34 by iljungr (2014-11-11 03:47:41+00:00)
Title: Irwin taxon filter

- Implemented deplete_blastn. It takes a single fastq input file rather than two. It runs noBlastHits_v3, but the call to mergeShuffledFastqSeqs.pl has been separated out into its own utility. Got rid of the 3-part version of deplete_blastn.

- Created read_utils.py at top level of viral_ngs (I didn't put it in utils because it has command-line utilities for our user, rather than python utilities for us). It contains the following 4 utilities:
1) purge_unmated, a wrapper around mergeShuffledFastqSeqs.pl. Note that the latter assumes that corresponding reads are of the form SEQID/1 and SEQID/2.
2) fastq_to_fasta. I didn't use prinseq because if it fails it doesn't return an error, and might even create a 0-length file. Instead, I used BioPython. One consequence of that is that the output sequences might be split by newlines. That should be fine for its use in deplete_blastn, but if we were to convert to fasta and then use the unix split utility it would be a problem. I don't know how to fix this using BioPython's output routine, but of course it would be trivial to write our own (or postprocess the BioPython output) if we need to.
3) fastq_to_bam. Requires either a sample name or a header text file; in the latter case, it calls rehead after FastqToSam. Rather than hardcoding many separate optional arguments I included one, picardOptions, which can contain any number of options to be passed to picard's FastqToSam. The recipe called for passing in CREATE_MD5_FILE=True. However, since the md5 file won't be correct if we rehead, I didn't do it by default, and I only allow the user to include it in picardOptions if there's no header text file. If desired, the user can run md5sum after calling fastq_to_bam.
4) bam_to_fastq. Has optional outHeader argument to save header in a text file. Also has picardOptions optional argument.

- Added a class TestCaseWithTmp(unittest.TestCase) to test/__init__.py to do the tmpDir setup and tear down so the code needn't be duplicated in every one of our unit tests. Any test that needs to do additional setup or tear down should call the base class method as well.

- Added tests for DepleteBlastn and the four utilities in read_utils.

- Deleted any remaining recipe comments from taxon_filter.