Skip to content

Commit a3c70fe

Browse files
committed
Fix bug related to full output
1 parent edad71b commit a3c70fe

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/HaplotagLR/PhasedRead.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ def _fetch_phased_variants(self, aligned_segment, vcf_file, sample, ignore_phase
487487
# in a try block to prevent premature termination. Aligned segments that map to
488488
# such contigs will be skipped.
489489
try:
490+
#sys.stderr.write("%s, %s, %s\n\n" % (aligned_segment.reference_name, aligned_segment.reference_start, aligned_segment.reference_end ))
490491
vcf_recs = vcf_in.fetch(aligned_segment.reference_name, aligned_segment.reference_start, aligned_segment.reference_end)
491492
# Note that coordinates supplied in this way are assumed zero-based by pysam (see source code, https://github.com/pysam-developers/pysam/blob/master/pysam/libcbcf.pyx, line 4366. We should verify these are zero-based. If not, use pysam chr:start-end string -- these are treated as one-based. This may not be a huge deal, since only variants coinciding with the start/end of the fragment will be affected.
492493
#sys.stderr.write("PR 473: %s, ingnore_phase_sets: %s, sample: %s\n\n" % (vcf_recs, ignore_phase_sets, sample))

src/HaplotagLR/cli.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def trim_phased_reads_to_fdr_neg_binom(phased_reads_list, FDR_threshold, output_
206206
for i, phased_read in enumerate(sorted_reads_list):
207207
if i < e:
208208
# Relabel the first e observations as Unphased.
209-
phased_read.PhaseSet_max.phase = 'Unphased'
209+
phased_read.PhaseSet_max.tag = 'Unphased'
210210
phased_read.aligned_segment.set_tag(tag = 'HP', value = "Untagged", value_type='Z', replace=True)
211211
#sys.stderr.write("%s: %s, %s\n" % (phased_read.query_name, phased_read.PhaseSet_max.phase, phased_read.PhaseSet_max.max_log_likelihood_ratio))
212212
write_bam_output(phased_read, output_streams, args)
@@ -300,7 +300,7 @@ def write_full_bam_output(phased_read, maternal_output_bam, paternal_output_bam,
300300
# TO-DO: Need to handle all possible levels of ploidy.
301301
if phased_read.is_tagged:
302302
if (args.log_likelihood_threshold >= 0 and phased_read.log_likelihood_ratio >= args.log_likelihood_threshold) or phased_read.haplotag_error_rate <= args.error_rate_threshold:
303-
if phased_read.phase == 1:
303+
if phased_read.haplotype == 1:
304304
phased_read.write_to_bam(output_bam_pysam = paternal_output_bam)
305305
else:
306306
phased_read.write_to_bam(output_bam_pysam = maternal_output_bam)
@@ -615,9 +615,9 @@ def error_analysis(args):
615615
err_read.aligned_segment.reference_length,
616616
err_rate_mean,
617617
err_read.PhaseSet_max.total_hets_analyzed,
618-
err_read.phase,
619-
err_read.PhaseSet_max.matches[err_read.phase-1],
620-
err_read.PhaseSet_max.non_matches[err_read.phase-1],
618+
err_read.tag,
619+
err_read.PhaseSet_max.matches[err_read.tag-1],
620+
err_read.PhaseSet_max.non_matches[err_read.tag-1],
621621
err_read.PhaseSet_max.log_probability_read_given_haplotype_i[0],
622622
err_read.PhaseSet_max.log_probability_read_given_haplotype_i[1],
623623
err_read.log_likelihood_ratio,

0 commit comments

Comments
 (0)