Ejemplo n.º 1
0
 def test_variant_position_and_range(self):
   v1 = test_utils.make_variant(chrom='1', alleles=['A', 'C'], start=10)
   v2 = test_utils.make_variant(chrom='1', alleles=['AGCT', 'C'], start=10)
   pos = ranges.make_range('1', 10, 11)
   range_ = ranges.make_range('1', 10, 14)
   v1_range_tuple = ('1', 10, 11)
   v2_range_tuple = ('1', 10, 14)
   self.assertEqual(pos, variant_utils.variant_position(v1))
   self.assertEqual(pos, variant_utils.variant_position(v2))
   self.assertEqual(pos, variant_utils.variant_range(v1))
   self.assertEqual(range_, variant_utils.variant_range(v2))
   self.assertEqual(v1_range_tuple, variant_utils.variant_range_tuple(v1))
   self.assertEqual(v2_range_tuple, variant_utils.variant_range_tuple(v2))
Ejemplo n.º 2
0
 def test_variant_position_and_range(self):
   v1 = test_utils.make_variant(chrom='1', alleles=['A', 'C'], start=10)
   v2 = test_utils.make_variant(chrom='1', alleles=['AGCT', 'C'], start=10)
   pos = ranges.make_range('1', 10, 11)
   range_ = ranges.make_range('1', 10, 14)
   v1_range_tuple = ('1', 10, 11)
   v2_range_tuple = ('1', 10, 14)
   self.assertEqual(pos, variant_utils.variant_position(v1))
   self.assertEqual(pos, variant_utils.variant_position(v2))
   self.assertEqual(pos, variant_utils.variant_range(v1))
   self.assertEqual(range_, variant_utils.variant_range(v2))
   self.assertEqual(v1_range_tuple, variant_utils.variant_range_tuple(v1))
   self.assertEqual(v2_range_tuple, variant_utils.variant_range_tuple(v2))
Ejemplo n.º 3
0
    def _find_matching_variant_in_reader(self, variant):
        """Finds a variant in vcf_reader compatible with variant, if one exists."""
        region = variant_utils.variant_position(variant)
        matches = [
            variant_utils.simplify_variant_alleles(truth_variant)
            for truth_variant in self._get_truth_variants(region)
            if variant.start == truth_variant.start
        ]

        if not matches:
            return None

        best_match = None
        for match in matches:
            if (match.alternate_bases == variant.alternate_bases
                    and match.reference_bases == variant.reference_bases):
                best_match = match

        if best_match is None:
            logging.info(
                'Multiple matches detected; no good match found. Fall back '
                'to first. variant: %s: matches: %s', variant, matches)
            # redacted
            # likely not the best. Think about what to do for different use cases.
            best_match = matches[0]
        return best_match
Ejemplo n.º 4
0
    def _find_matching_variant_in_reader(self, variant):
        """Finds a variant in vcf_reader compatible with variant, if one exists."""
        region = variant_utils.variant_position(variant)
        matches = [
            truth_variant for truth_variant in self._get_truth_variants(region)
            if variant.start == truth_variant.start
        ]

        if not matches:
            return None
        elif len(matches) > 1:
            logging.warning(
                'Multiple matches detected, keeping first, for variant %s: %s',
                variant, matches)
        return matches[0]
Ejemplo n.º 5
0
  def _find_matching_variant_in_reader(self, variant):
    """Finds a variant in vcf_reader compatible with variant, if one exists."""
    region = variant_utils.variant_position(variant)
    matches = [
        truth_variant for truth_variant in self._get_truth_variants(region)
        if variant.start == truth_variant.start
    ]

    if not matches:
      return None
    elif len(matches) > 1:
      logging.warning(
          'Multiple matches detected, keeping first, for variant %s: %s',
          variant, matches)
    return matches[0]
Ejemplo n.º 6
0
  def _find_matching_variant_in_reader(self, variant):
    """Finds a variant in vcf_reader compatible with variant, if one exists."""
    region = variant_utils.variant_position(variant)
    matches = [
        truth_variant for truth_variant in self._get_truth_variants(region)
        if variant.start == truth_variant.start
    ]

    if not matches:
      return None
    elif len(matches) > 1:
      logging.info('Multiple matches detected for variant %s: %s', variant,
                   matches)

    best_match = matches[0]
    for match in matches:
      if match.alternate_bases == variant.alternate_bases:
        best_match = match
    return best_match