view blast_entry.py @ 1:0c471588f014 draft

Uploaded
author nedias
date Wed, 12 Oct 2016 18:11:55 -0400
parents
children 0145fdbdcf90
line wrap: on
line source

#!/usr/bin/env python
"""
 Python script, served as the entry of BLAST API
 Separated the API with actual functionality (for Galaxy and future Web API)

 Use -v or --version to get the version, -h or --help for help.

 Author Nedias Sept 2016

"""
import sys
from optparse import OptionParser
import blast_tool

# Usage message
usage = """Use as follows:
$ python blast_entry.py -i input_seq_file -o output_xml -f format -p blast_program -d blast_database
"""

# User OptionParser to separate all optional arguments of the commandline
parser = OptionParser(usage=usage)
parser.add_option('-i', '--input', dest='input',
                  default=None, help='Input sequences filename',
                  metavar="FILE")
parser.add_option("-o", "--output", dest="output",
                  default=None,
                  help="Output of Blast result in xml form",
                  metavar="FILE")
parser.add_option("-f", "--format", dest="format",
                  default="fasta",
                  help="Set the format of input file")
parser.add_option("-p", "--program", dest="program",
                  default="blastp",
                  help="Define which BLAST API is used")
parser.add_option("-d", "--database", dest="database",
                  default="nr",
                  help="Define which database to search from")

options, args = parser.parse_args()

# Show version data (TODO:consider move to blast_tool.py)
if options.version:
    print("v0.1.0")
    sys.exit(0)

# Call actual function
else:
    blast_tool.exec_tool(options)