Exemplo n.º 1
0
def _create_cvo_proto(encoded_variant,
                      gls,
                      encoded_alt_allele_indices,
                      true_labels=None,
                      logits=None,
                      prelogits=None):
    """Returns a CallVariantsOutput proto from the relevant input information."""
    variant = variants_pb2.Variant.FromString(encoded_variant)
    alt_allele_indices = (deepvariant_pb2.CallVariantsOutput.AltAlleleIndices.
                          FromString(encoded_alt_allele_indices))
    debug_info = None
    if FLAGS.include_debug_info or FLAGS.debugging_true_label_mode:
        if prelogits is not None:
            assert prelogits.shape == (1, 1, 2048)
            prelogits = prelogits[0][0]
        debug_info = deepvariant_pb2.CallVariantsOutput.DebugInfo(
            has_insertion=variant_utils.has_insertion(variant),
            has_deletion=variant_utils.has_deletion(variant),
            is_snp=variant_utils.is_snp(variant),
            predicted_label=np.argmax(gls),
            true_label=true_labels,
            logits=logits,
            prelogits=prelogits)
    call_variants_output = deepvariant_pb2.CallVariantsOutput(
        variant=variant,
        alt_allele_indices=alt_allele_indices,
        genotype_probabilities=gls,
        debug_info=debug_info)
    return call_variants_output
Exemplo n.º 2
0
 def test_exception_extract_single_variant_name(self, names):
   variant_calls = [
       variants_pb2.VariantCall(call_set_name=name) for name in names
   ]
   variant = variants_pb2.Variant(calls=variant_calls)
   record = deepvariant_pb2.CallVariantsOutput(variant=variant)
   with self.assertRaisesRegexp(ValueError, 'Expected exactly one VariantCal'):
     postprocess_variants._extract_single_sample_name(record)
Exemplo n.º 3
0
def _create_call_variants_output(indices,
                                 probabilities,
                                 ref=None,
                                 alts=None,
                                 variant=None):
  if alts is None != variant is None:
    raise ValueError('Exactly one of either `alts` or `variant` should be set.')
  if not variant:
    variant = _create_variant_with_alleles(ref=ref, alts=alts)
  return deepvariant_pb2.CallVariantsOutput(
      genotype_probabilities=probabilities,
      alt_allele_indices=deepvariant_pb2.CallVariantsOutput.AltAlleleIndices(
          indices=indices),
      variant=variant)
Exemplo n.º 4
0
def _create_cvo_proto(encoded_variant, gls, encoded_alt_allele_indices):
    """Returns a CallVariantsOutput proto from the relevant input information."""
    variant = variants_pb2.Variant.FromString(encoded_variant)
    alt_allele_indices = (deepvariant_pb2.CallVariantsOutput.AltAlleleIndices.
                          FromString(encoded_alt_allele_indices))
    debug_info = None
    if FLAGS.include_debug_info:
        debug_info = deepvariant_pb2.CallVariantsOutput.DebugInfo(
            has_insertion=variantutils.has_insertion(variant),
            has_deletion=variantutils.has_deletion(variant),
            is_snp=variantutils.is_snp(variant),
            predicted_label=np.argmax(gls))
    call_variants_output = deepvariant_pb2.CallVariantsOutput(
        variant=variant,
        alt_allele_indices=alt_allele_indices,
        genotype_probabilities=gls,
        debug_info=debug_info)
    return call_variants_output
Exemplo n.º 5
0
 def write_output(encoded_variant, gls, encoded_alt_allele_indices):
     """Provides a write function for a CallVariantsOutput proto."""
     variant = variants_pb2.Variant.FromString(encoded_variant)
     alt_allele_indices = (
         deepvariant_pb2.CallVariantsOutput.AltAlleleIndices.FromString(
             encoded_alt_allele_indices))
     debug_info = None
     if FLAGS.include_debug_info:
         debug_info = deepvariant_pb2.CallVariantsOutput.DebugInfo(
             has_insertion=variantutils.has_insertion(variant),
             has_deletion=variantutils.has_deletion(variant),
             is_snp=variantutils.is_snp(variant),
             predicted_label=np.argmax(gls))
     call_variants_output = deepvariant_pb2.CallVariantsOutput(
         variant=variant,
         alt_allele_indices=alt_allele_indices,
         genotype_probabilities=gls,
         debug_info=debug_info)
     write_fn(call_variants_output)