Skip to content

Commit

Permalink
output original AO
Browse files Browse the repository at this point in the history
  • Loading branch information
dolittle007 committed Nov 8, 2024
1 parent f319fd0 commit 24f8469
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/scanitd/base/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Event:
__slots__ = (
"af",
"alt_allele",
"oao",
"ao",
"break_point_region",
"chrom",
Expand All @@ -74,6 +75,7 @@ def __init__(
event_size: int,
event_sequence: str,
event_type: str,
oao: int,
ao: int,
dp: int,
end: int,
Expand All @@ -86,6 +88,7 @@ def __init__(
self.event_size = event_size
self.event_sequence = event_sequence
self.event_type = event_type
self.oao = oao
self.ao = ao
self.dp = dp
self.af = round(float(ao / dp), 4)
Expand Down Expand Up @@ -114,6 +117,7 @@ def new(
cls,
event_type: str,
event_id: tuple[str, int, int, str, MicroRegion],
oao: int,
ao: int,
dp: int,
ref_allele: str | None = None,
Expand All @@ -132,6 +136,7 @@ def new(
event_size,
event_sequence,
event_type,
oao,
ao,
dp,
end,
Expand Down
4 changes: 2 additions & 2 deletions src/scanitd/inference/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,14 @@ def scan_itd(
_chrom, _ref_start, _event_size, _event_seq, break_point_region = tdup_id
depth = obtain_depth_given_genomic_position(bam_object, _chrom, _ref_start)
ref_allele, alt_allele = tdup_allele_dict[tdup_id]
event_list.append(Event.new("TDUP", tdup_id, new_ao, depth, ref_allele, alt_allele))
event_list.append(Event.new("TDUP", tdup_id, original_ao, new_ao, depth, ref_allele, alt_allele))

for ins_id in ins_ao:
_chrom, _ref_start, _event_size, _event_seq, break_point_region = ins_id
ao = ins_ao[tdup_id]
depth = obtain_depth_given_genomic_position(bam_object, _chrom, _ref_start)
ref_allele, alt_allele = ins_allele_dict[ins_id]
event_list.append(Event.new("INS", ins_id, ao, depth, ref_allele, alt_allele))
event_list.append(Event.new("INS", ins_id, ao, ao, depth, ref_allele, alt_allele))

# Sort by chrom, then by reference position
sorted_event_list = sorted(event_list, key=lambda event: (event.chrom, event.ref_start))
Expand Down
8 changes: 6 additions & 2 deletions src/scanitd/writer/vcf_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class VCFWriter(Writer):

reserved_info: ClassVar[dict[str, str]] = {
"DP": "Integer",
"OAO": "Integer",
"AO": "Integer",
"AF": "Float",
"SVMETHOD": "String",
Expand All @@ -64,7 +65,8 @@ class VCFWriter(Writer):

description: ClassVar[dict[str, str]] = {
"DP": "Total read depth at the locus",
"AO": "Alternate allele observations, with partial observations recorded fractionally",
"OAO": "Original alternate allele observations",
"AO": "Alternate allele observations",
"AF": "Estimated allele frequency in the range (0,1], representing the ratio of reads showing the alternative allele to all reads",
"SVTYPE": "The type of event, TDUP, INS.",
"SVLEN": "Difference in length between REF and ALT alleles",
Expand Down Expand Up @@ -226,6 +228,7 @@ def get_vcf_features_from_event(
sv_type = event.event_type
chrom = event.chrom
ref_start = event.ref_start
oao = event.oao
ao = event.ao
dp = event.dp
af = event.af
Expand All @@ -248,6 +251,7 @@ def get_vcf_features_from_event(
"SVTYPE": sv_type,
"CHR2": chrom,
"END": f"{end + 1}",
"OAO": f"{oao}",
"AO": f"{ao}",
"DP": f"{dp}",
"AF": f"{af:.3g}",
Expand All @@ -262,7 +266,7 @@ def get_vcf_features_from_event(
def vcf_feature_transformer(feature_dict: dict[str, str], event_id: int) -> list[str]:
"""VCF feature transformer."""
info_field = (
f'SVTYPE={feature_dict["SVTYPE"]};AO={feature_dict["AO"]};'
f'SVTYPE={feature_dict["SVTYPE"]};OAO={feature_dict["OAO"]};AO={feature_dict["AO"]};'
f'CHR2={feature_dict["CHR2"]};END={feature_dict["END"]};'
f'DP={feature_dict["DP"]};AF={feature_dict["AF"]};SVLEN={feature_dict["SVLEN"]};'
f'INSSEQ={feature_dict["INSSEQ"]};HOMSEQ={feature_dict["HOMSEQ"]};'
Expand Down

0 comments on commit 24f8469

Please sign in to comment.