From 87e634040767373309fd7eb99784de0537f72059 Mon Sep 17 00:00:00 2001 From: Andrea Guarracino Date: Fri, 10 Jul 2020 11:50:06 +0200 Subject: other term for Homo sapiens (for SRA samples) --- scripts/dict_ontology_standardization/ncbi_host_species.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/dict_ontology_standardization/ncbi_host_species.csv b/scripts/dict_ontology_standardization/ncbi_host_species.csv index 40572a3..0bfc455 100644 --- a/scripts/dict_ontology_standardization/ncbi_host_species.csv +++ b/scripts/dict_ontology_standardization/ncbi_host_species.csv @@ -2,6 +2,7 @@ Homo sapiens,http://purl.obolibrary.org/obo/NCBITaxon_9606 human,http://purl.obolibrary.org/obo/NCBITaxon_9606 Human,http://purl.obolibrary.org/obo/NCBITaxon_9606 sapiens,http://purl.obolibrary.org/obo/NCBITaxon_9606 +homosapiens,http://purl.obolibrary.org/obo/NCBITaxon_9606 Mustela lutreola,http://purl.obolibrary.org/obo/NCBITaxon_9666 Manis javanica,http://purl.obolibrary.org/obo/NCBITaxon_9974 Felis catus,http://purl.obolibrary.org/obo/NCBITaxon_9685 -- cgit v1.2.3 From 1655762b516804dad3d71538e95d97d74653c3e9 Mon Sep 17 00:00:00 2001 From: AndreaGuarracino Date: Fri, 10 Jul 2020 13:43:59 +0200 Subject: updated metadata source --- .../SraExperimentPackage.2020.07.05.xml.gz | Bin 6502056 -> 0 bytes .../SraExperimentPackage.2020.07.09.xml.gz | Bin 0 -> 9744133 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 scripts/create_sra_metadata/SraExperimentPackage.2020.07.05.xml.gz create mode 100644 scripts/create_sra_metadata/SraExperimentPackage.2020.07.09.xml.gz diff --git a/scripts/create_sra_metadata/SraExperimentPackage.2020.07.05.xml.gz b/scripts/create_sra_metadata/SraExperimentPackage.2020.07.05.xml.gz deleted file mode 100644 index 88acb18..0000000 Binary files a/scripts/create_sra_metadata/SraExperimentPackage.2020.07.05.xml.gz and /dev/null differ diff --git a/scripts/create_sra_metadata/SraExperimentPackage.2020.07.09.xml.gz b/scripts/create_sra_metadata/SraExperimentPackage.2020.07.09.xml.gz new file mode 100644 index 0000000..93ef550 Binary files /dev/null and b/scripts/create_sra_metadata/SraExperimentPackage.2020.07.09.xml.gz differ -- cgit v1.2.3 From 8cb542fdf60273aec7ec107f8bc4896375381263 Mon Sep 17 00:00:00 2001 From: AndreaGuarracino Date: Fri, 10 Jul 2020 13:55:49 +0200 Subject: an output file is created with the accessions for which no YAML file is created --- scripts/create_sra_metadata/create_sra_metadata.py | 55 +++++++++++++--------- .../from_genbank_to_fasta_and_yaml.py | 10 +++- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/scripts/create_sra_metadata/create_sra_metadata.py b/scripts/create_sra_metadata/create_sra_metadata.py index ef0d119..10ac85b 100644 --- a/scripts/create_sra_metadata/create_sra_metadata.py +++ b/scripts/create_sra_metadata/create_sra_metadata.py @@ -8,7 +8,7 @@ import gzip dir_yaml = 'yaml' -date = '2020.07.05' +date = '2020.07.09' # Query on SRA: 'txid2697049[Organism]' (https://www.ncbi.nlm.nih.gov/sra/?term=txid2697049%5BOrganism%5D) # Query on SRA: 'txid2697049[Organism:noexp] NOT 0[Mbases ' (https://www.ncbi.nlm.nih.gov/sra/?term=txid2697049%5BOrganism:noexp%5D%20NOT%200[Mbases) @@ -50,13 +50,14 @@ sra_metadata_xml_file.close() EXPERIMENT_PACKAGE_SET = tree.getroot() missing_value_list = [] +not_created_accession_list = [] run_accession_set = set() run_accession_to_downloadble_file_url_dict = {} for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET): #print(i, EXPERIMENT_PACKAGE) - + # A general default-empty yaml could be read from the definitive one info_for_yaml_dict = { 'id': 'placeholder', @@ -74,17 +75,17 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET): #print(accession) info_for_yaml_dict['sample']['sample_id'] = accession - + #SRAFiles = RUN.find('SRAFiles') #if SRAFiles is not None: # url = SRAFiles.find('SRAFile').attrib['url'] # if 'sra-download.ncbi.nlm.nih.gov' in url: # run_accession_to_downloadble_file_url_dict[accession] = url - + SAMPLE = EXPERIMENT_PACKAGE.find('SAMPLE') SAMPLE_ATTRIBUTE_list = SAMPLE.iter('SAMPLE_ATTRIBUTE') - + for SAMPLE_ATTRIBUTE in SAMPLE_ATTRIBUTE_list: VALUE = SAMPLE_ATTRIBUTE.find('VALUE') if VALUE is not None: @@ -101,7 +102,7 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET): missing_value_list.append('\t'.join([accession, 'host_species', VALUE_text])) elif TAG_text in ['host_health_status', 'host health state']: if VALUE_text in term_to_uri_dict: - info_for_yaml_dict['host']['host_health_status'] = term_to_uri_dict[VALUE_text] + info_for_yaml_dict['host']['host_health_status'] = term_to_uri_dict[VALUE_text] elif VALUE_text.strip("'") not in ['missing', 'not collected', 'not provided']: missing_value_list.append('\t'.join([accession, 'host_health_status', VALUE_text])) elif TAG_text in ['strain', 'isolate']: @@ -113,12 +114,12 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET): if value_to_insert in term_to_uri_dict: value_to_insert = term_to_uri_dict[value_to_insert] - - if 'virus_strain' not in info_for_yaml_dict: + + if 'virus_strain' not in info_for_yaml_dict: info_for_yaml_dict['virus']['virus_strain'] = value_to_insert else: info_for_yaml_dict['virus']['virus_strain'] += '; ' + value_to_insert - elif TAG_text in ['isolation_source', 'isolation source host-associated']: + elif TAG_text in ['isolation_source', 'isolation source host-associated']: if VALUE_text in term_to_uri_dict: info_for_yaml_dict['sample']['specimen_source'] = [term_to_uri_dict[VALUE_text]] else: @@ -145,7 +146,7 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET): elif TAG_text == 'collected_by': if VALUE_text.lower() not in ['not available', 'missing']: name = VALUE_text in ['Dr. Susie Bartlett', 'Ahmed Babiker', 'Aisi Fu', 'Brandi Williamson', 'George Taiaroa', 'Natacha Ogando', 'Tim Dalebout', 'ykut Ozdarendeli'] - + info_for_yaml_dict['sample']['collector_name' if name else 'collecting_institution'] = VALUE_text elif TAG_text == 'collecting institution': if VALUE_text.lower() not in ['not provided', 'na']: @@ -154,11 +155,11 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET): if VALUE_text.lower() not in ['not applicable', 'missing', 'na']: date_to_write = VALUE_text date_is_estimated = True - + VALUE_text_list = VALUE_text.split('-') if len(VALUE_text_list) == 3: date_is_estimated = False - + if VALUE_text_list[1].isalpha(): date_to_write = parse(VALUE_text).strftime('%Y-%m-%d') elif len(VALUE_text_list) == 2: @@ -170,7 +171,7 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET): date_to_write = "{}-01-15".format(VALUE_text) info_for_yaml_dict['sample']['collection_date'] = date_to_write - + if date_is_estimated: if 'additional_collection_information' in info_for_yaml_dict['sample']: info_for_yaml_dict['sample']['additional_collection_information'] += "; The 'collection_date' is estimated (the original date was: {})".format(VALUE_text) @@ -188,8 +189,8 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET): taxon_id = SAMPLE.find('SAMPLE_NAME').find('TAXON_ID').text info_for_yaml_dict['virus']['virus_species'] = "http://purl.obolibrary.org/obo/NCBITaxon_"+taxon_id - - + + EXPERIMENT = EXPERIMENT_PACKAGE.find('EXPERIMENT') INSTRUMENT_MODEL = [x.text for x in EXPERIMENT.find('PLATFORM').iter('INSTRUMENT_MODEL')][0] @@ -206,18 +207,18 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET): SUBMISSION = EXPERIMENT_PACKAGE.find('SUBMISSION') info_for_yaml_dict['submitter']['submitter_sample_id'] = SUBMISSION.attrib['accession'] - + if SUBMISSION.attrib['lab_name'].lower() not in ['na']: info_for_yaml_dict['submitter']['originating_lab'] = SUBMISSION.attrib['lab_name'] - STUDY = EXPERIMENT_PACKAGE.find('STUDY') + STUDY = EXPERIMENT_PACKAGE.find('STUDY') info_for_yaml_dict['submitter']['publication'] = STUDY.attrib['alias'] - - + + Organization = EXPERIMENT_PACKAGE.find('Organization') Organization_Name = Organization.find('Name') info_for_yaml_dict['submitter']['authors'] = [Organization_Name.text] - + Organization_Contact = Organization.find('Contact') if Organization_Contact is not None: Organization_Contact_Name = Organization_Contact.find('Name') @@ -231,20 +232,28 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET): Organization_Address = Organization.find('Address') if Organization_Address is not None: info_for_yaml_dict['submitter']['lab_address'] = '; '.join([x.text for x in Organization_Address] + ['Postal code ' + Organization_Address.attrib['postal_code']]) - + if 'collection_date' not in info_for_yaml_dict['sample']: info_for_yaml_dict['sample']['collection_date'] = '1970-01-01' info_for_yaml_dict['sample']['additional_collection_information'] = "The real 'collection_date' is missing" if 'sample_sequencing_technology' not in info_for_yaml_dict['technology']: - print(accession, ' - technology not found') + #print(accession, ' - technology not found') + not_created_accession_list.append([accession, 'technology not found']) continue with open(os.path.join(dir_yaml, '{}.yaml'.format(accession)), 'w') as fw: json.dump(info_for_yaml_dict, fw, indent=2) - + if len(missing_value_list) > 0: path_missing_terms_tsv = 'missing_terms.tsv' print('Written missing terms in {}'.format(path_missing_terms_tsv)) with open(path_missing_terms_tsv, 'w') as fw: fw.write('\n'.join(missing_value_list)) + +if len(not_created_accession_list) > 0: + path_not_created_accession_tsv = 'not_created_accession.tsv' + print('Written not created accession in {}'.format(path_not_created_accession_tsv)) + with open(path_not_created_accession_tsv, 'w') as fw: + fw.write('\n'.join(['\t'.join(x) for x in not_created_accession_list])) + diff --git a/scripts/download_genbank_data/from_genbank_to_fasta_and_yaml.py b/scripts/download_genbank_data/from_genbank_to_fasta_and_yaml.py index 39e401a..d5b0ffd 100755 --- a/scripts/download_genbank_data/from_genbank_to_fasta_and_yaml.py +++ b/scripts/download_genbank_data/from_genbank_to_fasta_and_yaml.py @@ -138,6 +138,7 @@ min_len_to_count = 27500 num_seq_with_len_ge_X_bp = 0 missing_value_list = [] +not_created_accession_list = [] accession_with_errors_list = [] for path_metadata_xxx_xml in [os.path.join(dir_metadata, name_metadata_xxx_xml) for name_metadata_xxx_xml in os.listdir(dir_metadata) if name_metadata_xxx_xml.endswith('.xml')]: @@ -371,7 +372,8 @@ for path_metadata_xxx_xml in [os.path.join(dir_metadata, name_metadata_xxx_xml) if 'sample_sequencing_technology' not in info_for_yaml_dict['technology']: - print(accession_version, ' - technology not found') + #print(accession_version, ' - technology not found') + not_created_accession_list.append([accession_version, 'technology not found']) continue with open(os.path.join(dir_fasta_and_yaml, '{}.fasta'.format(accession_version)), 'w') as fw: @@ -400,4 +402,10 @@ if len(accession_with_errors_list) > 0: with open(path_accession_with_errors_tsv, 'w') as fw: fw.write('\n'.join(accession_with_errors_list)) +if len(not_created_accession_list) > 0: + path_not_created_accession_tsv = 'not_created_accession.tsv' + print('Written not created accession in {}'.format(path_not_created_accession_tsv)) + with open(path_not_created_accession_tsv, 'w') as fw: + fw.write('\n'.join(['\t'.join(x) for x in not_created_accession_list])) + print('Num. new sequences with length >= {} bp: {}'.format(min_len_to_count, num_seq_with_len_ge_X_bp)) -- cgit v1.2.3 From 2eab71a70b8630649303a9319e1baf9fa06f8ab4 Mon Sep 17 00:00:00 2001 From: AndreaGuarracino Date: Fri, 10 Jul 2020 15:39:02 +0200 Subject: metadata with missing host_species are not created --- scripts/create_sra_metadata/create_sra_metadata.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/create_sra_metadata/create_sra_metadata.py b/scripts/create_sra_metadata/create_sra_metadata.py index 10ac85b..a31bd36 100644 --- a/scripts/create_sra_metadata/create_sra_metadata.py +++ b/scripts/create_sra_metadata/create_sra_metadata.py @@ -242,6 +242,11 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET): not_created_accession_list.append([accession, 'technology not found']) continue + if 'host_species' not in info_for_yaml_dict['host']: + #print(accession, ' - technology not found') + not_created_accession_list.append([accession, 'missing host species']) + continue + with open(os.path.join(dir_yaml, '{}.yaml'.format(accession)), 'w') as fw: json.dump(info_for_yaml_dict, fw, indent=2) -- cgit v1.2.3 From bb90f06da570624952d4b7001ee37fc7018e3a7d Mon Sep 17 00:00:00 2001 From: AndreaGuarracino Date: Sun, 12 Jul 2020 15:58:29 +0200 Subject: added a suffix to distinguish which script created the error/warning files --- scripts/create_sra_metadata/create_sra_metadata.py | 4 ++-- scripts/download_genbank_data/from_genbank_to_fasta_and_yaml.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/create_sra_metadata/create_sra_metadata.py b/scripts/create_sra_metadata/create_sra_metadata.py index a31bd36..352a30e 100644 --- a/scripts/create_sra_metadata/create_sra_metadata.py +++ b/scripts/create_sra_metadata/create_sra_metadata.py @@ -251,13 +251,13 @@ for i, EXPERIMENT_PACKAGE in enumerate(EXPERIMENT_PACKAGE_SET): json.dump(info_for_yaml_dict, fw, indent=2) if len(missing_value_list) > 0: - path_missing_terms_tsv = 'missing_terms.tsv' + path_missing_terms_tsv = 'missing_terms.sra.tsv' print('Written missing terms in {}'.format(path_missing_terms_tsv)) with open(path_missing_terms_tsv, 'w') as fw: fw.write('\n'.join(missing_value_list)) if len(not_created_accession_list) > 0: - path_not_created_accession_tsv = 'not_created_accession.tsv' + path_not_created_accession_tsv = 'not_created_accession.sra.tsv' print('Written not created accession in {}'.format(path_not_created_accession_tsv)) with open(path_not_created_accession_tsv, 'w') as fw: fw.write('\n'.join(['\t'.join(x) for x in not_created_accession_list])) diff --git a/scripts/download_genbank_data/from_genbank_to_fasta_and_yaml.py b/scripts/download_genbank_data/from_genbank_to_fasta_and_yaml.py index d5b0ffd..dbebfbb 100755 --- a/scripts/download_genbank_data/from_genbank_to_fasta_and_yaml.py +++ b/scripts/download_genbank_data/from_genbank_to_fasta_and_yaml.py @@ -391,19 +391,19 @@ for path_metadata_xxx_xml in [os.path.join(dir_metadata, name_metadata_xxx_xml) continue if len(missing_value_list) > 0: - path_missing_terms_tsv = 'missing_terms.tsv' + path_missing_terms_tsv = 'missing_terms.genbank.tsv' print('Written missing terms in {}'.format(path_missing_terms_tsv)) with open(path_missing_terms_tsv, 'w') as fw: fw.write('\n'.join(missing_value_list)) if len(accession_with_errors_list) > 0: - path_accession_with_errors_tsv = 'accession_with_errors.tsv' + path_accession_with_errors_tsv = 'accession_with_errors.genbank.tsv' print('Written the accession with errors in {}'.format(path_accession_with_errors_tsv)) with open(path_accession_with_errors_tsv, 'w') as fw: fw.write('\n'.join(accession_with_errors_list)) if len(not_created_accession_list) > 0: - path_not_created_accession_tsv = 'not_created_accession.tsv' + path_not_created_accession_tsv = 'not_created_accession.genbank.tsv' print('Written not created accession in {}'.format(path_not_created_accession_tsv)) with open(path_not_created_accession_tsv, 'w') as fw: fw.write('\n'.join(['\t'.join(x) for x in not_created_accession_list])) -- cgit v1.2.3 From f44d555b788e29a1896a69d75401f0e145ad9299 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 15 Jul 2020 11:37:19 +0100 Subject: Update Guix install --- doc/INSTALL.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/INSTALL.md b/doc/INSTALL.md index 6dcd72b..3b270dd 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -42,7 +42,7 @@ repository. ### Using the Web Uploader -To run the web uploader in a GNU Guix environment/container +To run the web uploader in a GNU Guix environment/container run it with something like ``` guix environment guix --ad-hoc git python python-flask python-pyyaml python-pycurl python-magic nss-certs --network openssl -- env FLASK_ENV=development PYTHONPATH=$PYTHONPATH:./bh20sequploader FLASK_APP=bh20simplewebuploader/main.py flask run @@ -59,7 +59,7 @@ WIP: add gunicorn container Currently the full webserver container deploy command looks like ``` -penguin2:~/iwrk/opensource/code/vg/bh20-seq-resource$ env GUIX_PACKAGE_PATH=~/iwrk/opensource/guix/guix-bioinformatics/ ~/iwrk/opensource/guix/guix/pre-inst-env guix environment -C guix --ad-hoc git python python-flask python-pyyaml python-pycurl python-magic nss-certs python-pyshex python-pyyaml --network openssl python-pyshex python-pyshexc clustalw python-schema-salad python-arvados-python-client --share=/export/tmp -- env TMPDIR=/export/tmp FLASK_ENV=development FLASK_APP=bh20simplewebuploader/main.py flask run -`` +penguin2:~/iwrk/opensource/code/vg/bh20-seq-resource$ env GUIX_PACKAGE_PATH=~/iwrk/opensource/guix/guix-oinformatics/ ~/iwrk/opensource/guix/guix/pre-inst-env guix environment -C guix --ad-hoc git python python-flask python-pyyaml python-pycurl python-magic nss-certs python-pyshex python-pyyaml --network openssl python-pyshex python-pyshexc clustalw python-schema-salad python-arvados-python-client --share=/export/tmp -- env TMPDIR=/export/tmp FLASK_ENV=development FLASK_APP=bh20simplewebuploader/main.py flask run +``` Note: see above on GUIX_PACKAGE_PATH. -- cgit v1.2.3 From 9c9512a7e040f8247d259bdc6f9cf55d5d276baf Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 15 Jul 2020 12:48:12 +0100 Subject: Load metadata locally without pkg_resources --- bh20simplewebuploader/main.py | 9 +++++++-- bh20simplewebuploader/static/main.js | 2 +- doc/blog/using-covid-19-pubseq-part5.org | 14 +++++++++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 77e345b..8b5781a 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -227,8 +227,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('/') diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js index 751e478..4703047 100644 --- a/bh20simplewebuploader/static/main.js +++ b/bh20simplewebuploader/static/main.js @@ -195,7 +195,7 @@ function addField(e) { // Increment the number and use the keypath and number to set IDs and cross // references. // TODO: Heavily dependent on the form field HTML. Maybe we want custom - // elements for the labeled controlsd that know how to be list items? + // elements for the labeled controls that know how to be list items? fieldNumber++ newField.dataset.number = fieldNumber let newID = keypath + '[' + fieldNumber + ']' diff --git a/doc/blog/using-covid-19-pubseq-part5.org b/doc/blog/using-covid-19-pubseq-part5.org index 4b0ea64..aa06d5e 100644 --- a/doc/blog/using-covid-19-pubseq-part5.org +++ b/doc/blog/using-covid-19-pubseq-part5.org @@ -13,6 +13,7 @@ - [[#what-is-the-schema][What is the schema?]] - [[#how-is-the-website-generated][How is the website generated?]] - [[#modifying-the-schema][Modifying the schema]] + - [[#adding-fields-to-the-form][Adding fields to the form]] * Modify Metadata @@ -113,8 +114,15 @@ So, we'll add it simply as a title field. Now the draft schema is _id: https://creativecommons.org/ns#Work #+END_SRC -Now, we are no ontology experts, right? So, next we submit a patch to our source tree and -ask for feedback before wiring it up in the data entry form. The pull request was -submitted here FIXME. +Now, we are no ontology experts, right? So, next we submit a patch to +our source tree and ask for feedback before wiring it up in the data +entry form. The pull request was submitted [[https://github.com/arvados/bh20-seq-resource/pull/97][here]] and reviewed on the +gitter channel and I merged it. + +* Adding fields to the form + +To add the new fields to the form we have to modify it a little. If we +go to the upload form we need to add the license box. The schema is +loaded in [[https://github.com/arvados/bh20-seq-resource/blob/a0c8ebd57b875f265e8b0efec4abfaf892eb6c45/bh20simplewebuploader/main.py#L229][main.py]] in the 'generate_form' function. /Note: work in progress/ -- cgit v1.2.3 From b9691c7deae30bd6422fb7b0681572b7b6f78ae3 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 15 Jul 2020 14:16:11 +0100 Subject: Web: add license to input form --- bh20sequploader/bh20seq-schema.yml | 3 ++- bh20simplewebuploader/main.py | 3 ++- example/minimal_metadata_example.yaml | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bh20sequploader/bh20seq-schema.yml b/bh20sequploader/bh20seq-schema.yml index b3d4d12..29ac22c 100644 --- a/bh20sequploader/bh20seq-schema.yml +++ b/bh20sequploader/bh20seq-schema.yml @@ -15,7 +15,7 @@ $graph: fields: license_type: doc: License types as defined in https://wiki.creativecommons.org/images/d/d6/Ccrel-1.0.pdf - type: string? + type: string jsonldPredicate: _id: https://creativecommons.org/ns#License title: @@ -258,6 +258,7 @@ $graph: virus: virusSchema technology: technologySchema submitter: submitterSchema + license: licenseSchema id: doc: The subject (eg the fasta/fastq file) that the metadata describes type: string diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 8b5781a..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 @@ -233,7 +234,7 @@ if os.path.isfile("bh20sequploader/bh20seq-schema.yml"): 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) +# print(METADATA_SCHEMA,file=sys.stderr) FORM_ITEMS = generate_form(METADATA_SCHEMA, METADATA_OPTION_DEFINITIONS) @app.route('/') diff --git a/example/minimal_metadata_example.yaml b/example/minimal_metadata_example.yaml index 51f8a87..1b46cc7 100644 --- a/example/minimal_metadata_example.yaml +++ b/example/minimal_metadata_example.yaml @@ -1,5 +1,9 @@ id: placeholder + +license: + license_type: http://creativecommons.org/licenses/by/4.0/ + host: host_species: http://purl.obolibrary.org/obo/NCBITaxon_9606 @@ -15,4 +19,4 @@ technology: sample_sequencing_technology: [http://www.ebi.ac.uk/efo/EFO_0008632] submitter: - authors: [John Doe] \ No newline at end of file + authors: [John Doe] -- cgit v1.2.3 From f4ed46dae20abe5147871495ede2d6ac2b0854bc Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 15 Jul 2020 14:30:56 +0100 Subject: Add RDF output --- bh20sequploader/bh20seq-schema.yml | 9 +++++++-- bh20sequploader/bh20seq-shex.rdf | 24 +++++++++++++++++------- doc/blog/using-covid-19-pubseq-part5.org | 2 ++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/bh20sequploader/bh20seq-schema.yml b/bh20sequploader/bh20seq-schema.yml index 29ac22c..c690e8a 100644 --- a/bh20sequploader/bh20seq-schema.yml +++ b/bh20sequploader/bh20seq-schema.yml @@ -23,16 +23,21 @@ $graph: type: string? jsonldPredicate: _id: http://semanticscience.org/resource/SIO_001167 + attribution_name: + doc: Attribution NAME related to data license + type: string? + jsonldPredicate: + _id: https://creativecommons.org/ns#attributionName attribution_url: doc: Attribution URL related to data license type: string? jsonldPredicate: - _id: https://creativecommons.org/ns#Work + _id: https://creativecommons.org/ns#attributionURL attribution_source: doc: Attribution source URL related to data license type: string? jsonldPredicate: - _id: https://creativecommons.org/ns#Work + _id: https://creativecommons.org/ns#attributionSource - name: hostSchema type: record diff --git a/bh20sequploader/bh20seq-shex.rdf b/bh20sequploader/bh20seq-shex.rdf index 965229c..c48267d 100644 --- a/bh20sequploader/bh20seq-shex.rdf +++ b/bh20sequploader/bh20seq-shex.rdf @@ -1,6 +1,7 @@ PREFIX : PREFIX MainSchema: PREFIX hostSchema: +PREFIX cc: PREFIX xsd: PREFIX obo: PREFIX sio: @@ -15,10 +16,11 @@ PREFIX wikidata: MainSchema:submitter @:submitterShape ; MainSchema:technology @:technologyShape ; MainSchema:virus @:virusShape; + MainSchema:license @:licenseShape; } :hostShape { - efo:EFO_0000532 [ obo:NCBITaxon_~ ] ; + efo:EFO_0000532 [ obo:NCBITaxon_~ ] ; sio:SIO_000115 xsd:string ?; obo:PATO_0000047 [ obo:PATO_0000384 obo:PATO_0000383 obo:PATO_0001340] ?; obo:PATO_0000011 xsd:integer ?; @@ -32,14 +34,14 @@ PREFIX wikidata: :sampleShape { sio:SIO_000115 xsd:string; - evs:C25164 xsd:string; - obo:GAZ_00000448 [wikidata:~] ; + evs:C25164 xsd:string; + obo:GAZ_00000448 [wikidata:~] ; obo:OBI_0001895 xsd:string ?; obo:NCIT_C41206 xsd:string ?; obo:OBI_0001479 IRI {0,2}; obo:OBI_0001472 xsd:string ?; sio:SIO_001167 xsd:string ?; - edam:data_2091 IRI {0,3}; + edam:data_2091 IRI {0,3}; } :submitterShape { @@ -47,7 +49,7 @@ PREFIX wikidata: sio:SIO_000116 xsd:string *; sio:SIO_000172 xsd:string ?; obo:NCIT_C37984 xsd:string ?; - obo:NCIT_C37900 xsd:string ?; + obo:NCIT_C37900 xsd:string ?; efo:EFO_0001741 xsd:string ?; obo:NCIT_C42781 xsd:string ?; obo:NCIT_C19026 xsd:string ?; @@ -63,6 +65,14 @@ PREFIX wikidata: } :virusShape{ - edam:data_1875 [ obo:NCBITaxon_~ ] ; - sio:SIO_010055 xsd:string ?; + edam:data_1875 [ obo:NCBITaxon_~ ] ; + sio:SIO_010055 xsd:string ?; } + +:licenseShape{ + cc:License xsd:string; + sio:SIO_001167 xsd:string ?; + cc:attributionName xsd:string ?; + cc:attributionURL xsd:string ?; + cc:attributionSource xsd:string ?; +} \ No newline at end of file diff --git a/doc/blog/using-covid-19-pubseq-part5.org b/doc/blog/using-covid-19-pubseq-part5.org index aa06d5e..cb11f43 100644 --- a/doc/blog/using-covid-19-pubseq-part5.org +++ b/doc/blog/using-covid-19-pubseq-part5.org @@ -125,4 +125,6 @@ To add the new fields to the form we have to modify it a little. If we go to the upload form we need to add the license box. The schema is loaded in [[https://github.com/arvados/bh20-seq-resource/blob/a0c8ebd57b875f265e8b0efec4abfaf892eb6c45/bh20simplewebuploader/main.py#L229][main.py]] in the 'generate_form' function. +With this [[https://github.com/arvados/bh20-seq-resource/commit/b9691c7deae30bd6422fb7b0681572b7b6f78ae3][patch]] the website adds the license input fields on the form. + /Note: work in progress/ -- cgit v1.2.3 From 712614e5627e54df7ec6ab975dc86a1055051455 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 15 Jul 2020 14:54:59 +0100 Subject: License RDF --- bh20sequploader/bh20seq-schema.yml | 3 ++- bh20sequploader/bh20seq-shex.rdf | 3 ++- doc/blog/using-covid-19-pubseq-part5.org | 29 +++++++++++++++++++++++------ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/bh20sequploader/bh20seq-schema.yml b/bh20sequploader/bh20seq-schema.yml index c690e8a..ef55c55 100644 --- a/bh20sequploader/bh20seq-schema.yml +++ b/bh20sequploader/bh20seq-schema.yml @@ -1,6 +1,7 @@ $base: http://biohackathon.org/bh20-seq-schema $namespaces: cc: http://creativecommons.org/ns# + dc: http://purl.org/metadata/dublin_core_elements# sch: https://schema.org/ efo: http://www.ebi.ac.uk/efo/ obo: http://purl.obolibrary.org/obo/ @@ -22,7 +23,7 @@ $graph: doc: Attribution title related to data license type: string? jsonldPredicate: - _id: http://semanticscience.org/resource/SIO_001167 + _id: http://purl.org/metadata/dublin_core_elements#Title attribution_name: doc: Attribution NAME related to data license type: string? diff --git a/bh20sequploader/bh20seq-shex.rdf b/bh20sequploader/bh20seq-shex.rdf index c48267d..9fab334 100644 --- a/bh20sequploader/bh20seq-shex.rdf +++ b/bh20sequploader/bh20seq-shex.rdf @@ -2,6 +2,7 @@ PREFIX : PREFIX hostSchema: PREFIX cc: +PREFIX dc: PREFIX xsd: PREFIX obo: PREFIX sio: @@ -71,7 +72,7 @@ PREFIX wikidata: :licenseShape{ cc:License xsd:string; - sio:SIO_001167 xsd:string ?; + dc:Title xsd:string ?; cc:attributionName xsd:string ?; cc:attributionURL xsd:string ?; cc:attributionSource xsd:string ?; diff --git a/doc/blog/using-covid-19-pubseq-part5.org b/doc/blog/using-covid-19-pubseq-part5.org index cb11f43..98c2c31 100644 --- a/doc/blog/using-covid-19-pubseq-part5.org +++ b/doc/blog/using-covid-19-pubseq-part5.org @@ -14,19 +14,20 @@ - [[#how-is-the-website-generated][How is the website generated?]] - [[#modifying-the-schema][Modifying the schema]] - [[#adding-fields-to-the-form][Adding fields to the form]] + - [[#testing-the-license-fields][Testing the license fields]] * Modify Metadata The public sequence resource uses multiple data formats listed on the -[[./download][DOWNLOAD]] page. One of the most exciting features is the full support +[[http://covid19.genenetwork.org/download][download]] page. One of the most exciting features is the full support for RDF and semantic web/linked data ontologies. This technology allows for querying data in unprescribed ways - that is, you can formulate your own queries without dealing with a preset model of that data (so typical of CSV files and SQL tables). Examples of exploring -data are listed [[./blog?id=using-covid-19-pubseq-part1][here]]. +data are listed [[http://covid19.genenetwork.org/blog?id=using-covid-19-pubseq-part1][here]]. In this BLOG we are going to look at the metadata entered on the -[[./][COVID-19 PubSeq]] website (or command line client). It is important to +COVID-19 PubSeq website (or command line client). It is important to understand that anyone, including you, can change that information! * What is the schema? @@ -42,8 +43,8 @@ All from that one metadata schema. * Modifying the schema One of the first things we want to do is to add a field for the data -license. Initially we only support CC-4.0 as a license by default, but -now we want to give uploaders the option to make it an even more +license. Initially we only supported CC-4.0 as a license, but +we wanted to give uploaders the option to use an even more liberal CC0 license. The first step is to find a good ontology term for the field. Searching for `creative commons cc0 rdf' rendered this useful [[https://creativecommons.org/ns][page]]. We also find an [[https://wiki.creativecommons.org/wiki/CC_License_Rdf_Overview][overview]] where CC0 is represented as URI @@ -127,4 +128,20 @@ loaded in [[https://github.com/arvados/bh20-seq-resource/blob/a0c8ebd57b875f265e With this [[https://github.com/arvados/bh20-seq-resource/commit/b9691c7deae30bd6422fb7b0681572b7b6f78ae3][patch]] the website adds the license input fields on the form. -/Note: work in progress/ +Finally, to make RDF output work we need to add expressions to bh20seq-shex.rdf. This +was done with this [[https://github.com/arvados/bh20-seq-resource/commit/f4ed46dae20abe5147871495ede2d6ac2b0854bc][patch]]. In the end we decided to use the Dublin core title, +http://purl.org/metadata/dublin_core_elements#Title: + +#+BEGIN_SRC js +:licenseShape{ + cc:License xsd:string; + dc:Title xsd:string ?; + cc:attributionName xsd:string ?; + cc:attributionURL xsd:string ?; + cc:attributionSource xsd:string ?; +} +#+END_SRC + +Note that cc:AttributionSource is not really defined in the cc standard. + +* TODO Testing the license fields -- cgit v1.2.3 From 01b192417f858d4389226b5130a430bd3b6d4416 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Thu, 16 Jul 2020 09:25:58 +0100 Subject: Make license optional for now --- bh20sequploader/bh20seq-schema.yml | 2 +- bh20sequploader/bh20seq-shex.rdf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bh20sequploader/bh20seq-schema.yml b/bh20sequploader/bh20seq-schema.yml index ef55c55..ee852fa 100644 --- a/bh20sequploader/bh20seq-schema.yml +++ b/bh20sequploader/bh20seq-schema.yml @@ -16,7 +16,7 @@ $graph: fields: license_type: doc: License types as defined in https://wiki.creativecommons.org/images/d/d6/Ccrel-1.0.pdf - type: string + type: string? jsonldPredicate: _id: https://creativecommons.org/ns#License title: diff --git a/bh20sequploader/bh20seq-shex.rdf b/bh20sequploader/bh20seq-shex.rdf index 9fab334..7331e86 100644 --- a/bh20sequploader/bh20seq-shex.rdf +++ b/bh20sequploader/bh20seq-shex.rdf @@ -71,7 +71,7 @@ PREFIX wikidata: } :licenseShape{ - cc:License xsd:string; + cc:License xsd:string ?; dc:Title xsd:string ?; cc:attributionName xsd:string ?; cc:attributionURL xsd:string ?; -- cgit v1.2.3 From 73be46fd1db58f132fa60ff30d33d67927a341a7 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Thu, 16 Jul 2020 09:48:31 +0100 Subject: Addes ESR logo and cropped CWL logo --- bh20simplewebuploader/static/image/CWL.png | Bin 0 -> 11066 bytes bh20simplewebuploader/static/image/ESR.png | Bin 0 -> 67869 bytes bh20simplewebuploader/templates/footer.html | 6 +++++- doc/blog/using-covid-19-pubseq-part5.org | 4 ++++ 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 bh20simplewebuploader/static/image/CWL.png create mode 100644 bh20simplewebuploader/static/image/ESR.png diff --git a/bh20simplewebuploader/static/image/CWL.png b/bh20simplewebuploader/static/image/CWL.png new file mode 100644 index 0000000..81d1807 Binary files /dev/null and b/bh20simplewebuploader/static/image/CWL.png differ diff --git a/bh20simplewebuploader/static/image/ESR.png b/bh20simplewebuploader/static/image/ESR.png new file mode 100644 index 0000000..557c798 Binary files /dev/null and b/bh20simplewebuploader/static/image/ESR.png differ diff --git a/bh20simplewebuploader/templates/footer.html b/bh20simplewebuploader/templates/footer.html index a1dd4fd..37a6b64 100644 --- a/bh20simplewebuploader/templates/footer.html +++ b/bh20simplewebuploader/templates/footer.html @@ -21,7 +21,7 @@
- +
@@ -29,6 +29,10 @@
+
+ +
+
- +
+
+ +
-- cgit v1.2.3 From 474d15e17be63046a091615e89ba63adecdb109b Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Thu, 16 Jul 2020 14:28:02 -0400 Subject: Cleanup script also clears errors for revalidate Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- scripts/cleanup.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/scripts/cleanup.py b/scripts/cleanup.py index f4bd0b4..6a82659 100644 --- a/scripts/cleanup.py +++ b/scripts/cleanup.py @@ -3,18 +3,36 @@ import arvados.util api = arvados.api() -patterns = [ +delete_patterns = [ "%missing%`collection_location`%", "%missing%`technology`%", "%missing%`host_species`%", "%QC fail: alignment%", "%does not look like a valid URI%", + "%Duplicate of%" ] -for p in patterns: +revalidate_patterns = [ + "%missing%`license`%" +] + +for p in delete_patterns: c = arvados.util.list_all(api.collections().list, filters=[ ["owner_uuid", "=", "lugli-j7d0g-n5clictpuvwk8aa"], ["properties.errors", "like", p]]) for i in c: print("trashing %s %s" % (i["uuid"], i["properties"].get("sequence_label"))) api.collections().delete(uuid=i["uuid"]).execute() + +for p in revalidate_patterns: + c = arvados.util.list_all(api.collections().list, filters=[ + ["owner_uuid", "=", "lugli-j7d0g-n5clictpuvwk8aa"], + ["properties.errors", "like", p]]) + for i in c: + print("clearing status %s %s" % (i["uuid"], i["properties"].get("sequence_label"))) + pr = i["properties"] + if "status" in pr: + del pr["status"] + if "errors" in pr: + del pr["errors"] + api.collections().update(uuid=i["uuid"], body={"properties": pr}).execute() -- cgit v1.2.3 From d34374f0e822edd1539ea5de6f8522f2b761de3f Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Thu, 16 Jul 2020 14:48:22 -0400 Subject: Improve uploader reporting. Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- bh20sequploader/main.py | 22 ++++++++++------------ bh20simplewebuploader/main.py | 4 ++-- bh20simplewebuploader/templates/error.html | 2 +- bh20simplewebuploader/templates/success.html | 2 +- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/bh20sequploader/main.py b/bh20sequploader/main.py index f744a8c..6049bf9 100644 --- a/bh20sequploader/main.py +++ b/bh20sequploader/main.py @@ -29,11 +29,10 @@ def qc_stuff(metadata, sequence_p1, sequence_p2, do_qc=True): try: log.debug("Checking metadata" if do_qc else "Skipping metadata check") if do_qc and not qc_metadata(metadata.name): - log.warning("Failed metadata qc") + log.warning("Failed metadata QC") failed = True except Exception as e: - log.debug(e) - print(e) + log.exception("Failed metadata QC") failed = True target = [] @@ -45,8 +44,7 @@ def qc_stuff(metadata, sequence_p1, sequence_p2, do_qc=True): target[0] = ("reads_1."+target[0][0][6:], target[0][1]) target[1] = ("reads_2."+target[1][0][6:], target[0][1]) except Exception as e: - log.debug(e) - print(e) + log.exception("Failed sequence QC") failed = True if failed: @@ -82,7 +80,7 @@ def main(): seqlabel = target[0][1] if args.validate: - print("Valid") + log.info("Valid") exit(0) col = arvados.collection.Collection(api_client=api) @@ -91,10 +89,10 @@ def main(): if args.sequence_p2: upload_sequence(col, target[1], args.sequence_p2) - print("Reading metadata") + log.info("Reading metadata") with col.open("metadata.yaml", "w") as f: r = args.metadata.read(65536) - print(r[0:20]) + log.info(r[0:20]) while r: f.write(r) r = args.metadata.read(65536) @@ -118,7 +116,7 @@ def main(): ["portable_data_hash", "=", col.portable_data_hash()]]).execute() if dup["items"]: # This exact collection has been uploaded before. - print("Duplicate of %s" % ([d["uuid"] for d in dup["items"]])) + log.error("Duplicate of %s" % ([d["uuid"] for d in dup["items"]])) exit(1) if args.trusted: @@ -131,9 +129,9 @@ def main(): (seqlabel, properties['upload_user'], properties['upload_ip']), properties=properties, ensure_unique_name=True) - print("Saved to %s" % col.manifest_locator()) - - print("Done") + log.info("Saved to %s" % col.manifest_locator()) + log.info("Done") + exit(0) if __name__ == "__main__": main() diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 62b68d9..c814f30 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -445,12 +445,12 @@ def receive_files(): if result.returncode != 0: # It didn't work. Complain. - error_message="Uploader returned value {} and said:".format(result.returncode) + str(result.stderr.decode('utf-8')) + error_message="Uploader returned value {} and said:\n".format(result.returncode) + str(result.stderr.decode('utf-8')) print(error_message, file=sys.stderr) return (render_template('error.html', error_message=error_message), 403) else: # It worked. Say so. - return render_template('success.html', log=result.stdout.decode('utf-8', errors='replace')) + return render_template('success.html', log=result.stderr.decode('utf-8', errors='replace')) finally: shutil.rmtree(dest_dir) diff --git a/bh20simplewebuploader/templates/error.html b/bh20simplewebuploader/templates/error.html index b1d9402..fc08aed 100644 --- a/bh20simplewebuploader/templates/error.html +++ b/bh20simplewebuploader/templates/error.html @@ -15,7 +15,7 @@

