/tools/vcf_tools/vcfPytools.py

https://bitbucket.org/cistrome/cistrome-harvard/ · Python · 82 lines · 70 code · 9 blank · 3 comment · 20 complexity · 51985d6487051917d19cda23fda383d6 MD5 · raw file

  1. #!/usr/bin/python
  2. import os.path
  3. import sys
  4. __author__ = "alistair ward"
  5. __version__ = "version 0.26"
  6. __date__ = "february 2011"
  7. def main():
  8. usage = "Usage: vcfPytools.py [tool] [options]\n\n" + \
  9. "Available tools:\n" + \
  10. " annotate:\n\tAnnotate the vcf file with membership in other vcf files.\n" + \
  11. " extract:\n\tExtract vcf records from a region.\n" + \
  12. " filter:\n\tFilter the vcf file.\n" + \
  13. " intersect:\n\tGenerate the intersection of two vcf files.\n" + \
  14. " merge:\n\tMerge a list of vcf files.\n" + \
  15. " multi:\n\tFind the intersections and unique fractions of multiple vcf files.\n" + \
  16. " sort:\n\tSort a vcf file.\n" + \
  17. " stats:\n\tGenerate statistics from a vcf file.\n" + \
  18. " union:\n\tGenerate the union of two vcf files.\n" + \
  19. " unique:\n\tGenerate the unique fraction from two vcf files.\n" + \
  20. " validate:\n\tValidate the input vcf file.\n\n" + \
  21. "vcfPytools.py [tool] --help for information on a specific tool."
  22. # Determine the requested tool.
  23. if len(sys.argv) > 1:
  24. tool = sys.argv[1]
  25. else:
  26. print >> sys.stderr, usage
  27. exit(1)
  28. if tool == "annotate":
  29. import annotate
  30. success = annotate.main()
  31. elif tool == "extract":
  32. import extract
  33. success = extract.main()
  34. elif tool == "filter":
  35. import filter
  36. success = filter.main()
  37. elif tool == "intersect":
  38. import intersect
  39. success = intersect.main()
  40. elif tool == "multi":
  41. import multi
  42. success = multi.main()
  43. elif tool == "merge":
  44. import merge
  45. success = merge.main()
  46. elif tool == "sort":
  47. import sort
  48. success = sort.main()
  49. elif tool == "stats":
  50. import stats
  51. success = stats.main()
  52. elif tool == "union":
  53. import union
  54. success = union.main()
  55. elif tool == "unique":
  56. import unique
  57. success = unique.main()
  58. elif tool == "test":
  59. import test
  60. success = test.main()
  61. elif tool == "validate":
  62. import validate
  63. success = validate.main()
  64. elif tool == "--help" or tool == "-h" or tool == "?":
  65. print >> sys.stderr, usage
  66. else:
  67. print >> sys.stderr, "Unknown tool: ",tool
  68. print >> sys.stderr, "\n", usage
  69. exit(1)
  70. # If program completed properly, terminate.
  71. if success == 0: exit(0)
  72. if __name__ == "__main__":
  73. main()