1
|
1 #!/usr/bin/env python
|
|
2 """
|
|
3 Python script, served as the entry of BLAST API
|
|
4 Separated the API with actual functionality (for Galaxy and future Web API)
|
|
5
|
|
6 Use -v or --version to get the version, -h or --help for help.
|
|
7
|
|
8 Author Nedias Sept 2016
|
|
9
|
|
10 """
|
|
11 import sys
|
|
12 from optparse import OptionParser
|
|
13 import blast_tool
|
|
14
|
|
15 # Usage message
|
|
16 usage = """Use as follows:
|
|
17 $ python blast_entry.py -i input_seq_file -o output_xml -f format -p blast_program -d blast_database
|
|
18 """
|
|
19
|
|
20 # User OptionParser to separate all optional arguments of the commandline
|
|
21 parser = OptionParser(usage=usage)
|
|
22 parser.add_option('-i', '--input', dest='input',
|
|
23 default=None, help='Input sequences filename',
|
|
24 metavar="FILE")
|
|
25 parser.add_option("-o", "--output", dest="output",
|
|
26 default=None,
|
|
27 help="Output of Blast result in xml form",
|
|
28 metavar="FILE")
|
4
|
29 parser.add_option("-v", "--version", dest="version",
|
|
30 default=False, action="store_true",
|
|
31 help="Show version and quit")
|
1
|
32 parser.add_option("-f", "--format", dest="format",
|
|
33 default="fasta",
|
|
34 help="Set the format of input file")
|
|
35 parser.add_option("-p", "--program", dest="program",
|
|
36 default="blastp",
|
|
37 help="Define which BLAST API is used")
|
|
38 parser.add_option("-d", "--database", dest="database",
|
|
39 default="nr",
|
|
40 help="Define which database to search from")
|
|
41
|
|
42 options, args = parser.parse_args()
|
|
43
|
|
44 # Show version data (TODO:consider move to blast_tool.py)
|
|
45 if options.version:
|
|
46 print("v0.1.0")
|
|
47 sys.exit(0)
|
|
48
|
|
49 # Call actual function
|
|
50 else:
|
|
51 blast_tool.exec_tool(options)
|
|
52
|
|
53
|