コード例 #1
0
    def testEmptyFileVCFGZWithoutIndex(self):
        with get_temp_context("tmp_testEmptyFileWithoutIndex.vcf") as fn:
            with open(fn, "w"):
                pass

            pysam.tabix_compress(fn, fn + ".gz", force=True)

            self.assertRaises(ValueError, pysam.VariantFile, fn + ".gz")
コード例 #2
0
    def testEmptyFileVCFGZWithIndex(self):
        with get_temp_context("tmp_testEmptyFile.vcf") as fn:
            with open(fn, "w"):
                pass
            # tabix_index will automatically compress
            pysam.tabix_index(fn, preset="vcf", force=True)

            self.assertRaises(ValueError, pysam.VariantFile, fn + ".gz")
コード例 #3
0
    def test_vcf_with_tbi_index(self):
        with get_temp_context("tmp_fn.vcf") as fn:
            shutil.copyfile(self.vcf_filename, fn)
            pysam.tabix_index(fn, preset="vcf", force=True)
            self.assertTrue(os.path.exists(fn + ".gz" + ".tbi"))
            self.assertFalse(os.path.exists(fn + ".gz" + ".csi"))

            with pysam.VariantFile(fn + ".gz") as inf:
                self.assertEqual(len(list(inf.fetch("20"))), 3)
コード例 #4
0
ファイル: VariantFile_test.py プロジェクト: msto/pysam
 def test_vcf_with_tbi_index(self):
     with get_temp_context("tmp_fn.vcf") as fn:
         shutil.copyfile(self.vcf_filename, fn)
         pysam.tabix_index(fn, preset="vcf", force=True)
         self.assertTrue(os.path.exists(fn + ".gz" + ".tbi"))
         self.assertFalse(os.path.exists(fn + ".gz" + ".csi"))
         
         with pysam.VariantFile(fn + ".gz") as inf:
             self.assertEqual(len(list(inf.fetch("20"))), 3)
コード例 #5
0
    def test_bcf_with_prebuilt_csi(self):
        with get_temp_context("tmp_fn.bcf") as fn:
            shutil.copyfile(self.bcf_filename, fn)
            shutil.copyfile(self.bcf_filename + ".csi", fn + ".csi")

            self.assertTrue(os.path.exists(fn + ".csi"))
            self.assertFalse(os.path.exists(fn + ".tbi"))

            with pysam.VariantFile(fn) as inf:
                self.assertEqual(len(list(inf.fetch("20"))), 3)
コード例 #6
0
ファイル: VariantFile_test.py プロジェクト: msto/pysam
    def test_bcf_with_prebuilt_csi(self):
        with get_temp_context("tmp_fn.bcf") as fn:
            shutil.copyfile(self.bcf_filename, fn)
            shutil.copyfile(self.bcf_filename + ".csi", fn + ".csi")

            self.assertTrue(os.path.exists(fn + ".csi"))
            self.assertFalse(os.path.exists(fn + ".tbi"))
            
            with pysam.VariantFile(fn) as inf:
                self.assertEqual(len(list(inf.fetch("20"))), 3)
コード例 #7
0
ファイル: VariantFile_test.py プロジェクト: msto/pysam
    def testEmptyFileVCFGZWithoutIndex(self):
        with get_temp_context("tmp_testEmptyFileWithoutIndex.vcf") as fn:
            with open(fn, "w"):
                pass

            pysam.tabix_compress(fn,
                                 fn + ".gz",
                                 force=True)

            self.assertRaises(ValueError, pysam.VariantFile, fn + ".gz")
コード例 #8
0
ファイル: VariantFile_test.py プロジェクト: msto/pysam
    def testEmptyFileVCFGZWithIndex(self):
        with get_temp_context("tmp_testEmptyFile.vcf") as fn:
            with open(fn, "w"):
                pass
            # tabix_index will automatically compress
            pysam.tabix_index(fn,
                              preset="vcf",
                              force=True)

            self.assertRaises(ValueError, pysam.VariantFile, fn + ".gz")
コード例 #9
0
    def test_bcf_with_tbi_index_will_produce_csi(self):
        with get_temp_context("tmp_fn.bcf") as fn:
            shutil.copyfile(self.bcf_filename, fn)

            pysam.tabix_index(fn, preset="bcf", force=True, csi=False)
            self.assertTrue(os.path.exists(fn + ".csi"))
            self.assertEqual(read_index_header(fn + ".csi"), b"CSI\1")
            self.assertFalse(os.path.exists(fn + ".tbi"))

            with pysam.VariantFile(fn) as inf:
                self.assertEqual(len(list(inf.fetch("20"))), 3)
コード例 #10
0
ファイル: AlignedSegment_test.py プロジェクト: yesimon/pysam
 def testNegativeIntegersWrittenToFile(self):
     r = self.build_read()
     x = -2
     r.tags = [("XD", x)]
     with get_temp_context("negative_integers.bam") as fn:
         with pysam.AlignmentFile(fn,
                                  "wb",
                                  referencenames=("chr1", ),
                                  referencelengths=(1000, )) as outf:
             outf.write(r)
         with pysam.AlignmentFile(fn) as inf:
             r = next(inf)
         self.assertEqual(r.tags, [("XD", x)])
コード例 #11
0
ファイル: AlignedSegment_test.py プロジェクト: msto/pysam
 def testNegativeIntegersWrittenToFile(self):
     r = self.build_read()
     x = -2
     r.tags = [("XD", x)]
     with get_temp_context("negative_integers.bam") as fn:
         with pysam.AlignmentFile(fn,
                                  "wb",
                                  referencenames=("chr1",),
                                  referencelengths=(1000,)) as outf:
             outf.write(r)
         with pysam.AlignmentFile(fn) as inf:
             r = next(inf)
         self.assertEqual(r.tags, [("XD", x)])
コード例 #12
0
 def testEmptyFileVCFFromPath(self):
     with get_temp_context("tmp_testEmptyFile.vcf") as fn:
         with open(fn, "w"):
             pass
         self.assertRaises(ValueError, pysam.VariantFile, Path(fn))
コード例 #13
0
ファイル: VariantFile_test.py プロジェクト: msto/pysam
 def testEmptyFileVCFFromPath(self):
     with get_temp_context("tmp_testEmptyFile.vcf") as fn:
         with open(fn, "w"):
             pass
         self.assertRaises(ValueError, pysam.VariantFile,
                           Path(fn))