modified: myjupyterlab.sh
[GalaxyCodeBases.git] / c_cpp / fromOthers / PEAR / test / test.py
blob5bc72b3012c2714063179c3edd297261017ae73e
1 #! /usr/bin/env python
2 import sys
3 import os
4 import filecmp
5 import subprocess
6 import shutil
8 def unit_test(f, r, o, fcompare):
9 subprocess.call(["../src/pear", "-f", f, "-r", r, "-o", o, "-c", "0"], stdout=open(os.devnull, "w"), stderr=subprocess.STDOUT)
10 correct = filecmp.cmp(o+".assembled.fastq", fcompare)
11 os.remove(o+".assembled.fastq")
12 os.remove(o+".discarded.fastq")
13 os.remove(o+".unassembled.forward.fastq")
14 os.remove(o+".unassembled.reverse.fastq")
15 if correct:
16 return "passed"
17 else:
18 return "failed"
20 def gen(f, r, o, fcompare):
21 subprocess.call(["../src/pear", "-f", f, "-r", r, "-o", o, "-c", "0"], stdout=open(os.devnull, "w"), stderr=subprocess.STDOUT)
22 shutil.copyfile(o+".assembled.fastq", fcompare)
23 os.remove(o+".discarded.fastq")
24 os.remove(o+".unassembled.forward.fastq")
25 os.remove(o+".unassembled.reverse.fastq")
28 if __name__ == "__main__":
29 test_files = [["raw/16S_101bp1.fq", "raw/16S_101bp2.fq", "raw/compare/101bp.assembled.fastq"],
30 ["raw/16S_101bp1.fq.through.fastq", "raw/16S_101bp2.fq.through.fastq", "raw/compare/101bp.through.assembled.fastq"],
31 ["raw/16S_150bp1.fq", "raw/16S_150bp2.fq", "raw/compare/150bp.assembled.fastq"],
32 ["raw/16S_165bp1.fq", "raw/16S_165bp2.fq", "raw/compare/165bp.assembled.fastq"],
33 ["raw/16S_180bp1.fq", "raw/16S_180bp2.fq", "raw/compare/180bp.assembled.fastq"],
34 ["raw/16S_190bp1.fq", "raw/16S_190bp2.fq", "raw/compare/190bp.assembled.fastq"],
35 ["raw/16S_250bp1.fq", "raw/16S_250bp2.fq", "raw/compare/250bp.assembled.fastq"],
36 ["nooverlap/equall_1.fq", "nooverlap/equall_2.fq", "nooverlap/compare/equall.assembled.fastq"],
37 ["nooverlap/f_long_1.fq", "nooverlap/f_long_2.fq", "nooverlap/compare/f_long.assembled.fastq"],
38 ["nooverlap/r_long_1.fq", "nooverlap/r_long_2.fq", "nooverlap/compare/r_long.assembled.fastq"],
39 ["normal/equall_1.fq", "normal/equall_2.fq", "normal/compare/equall.assembled.fastq"],
40 ["normal/f_long_1.fq", "normal/f_long_2.fq", "normal/compare/f_long.assembled.fastq"],
41 ["normal/r_long_1.fq", "normal/r_long_2.fq", "normal/compare/r_long.assembled.fastq"],
42 ["runthrough/equall_1.fq", "runthrough/equall_2.fq", "runthrough/compare/equall.assembled.fastq"],
43 ["runthrough/f_long_c2_1.fq", "runthrough/f_long_c2_2.fq", "runthrough/compare/f_long_c2.assembled.fastq"],
44 ["runthrough/f_long_c3_1.fq", "runthrough/f_long_c3_2.fq", "runthrough/compare/f_long_c3.assembled.fastq"],
45 ["runthrough/r_long_c2_1.fq", "runthrough/r_long_c2_2.fq", "runthrough/compare/r_long_c2.assembled.fastq"],
46 ["runthrough/r_long_c3_1.fq", "runthrough/r_long_c3_2.fq", "runthrough/compare/r_long_c3.assembled.fastq"],
48 i = 1
49 for test in test_files:
50 #gen(test[0], test[1], "temp", test[2])
51 flag = unit_test(test[0], test[1], "temp", test[2])
52 print("Test " + repr(i) + " " + flag)
53 i = i + 1