Exemplo n.º 1
0
    def test_loadmetadata_from_dataset_create_cli(self):
        fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
        fn2 = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
        log.debug(fn)

        aln = AlignmentSet(data.getXml(8))
        aln.metadata.collections = None
        aln.copyTo(fn)
        aln.close()
        del aln
        self.assertTrue(os.path.exists(fn))

        aln = AlignmentSet(fn)
        self.assertFalse(aln.metadata.collections)

        cmd = "dataset create --metadata {m} {o} {i}".format(
            o=fn2,
            i=fn,
            m=("/pbi/dept/secondary/siv/testdata/"
               "SA3-Sequel/lambda/roche_SAT/"
               "m54013_151205_032353.subreadset.xml"))
        log.debug(cmd)
        o, r, m = backticks(cmd)
        self.assertEqual(r, 0, m)
        aln = AlignmentSet(fn2)
        self.assertTrue(aln.metadata.collections)
Exemplo n.º 2
0
    def test_loadmetadata_from_dataset_create_cli(self):
        fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
        fn2 = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
        log.debug(fn)

        aln = AlignmentSet(data.getXml(8))
        aln.metadata.collections = None
        aln.copyTo(fn)
        aln.close()
        del aln
        self.assertTrue(os.path.exists(fn))

        aln = AlignmentSet(fn)
        self.assertFalse(aln.metadata.collections)

        cmd = "dataset create --metadata {m} {o} {i}".format(
            o=fn2,
            i=fn,
            m=("/pbi/dept/secondary/siv/testdata/"
               "SA3-Sequel/lambda/roche_SAT/"
               "m54013_151205_032353.subreadset.xml"))
        log.debug(cmd)
        o, r, m = backticks(cmd)
        self.assertEqual(r, 0, m)
        aln = AlignmentSet(fn2)
        self.assertTrue(aln.metadata.collections)
Exemplo n.º 3
0
 def test_absolutize_cli(self):
     fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
     aln = AlignmentSet(data.getXml(7))
     aln.copyTo(fn, relative=True)
     assert _is_relative(fn)
     cmd = "dataset absolutize {d}".format(d=fn)
     self._run_cmd_with_output(cmd, fn)
     assert not _is_relative(fn)
Exemplo n.º 4
0
 def test_relativize_cli(self):
     fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
     aln = AlignmentSet(data.getXml(8))
     aln.copyTo(fn)
     self.assertFalse(_is_relative(fn))
     cmd = "dataset relativize {d}".format(d=fn)
     log.debug(cmd)
     o, r, m = backticks(cmd)
     self.assertEqual(r, 0)
     self.assertTrue(os.path.exists(fn))
     self.assertTrue(_is_relative(fn))
Exemplo n.º 5
0
 def test_relativize_cli(self):
     fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
     aln = AlignmentSet(data.getXml(8))
     aln.copyTo(fn)
     self.assertFalse(_is_relative(fn))
     cmd = "dataset relativize {d}".format(d=fn)
     log.debug(cmd)
     o, r, m = backticks(cmd)
     self.assertEqual(r, 0)
     self.assertTrue(os.path.exists(fn))
     self.assertTrue(_is_relative(fn))
Exemplo n.º 6
0
 def test_newUuid_cli(self):
     fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
     aln = AlignmentSet(data.getXml(8))
     aln.copyTo(fn)
     pre_uuid = AlignmentSet(fn).uuid
     cmd = "dataset newuuid {d}".format(d=fn)
     log.debug(cmd)
     o, r, m = backticks(cmd)
     post_uuid = AlignmentSet(fn).uuid
     self.assertEqual(r, 0)
     self.assertTrue(os.path.exists(fn))
     self.assertNotEqual(pre_uuid, post_uuid)
Exemplo n.º 7
0
 def test_newUuid_cli(self):
     fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
     aln = AlignmentSet(data.getXml(8))
     aln.copyTo(fn)
     pre_uuid = AlignmentSet(fn).uuid
     cmd = "dataset newuuid {d}".format(d=fn)
     log.debug(cmd)
     o, r, m = backticks(cmd)
     post_uuid = AlignmentSet(fn).uuid
     self.assertEqual(r, 0)
     self.assertTrue(os.path.exists(fn))
     self.assertNotEqual(pre_uuid, post_uuid)
Exemplo n.º 8
0
 def test_absolutize_cli_3(self):
     fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
     outdir = tempfile.mkdtemp(suffix="dataset-unittest")
     outfn = os.path.join(outdir, os.path.split(fn)[1])
     aln = AlignmentSet(data.getXml(7))
     aln.copyTo(fn, relative=True)
     assert _is_relative(fn)
     cmd = "dataset absolutize {d} --outdir {o}".format(d=fn, o=outdir)
     self._run_cmd_with_output(cmd, fn)
     assert os.path.exists(outfn)
     assert _is_relative(fn)
     assert not _is_relative(outfn)
Exemplo n.º 9
0
 def test_newUuid_cli(self):
     fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
     aln = AlignmentSet(data.getXml(7))
     aln.copyTo(fn)
     pre_uuid = AlignmentSet(fn).uuid
     cmd = "dataset newuuid {d}".format(d=fn)
     self._run_cmd_with_output(cmd, fn)
     post_uuid = AlignmentSet(fn).uuid
     assert pre_uuid != post_uuid
     cmd = "dataset newuuid --updateCounts {d}".format(d=fn)
     self._run_cmd_with_output(cmd, fn)
     post_uuid = AlignmentSet(fn).uuid
     assert pre_uuid != post_uuid
