예제 #1
0
 def __lt__(self, other):
     """
     Define comparison operator for variants, to allow sorting.
     """
     # TODO: deal with ambiguous representations caused by non-left-aligned
     # data
     if self.chrom != other.chrom:
         return chromosome_comp(self.chrom, other.chrom)
     elif self.pos_from != other.pos_from:
         return self.pos_from < other.pos_from
     elif self.pos_to != other.pos_to:
         return self.pos_to < other.pos_to
     elif self.ref != other.ref:
         return self.ref < other.ref
     elif self.alt != other.alt:
         return self.alt < other.alt
     else:
         return False
예제 #2
0
파일: interval.py 프로젝트: dylex/wecall
 def __lt__(self, other):
     if self.chrom == other.chrom:
         return self.interval < other.interval
     else:
         return chromosome_comp(self.chrom, other.chrom)
예제 #3
0
 def test_should_sort_chrom_2_before_chrom_10(self):
     self.assertTrue(chromosome_comp('2', '10'))
     self.assertFalse(chromosome_comp('10', '2'))
예제 #4
0
 def test_should_sort_non_standard_chroms_lexicographically(self):
     self.assertTrue(chromosome_comp("GL000193.1", "GL000193.2"))
     self.assertFalse(chromosome_comp("GL000193.2", "GL000193.1"))
예제 #5
0
 def test_should_sort_non_standard_chroms_after_standard_chroms(self):
     self.assertTrue(chromosome_comp("MT", "GL000193.1"))
     self.assertFalse(chromosome_comp("GL000193.1", "MT"))
예제 #6
0
 def test_should_sort_Y_before_MT(self):
     self.assertTrue(chromosome_comp('Y', 'MT'))
     self.assertFalse(chromosome_comp('MT', 'Y'))
예제 #7
0
 def test_should_sort_X_before_Y(self):
     self.assertTrue(chromosome_comp('X', 'Y'))
     self.assertFalse(chromosome_comp('Y', 'X'))
예제 #8
0
 def test_should_sort_22_before_X(self):
     self.assertTrue(chromosome_comp('22', 'X'))
     self.assertFalse(chromosome_comp('X', '22'))