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.

43 lines
893B

  1. import sys,getopt
  2. import os
  3. import fileinput
  4. outFile = open(sys.argv[2],'w')
  5. for line in fileinput.input(sys.argv[1]):
  6. line = line.rstrip()
  7. strings = line.strip().split('\t')
  8. #d5
  9. if ',' in strings[6]:
  10. alt_strings = strings[6].split(',')
  11. alt_len = [len(i) for i in alt_strings]
  12. alt = max(alt_len)
  13. else:
  14. alt = len(strings[6])
  15. ref = strings[5]
  16. pos = int(strings[1])
  17. if len(ref) == 1 and alt == 1:
  18. StartPos = int(pos) -1
  19. EndPos = int(pos)
  20. cate = 'SNV'
  21. elif len(ref) > alt:
  22. StartPos = int(pos) - 1
  23. EndPos = int(pos) + (len(ref) - 1)
  24. cate = 'INDEL'
  25. elif alt > len(ref):
  26. StartPos = int(pos) - 1
  27. EndPos = int(pos) + (alt - 1)
  28. cate = 'INDEL'
  29. elif len(ref) == alt:
  30. StartPos = int(pos) - 1
  31. EndPos = int(pos) + (alt - 1)
  32. cate = 'INDEL'
  33. outline = '\t'.join(strings) + '\t' + str(StartPos) + '\t' + str(EndPos) + '\t' + cate + '\n'
  34. outFile.write(outline)