def create_interfaces(args, logger): """Check third-party executable dependencies exist and instantiate. The instantiated interfaces are returned. """ # Check for presence of third-party tools, by instantiating interfaces logger.info("Checking third-party packages:") logger.info("\tFastQC... (%s)", args.fastqc) fastqc_qc = fastqc.FastQC(args.fastqc) logger.info("\ttrim_quality... (%s)", args.trim_quality) trim_quality = seq_crumbs.Trim_Quality(args.trim_quality, logger) logger.info("\tjoin_paired_ends.py... (%s)", args.join_paired_ends) jpe = qiime.Join_Paired_Ends(args.join_paired_ends, logger) logger.info("\tconvert_format... (%s)", args.convert_format) convert_format = seq_crumbs.Convert_Format(args.convert_format, logger) logger.info("\tblastclust... (%s)", args.blastclust) blastclust = blast.Blastclust(args.blastclust) logger.info("\tmuscle... (%s)", args.muscle) muscle_aln = muscle.Muscle(args.muscle) logger.info("\tpick_otus.py... (%s)", args.pick_otus) pick_otus = qiime.Pick_Otus(args.pick_otus, logger) logger.info("\tpick_closed_reference_otus.py... (%s)", args.pick_closed_reference_otus) pcro = qiime.Pick_Closed_Ref_Otus(args.pick_closed_reference_otus, logger) return (fastqc_qc, trim_quality, jpe, convert_format, blastclust, muscle_aln, pick_otus, pcro)
def test_blastclust_exec(): """Run blastclust on test data and compare output to precomputed target""" bc = blast.Blastclust("blastclust") result = bc.run(os.path.join(INDIR, "trimmed.fasta"), OUTDIR, THREADS) with open(TARGET, "r") as target_fh: with open(result.outfilename, "r") as test_fh: assert_equal(target_fh.read(), test_fh.read())
def test_blastclust_notexec(): """Error thrown if blastclust exe not executable""" try: bc = blast.Blastclust("LICENSE") except NotExecutableError: return True else: return False
def test_blastclust_exec_notexist(): """Error thrown if executable does not exist""" try: bc = blast.Blastclust(os.path.join(".", "blastclust")) except NotExecutableError: return True else: return False
def test_blastclust_cmd(): """Blastclust instantiates and returns correct form of cmd-line""" bc = blast.Blastclust("blastclust") target = ' '.join(["blastclust -L 0.90 -S 99 -a 4 -p F", "-i trimmed.fasta", "-o", os.path.join("test_out", "trimmed.fasta.blastclust99.lst")]) assert_equal(bc.run("trimmed.fasta", "test_out", 4, dry_run=True), target)
def test_blastclust_cmd(): """Blastclust instantiates and returns correct form of cmd-line""" bc = blast.Blastclust("blastclust") target = ' '.join([ "blastclust", "-L 0.90", "-S 99", "-a 4", "-p F", "-i trimmed.fasta", "-o", os.path.join("tests", "test_out", "blastclust", "trimmed.fasta.blastclust99.lst") ]) result = bc.run("trimmed.fasta", OUTDIR, 4, dry_run=True) assert_equal(result.command, target)
def test_blastclust_exec(): """Run blastclust on test data and compare output to precomputed target""" bc = blast.Blastclust("blastclust") try: shutil.rmtree(OUTDIR) except FileNotFoundError: pass os.makedirs(OUTDIR, exist_ok=True) result = bc.run(os.path.join(INDIR, "trimmed.fasta"), OUTDIR, THREADS) with open(TARGET, "r") as target_fh: with open(result.outfilename, "r") as test_fh: assert_equal(target_fh.read(), test_fh.read())
def test_blastclust(): """Blastclust instantiates with cmd-line and blastclust is in $PATH""" blast.Blastclust("blastclust")
"'%s' contains whitespace" % fname) logger.error("(exiting)") sys.exit(1) # Check for presence of third-party tools, by instantiating interfaces logger.info("Checking third-party packages:") logger.info("\tFastQC... (%s)" % args.fastqc) fastQC = fastqc.FastQC(args.fastqc, logger) logger.info("\ttrim_quality... (%s)" % args.trim_quality) trim_quality = seq_crumbs.Trim_Quality(args.trim_quality, logger) logger.info("\tjoin_paired_ends.py... (%s)" % args.join_paired_ends) jpe = qiime.Join_Paired_Ends(args.join_paired_ends, logger) logger.info("\tconvert_format... (%s)" % args.convert_format) convert_format = seq_crumbs.Convert_Format(args.convert_format, logger) logger.info("\tblastclust... (%s)" % args.blastclust) blastclust = blast.Blastclust(args.blastclust) logger.info("\tmuscle... (%s)" % args.muscle) muscle = muscle.Muscle(args.muscle, logger) logger.info("\tpick_otus.py... (%s)" % args.pick_otus) pick_otus = qiime.Pick_Otus(args.pick_otus, logger) logger.info("\tpick_closed_reference_otus.py... (%s)" % args.pick_closed_reference_otus) pcro = qiime.Pick_Closed_Ref_Otus(args.pick_closed_reference_otus, logger) # How many threads are we using? args.threads = min(args.threads, multiprocessing.cpu_count()) logger.info("Using %d threads/CPUs where available" % args.threads) # Trim reads on quality - forward and reverse reads logger.info("Trim reads by quality") try:
def test_blastclust(): """blastclust is in $PATH""" blast.Blastclust("blastclust")