Skip to content
Open
13 changes: 7 additions & 6 deletions REQUIREMENTS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ flask-log
flask-mail
flask-restful
gunicorn
biocommons.seqrepo>=0.5.1
httplib2>=0.9.0
configparser>=3.5.0
pyliftover>=0.3
biotools>=0.3.0
biocommons.seqrepo
httplib2
configparser
pyliftover
biotools
mysql-connector-python
requests
pytest>=3.6
pytest
pytest-cov
codecov
dicttoxml



31 changes: 31 additions & 0 deletions application/app_v1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Simple rest interface for VariantVlidator built using Flask Flask-RESTPlus and Swagger UI
"""

# Import modules
from flask import Flask
from flask_restx import Api, Resource

# Define the application as a Flask app with the name defined by __name__ (i.e. the name of the current module)
# Most tutorials define application as "app", but I have had issues with this when it comes to deployment,
# so application is recommended
application = Flask(__name__)

# Define the API as api
api = Api(app = application)

# Define a name-space to be read Swagger UI which is built in to Flask-RESTPlus
# The first variable is the path of the namespace the second variable describes the space
hello_space = api.namespace('hello', description='Simple API that returns a greeting')
@hello_space.route("/")
class HelloClass(Resource):
def get(self):
return {
"greeting": "Hello World"
}


# Allows app to be run in debug mode
if __name__ == '__main__':
application.debug = True # Enable debugging mode
application.run(host="127.0.0.1", port=5000) # Specify a host and port fot the app
40 changes: 40 additions & 0 deletions application/app_v2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
Simple rest interface for VariantVlidator built using Flask Flask-RESTPlus and Swagger UI
"""

# Import modules
from flask import Flask
from flask_restx import Api, Resource

# Define the application as a Flask app with the name defined by __name__ (i.e. the name of the current module)
# Most tutorials define application as "app", but I have had issues with this when it comes to deployment,
# so application is recommended
application = Flask(__name__)

# Define the API as api
api = Api(app = application)

# Define a name-space to be read Swagger UI which is built in to Flask-RESTPlus
# The first variable is the path of the namespace the second variable describes the space
hello_space = api.namespace('hello', description='Simple API that returns a greeting')
@hello_space.route("/")
class HelloClass(Resource):
def get(self):
return {
"greeting": "Hello World"
}


name_space = api.namespace('name', description='Return a name provided by the user')
@name_space.route("/<string:name>")
class NameClass(Resource):
def get(self, name):
return {
"My name is" : name
}


# Allows app to be run in debug mode
if __name__ == '__main__':
application.debug = True # Enable debugging mode
application.run(host="127.0.0.1", port=5000) # Specify a host and port fot the app
51 changes: 51 additions & 0 deletions application/app_v3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""
Simple rest interface for VariantVlidator built using Flask Flask-RESTPlus and Swagger UI
"""

# Import modules
from flask import Flask
from flask_restx import Api, Resource
import _____

# Define the application as a Flask app with the name defined by __name__ (i.e. the name of the current module)
# Most tutorials define application as "app", but I have had issues with this when it comes to deployment,
# so application is recommended
application = Flask(__name__)

# Define the API as api
api = Api(app = application)

# Define a name-space to be read Swagger UI which is built in to Flask-RESTPlus
# The first variable is the path of the namespace the second variable describes the space
hello_space = api.namespace('hello', description='Simple API that returns a greeting')
@hello_space.route("/")
class HelloClass(Resource):
def get(self):
return {
"greeting": "Hello World"
}


name_space = api.namespace('name', description='Return a name provided by the user')
@name_space.route("/<string:name>")
class NameClass(Resource):
def get(self, name):
return {
"My name is" : name
}

vv_space = api.namespace('VariantValidator', description='VariantValidator APIs')
@vv_space.route("/variantvalidator/_____")
class VariantValidatorClass(Resource):
def get(self, _____):

# Make a request to the curent VariantValidator rest-API
url = _____
validation = _____
content = _____
return _____

# Allows app to be run in debug mode
if __name__ == '__main__':
application.debug = True # Enable debugging mode
application.run(host="127.0.0.1", port=5000) # Specify a host and port fot the app
68 changes: 68 additions & 0 deletions application/app_v4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""
Simple rest interface for VariantVlidator built using Flask Flask-RESTPlus and Swagger UI
"""

# Import modules
from flask import Flask, make_response
from flask_restx import Api, Resource
import requests
from dicttoxml import dicttoxml

# Define the application as a Flask app with the name defined by __name__ (i.e. the name of the current module)
# Most tutorials define application as "app", but I have had issues with this when it comes to deployment,
# so application is recommended
application = Flask(__name__)

# Define the API as api
api = Api(app = application)


"""
Representations
- Adds a response-type into the "Response content type" drop-down menu displayed in Swagger
- When selected, the APP will return the correct response-header and content type
- The default for flask-restx is aspplication/json
"""
# Add additional representations using the @api.representation decorator
# Requires the module make_response from flask and json2xml
@api.representation('text/xml')
def xml(data, code, headers):
data = dicttoxml(data)
resp = make_response(data, code)
resp.headers['Content-Type'] = 'text/xml'
return resp


# Define a name-space to be read Swagger UI which is built in to Flask-RESTPlus
# The first variable is the path of the namespace the second variable describes the space
hello_space = api.namespace('hello', description='Simple API that returns a greeting')
@hello_space.route("/")
class HelloClass(Resource):
def get(self):
return {
"greeting": "Hello World"
}