Exemplo n.º 10
0
 def test_create_cli_generate_indices_4(self):
     log.debug("Generate indices, no type specified")
     outdir = tempfile.mkdtemp(suffix="dataset-unittest")
     ifn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml",
                                       dir=outdir).name
     log.info(ifn)
     # copy the resources and xml
     aset = AlignmentSet(data.getXml(11))
     aset.copyTo(ifn)
     aset = AlignmentSet(ifn)
     # get the key resource filename
     ifn = aset.toExternalFiles()[0]
     log.info(ifn)
     ofn = self._get_mock_alignment_set_out(outdir)
     cmd = ("dataset create --generateIndices {} {}").format(ofn, ifn)
     self._run_cmd_with_output(cmd, ofn)
     aset = AlignmentSet(ofn, strict=True)
     shutil.rmtree(outdir)
Exemplo n.º 11
0
    def test_loadmetadata_from_dataset_cli(self):
        fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
        log.debug(fn)

        aln = AlignmentSet(data.getXml(7))
        aln.metadata.collections = None
        aln.copyTo(fn)
        aln.close()
        del aln
        assert os.path.exists(fn)

        aln = AlignmentSet(fn)
        assert not aln.metadata.collections

        cmd = "dataset loadmetadata {i} {m}".format(
            i=fn,
            m=("/pbi/dept/secondary/siv/testdata/"
               "SA3-Sequel/lambda/roche_SAT/"
               "m54013_151205_032353.subreadset.xml"))
        self._check_cmd(cmd)
        aln = AlignmentSet(fn)
        assert aln.metadata.collections
Exemplo n.º 12
0
    def test_absolutize_cli(self):
        fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
        aln = AlignmentSet(data.getXml(8))
        aln.copyTo(fn, relative=True)
        self.assertTrue(_is_relative(fn))
        cmd = "dataset absolutize {d}".format(d=fn)
        log.debug(cmd)
        o, r, m = backticks(cmd)
        self.assertEqual(r, 0)
        self.assertTrue(os.path.exists(fn))
        self.assertFalse(_is_relative(fn))

        fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
        outfn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
        aln = AlignmentSet(data.getXml(8))
        aln.copyTo(fn, relative=True)
        self.assertTrue(_is_relative(fn))
        cmd = "dataset absolutize {d} --outdir {o}".format(d=fn, o=outfn)
        log.debug(cmd)
        o, r, m = backticks(cmd)
        self.assertEqual(r, 0)
        self.assertTrue(os.path.exists(fn))
        self.assertTrue(os.path.exists(outfn))
        self.assertTrue(_is_relative(fn))
        self.assertFalse(_is_relative(outfn))

        fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
        outdir = tempfile.mkdtemp(suffix="dataset-unittest")
        outfn = os.path.join(outdir, os.path.split(fn)[1])
        aln = AlignmentSet(data.getXml(8))
        aln.copyTo(fn, relative=True)
        self.assertTrue(_is_relative(fn))
        cmd = "dataset absolutize {d} --outdir {o}".format(d=fn, o=outdir)
        log.debug(cmd)
        o, r, m = backticks(cmd)
        self.assertEqual(r, 0)
        self.assertTrue(os.path.exists(fn))
        self.assertTrue(os.path.exists(outfn))
        self.assertTrue(_is_relative(fn))
        self.assertFalse(_is_relative(outfn))
Exemplo n.º 13
0
    def test_absolutize_cli(self):
        fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
        aln = AlignmentSet(data.getXml(8))
        aln.copyTo(fn, relative=True)
        self.assertTrue(_is_relative(fn))
        cmd = "dataset absolutize {d}".format(d=fn)
        log.debug(cmd)
        o, r, m = backticks(cmd)
        self.assertEqual(r, 0)
        self.assertTrue(os.path.exists(fn))
        self.assertFalse(_is_relative(fn))

        fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
        outfn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
        aln = AlignmentSet(data.getXml(8))
        aln.copyTo(fn, relative=True)
        self.assertTrue(_is_relative(fn))
        cmd = "dataset absolutize {d} --outdir {o}".format(d=fn, o=outfn)
        log.debug(cmd)
        o, r, m = backticks(cmd)
        self.assertEqual(r, 0)
        self.assertTrue(os.path.exists(fn))
        self.assertTrue(os.path.exists(outfn))
        self.assertTrue(_is_relative(fn))
        self.assertFalse(_is_relative(outfn))

        fn = tempfile.NamedTemporaryFile(suffix=".alignmentset.xml").name
        outdir = tempfile.mkdtemp(suffix="dataset-unittest")
        outfn = os.path.join(outdir, os.path.split(fn)[1])
        aln = AlignmentSet(data.getXml(8))
        aln.copyTo(fn, relative=True)
        self.assertTrue(_is_relative(fn))
        cmd = "dataset absolutize {d} --outdir {o}".format(d=fn, o=outdir)
        log.debug(cmd)
        o, r, m = backticks(cmd)
        self.assertEqual(r, 0)
        self.assertTrue(os.path.exists(fn))
        self.assertTrue(os.path.exists(outfn))
        self.assertTrue(_is_relative(fn))
        self.assertFalse(_is_relative(outfn))