- Click here to try again. + Click here to try again.


diff --git a/bh20simplewebuploader/templates/success.html b/bh20simplewebuploader/templates/success.html index 9f0987c..c2302fa 100644 --- a/bh20simplewebuploader/templates/success.html +++ b/bh20simplewebuploader/templates/success.html @@ -9,7 +9,7 @@

Upload Successful


- Your files have been uploaded. They should soon appear as output of the Public SARS-CoV-2 Sequence Resource. + Your files have been uploaded. You can track their QC status, once validated they will be part of the Public SARS-CoV-2 Sequence Resource.

The upload log was: -- cgit v1.2.3 From d49f6b5e11a41a51cb257bbafdcba410544f8486 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Thu, 16 Jul 2020 16:27:32 -0400 Subject: Add "validated" and "running workflows" tables to status Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- bh20seqanalyzer/main.py | 12 +-- bh20simplewebuploader/main.py | 112 +++++++++++++++++++------ bh20simplewebuploader/templates/status.html | 3 +- bh20simplewebuploader/templates/validated.html | 17 ++++ 4 files changed, 114 insertions(+), 30 deletions(-) create mode 100644 bh20simplewebuploader/templates/validated.html diff --git a/bh20seqanalyzer/main.py b/bh20seqanalyzer/main.py index f18a93a..b3a439d 100644 --- a/bh20seqanalyzer/main.py +++ b/bh20seqanalyzer/main.py @@ -240,24 +240,26 @@ class SeqAnalyzer: def move_fastq_to_fasta_results(self): projects = self.api.groups().list(filters=[['owner_uuid', '=', self.fastq_project], ["properties.moved_output", "!=", True]], - order="created_at desc",).execute() + order="created_at asc",).execute() for p in projects["items"]: wf = self.get_workflow_output_from_project(p["uuid"]) if not wf: continue logging.info("Moving completed fastq2fasta result %s back to uploader project", wf["output_uuid"]) - self.api.collections().update(uuid=wf["output_uuid"], - body={"owner_uuid": self.uploader_project}).execute() col = arvados.collection.Collection(wf["output_uuid"], api_client=self.api, keep_client=self.keepclient) with col.open("metadata.yaml") as md: metadata_content = ruamel.yaml.round_trip_load(md) + colprop = col.get_properties() + colprop["sequence_label"] = metadata_content["sample"]["sample_id"] + self.api.collections().update(uuid=wf["output_uuid"], + body={"owner_uuid": self.uploader_project, + "properties": colprop}).execute() + p["properties"]["moved_output"] = True - p["properties"]["sequence_label"] = metadata_content["sample"]["sample_id"] self.api.groups().update(uuid=p["uuid"], body={"properties": p["properties"]}).execute() - break def upload_schema(self): diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index c814f30..7dd07fe 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -144,6 +144,28 @@ def generate_form(components, options): optional = False is_list = False + # It may have documentation + docstring = field.get('doc', None) + + # See if it has a more info/what goes here URL + predicate = field.get('jsonldPredicate', {}) + # Predicate may be a URL, a dict with a URL in _id, maybe a + # dict with a URL in _type, or a dict with _id and _type but no + # URLs anywhere. Some of these may not technically be allowed + # by the format, but if they occur, we might as well try to + # handle them. + if isinstance(predicate, str): + if is_iri(predicate): + ref_iri = predicate + else: + # Assume it's a dict. Look at the fields we know about. + for field in ['_id', 'type']: + field_value = predicate.get(field, None) + if isinstance(field_value, str) and is_iri(field_value) and ref_iri is None: + # Take the first URL-looking thing we find + ref_iri = field_value + break + if isinstance(field_type, MutableSequence): if field_type[0] == "null" and len(field_type) == 2: optional = True @@ -152,28 +174,6 @@ def generate_form(components, options): raise Exception("Can't handle it") if isinstance(field_type, MutableMapping): - # It may have documentation - docstring = field_type.get('doc', None) - - # See if it has a more info/what goes here URL - predicate = field_type.get('jsonldPredicate', {}) - # Predicate may be a URL, a dict with a URL in _id, maybe a - # dict with a URL in _type, or a dict with _id and _type but no - # URLs anywhere. Some of these may not technically be allowed - # by the format, but if they occur, we might as well try to - # handle them. - if isinstance(predicate, str): - if is_iri(predicate): - ref_iri = predicate - else: - # Assume it's a dict. Look at the fields we know about. - for field in ['_id', 'type']: - field_value = predicate.get(field, None) - if isinstance(field_value, str) and is_iri(field_value) and ref_iri is None: - # Take the first URL-looking thing we find - ref_iri = field_value - break - if field_type["type"] == "array": # Now replace the field type with the actual type string is_list = True @@ -525,6 +525,54 @@ def rejected_table(output, items): """) +def workflows_table(output, items): + output.write( +""" + + + + + + + +""") + for r in items: + output.write("") + try: + sid = r["mounts"]["/var/lib/cwl/cwl.input.json"]["content"]["sample_id"] + output.write("" % Markup.escape(r["name"])) + output.write("" % Markup.escape(sid)) + output.write("" % Markup.escape(r["created_at"])) + output.write("" % (r["uuid"], r["uuid"])) + except: + pass + output.write("") + output.write( +""" +
NameSample idStartedContainer request
%s%s%s%s
+""") + +def validated_table(output, items): + output.write( +""" + + + + + +""") + for r in items: + try: + output.write("") + output.write("" % (r["uuid"], r["uuid"])) + output.write("" % Markup.escape(r["properties"].get("sequence_label"))) + output.write("") + except: + pass + output.write( +""" +
CollectionSequence label
%s%s
+""") @app.route('/status') def status_page(): @@ -545,22 +593,39 @@ def status_page(): prop["uuid"] = p["uuid"] status[prop["status"]] = status.get(prop["status"], 0) + 1 + workflows = arvados.util.list_all(api.container_requests().list, + filters=[["name", "in", ["fastq2fasta.cwl"]], ["state", "=", "Committed"]], + order="created_at asc") + output = io.StringIO() validated = api.collections().list(filters=[["owner_uuid", "=", VALIDATED_PROJECT]], limit=1).execute() status["passed"] = validated["items_available"] - for s in (("passed", "/download"), ("pending", "#pending"), ("rejected", "#rejected")): + for s in (("passed", "/validated"), ("pending", "#pending"), ("rejected", "#rejected")): output.write("

%s sequences QC %s

" % (s[1], status.get(s[0], 0), s[0])) + output.write("

%s analysis workflows running

" % ('#workflows', len(workflows))) + output.write("

Pending

") pending_table(output, out) output.write("

Rejected

") rejected_table(output, out) + output.write("

Running Workflows

") + workflows_table(output, workflows) + return render_template('status.html', table=Markup(output.getvalue()), menu='STATUS') +@app.route('/validated') +def validated_page(): + api = arvados.api(host=ARVADOS_API, token=ANONYMOUS_TOKEN, insecure=True) + output = io.StringIO() + validated = arvados.util.list_all(api.collections().list, filters=[["owner_uuid", "=", VALIDATED_PROJECT]]) + validated_table(output, validated) + return render_template('validated.html', table=Markup(output.getvalue()), menu='STATUS') + @app.route('/demo') def demo_page(): return render_template('demo.html',menu='DEMO') @@ -585,7 +650,6 @@ def map_page(): return render_template('map.html',menu='DEMO') - ## Dynamic API functions starting here ## This is quick and dirty for now, just to get something out and demonstrate the queries ## Feel free to rename the functions/endpoints, feel free to process result so we get nicer JSON diff --git a/bh20simplewebuploader/templates/status.html b/bh20simplewebuploader/templates/status.html index a1cf28f..e89437e 100644 --- a/bh20simplewebuploader/templates/status.html +++ b/bh20simplewebuploader/templates/status.html @@ -7,7 +7,8 @@

Sequence upload processing status

-
+
+ {{ table }}
diff --git a/bh20simplewebuploader/templates/validated.html b/bh20simplewebuploader/templates/validated.html new file mode 100644 index 0000000..cee94bd --- /dev/null +++ b/bh20simplewebuploader/templates/validated.html @@ -0,0 +1,17 @@ + + + {% include 'header.html' %} + + {% include 'banner.html' %} + {% include 'menu.html' %} + +

Validated sequences

+ +
+ {{ table }} +
+ +{% include 'footer.html' %} + + + -- cgit v1.2.3 From b1750731b654be3322a6793f47d52fafcaaea9ac Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Thu, 16 Jul 2020 21:24:05 -0400 Subject: Report similarity == 0 Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- bh20sequploader/qc_fasta.py | 4 +--- scripts/cleanup.py | 7 +++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bh20sequploader/qc_fasta.py b/bh20sequploader/qc_fasta.py index 37eb4e8..0c7e16d 100644 --- a/bh20sequploader/qc_fasta.py +++ b/bh20sequploader/qc_fasta.py @@ -84,10 +84,8 @@ def qc_fasta(arg_sequence, check_with_clustalw=True): except Exception as e: logging.warn("QC against reference sequence using 'minimap2': %s", e, exc_info=e) - if similarity and similarity < 70.0: + if similarity < 70.0: raise ValueError("QC fail: alignment to reference was less than 70%% (was %2.2f%%)" % (similarity)) - if similarity == 0: - raise ValueError("QC fail") return ("sequence.fasta"+gz, seqlabel) elif seq_type == "text/fastq": diff --git a/scripts/cleanup.py b/scripts/cleanup.py index 6a82659..78f34c8 100644 --- a/scripts/cleanup.py +++ b/scripts/cleanup.py @@ -9,11 +9,14 @@ delete_patterns = [ "%missing%`host_species`%", "%QC fail: alignment%", "%does not look like a valid URI%", - "%Duplicate of%" + "%Duplicate of%", + "%No matching triples found for predicate obo:NCIT_C42781%", + "%does not look like a valid URI%" ] revalidate_patterns = [ - "%missing%`license`%" + "%missing%`license`%", + "%QC fail%" ] for p in delete_patterns: -- cgit v1.2.3 From 7a0a05a8df8d12eb55e6a2e6392d4d384f481c7c Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Thu, 16 Jul 2020 11:37:47 +0100 Subject: Remove extra exclamation mark --- bh20simplewebuploader/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 7dd07fe..1147176 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -456,7 +456,7 @@ def receive_files(): def edit_button(url,text="Edit text!"): - return '

'+text+'!

' + return '

'+text+'

' def get_html_body(fn,source="https://github.com/arvados/bh20-seq-resource/tree/master/doc"): buf = edit_button(source) -- cgit v1.2.3 From 0a94b15d1bb84042f5e136fd59974de41192b68d Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Thu, 16 Jul 2020 13:00:24 +0100 Subject: Blog: workflows --- doc/blog/using-covid-19-pubseq-part4.org | 6 ++++++ doc/web/about.org | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/blog/using-covid-19-pubseq-part4.org b/doc/blog/using-covid-19-pubseq-part4.org index 5fe71d1..8ad5e2d 100644 --- a/doc/blog/using-covid-19-pubseq-part4.org +++ b/doc/blog/using-covid-19-pubseq-part4.org @@ -10,6 +10,7 @@ * Table of Contents :TOC:noexport: - [[#what-does-this-mean][What does this mean?]] + - [[#where-can-i-find-the-workflows][Where can I find the workflows?]] - [[#modify-workflow][Modify Workflow]] * What does this mean? @@ -18,6 +19,11 @@ This means that when someone uploads a SARS-CoV-2 sequence using one of our tools (CLI or web-based) they add a sequence and some metadata which triggers a rerun of our workflows. +* Where can I find the workflows? + +Workflows are written in the common workflow language (CWL) and listed +on [[https://github.com/arvados/bh20-seq-resource/tree/master/workflows][github]]. PubSeq being an open project these workflows can be studied +and modified! * Modify Workflow diff --git a/doc/web/about.org b/doc/web/about.org index ad13bc3..1949e2d 100644 --- a/doc/web/about.org +++ b/doc/web/about.org @@ -140,7 +140,8 @@ See the [[http://covid19.genenetwork.org/blog]]! * How do I change the work flows? -See the [[http://covid19.genenetwork.org/blog]]! +Workflows are on [[https://github.com/arvados/bh20-seq-resource/tree/master/workflows][github]] and can be modified. See also the +[[[[http://covid19.genenetwork.org/blog]]][workflow blog]]. * How do I change the source code? -- cgit v1.2.3 From 317a04666addffb805ad9c7917eb80a2985aa390 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 17 Jul 2020 07:59:01 +0100 Subject: Align Curii image --- bh20simplewebuploader/static/image/curii.logo.ai.png | Bin 0 -> 16739 bytes bh20simplewebuploader/templates/footer.html | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 bh20simplewebuploader/static/image/curii.logo.ai.png diff --git a/bh20simplewebuploader/static/image/curii.logo.ai.png b/bh20simplewebuploader/static/image/curii.logo.ai.png new file mode 100644 index 0000000..401afad Binary files /dev/null and b/bh20simplewebuploader/static/image/curii.logo.ai.png differ diff --git a/bh20simplewebuploader/templates/footer.html b/bh20simplewebuploader/templates/footer.html index 5a1f3c9..2064036 100644 --- a/bh20simplewebuploader/templates/footer.html +++ b/bh20simplewebuploader/templates/footer.html @@ -21,7 +21,7 @@
- +
-- cgit v1.2.3 From 2c1a907cbfe222d1deed8c31a44d3ea4c382bc3c Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 17 Jul 2020 08:00:48 +0100 Subject: Add Curii svg --- bh20simplewebuploader/static/image/curii.logo.ai.svg | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 bh20simplewebuploader/static/image/curii.logo.ai.svg diff --git a/bh20simplewebuploader/static/image/curii.logo.ai.svg b/bh20simplewebuploader/static/image/curii.logo.ai.svg new file mode 100644 index 0000000..e87ea05 --- /dev/null +++ b/bh20simplewebuploader/static/image/curii.logo.ai.svg @@ -0,0 +1,3 @@ + + +image/svg+xml \ No newline at end of file -- cgit v1.2.3 From d3fa51ee16d902fc0bfa414611d5e0bae6618009 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 17 Jul 2020 09:09:23 +0100 Subject: Refactoring map code --- bh20simplewebuploader/main.py | 7 +- bh20simplewebuploader/static/main.js | 149 ++++++++------------------ bh20simplewebuploader/static/map.js | 67 ++++++++++++ bh20simplewebuploader/templates/demo-run.html | 26 ----- bh20simplewebuploader/templates/demo.html | 30 +++++- bh20simplewebuploader/templates/footer.html | 3 + bh20simplewebuploader/templates/header.html | 18 ---- bh20simplewebuploader/templates/map.html | 24 ++++- 8 files changed, 164 insertions(+), 160 deletions(-) create mode 100644 bh20simplewebuploader/static/map.js diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 1147176..e8bb507 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -628,7 +628,7 @@ def validated_page(): @app.route('/demo') def demo_page(): - return render_template('demo.html',menu='DEMO') + return render_template('demo.html',menu='DEMO',load_map=True) @app.route('/blog',methods=['GET']) def blog_page(): @@ -644,11 +644,6 @@ def about_page(): buf = get_html_body('doc/web/about.html','https://github.com/arvados/bh20-seq-resource/blob/master/doc/web/about.org') return render_template('about.html',menu='ABOUT',embed=buf) -## -@app.route('/map') -def map_page(): - return render_template('map.html',menu='DEMO') - ## Dynamic API functions starting here ## This is quick and dirty for now, just to get something out and demonstrate the queries diff --git a/bh20simplewebuploader/static/main.js b/bh20simplewebuploader/static/main.js index 4703047..1633c25 100644 --- a/bh20simplewebuploader/static/main.js +++ b/bh20simplewebuploader/static/main.js @@ -13,70 +13,41 @@ function myFunction() { } } -let map = L.map( 'map', { - center: [37.0902, -95.7129], // Default to U.S.A - minZoom: 3, - zoom: 0 -}); -L.tileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: '© OpenStreetMap', - subdomains: ['a','b','c'] -}).addTo( map ); - -let markers = L.markerClusterGroup().addTo(map) - - function fetchAPI(apiEndPoint) { - fetch(scriptRoot + apiEndPoint) - .then(response => { - return response.json(); - }) - .then(data => { - console.log(data); - markers.clearLayers(); - document.getElementById("results").classList.remove("invisible"); - document.getElementById("loader").classList.add("invisible"); - if (!(apiEndPoint === "/api/getAllaccessions")) { - for (let i = 0; i < data.length; i++) { - let {"count": fastaCount, GPS, LocationLabel: label } = data[i]; - let coordinates = GPS.split(" "); - if (!(coordinates == null)) { - let lat, lon; - [lon, lat] = coordinates.map(parseFloat); - let point = L.point() - let marker = L.marker([lat, lon]); - marker.bindPopup("" + label + "
" + "FastaCount: " +fastaCount); - markers.addLayer(marker) - }} - } - // Reload the map - map.invalidateSize(); - }); - document.getElementById("results").classList.add("invisible"); - document.getElementById("loader").classList.remove("invisible"); - -} - -// Copy from function above but now added as table instead of plain json -function fetchAPIV2(apiEndPoint) { - fetch(scriptRoot + apiEndPoint) - .then(response => { - return response.json(); - }) - .then(data => { - console.log(data) - htmlString="" - - // Depending on what we want to explore we'd have to call a different function ....? But how to Include that? - for (var i=0; i" - } - htmlString=htmlString+"
"+data[i]["label"]+""+data[i]["count"]+"
" - - document.getElementById("table").innerHTML = htmlString - }); - - document.getElementById("results").classList.add("invisible"); + fetch(scriptRoot + apiEndPoint) + .then(response => { + return response.json(); + }) + .then(data => { + console.log(data); + }); + document.getElementById("map_view").classList.add("invisible"); + document.getElementById("loader").classList.remove("invisible"); +} + +// Copy from function above but now output HTML table instead of plain json +function fetchHTMLTable(apiEndPoint) { + fetch(scriptRoot + apiEndPoint) + .then(response => { + return response.json(); + }) + .then(data => { + console.log(data) + htmlString="" + + // Depending on what we want to explore we'd have to call a different function ....? But how to Include that? + /* + for (var i=0; i" + } +*/ + for (var i=0; i" + } + htmlString=htmlString+"
"+data[i]["label"]+""+data[i]["count"]+"
"+data[i]["label"]+""+data[i]["count"]+"
" + + document.getElementById("table").innerHTML = htmlString + }); } @@ -85,36 +56,39 @@ let search = () => { fetchAPI(scriptRoot + "/api/getDetailsForSeq?seq=" + encodeURIComponent(m)); } +// Get count from Arvados let fetchCount = () => { fetchAPI("/api/getCount"); } +// Get count from Virtuoso let fetchCountDB = () => { fetchAPI("/api/getCountDB"); } let fetchSEQCountBySpecimen = () => { - fetchAPIV2("/api/getSEQCountbySpecimenSource"); + fetchHTMLTable("/api/getSEQCountbySpecimenSource"); } let fetchSEQCountByLocation = () => { - fetchAPIV2("/api/getSEQCountbyLocation"); + fetchHTMLTable("/api/getSEQCountbyLocation"); } let fetchSEQCountByTech = () => { - fetchAPIV2("/api/getSEQCountbytech"); + fetchHTMLTable("/api/getSEQCountbytech"); } let fetchAllaccessions = () => { - fetchAPI("/api/getAllaccessions"); + fetchHTMLTable("/api/getAllaccessions"); }; -let fetchCountByGPS = () => { - fetchAPI("/api/getCountByGPS"); +let fetchMap = () => { + fetchAPI("/api/getCountByGPS"); + updateMapMarkers(); }; let fetchSEQCountbyLocation = () => { - fetchAPIV2("/api/getSEQCountbyLocation"); + fetchHTMLTable("/api/getSEQCountbyLocation"); }; let fetchSEQByLocation = () => { @@ -122,7 +96,7 @@ let fetchSEQByLocation = () => { }; let fetchSEQCountbyContinent = () => { - fetchAPIV2("/api/getSEQCountbyContinent"); + fetchHTMLTable("/api/getSEQCountbyContinent"); } @@ -252,36 +226,3 @@ function on_submit_button() { return false; } } - - - -// - -function drawMap(){ - -// initialize the map on the "map" div with a given center and zoom -var mymap = L.map('mapid').setView([51.505, -0.09], 1); - -L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: '© OpenStreetMap contributors' -}).addTo(mymap); - -fetch(scriptRoot + "api/getCountByGPS") - .then(response => { - console.log(response) - return response.json(); - }) - .then(data => { - - for (var i=0; iOpenStreetMap', + subdomains: ['a','b','c'] +}).addTo( map ); + +let markers = L.markerClusterGroup().addTo(map) + + +function drawMap(){ + +// initialize the map on the "map" div with a given center and zoom +var mymap = L.map('mapid').setView([51.505, -0.09], 1); + +L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: '© OpenStreetMap contributors' +}).addTo(mymap); + +fetch(scriptRoot + "api/getCountByGPS") + .then(response => { + console.log(response) + return response.json(); + }) + .then(data => { + + for (var i=0; i" + label + "
" + "FastaCount: " +fastaCount); + markers.addLayer(marker) + }} + // Reload the map + map.invalidateSize(); + document.getElementById("map_view").classList.add("invisible"); + document.getElementById("loader").classList.add("invisible"); +} diff --git a/bh20simplewebuploader/templates/demo-run.html b/bh20simplewebuploader/templates/demo-run.html index a8f9edc..e69de29 100644 --- a/bh20simplewebuploader/templates/demo-run.html +++ b/bh20simplewebuploader/templates/demo-run.html @@ -1,26 +0,0 @@ -
-
-

[Demo] Display content sequences by:

-
- - - - - - - -
- -
- -
- - - - -
-
-
diff --git a/bh20simplewebuploader/templates/demo.html b/bh20simplewebuploader/templates/demo.html index 44aded0..2e290c6 100644 --- a/bh20simplewebuploader/templates/demo.html +++ b/bh20simplewebuploader/templates/demo.html @@ -5,8 +5,34 @@ {% include 'banner.html' %} {% include 'menu.html' %} {% include 'search.html' %} -

The Virtuoso database contains public sequences!

- {% include 'demo-run.html' %} +

The Virtuoso database contains public sequences!

+ +
+
+

[Demo] Display content sequences by:

+
+ + + + + + +
+ +
+ +
+ + + + +
+
+
+ {% include 'footer.html' %} +{% endif %} - - diff --git a/bh20simplewebuploader/templates/map.html b/bh20simplewebuploader/templates/map.html index 595af0c..4aa22b9 100644 --- a/bh20simplewebuploader/templates/map.html +++ b/bh20simplewebuploader/templates/map.html @@ -1,7 +1,26 @@ {% include 'header.html' %} - + + + + + + + + + @@ -11,9 +30,6 @@ {% include 'footer.html' %} - - - -- cgit v1.2.3 From 7565f72b1bf0d70426947a50d1b9a62edc48071d Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 17 Jul 2020 09:45:58 +0100 Subject: Map is back --- bh20simplewebuploader/static/main.css | 2 +- bh20simplewebuploader/static/map.js | 71 +++++++++++++++---------------- bh20simplewebuploader/templates/demo.html | 27 +++++++++++- bh20simplewebuploader/templates/map.html | 49 --------------------- 4 files changed, 61 insertions(+), 88 deletions(-) diff --git a/bh20simplewebuploader/static/main.css b/bh20simplewebuploader/static/main.css index b28ee9c..9f89045 100644 --- a/bh20simplewebuploader/static/main.css +++ b/bh20simplewebuploader/static/main.css @@ -47,7 +47,7 @@ h2 > svg { float: right; } -#map { +#mapid { width: 800px; height: 440px; border: 1px solid #AAA; diff --git a/bh20simplewebuploader/static/map.js b/bh20simplewebuploader/static/map.js index afc6c3f..e1a4289 100644 --- a/bh20simplewebuploader/static/map.js +++ b/bh20simplewebuploader/static/map.js @@ -1,43 +1,40 @@ -let map = L.map( 'map', { - center: [37.0902, -95.7129], // Default to U.S.A - minZoom: 3, - zoom: 0 + +var map = L.map( 'mapid', { + center: [51.505, -0.09], // Default to U.S.A + minZoom: 2, + zoom: 0 }); + L.tileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: '© OpenStreetMap', - subdomains: ['a','b','c'] -}).addTo( map ); + attribution: '© OpenStreetMap', + subdomains: ['a','b','c'] +}).addTo(map); -let markers = L.markerClusterGroup().addTo(map) +var markers = L.markerClusterGroup().addTo(mapid) function drawMap(){ + var mymap = map; -// initialize the map on the "map" div with a given center and zoom -var mymap = L.map('mapid').setView([51.505, -0.09], 1); - -L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: '© OpenStreetMap contributors' -}).addTo(mymap); - -fetch(scriptRoot + "api/getCountByGPS") - .then(response => { - console.log(response) - return response.json(); - }) - .then(data => { - - for (var i=0; i { + console.log(response) + return response.json(); + }) + .then(data => { + for (var i=0; i" + label + "
" + "FastaCount: " +fastaCount); - markers.addLayer(marker) + // markers.addLayer(marker) }} + */ // Reload the map map.invalidateSize(); - document.getElementById("map_view").classList.add("invisible"); - document.getElementById("loader").classList.add("invisible"); + // document.getElementById("map_view").classList.add("invisible"); + // document.getElementById("loader").classList.add("invisible"); } diff --git a/bh20simplewebuploader/templates/demo.html b/bh20simplewebuploader/templates/demo.html index 2e290c6..3a80abf 100644 --- a/bh20simplewebuploader/templates/demo.html +++ b/bh20simplewebuploader/templates/demo.html @@ -1,10 +1,30 @@ {% include 'header.html' %} + + + + + + + + + {% include 'banner.html' %} {% include 'menu.html' %} {% include 'search.html' %} +

The Virtuoso database contains public sequences!

@@ -26,14 +46,14 @@
- {% include 'footer.html' %} + {% include 'footer.html' %} + diff --git a/bh20simplewebuploader/templates/map.html b/bh20simplewebuploader/templates/map.html index 4aa22b9..e69de29 100644 --- a/bh20simplewebuploader/templates/map.html +++ b/bh20simplewebuploader/templates/map.html @@ -1,49 +0,0 @@ - - - {% include 'header.html' %} - - - - - - - - - - - - {% include 'banner.html' %} - {% include 'menu.html' %} -
- - {% include 'footer.html' %} - - - - - - - - - - - -- cgit v1.2.3 From 06e3922a5541641077b18016e272cddc7e50205b Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 17 Jul 2020 09:59:32 +0100 Subject: Map refactoring, now shows on HOME --- bh20simplewebuploader/main.py | 2 +- bh20simplewebuploader/static/map.js | 14 ++++++++------ bh20simplewebuploader/templates/demo-run.html | 0 bh20simplewebuploader/templates/demo.html | 21 +-------------------- bh20simplewebuploader/templates/home.html | 15 ++++++++++++++- bh20simplewebuploader/templates/map.html | 0 bh20simplewebuploader/templates/mapheader.html | 16 ++++++++++++++++ 7 files changed, 40 insertions(+), 28 deletions(-) delete mode 100644 bh20simplewebuploader/templates/demo-run.html delete mode 100644 bh20simplewebuploader/templates/map.html create mode 100644 bh20simplewebuploader/templates/mapheader.html diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index e8bb507..206f884 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -253,7 +253,7 @@ def send_home(): Send the front page. """ - return render_template('home.html', menu='HOME') + return render_template('home.html', menu='HOME', load_map=True) @app.route('/upload') diff --git a/bh20simplewebuploader/static/map.js b/bh20simplewebuploader/static/map.js index e1a4289..8b8ecba 100644 --- a/bh20simplewebuploader/static/map.js +++ b/bh20simplewebuploader/static/map.js @@ -31,6 +31,7 @@ function drawMap(){ radius: parseInt(data[i]["count"]) //not working for whatever reason }).addTo(mymap); } + // updateMapMarkers(data); }); document.getElementById("map_view").classList.remove("invisible"); @@ -42,11 +43,11 @@ function drawMap(){ /* This function updates the map with markers * */ -function updateMapMarkers() { +function updateMapMarkers(data) { // markers.clearLayers(); // remove all markers // document.getElementById("results").classList.remove("invisible"); - document.getElementById("loader").classList.add("invisible"); - /* + // document.getElementById("loader").classList.add("invisible"); + for (let i = 0; i < data.length; i++) { let {"count": fastaCount, GPS, LocationLabel: label } = data[i]; let coordinates = GPS.split(" "); @@ -57,10 +58,11 @@ function updateMapMarkers() { let marker = L.marker([lat, lon]); marker.bindPopup("" + label + "
" + "FastaCount: " +fastaCount); // markers.addLayer(marker) - }} - */ + } + } + // Reload the map - map.invalidateSize(); + // map.invalidateSize(); // document.getElementById("map_view").classList.add("invisible"); // document.getElementById("loader").classList.add("invisible"); } diff --git a/bh20simplewebuploader/templates/demo-run.html b/bh20simplewebuploader/templates/demo-run.html deleted file mode 100644 index e69de29..0000000 diff --git a/bh20simplewebuploader/templates/demo.html b/bh20simplewebuploader/templates/demo.html index 3a80abf..65ba462 100644 --- a/bh20simplewebuploader/templates/demo.html +++ b/bh20simplewebuploader/templates/demo.html @@ -1,25 +1,7 @@ {% include 'header.html' %} - - - - - - - - - + {% include 'mapheader.html' %} {% include 'banner.html' %} {% include 'menu.html' %} @@ -36,7 +18,6 @@ - diff --git a/bh20simplewebuploader/templates/home.html b/bh20simplewebuploader/templates/home.html index b90a18d..42b08c0 100644 --- a/bh20simplewebuploader/templates/home.html +++ b/bh20simplewebuploader/templates/home.html @@ -1,6 +1,7 @@ {% include 'header.html' %} + {% include 'mapheader.html' %} {% include 'banner.html' %} {% include 'menu.html' %} @@ -44,7 +45,19 @@ -{% include 'footer.html' %} + + + {% include 'footer.html' %} + + + diff --git a/bh20simplewebuploader/templates/map.html b/bh20simplewebuploader/templates/map.html deleted file mode 100644 index e69de29..0000000 diff --git a/bh20simplewebuploader/templates/mapheader.html b/bh20simplewebuploader/templates/mapheader.html new file mode 100644 index 0000000..ca62051 --- /dev/null +++ b/bh20simplewebuploader/templates/mapheader.html @@ -0,0 +1,16 @@ + + + + + + -- cgit v1.2.3 From b8376a3174835d75cb8235c622ac49585f23e8ee Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 17 Jul 2020 10:20:04 +0100 Subject: Map markers; disabled search again --- bh20simplewebuploader/static/map.js | 23 +++++++---------------- bh20simplewebuploader/templates/demo.html | 13 ++++++++++++- bh20simplewebuploader/templates/search.html | 10 ---------- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/bh20simplewebuploader/static/map.js b/bh20simplewebuploader/static/map.js index 8b8ecba..e877454 100644 --- a/bh20simplewebuploader/static/map.js +++ b/bh20simplewebuploader/static/map.js @@ -6,12 +6,11 @@ var map = L.map( 'mapid', { }); L.tileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: '© OpenStreetMap', + attribution: '© OpenStreetMap | COVID-19 PubSeq', subdomains: ['a','b','c'] }).addTo(map); -var markers = L.markerClusterGroup().addTo(mapid) - +// var markers = L.markerClusterGroup().addTo(mapid) function drawMap(){ var mymap = map; @@ -22,6 +21,7 @@ function drawMap(){ return response.json(); }) .then(data => { + /* for (var i=0; i" + label + "
" + "FastaCount: " +fastaCount); - // markers.addLayer(marker) + L.marker([lat, lon]).addTo(map) + .bindPopup("" + label + "
" + "FastaCount: " +fastaCount); } } - - // Reload the map - // map.invalidateSize(); - // document.getElementById("map_view").classList.add("invisible"); - // document.getElementById("loader").classList.add("invisible"); } diff --git a/bh20simplewebuploader/templates/demo.html b/bh20simplewebuploader/templates/demo.html index 65ba462..04bf877 100644 --- a/bh20simplewebuploader/templates/demo.html +++ b/bh20simplewebuploader/templates/demo.html @@ -5,10 +5,21 @@ {% include 'banner.html' %} {% include 'menu.html' %} - {% include 'search.html' %}

The Virtuoso database contains public sequences!

+ +

[Demo] Display content sequences by:

diff --git a/bh20simplewebuploader/templates/search.html b/bh20simplewebuploader/templates/search.html index dbdca90..e69de29 100644 --- a/bh20simplewebuploader/templates/search.html +++ b/bh20simplewebuploader/templates/search.html @@ -1,10 +0,0 @@ - - -- cgit v1.2.3 From fdb534f551e11ba5d43bec4aeba2bab4d141700b Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 17 Jul 2020 10:31:34 +0100 Subject: Using mapcluster again --- bh20simplewebuploader/static/map.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bh20simplewebuploader/static/map.js b/bh20simplewebuploader/static/map.js index e877454..36208b5 100644 --- a/bh20simplewebuploader/static/map.js +++ b/bh20simplewebuploader/static/map.js @@ -10,7 +10,6 @@ L.tileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { subdomains: ['a','b','c'] }).addTo(map); -// var markers = L.markerClusterGroup().addTo(mapid) function drawMap(){ var mymap = map; @@ -45,6 +44,7 @@ function drawMap(){ * */ function updateMapMarkers(data) { + let markers = L.markerClusterGroup(); for (let i = 0; i < data.length; i++) { let {"count": fastaCount, GPS, LocationLabel: label } = data[i]; let coordinates = GPS.split(" "); @@ -52,8 +52,10 @@ function updateMapMarkers(data) { let lat, lon; [lon, lat] = coordinates.map(parseFloat); let point = L.point() - L.marker([lat, lon]).addTo(map) - .bindPopup("" + label + "
" + "FastaCount: " +fastaCount); + marker = (L.marker([lat, lon])); + // .bindPopup("" + label + "
" + "FastaCount: " +fastaCount)); + markers.addLayer(marker); } } + map.addLayer(markers); } -- cgit v1.2.3 From 22dc44b243674f3acb6ef464985f333cdc983824 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 17 Jul 2020 10:32:42 +0100 Subject: Map: show FASTA count --- bh20simplewebuploader/static/map.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/bh20simplewebuploader/static/map.js b/bh20simplewebuploader/static/map.js index 36208b5..5ecf95d 100644 --- a/bh20simplewebuploader/static/map.js +++ b/bh20simplewebuploader/static/map.js @@ -20,17 +20,6 @@ function drawMap(){ return response.json(); }) .then(data => { - /* - for (var i=0; i" + label + "
" + "FastaCount: " +fastaCount)); + marker.bindPopup("" + label + "
" + "FastaCount: " +fastaCount); markers.addLayer(marker); } } -- cgit v1.2.3 From 108a96f8608c3d82c8cfe1d33ebb37501c01413b Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 17 Jul 2020 10:38:23 +0100 Subject: Align map a bit --- bh20simplewebuploader/static/main.css | 5 +++++ bh20simplewebuploader/templates/demo.html | 2 +- bh20simplewebuploader/templates/home.html | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bh20simplewebuploader/static/main.css b/bh20simplewebuploader/static/main.css index 9f89045..6e651a4 100644 --- a/bh20simplewebuploader/static/main.css +++ b/bh20simplewebuploader/static/main.css @@ -385,6 +385,11 @@ div.status { border-bottom: 1px solid #ddd; } +.map { + padding: 20px 32px; + // display: inline-block; +} + .editbutton { float: right; text-align: right; diff --git a/bh20simplewebuploader/templates/demo.html b/bh20simplewebuploader/templates/demo.html index 04bf877..75bc0e2 100644 --- a/bh20simplewebuploader/templates/demo.html +++ b/bh20simplewebuploader/templates/demo.html @@ -37,7 +37,7 @@ -
-