|
a |
|
b/deepvariant/dv_constants.py |
|
|
1 |
# Copyright 2017 Google LLC. |
|
|
2 |
# |
|
|
3 |
# Redistribution and use in source and binary forms, with or without |
|
|
4 |
# modification, are permitted provided that the following conditions |
|
|
5 |
# are met: |
|
|
6 |
# |
|
|
7 |
# 1. Redistributions of source code must retain the above copyright notice, |
|
|
8 |
# this list of conditions and the following disclaimer. |
|
|
9 |
# |
|
|
10 |
# 2. Redistributions in binary form must reproduce the above copyright |
|
|
11 |
# notice, this list of conditions and the following disclaimer in the |
|
|
12 |
# documentation and/or other materials provided with the distribution. |
|
|
13 |
# |
|
|
14 |
# 3. Neither the name of the copyright holder nor the names of its |
|
|
15 |
# contributors may be used to endorse or promote products derived from this |
|
|
16 |
# software without specific prior written permission. |
|
|
17 |
# |
|
|
18 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
|
19 |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
|
20 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
|
21 |
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
|
22 |
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
|
23 |
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
|
24 |
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
|
25 |
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
|
26 |
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
|
27 |
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
|
28 |
# POSSIBILITY OF SUCH DAMAGE. |
|
|
29 |
"""Common constants shared across DeepVariant's codebase. |
|
|
30 |
|
|
|
31 |
This file is for very general constants in the code that end up needing to be |
|
|
32 |
accessed in a variety of places, often in live code as well as throughout the |
|
|
33 |
code in tests. |
|
|
34 |
""" |
|
|
35 |
|
|
|
36 |
from deepvariant.protos import deepvariant_pb2 |
|
|
37 |
|
|
|
38 |
# Default width [in basepairs] for our DeepVariant data tensor. |
|
|
39 |
PILEUP_DEFAULT_WIDTH = 221 |
|
|
40 |
|
|
|
41 |
# Default height [in rows] for our DeepVariant data tensor. |
|
|
42 |
PILEUP_DEFAULT_HEIGHT = 100 |
|
|
43 |
|
|
|
44 |
# Default channels if none are provided |
|
|
45 |
PILEUP_DEFAULT_CHANNELS = [ |
|
|
46 |
'read_base', |
|
|
47 |
'base_quality', |
|
|
48 |
'mapping_quality', |
|
|
49 |
'strand', |
|
|
50 |
'read_supports_variant', |
|
|
51 |
'base_differs_from_ref', |
|
|
52 |
] |
|
|
53 |
|
|
|
54 |
# Channels that include insert size. |
|
|
55 |
PILEUP_CHANNELS_WITH_INSERT_SIZE = [ |
|
|
56 |
'read_base', |
|
|
57 |
'base_quality', |
|
|
58 |
'mapping_quality', |
|
|
59 |
'strand', |
|
|
60 |
'read_supports_variant', |
|
|
61 |
'base_differs_from_ref', |
|
|
62 |
'insert_size', |
|
|
63 |
] |
|
|
64 |
|
|
|
65 |
# Not a default because it's hard-coded into the code. |
|
|
66 |
PILEUP_NUM_CHANNELS = len(PILEUP_DEFAULT_CHANNELS) |
|
|
67 |
|
|
|
68 |
# The dimensions of a pileup image tensor as height x width x rank. |
|
|
69 |
PILEUP_DEFAULT_DIMS = [ |
|
|
70 |
PILEUP_DEFAULT_HEIGHT, |
|
|
71 |
PILEUP_DEFAULT_WIDTH, |
|
|
72 |
PILEUP_NUM_CHANNELS, |
|
|
73 |
] |
|
|
74 |
|
|
|
75 |
# Number of classes represented in the data set. The three classes are |
|
|
76 |
# homozygous reference (0), heterozygous (1) and homozygous alternative (2). |
|
|
77 |
NUM_CLASSES = 3 |
|
|
78 |
NUM_DENOVO_CLASSES = 2 |
|
|
79 |
|
|
|
80 |
# Default sample name if no sample name is found from the BAM header. |
|
|
81 |
DEFAULT_SAMPLE_NAME = 'default' |
|
|
82 |
|
|
|
83 |
# Define all available channels, configured using --channel_list |
|
|
84 |
CHANNELS = [ |
|
|
85 |
'read_base', |
|
|
86 |
'base_quality', |
|
|
87 |
'mapping_quality', |
|
|
88 |
'strand', |
|
|
89 |
'read_supports_variant', |
|
|
90 |
'base_differs_from_ref', |
|
|
91 |
'haplotype', |
|
|
92 |
'allele_frequency', |
|
|
93 |
'diff_channels_alternate_allele_1', |
|
|
94 |
'diff_channels_alternate_allele_2', |
|
|
95 |
'read_mapping_percent', |
|
|
96 |
'avg_base_quality', |
|
|
97 |
'identity', |
|
|
98 |
'gap_compressed_identity', |
|
|
99 |
'gc_content', |
|
|
100 |
'is_homopolymer', |
|
|
101 |
'homopolymer_weighted', |
|
|
102 |
'blank', |
|
|
103 |
'insert_size', |
|
|
104 |
'base_channels_alternate_allele_1', |
|
|
105 |
'base_channels_alternate_allele_2', |
|
|
106 |
'mean_coverage', |
|
|
107 |
] |
|
|
108 |
|
|
|
109 |
ALT_ALIGNED_PILEUP_CHANNELS = [ |
|
|
110 |
'base_channels_alternate_allele_1', |
|
|
111 |
'base_channels_alternate_allele_2', |
|
|
112 |
'diff_channels_alternate_allele_1', |
|
|
113 |
'diff_channels_alternate_allele_2', |
|
|
114 |
] |
|
|
115 |
|
|
|
116 |
# Create list of channels that can be used with --channel_list by removing |
|
|
117 |
# channels specified using --alt_aligned_pileup. |
|
|
118 |
USER_SET_CHANNELS = [ |
|
|
119 |
x for x in CHANNELS if x not in ALT_ALIGNED_PILEUP_CHANNELS |
|
|
120 |
] |
|
|
121 |
|
|
|
122 |
CHANNEL_ENUM_TO_STRING = { |
|
|
123 |
deepvariant_pb2.CH_READ_BASE: 'read_base', |
|
|
124 |
deepvariant_pb2.CH_BASE_QUALITY: 'base_quality', |
|
|
125 |
deepvariant_pb2.CH_MAPPING_QUALITY: 'mapping_quality', |
|
|
126 |
deepvariant_pb2.CH_STRAND: 'strand', |
|
|
127 |
deepvariant_pb2.CH_READ_SUPPORTS_VARIANT: 'read_supports_variant', |
|
|
128 |
deepvariant_pb2.CH_BASE_DIFFERS_FROM_REF: 'base_differs_from_ref', |
|
|
129 |
deepvariant_pb2.CH_HAPLOTYPE_TAG: 'haplotype', |
|
|
130 |
deepvariant_pb2.CH_ALLELE_FREQUENCY: 'allele_frequency', |
|
|
131 |
deepvariant_pb2.CH_DIFF_CHANNELS_ALTERNATE_ALLELE_1: ( |
|
|
132 |
'diff_channels_alternate_allele_1' |
|
|
133 |
), |
|
|
134 |
deepvariant_pb2.CH_DIFF_CHANNELS_ALTERNATE_ALLELE_2: ( |
|
|
135 |
'diff_channels_alternate_allele_2' |
|
|
136 |
), |
|
|
137 |
deepvariant_pb2.CH_READ_MAPPING_PERCENT: 'read_mapping_percent', |
|
|
138 |
deepvariant_pb2.CH_AVG_BASE_QUALITY: 'avg_base_quality', |
|
|
139 |
deepvariant_pb2.CH_IDENTITY: 'identity', |
|
|
140 |
deepvariant_pb2.CH_GAP_COMPRESSED_IDENTITY: 'gap_compressed_identity', |
|
|
141 |
deepvariant_pb2.CH_GC_CONTENT: 'gc_content', |
|
|
142 |
deepvariant_pb2.CH_IS_HOMOPOLYMER: 'is_homopolymer', |
|
|
143 |
deepvariant_pb2.CH_HOMOPOLYMER_WEIGHTED: 'homopolymer_weighted', |
|
|
144 |
deepvariant_pb2.CH_BLANK: 'blank', |
|
|
145 |
deepvariant_pb2.CH_INSERT_SIZE: 'insert_size', |
|
|
146 |
deepvariant_pb2.CH_BASE_CHANNELS_ALTERNATE_ALLELE_1: ( |
|
|
147 |
'base_channels_alternate_allele_1' |
|
|
148 |
), |
|
|
149 |
deepvariant_pb2.CH_BASE_CHANNELS_ALTERNATE_ALLELE_2: ( |
|
|
150 |
'base_channels_alternate_allele_2' |
|
|
151 |
), |
|
|
152 |
deepvariant_pb2.CH_MEAN_COVERAGE: 'mean_coverage', |
|
|
153 |
} |
|
|
154 |
|
|
|
155 |
# Used only when phasing is on (phase_reads=true). It allows to set the |
|
|
156 |
# region padding as a percantage over the region length. candidates are |
|
|
157 |
# calculated over an extended region. Output examples are not affected by |
|
|
158 |
# this value. |
|
|
159 |
PHASE_READS_REGION_PADDING_PCT = 20 |