def __do_pair_align_and_comparison(self, log_level=logging.WARNING, pairing_batch_size=None, seq_list_len=None, fastq_subfmt="fastq-sanger"): u.build_index(self.refseq_fn) #-- start = time.time() bwa_res = u.run_bwa_sampe(self.refseq_fn, self.read_fn, self.mate_fn) print 'BWA_SAMPE: %f secs' % (time.time() - start) #-- start = time.time() py_res = u.run_bwa_py_sampe(self.refseq_fn, self.read_fn, self.mate_fn, log_level, pairing_batch_size, seq_list_len, fastq_subfmt) print 'PYBWA_SAMPE: %f secs' % (time.time() - start) #-- self.assertEqual(len(bwa_res), len(py_res)) for o, n in it.izip(bwa_res, py_res): for k in o.keys(): if k == 'name': nn = n[k].rsplit( "/", 1)[0] # we are dropping the '/[12]' extension self.assertEqual(o[k], nn) elif k == 'aux': self.assertEqual(len(o[k]), len(n[k])) for x, y in it.izip(o[k], n[k]): self.assertEqual(x, y) else: self.assertEqual(o[k], n[k])
def __do_pair_align_and_comparison(self, log_level=logging.WARNING, pairing_batch_size=None, seq_list_len=None, fastq_subfmt="fastq-sanger"): u.build_index(self.refseq_fn) #-- start = time.time() bwa_res = u.run_bwa_sampe(self.refseq_fn, self.read_fn, self.mate_fn) print 'BWA_SAMPE: %f secs' % (time.time() - start) #-- start = time.time() py_res = u.run_bwa_py_sampe(self.refseq_fn, self.read_fn, self.mate_fn, log_level, pairing_batch_size, seq_list_len, fastq_subfmt) print 'PYBWA_SAMPE: %f secs' % (time.time() - start) #-- self.assertEqual(len(bwa_res), len(py_res)) for o, n in it.izip(bwa_res, py_res): for k in o.keys(): if k == 'name': nn = n[k].rsplit("/", 1)[0] # we are dropping the '/[12]' extension self.assertEqual(o[k], nn) elif k == 'aux': self.assertEqual(len(o[k]), len(n[k])) for x,y in it.izip(o[k], n[k]): self.assertEqual(x, y) else: self.assertEqual(o[k],n[k])
def __compare_step_by_step(self): if not self.opt.no_index: u.build_index(self.refseq_fn) #-- bwa_res = u.run_bwa_sampe(self.refseq_fn, self.read_fn, self.mate_fn) py_res = u.run_bwa_py_sampe(self.refseq_fn, self.read_fn, self.mate_fn, log_level=self.opt.log_level, pairing_batch_size=self.opt.pairing_batch_size, seq_list_len=self.opt.seq_list_len, fastq_subfmt=self.opt.fastq_subfmt) f = open("errors.dump", 'w') error_count = 0 try: self.assertEqual(len(bwa_res), len(py_res)) except AssertionError: error_count += 1 f.write("Error on result n. %d\n" % i) f.write("NUMBER OF RESULT FIELDS: %d, %d\n" % ( len(bwa_res), len(py_res))) for i, (o, n) in enumerate(it.izip(bwa_res, py_res)): try: for k in o.keys(): if k == 'name': nn = n[k].rsplit("/", 1)[0] # we are dropping the '/[12]' extension self.assertEqual(o[k], nn) elif k == 'aux': self.assertEqual(len(o[k]), len(n[k])) for x,y in it.izip(o[k], n[k]): self.assertEqual(x, y) else: self.assertEqual(o[k],n[k]) except AssertionError: error_count += 1 f.write("Error on result n. %d\n" % i) for k in o.keys(): f.write("%r %r %r %r\n" % (k, o[k], n[k], o[k]==n[k])) f.write("\n") print "error count: %d" % error_count f.close()