Example #1
0
 def test_variants_overlap(self):
   v1 = test_utils.make_variant(chrom='1', alleles=['A', 'C'], start=10)
   v2 = test_utils.make_variant(chrom='1', alleles=['A', 'C'], start=20)
   with mock.patch.object(ranges, 'ranges_overlap') as mock_overlap:
     mock_overlap.return_value = 'SENTINEL'
     self.assertEqual(variant_utils.variants_overlap(v1, v2), 'SENTINEL')
     mock_overlap.assert_called_once_with(
         variant_utils.variant_range(v1), variant_utils.variant_range(v2))
Example #2
0
 def test_variants_overlap(self):
   v1 = test_utils.make_variant(chrom='1', alleles=['A', 'C'], start=10)
   v2 = test_utils.make_variant(chrom='1', alleles=['A', 'C'], start=20)
   with mock.patch.object(ranges, 'ranges_overlap') as mock_overlap:
     mock_overlap.return_value = 'SENTINEL'
     self.assertEqual(variant_utils.variants_overlap(v1, v2), 'SENTINEL')
     mock_overlap.assert_called_once_with(
         variant_utils.variant_range(v1), variant_utils.variant_range(v2))
def split_independent_variants(variants_and_genotypes):
  """Splits variants_and_genotypes into an overlapping group and remaining."""
  if not variants_and_genotypes:
    raise ValueError('Expected at least one value in variants_and_genotypes')

  overlaps = [variants_and_genotypes[0]]
  for i in range(1, len(variants_and_genotypes)):
    vgi = variants_and_genotypes[i].variant
    if any(variant_utils.variants_overlap(vg.variant, vgi) for vg in overlaps):
      overlaps.append(variants_and_genotypes[i])
    else:
      return overlaps, variants_and_genotypes[i:]
  return overlaps, []
Example #4
0
def split_independent_variants(variants_and_genotypes):
  """Splits variants_and_genotypes into an overlapping group and remaining."""
  if not variants_and_genotypes:
    raise ValueError('Expected at least one value in variants_and_genotypes')

  overlaps = [variants_and_genotypes[0]]
  for i in range(1, len(variants_and_genotypes)):
    vgi = variants_and_genotypes[i].variant
    if any(variant_utils.variants_overlap(vg.variant, vgi) for vg in overlaps):
      overlaps.append(variants_and_genotypes[i])
    else:
      return overlaps, variants_and_genotypes[i:]
  return overlaps, []