Skip to content

Commit

Permalink
Added inversion detection
Browse files Browse the repository at this point in the history
  • Loading branch information
kjaisingh committed Jan 7, 2025
1 parent aba4ba4 commit a61a342
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/svtk/svtk/standardize/std_dragen.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,30 @@
from svtk.utils import is_smaller_chrom, parse_bnd_pos, parse_bnd_strands
from .standardize import VCFStandardizer

def checkInversion(record):
isInv3 = False
isInv5 = False
mateChr = ""
matePos = -1

def getMateInfo(splitChar):
items = record.alts[0].split(splitChar)
mateInfo = items[1].split(':')
matePos = mateInfo[-1]
mateChr = ":".join(mateInfo[:-1])
matePos = int(matePos)
return mateChr, matePos

if record.alts[0].startswith('['):
mateChr, matePos = getMateInfo('[')
if mateChr == record.chrom:
isInv5 = True
elif record.alts[0].endswith(']'):
mateChr, matePos = getMateInfo(']')
if mateChr == record.chrom:
isInv3 = True

return isInv3, isInv5, matePos

@VCFStandardizer.register('dragen')
class DragenStandardizer(VCFStandardizer):
Expand Down Expand Up @@ -102,6 +126,13 @@ def standardize_info(self, std_rec, raw_rec):

# Update ALGORITHMS
std_rec.info['ALGORITHMS'] = ['dragen']

# Update INV
isInv3, isInv5, matePos = checkInversion(raw_rec)
if isInv3 or isInv5:
std_rec.stop = matePos
std_rec.info['SVTYPE'] = 'INV'
std_rec.info['SVLEN'] = matePos - std_rec.pos

return std_rec

Expand Down

0 comments on commit a61a342

Please sign in to comment.