diff options
Diffstat (limited to 'bh20simplewebuploader/main.py')
-rw-r--r-- | bh20simplewebuploader/main.py | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 9132453..8a6794e 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -47,6 +47,7 @@ def type_to_heading(type_name): Turn a type name like "sampleSchema" from the metadata schema into a human-readable heading. """ + print(type_name,file=sys.stderr) # Remove camel case decamel = re.sub('([A-Z])', r' \1', type_name) # Split @@ -227,8 +228,13 @@ def generate_form(schema, options): # At startup, we need to load the metadata schema from the uploader module, so we can make a form for it -METADATA_SCHEMA = yaml.safe_load(pkg_resources.resource_stream("bh20sequploader", "bh20seq-schema.yml")) -METADATA_OPTION_DEFINITIONS = yaml.safe_load(pkg_resources.resource_stream("bh20sequploader", "bh20seq-options.yml")) +if os.path.isfile("bh20sequploader/bh20seq-schema.yml"): + METADATA_SCHEMA = yaml.safe_load(open("bh20sequploader/bh20seq-schema.yml","r").read()) + METADATA_OPTION_DEFINITIONS = yaml.safe_load(open("bh20sequploader/bh20seq-options.yml","r").read()) +else: + METADATA_SCHEMA = yaml.safe_load(pkg_resources.resource_stream("bh20sequploader", "bh20seq-schema.yml")) + METADATA_OPTION_DEFINITIONS = yaml.safe_load(pkg_resources.resource_stream("bh20sequploader", "bh20seq-options.yml")) +# print(METADATA_SCHEMA,file=sys.stderr) FORM_ITEMS = generate_form(METADATA_SCHEMA, METADATA_OPTION_DEFINITIONS) @app.route('/') @@ -505,7 +511,7 @@ def status_page(): Processing status """ - api = arvados.api(host=ARVADOS_API, token=ANONYMOUS_TOKEN) + api = arvados.api(host=ARVADOS_API, token=ANONYMOUS_TOKEN, insecure=True) pending = arvados.util.list_all(api.collections().list, filters=[["owner_uuid", "=", UPLOADER_PROJECT]]) out = [] status = {} @@ -567,11 +573,34 @@ baseURL='http://sparql.genenetwork.org/sparql/' @app.route('/api/getCount', methods=['GET']) def getCount(): - api = arvados.api(host=ARVADOS_API, token=ANONYMOUS_TOKEN) + """ + Get sequence counts from Arvados record + """ + api = arvados.api(host=ARVADOS_API, token=ANONYMOUS_TOKEN, insecure=True) c = api.collections().list(filters=[["owner_uuid", "=", VALIDATED_PROJECT]], limit=1).execute() return jsonify({'sequences': c["items_available"]}) +@app.route('/api/getCountDB', methods=['GET']) +def getCountDB(): + """ + Get sequence counts from Virtuoso DB + """ + query=""" + PREFIX pubseq: <http://biohackathon.org/bh20-seq-schema#MainSchema/> + select (COUNT(distinct ?dataset) as ?num) + { + ?dataset pubseq:submitter ?id . + ?id ?p ?submitter + } + """ + payload = {'query': query, 'format': 'json'} + r = requests.get(baseURL, params=payload) + result = r.json()['results']['bindings'] + # [{'num': {'type': 'typed-literal', 'datatype': 'http://www.w3.org/2001/XMLSchema#integer', 'value': '1352'}}] + # print(result, file=sys.stderr) + return jsonify({'sequences': int(result[0]["num"]["value"])}) + @app.route('/api/getAllaccessions', methods=['GET']) def getAllaccessions(): query="""SELECT DISTINCT ?fasta ?value WHERE {?fasta ?x[ <http://edamontology.org/data_2091> ?value ]}""" |