Skip to content

Commit

Permalink
Add haploid mode
Browse files Browse the repository at this point in the history
  • Loading branch information
chaklim committed Dec 22, 2019
1 parent 21ed5de commit e40b714
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clair/callVarBam.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def Run(args):
stop_consider_left_edge = command_option_from(args.stop_consider_left_edge, 'stop_consider_left_edge')
log_path = command_option_from(args.log_path, 'log_path', option_value=args.log_path)
pysam_for_all_indel_bases = command_option_from(args.pysam_for_all_indel_bases, 'pysam_for_all_indel_bases')
haploid_mode = command_option_from(args.haploid_mode, 'haploid_mode')
debug = command_option_from(args.debug, 'debug')
qual = command_option_from(args.qual, 'qual', option_value=args.qual)
fast_plotting = command_option_from(args.fast_plotting, 'fast_plotting')
Expand Down Expand Up @@ -161,6 +162,7 @@ def Run(args):
CommandOption('threads', numCpus),
CommandOption('ref_fn', ref_fn),
pysam_for_all_indel_bases,
haploid_mode,
qual,
debug
]
Expand Down Expand Up @@ -293,6 +295,9 @@ def main():
parser.add_argument('--pysam_for_all_indel_bases', action='store_true',
help="Always using pysam for outputting indel bases, optional")

parser.add_argument('--haploid_mode', action='store_true',
help="call haploid instead of diploid")

parser.add_argument('--activation_only', action='store_true',
help="Output activation only, no prediction")
parser.add_argument('--max_plot', type=int, default=10,
Expand Down
5 changes: 5 additions & 0 deletions clair/callVarBamParallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def Run(args):
stop_consider_left_edge = command_option_from(args.stop_consider_left_edge, 'stop_consider_left_edge')
log_path = command_option_from(args.log_path, 'log_path', option_value=args.log_path)
pysam_for_all_indel_bases = command_option_from(args.pysam_for_all_indel_bases, 'pysam_for_all_indel_bases')
haploid_mode = command_option_from(args.haploid_mode, 'haploid_mode')
debug = command_option_from(args.debug, 'debug')
qual = command_option_from(args.qual, 'qual', option_value=args.qual)
fast_plotting = command_option_from(args.fast_plotting, 'fast_plotting')
Expand All @@ -67,6 +68,7 @@ def Run(args):
stop_consider_left_edge,
debug,
pysam_for_all_indel_bases,
haploid_mode,
]

activation_only_command_options = [
Expand Down Expand Up @@ -174,6 +176,9 @@ def main():
parser.add_argument('--pysam_for_all_indel_bases', action='store_true',
help="Always using pysam for outputting indel bases, optional")

parser.add_argument('--haploid_mode', action='store_true',
help="call haploid instead of diploid")

parser.add_argument('--activation_only', action='store_true',
help="Output activation only, no prediction")
parser.add_argument('--max_plot', type=int, default=10,
Expand Down
19 changes: 19 additions & 0 deletions clair/call_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
OutputConfig = namedtuple('OutputConfig', [
'is_show_reference',
'is_debug',
'is_haploid_mode_enabled',
'quality_score_for_pass',
])
OutputUtilities = namedtuple('OutputUtilities', [
Expand Down Expand Up @@ -663,6 +664,7 @@ def output_from(
genotype_probabilities,
variant_length_probabilities_1,
variant_length_probabilities_2,
output_config,
output_utilities,
):
insertion_bases_using, deletion_bases_using, insertion_bases_using_pysam_using = (
Expand Down Expand Up @@ -723,6 +725,18 @@ def output_from(
is_hetero_DelDel = maximum_probability in hetero_DelDel_probabilities
is_insertion_and_deletion = maximum_probability in hetero_InsDel_probabilities


if output_config.is_haploid_mode_enabled:
if (
is_hetero_SNP or is_hetero_ACGT_Ins or is_hetero_InsIns or
is_hetero_ACGT_Del or is_hetero_DelDel or is_insertion_and_deletion
):
return (
(True, False, False, False, False, False, False, False, False, False),
(reference_base_ACGT, reference_base_ACGT)
)


if is_homo_SNP:
base1, base2 = homo_SNP_bases_from(gt21_probabilities)
reference_base = reference_sequence[tensor_position_center]
Expand Down Expand Up @@ -977,6 +991,7 @@ def batch_output(mini_batch, batch_Y, output_config, output_utilities):
genotype_probabilities,
variant_length_probabilities_1,
variant_length_probabilities_2,
output_config,
output_utilities,
)

Expand Down Expand Up @@ -1150,6 +1165,7 @@ def call_variants(args, m):
output_config = OutputConfig(
is_show_reference=args.showRef,
is_debug=args.debug,
is_haploid_mode_enabled=args.haploid_mode,
quality_score_for_pass=args.qual,
)
output_utilities = output_utilties_from(
Expand Down Expand Up @@ -1266,6 +1282,9 @@ def main():
parser.add_argument('--pysam_for_all_indel_bases', action='store_true',
help="Always using pysam for outputting indel bases, optional")

parser.add_argument('--haploid_mode', action='store_true',
help="call haploid instead of diploid")

args = parser.parse_args()

if len(sys.argv[1:]) == 0:
Expand Down

0 comments on commit e40b714

Please sign in to comment.