annotate tools/vcf_tools/vcfPytools.py @ 1:cdcb0ce84a1b

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