Skip to content
This repository has been archived by the owner on May 25, 2024. It is now read-only.

Commit

Permalink
Force sites with 0 depth to be ./.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 374764026
  • Loading branch information
danielecook authored and copybara-github committed May 20, 2021
1 parent 1ca8b28 commit 8478d6d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions nucleus/testing/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ py_library(
"//nucleus/protos:variants_py_pb2",
"//nucleus/util:cigar",
"@absl_py//absl/flags",
"@absl_py//absl/testing:absltest",
],
)

Expand Down
15 changes: 12 additions & 3 deletions nucleus/testing/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ def make_variant(chrom='chr1',
gq=None,
sample_name=None,
gls=None,
is_phased=None):
is_phased=None,
ad=None):
"""Creates a new Variant proto from args.
Args:
Expand All @@ -159,6 +160,7 @@ def make_variant(chrom='chr1',
gls: array-list of float, or None. If not None and gt is not None, sets the
genotype_likelihoods of our VariantCall to this value.
is_phased: bool. Indicates whether a VariantCall should be phased.
ad: list of allelic depths.
Returns:
nucleus.genomics.v1.Variant proto.
Expand All @@ -174,7 +176,8 @@ def make_variant(chrom='chr1',
gqs=None if gq is None else [gq],
sample_names=None if sample_name is None else [sample_name],
glss=None if gls is None else [gls],
is_phased=None if is_phased is None else [is_phased])
is_phased=None if is_phased is None else [is_phased],
ad=None if ad is None else [ad])


def make_variant_multiple_calls(chrom='chr1',
Expand All @@ -187,7 +190,8 @@ def make_variant_multiple_calls(chrom='chr1',
gqs=None,
sample_names=None,
glss=None,
is_phased=None):
is_phased=None,
ad=None):
"""Creates a new Variant proto from args that contains multi-sample calls.
Args:
Expand All @@ -214,6 +218,7 @@ def make_variant_multiple_calls(chrom='chr1',
specified. Sets the genotype_likelihoods of the corresponding VariantCall.
is_phased: list of bools. Must match the gts arg if specified. Indicates
whether the corresponding VariantCall should be phased.
ad: list of allelic depths. These are added together to calculate DP.
Returns:
nucleus.genomics.v1.Variant proto.
Expand Down Expand Up @@ -254,6 +259,10 @@ def make_variant_multiple_calls(chrom='chr1',
if is_phased and is_phased[i] is not None:
call.is_phased = is_phased[i]

if ad and ad[i] is not None:
set_list_values(call.info['AD'], ad[i])
set_list_values(call.info['DP'], [sum(ad[i])])

return variant


Expand Down

0 comments on commit 8478d6d

Please sign in to comment.