annotate blast_entry.py @ 4:0145fdbdcf90 draft default tip

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