You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.0KB

  1. import re
  2. def position_to_bed(chromo,pos,ref,alt):
  3. # snv
  4. # Start cooridinate BED = start coordinate VCF - 1
  5. # End cooridinate BED = start coordinate VCF
  6. if len(ref) == 1 and len(alt) == 1:
  7. StartPos = int(pos) -1
  8. EndPos = int(pos)
  9. # deletions
  10. # Start cooridinate BED = start coordinate VCF - 1
  11. # End cooridinate BED = start coordinate VCF + (reference length - alternate length)
  12. elif len(ref) > 1 and len(alt) == 1:
  13. StartPos = int(pos) - 1
  14. EndPos = int(pos) + (len(ref) - 1)
  15. #insertions
  16. # For insertions:
  17. # Start cooridinate BED = start coordinate VCF - 1
  18. # End cooridinate BED = start coordinate VCF + (alternate length - reference length)
  19. else:
  20. StartPos = int(pos) - 1
  21. EndPos = int(pos) + (len(alt) - 1)
  22. return chromo,StartPos,EndPos
  23. def padding_region(chromo,pos1,pos2,padding):
  24. StartPos1 = pos1 - padding
  25. EndPos1 = pos1
  26. StartPos2 = pos2
  27. EndPos2 = pos2 + padding
  28. return chromo,StartPos1,EndPos1,StartPos2,EndPos2