def test_pbmerge_indexing(self): log.debug("Test through API") aln = AlignmentSet(data.getXml(12)) self.assertEqual(len(aln.toExternalFiles()), 2) outdir = tempfile.mkdtemp(suffix="dataset-unittest") outfn = os.path.join(outdir, 'merged.bam') log.info(outfn) consolidateXml(aln, outfn, cleanup=False) self.assertTrue(os.path.exists(outfn)) self.assertTrue(os.path.exists(outfn + '.pbi')) cons = AlignmentSet(outfn) self.assertEqual(len(aln), len(cons)) orig_stats = os.stat(outfn + '.pbi') cons.externalResources[0].pbi = None self.assertEqual(None, cons.externalResources[0].pbi) # test is too quick, stat times might be within the same second time.sleep(1) cons.induceIndices() self.assertEqual(outfn + '.pbi', cons.externalResources[0].pbi) self.assertEqual(orig_stats, os.stat(cons.externalResources[0].pbi)) cons.externalResources[0].pbi = None self.assertEqual(None, cons.externalResources[0].pbi) # test is too quick, stat times might be within the same second time.sleep(1) cons.induceIndices(force=True) self.assertNotEqual(orig_stats, os.stat(cons.externalResources[0].pbi))
def test_pbmerge_indexing(self): log.debug("Test through API") aln = AlignmentSet(data.getXml(11)) assert len(aln.toExternalFiles()) == 2 outdir = tempfile.mkdtemp(suffix="dataset-unittest") outfn = os.path.join(outdir, 'merged.bam') log.info(outfn) consolidateXml(aln, outfn, cleanup=False) assert os.path.exists(outfn) assert os.path.exists(outfn + '.pbi') cons = AlignmentSet(outfn) assert len(aln) == len(cons) orig_stats = os.stat(outfn + '.pbi') cons.externalResources[0].pbi = None assert cons.externalResources[0].pbi is None # test is too quick, stat times might be within the same second time.sleep(1) cons.induceIndices() assert outfn + '.pbi' == cons.externalResources[0].pbi assert orig_stats == os.stat(cons.externalResources[0].pbi) cons.externalResources[0].pbi = None assert cons.externalResources[0].pbi is None # test is too quick, stat times might be within the same second time.sleep(1) cons.induceIndices(force=True) assert orig_stats != os.stat(cons.externalResources[0].pbi)