Beispiel #1
0
 def test_build_index_with_force_merged_nodups_with_no_preset(self):  ## recognizing custom parameters
     pypairix.build_index(TEST_FILE_2D_SPACE, delimiter=' ', sc=2, bc=3, ec=3, sc2=6, bc2=7, ec2=7, force=1)
     pr2 = pypairix.open(TEST_FILE_2D_SPACE)
     query = '{}:{}-{}|{}:{}-{}'.format(self.chrom, self.start, self.end, self.chrom2, self.start2, self.end2)
     it2 = pr2.querys2D(query)
     pr2_result = build_it_result(it2, self.f_type)
     self.assertEqual(self.result, pr2_result)
Beispiel #2
0
 def test_build_index_with_force(self):   ## recognizing file extension pairs.gz
     pypairix.build_index(TEST_FILE_LARGE_CHR, force=1)
     pr2 = pypairix.open(TEST_FILE_LARGE_CHR)
     query = '{}:{}-{}|{}:{}-{}'.format(self.chrom, self.start, self.end, self.chrom2, self.start2, self.end2)
     it2 = pr2.querys2D(query)
     pr2_result = build_it_result(it2, self.f_type)
     self.assertEqual(self.result, pr2_result)
Beispiel #3
0
 def test_build_index_with_force_merged_nodups(self):  ## recognizing preset merged_nodups
     pypairix.build_index(TEST_FILE_2D_SPACE, "merged_nodups", force=1)
     pr2 = pypairix.open(TEST_FILE_2D_SPACE)
     query = '{}:{}-{}|{}:{}-{}'.format(self.chrom, self.start, self.end, self.chrom2, self.start2, self.end2)
     it2 = pr2.querys2D(query)
     pr2_result = build_it_result(it2, self.f_type)
     self.assertEqual(self.result, pr2_result)
Beispiel #4
0
 def test_build_index_with_force_vcf(self):  ## recognizing file extension vcf.gz
     pypairix.build_index(TEST_FILE_1D, force=1)
     pr2 = pypairix.open(TEST_FILE_1D)
     query = '{}:{}-{}'.format(self.chrom, self.start, self.end)
     it2 = pr2.querys(query)
     pr2_result = [[x[0], x[1], x[1]] for x in it2]
     self.assertEqual(self.result, pr2_result)
Beispiel #5
0
 def test_build_index_with_region_split_character(self):
     pypairix.build_index(TEST_FILE_LARGE_CHR, region_split_character="^", force=1)
     pr2 = pypairix.open(TEST_FILE_LARGE_CHR)
     query = '{}:{}-{}^{}:{}-{}'.format(self.chrom, self.start, self.end, self.chrom2, self.start2, self.end2)
     it2 = pr2.querys2D(query)
     pr2_result = build_it_result(it2, self.f_type)
     pypairix.build_index(TEST_FILE_LARGE_CHR, force=1)  # revert
     self.assertEqual(self.result, pr2_result)
Beispiel #6
0
 def test_build_index_with_force_merged_nodups_tab(self):  ## recognizing custom set
     pypairix.build_index(TEST_FILE_2D, sc=2, bc=3, ec=3, sc2=6, bc2=7, ec2=7, force=1)
     # test with reindex
     pr2 = pypairix.open(TEST_FILE_2D)
     query = '{}:{}-{}|{}:{}-{}'.format(self.chrom, self.start, self.end, self.chrom2, self.start2, self.end2)
     it2 = pr2.querys2D(query)
     pr2_result = build_it_result(it2, self.f_type)
     self.assertEqual(self.result, pr2_result)
Beispiel #7
0
 def test_build_index_without_force(self):
     # expect an error here... the px2 file already exists
     with self.assertRaises(pypairix.PairixError) as error:
         pypairix.build_index(TEST_FILE_LARGE_CHR)
     # errors are handled differently in python 2 and python 3
     if sys.version_info > (3,0):
         self.assertEqual(error.exception.__str__(), "The index file exists. Please use force=1 to overwrite.")
     else:
         self.assertEqual(error.exception.message, "The index file exists. Please use force=1 to overwrite.")