name_space = api.namespace('name', description='Return a name provided by the user')
@name_space.route("/<string:name>")
class NameClass(Resource):
def get(self, name):
return {
"My name is" : name
}

vv_space = api.namespace('VariantValidator', description='VariantValidator APIs')
@vv_space.route("/variantvalidator/<string:genome_build>/<string:variant_description>/<string:select_transcripts>")
class VariantValidatorClass(Resource):
def get(self, genome_build, variant_description, select_transcripts):

# Make a request to the curent VariantValidator rest-API
url = '/'.join(['http://rest.variantvalidator.org/variantvalidator', genome_build, variant_description, select_transcripts])
validation = requests.get(url)
content = validation.json()
return content

# Allows app to be run in debug mode
if __name__ == '__main__':
application.debug = True # Enable debugging mode
application.run(host="127.0.0.1", port=5000) # Specify a host and port fot the app
68 changes: 68 additions & 0 deletions application/app_v5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""
Simple rest interface for VariantVlidator built using Flask Flask-RESTPlus and Swagger UI
"""

# Import modules
from flask import Flask, make_response
from flask_restx import Api, Resource
import requests
from dicttoxml import dicttoxml

# Define the application as a Flask app with the name defined by __name__ (i.e. the name of the current module)
# Most tutorials define application as "app", but I have had issues with this when it comes to deployment,
# so application is recommended
application = Flask(__name__)

# Define the API as api
api = Api(app = application)


"""
Representations
- Adds a response-type into the "Response content type" drop-down menu displayed in Swagger
- When selected, the APP will return the correct response-header and content type
- The default for flask-restx is aspplication/json
"""
# Add additional representations using the @api.representation decorator
# Requires the module make_response from flask and json2xml
@api.representation('text/xml')
def xml(data, code, headers):
data = dicttoxml(data)
resp = make_response(data, code)
resp.headers['Content-Type'] = 'text/xml'
return resp


# Define a name-space to be read Swagger UI which is built in to Flask-RESTPlus
# The first variable is the path of the namespace the second variable describes the space
hello_space = api.namespace('hello', description='Simple API that returns a greeting')
@hello_space.route("/")
class HelloClass(Resource):
def get(self):
return {
"greeting": "Hello World"
}

name_space = api.namespace('name', description='Return a name provided by the user')
@name_space.route("/<string:name>")
class NameClass(Resource):
def get(self, name):
return {
"My name is" : name
}

vv_space = api.namespace('VariantValidator', description='VariantValidator APIs')
@vv_space.route("/variantvalidator/<string:genome_build>/<string:variant_description>/<string:select_transcripts>")
class VariantValidatorClass(Resource):
def get(self, genome_build, variant_description, select_transcripts):

# Make a request to the curent VariantValidator rest-API
url = '/'.join(['http://rest.variantvalidator.org/variantvalidator', genome_build, variant_description, select_transcripts])
validation = requests.get(url)
content = validation.json()
return content

# Allows app to be run in debug mode
if __name__ == '__main__':
application.debug = True # Enable debugging mode
application.run(host="127.0.0.1", port=5000) # Specify a host and port fot the app
68 changes: 68 additions & 0 deletions application/app_v6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""
Simple rest interface for VariantVlidator built using Flask Flask-RESTPlus and Swagger UI
"""

# Import modules
from flask import Flask, make_response
from flask_restx import Api, Resource
import requests
from dicttoxml import dicttoxml

# Define the application as a Flask app with the name defined by __name__ (i.e. the name of the current module)
# Most tutorials define application as "app", but I have had issues with this when it comes to deployment,
# so application is recommended
application = Flask(__name__)

# Define the API as api
api = Api(app = application)


"""
Representations
- Adds a response-type into the "Response content type" drop-down menu displayed in Swagger
- When selected, the APP will return the correct response-header and content type
- The default for flask-restx is aspplication/json
"""
# Add additional representations using the @api.representation decorator
# Requires the module make_response from flask and json2xml
@api.representation('text/xml')
def xml(data, code, headers):
data = dicttoxml(data)
resp = make_response(data, code)
resp.headers['Content-Type'] = 'text/xml'
return resp


# Define a name-space to be read Swagger UI which is built in to Flask-RESTPlus
# The first variable is the path of the namespace the second variable describes the space
hello_space = api.namespace('hello', description='Simple API that returns a greeting')
@hello_space.route("/")
class HelloClass(Resource):
def get(self):
return {
"greeting": "Hello World"
}

name_space = api.namespace('name', description='Return a name provided by the user')
@name_space.route("/<string:name>")
class NameClass(Resource):
def get(self, name):
return {
"My name is" : name
}

vv_space = api.namespace('VariantValidator', description='VariantValidator APIs')
@vv_space.route("/variantvalidator/<string:genome_build>/<string:variant_description>/<string:select_transcripts>")
class VariantValidatorClass(Resource):
def get(self, genome_build, variant_description, select_transcripts):

# Make a request to the curent VariantValidator rest-API
url = '/'.join(['http://rest.variantvalidator.org/variantvalidator', genome_build, variant_description, select_transcripts])
validation = requests.get(url)
content = validation.json()
return content

# Allows app to be run in debug mode
if __name__ == '__main__':
application.debug = True # Enable debugging mode
application.run(host="127.0.0.1", port=5000) # Specify a host and port fot the app
Empty file added application/models.py
Empty file.
3 changes: 3 additions & 0 deletions application/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
flask==1.1.1
flask_restplus
Werkzeug==0.16.1
Loading