annotate vcfPytools.py @ 0:c6fb674dfda3 draft default tip

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