diff options
Diffstat (limited to 'uploader')
| -rw-r--r-- | uploader/genotypes/models.py | 100 | ||||
| -rw-r--r-- | uploader/genotypes/views.py | 104 | ||||
| -rw-r--r-- | uploader/phenotypes/views.py | 79 | ||||
| -rw-r--r-- | uploader/static/css/layout-large.css | 1 | ||||
| -rw-r--r-- | uploader/static/css/layout-medium.css | 1 | ||||
| -rw-r--r-- | uploader/static/css/layout-small.css | 1 | ||||
| -rw-r--r-- | uploader/static/js/files.js | 215 | ||||
| -rw-r--r-- | uploader/templates/genotypes/add-genotypes-records-base.html | 39 | ||||
| -rw-r--r-- | uploader/templates/genotypes/add-genotypes-records-csv.html | 146 | ||||
| -rw-r--r-- | uploader/templates/genotypes/base.html | 7 | ||||
| -rw-r--r-- | uploader/templates/genotypes/create-dataset.html | 4 | ||||
| -rw-r--r-- | uploader/templates/genotypes/index.html | 200 | ||||
| -rw-r--r-- | uploader/templates/genotypes/list-genotypes.html | 226 | ||||
| -rw-r--r-- | uploader/templates/genotypes/macro-display-dataset-card.html | 24 | ||||
| -rw-r--r-- | uploader/templates/macro-csv-fields.html | 102 | ||||
| -rw-r--r-- | uploader/templates/phenotypes/view-dataset.html | 26 | ||||
| -rw-r--r-- | uploader/templates/populations/view-population.html | 35 |
17 files changed, 976 insertions, 334 deletions
diff --git a/uploader/genotypes/models.py b/uploader/genotypes/models.py index 34d2cfe..41270da 100644 --- a/uploader/genotypes/models.py +++ b/uploader/genotypes/models.py @@ -1,13 +1,17 @@ """Functions for handling genotypes.""" +import logging from typing import Optional +from functools import reduce from datetime import datetime import MySQLdb as mdb from MySQLdb.cursors import Cursor, DictCursor -from flask import current_app as app from gn_libs.mysqldb import debug_query +logger = logging.getLogger(__name__) + + def genocode_by_population( conn: mdb.Connection, population_id: int) -> tuple[dict, ...]: """Get the allele/genotype codes.""" @@ -29,30 +33,102 @@ def genotype_markers_count(conn: mdb.Connection, species_id: int) -> int: def genotype_markers( conn: mdb.Connection, species_id: int, + population_id: int, offset: int = 0, - limit: Optional[int] = None + limit: int = -1# no limit if negative, zero returns empty list. ) -> tuple[tuple[dict, ...], int]: - """Retrieve markers from the database.""" + """Retrieve markers from the database. + + Return: A tuple of: + - Listing of the markers, + - The total number of markers found in the system. + """ _query_template = ( - "SELECT %%COLS%% FROM Geno AS gno " - "WHERE gno.SpeciesId=%s " + "SELECT %%COLS%% " + "FROM Species AS spc " + "INNER JOIN InbredSet AS iset " + "ON spc.Id = iset.SpeciesId " + "INNER JOIN GenoFreeze AS gfr " + "ON iset.Id = gfr.InbredSetId " + "INNER JOIN GenoXRef AS gxr " + "ON gfr.Id = gxr.GenoFreezeId " + "INNER JOIN Geno AS gno " + "ON gxr.GenoId = gno.Id " + "WHERE spc.Id=%s " + "AND iset.Id=%s " "%%LIMIT%%") with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute( _query_template.replace("%%LIMIT%%", "").replace( "%%COLS%%", "COUNT(gno.Id) AS total_records"), - (species_id,)) + (species_id, population_id)) _total_records = cursor.fetchone()["total_records"] cursor.execute( - _query_template.replace("%%COLS%%", "gno.*").replace( + _query_template.replace("%%COLS%%", "gno.*, gxr.cM").replace( "%%LIMIT%%", (f"LIMIT {int(limit)} OFFSET {int(offset)}" - if bool(limit) and limit > 0 + if bool(limit) and limit >= 0 else "")), - (species_id,)) - debug_query(cursor, app.logger) - return tuple(dict(row) for row in cursor.fetchall()), _total_records + (species_id, population_id)) + debug_query(cursor, logger) + _records = tuple(dict(row) for row in cursor.fetchall()) + return _records, _total_records + + +def genotype_records( + conn: mdb.Connection, + species_id: int, + population_id: int, + offset: int = 0, + limit: int = -1# no limit if negative, zero returns empty list. +) -> tuple[tuple[dict, ...], int]: + """Retrieve the actual genotype records from the database. + + Returns: A tuple of: + - the listing of the genotype data, + - the total number of genotype records for this population. + """ + def __organise_geno_records__(acc, row): + _current_row = acc.get(row["GenoId"], { + "GenoId": row["GenoId"], + "data": {} + }) + _current_row["data"][row["StrainName"]] = row["value"] + return { + **acc, + _current_row["GenoId"]: _current_row + } + + _query_template = ( + "SELECT gxr.GenoId, gxr.DataId, gdt.value, strn.Name AS StrainName " + "FROM GenoXRef AS gxr " + "INNER JOIN GenoData AS gdt ON gxr.DataId = gdt.Id " + "INNER JOIN Strain AS strn ON gdt.StrainId = strn.Id " + "WHERE gxr.GenoId IN (%%PARAMS_STR%%)") + + with conn.cursor(cursorclass=DictCursor) as cursor: + _markers, _num_records = genotype_markers( + conn, species_id, population_id, offset, limit) + if len(_markers) == 0: + return (tuple(), 0) + + _genoids = tuple(_marker["Id"] for _marker in _markers) + cursor.execute( + _query_template.replace( + "%%PARAMS_STR%%", ",".join(["%s"] * len(_genoids))), + _genoids) + debug_query(cursor, logger) + _records: dict[str, dict] = reduce( + __organise_geno_records__, cursor.fetchall(), {}) + return ( + tuple({ + **_marker, + "data": _records.get( + _marker["Id"], {} + ).get("data", {}) + } for _marker in _markers), + _num_records) def genotype_dataset( @@ -77,7 +153,7 @@ def genotype_dataset( with conn.cursor(cursorclass=DictCursor) as cursor: cursor.execute(_query, _params) - debug_query(cursor, app.logger) + debug_query(cursor, logger) result = cursor.fetchone() if bool(result): return dict(result) diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py index f27671c..648b38e 100644 --- a/uploader/genotypes/views.py +++ b/uploader/genotypes/views.py @@ -3,12 +3,15 @@ import logging from MySQLdb.cursors import DictCursor from pymonad.either import Left, Right, Either +from gn_libs.requests import request_json from gn_libs.mysqldb import database_connection +from werkzeug.exceptions import UnsupportedMediaType from flask import (flash, request, jsonify, redirect, Blueprint, + make_response, render_template, current_app as app) @@ -16,17 +19,16 @@ from uploader.flask_extensions import url_for from uploader.ui import make_template_renderer from uploader.oauth2.client import oauth2_post from uploader.authorisation import require_login -from uploader.route_utils import generic_select_population -from uploader.datautils import safe_int, enumerate_sequence -from uploader.species.models import all_species, species_by_id +from uploader.species.models import species_by_id from uploader.monadic_requests import make_either_error_handler from uploader.population.models import population_by_species_and_id -from uploader.request_checks import with_species, with_dataset, with_population +from uploader.request_checks import with_dataset, with_population + from .models import (genotype_markers, + genotype_records, genotype_dataset, save_new_dataset, - genotype_markers_count, genocode_by_population) logger = logging.getLogger(__name__) @@ -36,32 +38,65 @@ render_template = make_template_renderer("genotypes") @genotypesbp.route( "/<int:species_id>/populations/<int:population_id>/genotypes", - methods=["GET"]) + methods=["GET", "POST"]) @require_login @with_population(species_redirect_uri="species.list_species", redirect_uri="species.populations.list_species_populations") -def list_genotypes(species: dict, population: dict, **kwargs):# pylint: disable=[unused-argument] - """List genotype details for species and population.""" +def index(species: dict, population: dict, **kwargs):# pylint: disable=[unused-argument] + """Entry-point to the genotypes management section.""" with database_connection(app.config["SQL_URI"]) as conn: - return render_template("genotypes/list-genotypes.html", - species=species, - population=population, - genocode=genocode_by_population( - conn, population["Id"]), - total_markers=genotype_markers_count( - conn, species["SpeciesId"]), - dataset=genotype_dataset(conn, - species["SpeciesId"], - population["Id"]), - activelink="list-genotypes") + form = request_json() + offset = int(form.get("start", "0")) + number_of_records = int(form.get("length", "10")) + _markers, _total_markers, = genotype_markers( + conn, species["SpeciesId"], population["Id"]) + _genotype_records, _count = genotype_records( + conn, + species["SpeciesId"], + population["Id"], + offset, + number_of_records) + _genotype_records = tuple( + {**_record, "index": _idx} + for _idx, _record + in enumerate(_genotype_records, start=offset+1)) + + ## Order these correctly + _samples = (tuple() if len(_genotype_records) == 0 + else tuple(_genotype_records[0]["data"].keys())) + + if "application/json" in request.headers["Accept"]: + return make_response( + jsonify({ + "genotype_records": _genotype_records, + "total_genotype_records": _count, + "fetched_genotype_records": len(_genotype_records), + "samples_order": _samples, + "draw": int(request.args.get("draw", "0")) + }), 200) + + if "text/html" in request.headers["Accept"]: + return render_template( + "genotypes/index.html", + species=species, + population=population, + genocode=genocode_by_population(conn, population["Id"]), + dataset=genotype_dataset( + conn, species["SpeciesId"], population["Id"]), + genotype_records=_genotype_records, + samples=_samples, + activelink="list-genotypes") + + raise UnsupportedMediaType("This endpoint can only server HTML or JSON") @genotypesbp.route( "/<int:species_id>/populations/<int:population_id>/genotypes/<int:dataset_id>/list-markers", methods=["GET"]) @require_login -@with_species(redirect_uri="species.populations.genotypes.list_genotypes") -def list_markers(species: dict, **_kwargs): +@with_population(species_redirect_uri="species.list_species", + redirect_uri="species.populations.index") +def list_markers(species: dict, population: dict, **_kwargs): """List the markers that exist for this species.""" args = request.args offset = int(args.get("start") or 0) @@ -69,11 +104,12 @@ def list_markers(species: dict, **_kwargs): markers, total_records = genotype_markers( conn, species["SpeciesId"], + population["Id"], offset=offset, limit=int(args.get("length") or 0)) return jsonify({ - **({"draw": int(args.get("draw"))} - if bool(args.get("draw") or False) + **({"draw": int(args.get("draw", "0"))} + if bool(args.get("draw")) else {}), "recordsTotal": total_records, "recordsFiltered": len(markers), @@ -146,7 +182,7 @@ def create_dataset(species: dict, population: dict, **kwargs):# pylint: disable= form["geno-dataset-name"], form["geno-dataset-fullname"], form["geno-dataset-shortname"])) - except Exception: + except Exception:# pylint: disable=[broad-exception-caught] msg = "Error adding new Genotype dataset to database." logger.error(msg, exc_info=True) return Left(Exception(msg)) @@ -176,3 +212,23 @@ def create_dataset(species: dict, population: dict, **kwargs):# pylint: disable= make_either_error_handler( "There was an error creating the genotype dataset."), __success__) + + +@genotypesbp.route( + "/<int:species_id>/populations/<int:population_id>/genotypes/datasets/" + "<int:dataset_id>/add-records", + methods=["GET", "POST"]) +@require_login +@with_population(species_redirect_uri="species.list_species", + redirect_uri="species.populations.list_species_populations") +@with_dataset(species_redirect_uri="species.list_species", + population_redirect_uri="species.populations.list_species_populations", + redirect_uri="species.populations.genotypes.index", + dataset_by_id=genotype_dataset) +def add_genotype_records(species: dict, population: dict, dataset: dict, **kwargs): + """Add new Genotype records to the dataset.""" + return render_template("genotypes/add-genotypes-records-csv.html", + species=species, + population=population, + dataset=dataset, + activelink="add-genotypes-records") diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py index c03f3f5..85d6357 100644 --- a/uploader/phenotypes/views.py +++ b/uploader/phenotypes/views.py @@ -8,7 +8,7 @@ import logging from typing import Any from pathlib import Path from zipfile import ZipFile -from functools import wraps, reduce +from functools import reduce from urllib.parse import urljoin, urlparse, ParseResult, urlunparse, urlencode import datetime @@ -51,7 +51,7 @@ from uploader.datautils import safe_int, enumerate_sequence from uploader.species.models import all_species, species_by_id from uploader.monadic_requests import make_either_error_handler from uploader.publications.models import fetch_publication_by_id -from uploader.request_checks import with_species, with_population +from uploader.request_checks import with_species, with_dataset, with_population from uploader.input_validation import (encode_errors, decode_errors, is_valid_representative_name) @@ -136,45 +136,6 @@ def list_datasets(species: dict, population: dict, **kwargs):# pylint: disable=[ activelink="list-datasets") -def with_dataset( - species_redirect_uri: str, - population_redirect_uri: str, - redirect_uri: str -): - """Ensure the dataset actually exists.""" - def __decorator__(func): - @wraps(func) - @with_population(species_redirect_uri, population_redirect_uri) - def __with_dataset__(**kwargs): - try: - _spcid = int(kwargs["species_id"]) - _popid = int(kwargs["population_id"]) - _dsetid = int(kwargs.get("dataset_id")) - select_dataset_uri = redirect(url_for( - redirect_uri, species_id=_spcid, population_id=_popid)) - if not bool(_dsetid): - flash("You need to select a valid 'dataset_id' value.", - "alert-danger") - return select_dataset_uri - with database_connection(app.config["SQL_URI"]) as conn: - dataset = dataset_by_id(conn, _spcid, _popid, _dsetid) - if not bool(dataset): - flash("You must select a valid dataset.", - "alert-danger") - return select_dataset_uri - except ValueError as _verr: - app.logger.debug( - "Exception converting 'dataset_id' to integer: %s", - kwargs.get("dataset_id"), - exc_info=True) - flash("Expected 'dataset_id' value to be an integer." - "alert-danger") - return select_dataset_uri - return func(dataset=dataset, **kwargs) - return __with_dataset__ - return __decorator__ - - @phenotypesbp.route( "<int:species_id>/populations/<int:population_id>/phenotypes/datasets" "/<int:dataset_id>/view", @@ -183,7 +144,8 @@ def with_dataset( @with_dataset( species_redirect_uri="species.populations.phenotypes.index", population_redirect_uri="species.populations.phenotypes.select_population", - redirect_uri="species.populations.phenotypes.list_datasets") + redirect_uri="species.populations.phenotypes.list_datasets", + dataset_by_id=dataset_by_id) def view_dataset(# pylint: disable=[unused-argument] species: dict, population: dict, dataset: dict, **kwargs): """View a specific dataset""" @@ -223,7 +185,8 @@ def view_dataset(# pylint: disable=[unused-argument] @with_dataset( species_redirect_uri="species.populations.phenotypes.index", population_redirect_uri="species.populations.phenotypes.select_population", - redirect_uri="species.populations.phenotypes.list_datasets") + redirect_uri="species.populations.phenotypes.list_datasets", + dataset_by_id=dataset_by_id) def view_phenotype(# pylint: disable=[unused-argument] species: dict, population: dict, @@ -412,7 +375,8 @@ def process_phenotypes_individual_files(error_uri): @with_dataset( species_redirect_uri="species.populations.phenotypes.index", population_redirect_uri="species.populations.phenotypes.select_population", - redirect_uri="species.populations.phenotypes.list_datasets") + redirect_uri="species.populations.phenotypes.list_datasets", + dataset_by_id=dataset_by_id) def add_phenotypes(species: dict, population: dict, dataset: dict, **kwargs):# pylint: disable=[unused-argument, too-many-locals] """Add one or more phenotypes to the dataset.""" use_bundle = request.args.get("use_bundle", "").lower() == "true" @@ -501,7 +465,8 @@ def add_phenotypes(species: dict, population: dict, dataset: dict, **kwargs):# p @with_dataset( species_redirect_uri="species.populations.phenotypes.index", population_redirect_uri="species.populations.phenotypes.select_population", - redirect_uri="species.populations.phenotypes.list_datasets") + redirect_uri="species.populations.phenotypes.list_datasets", + dataset_by_id=dataset_by_id) def job_status( species: dict, population: dict, @@ -537,7 +502,8 @@ def job_status( @with_dataset( species_redirect_uri="species.populations.phenotypes.index", population_redirect_uri="species.populations.phenotypes.select_population", - redirect_uri="species.populations.phenotypes.list_datasets") + redirect_uri="species.populations.phenotypes.list_datasets", + dataset_by_id=dataset_by_id) def download_errors( species: dict, population: dict, @@ -596,7 +562,8 @@ def download_errors( @with_dataset( species_redirect_uri="species.populations.phenotypes.index", population_redirect_uri="species.populations.phenotypes.select_population", - redirect_uri="species.populations.phenotypes.list_datasets") + redirect_uri="species.populations.phenotypes.list_datasets", + dataset_by_id=dataset_by_id) def review_job_data( species: dict, population: dict, @@ -696,7 +663,8 @@ def proceed_to_job_status(job): @with_dataset( species_redirect_uri="species.populations.phenotypes.index", population_redirect_uri="species.populations.phenotypes.select_population", - redirect_uri="species.populations.phenotypes.list_datasets") + redirect_uri="species.populations.phenotypes.list_datasets", + dataset_by_id=dataset_by_id) def load_data_to_database( species: dict, population: dict, @@ -909,7 +877,8 @@ def update_phenotype_data(conn, data: dict): @with_dataset( species_redirect_uri="species.populations.phenotypes.index", population_redirect_uri="species.populations.phenotypes.select_population", - redirect_uri="species.populations.phenotypes.list_datasets") + redirect_uri="species.populations.phenotypes.list_datasets", + dataset_by_id=dataset_by_id) def edit_phenotype_data(# pylint: disable=[unused-argument] species: dict, population: dict, @@ -1029,7 +998,8 @@ def edit_phenotype_data(# pylint: disable=[unused-argument] @with_dataset( species_redirect_uri="species.populations.phenotypes.index", population_redirect_uri="species.populations.phenotypes.select_population", - redirect_uri="species.populations.phenotypes.list_datasets") + redirect_uri="species.populations.phenotypes.list_datasets", + dataset_by_id=dataset_by_id) def load_data_success( species: dict, population: dict, @@ -1095,7 +1065,8 @@ def load_data_success( @with_dataset( species_redirect_uri="species.populations.phenotypes.index", population_redirect_uri="species.populations.phenotypes.select_population", - redirect_uri="species.populations.phenotypes.list_datasets") + redirect_uri="species.populations.phenotypes.list_datasets", + dataset_by_id=dataset_by_id) def recompute_means(# pylint: disable=[unused-argument] species: dict, population: dict, @@ -1171,7 +1142,8 @@ def recompute_phenotype_means_success_handler(job): @with_dataset( species_redirect_uri="species.populations.phenotypes.index", population_redirect_uri="species.populations.phenotypes.select_population", - redirect_uri="species.populations.phenotypes.list_datasets") + redirect_uri="species.populations.phenotypes.list_datasets", + dataset_by_id=dataset_by_id) def rerun_qtlreaper(# pylint: disable=[unused-argument] species: dict, population: dict, @@ -1249,7 +1221,8 @@ def delete_phenotypes_success_handler(job): @with_dataset( species_redirect_uri="species.populations.phenotypes.index", population_redirect_uri="species.populations.phenotypes.select_population", - redirect_uri="species.populations.phenotypes.list_datasets") + redirect_uri="species.populations.phenotypes.list_datasets", + dataset_by_id=dataset_by_id) def delete_phenotypes(# pylint: disable=[unused-argument, too-many-locals] species: dict, population: dict, diff --git a/uploader/static/css/layout-large.css b/uploader/static/css/layout-large.css index 2d53627..c1950b1 100644 --- a/uploader/static/css/layout-large.css +++ b/uploader/static/css/layout-large.css @@ -52,6 +52,7 @@ grid-column-start: 1; grid-column-end: 2; + overflow-x: auto; } #main #sidebar-content { diff --git a/uploader/static/css/layout-medium.css b/uploader/static/css/layout-medium.css index 50ceeb4..a29411d 100644 --- a/uploader/static/css/layout-medium.css +++ b/uploader/static/css/layout-medium.css @@ -52,6 +52,7 @@ /* Define layout for the children elements */ max-width: 100%; + overflow-x: auto; } #main #sidebar-content { diff --git a/uploader/static/css/layout-small.css b/uploader/static/css/layout-small.css index 2e47217..87dd910 100644 --- a/uploader/static/css/layout-small.css +++ b/uploader/static/css/layout-small.css @@ -56,6 +56,7 @@ #main #main-content { grid-row-start: 2; grid-row-end: 3; + overflow-x: auto; } #main #sidebar-content { diff --git a/uploader/static/js/files.js b/uploader/static/js/files.js index 0bde6f7..7cb3d0e 100644 --- a/uploader/static/js/files.js +++ b/uploader/static/js/files.js @@ -116,3 +116,218 @@ var makeResumableElement = (targeturi, fileinput, droparea, uploadbutton, filety return resumable; }; + + +var CSVFilesMetadata = () => { + return { + "separator": $("#txt-file-separator").val(), + "comment_char": $( + "#txt-file-comment-character").val(), + "na_strings": $("#txt-file-na").val() + } +}; + + +var updatePreview = (table, filedata, formdata, numrows) => { + table.find("thead tr").remove() + table.find(".data-row").remove(); + var linenum = 0; + var tableheader = table.find("thead"); + var tablebody = table.find("tbody"); + var numheadings = 0; + var comment_chars = formdata + .comment_char + .split(" ") + .map((v) => {return v.trim();}) + .filter((v) => {return Boolean(v);}); + var navalues = formdata + .na_strings + .split(" ") + .map((v) => {return v.trim();}) + .filter((v) => {return Boolean(v);}); + filedata.forEach((line) => { + if(comment_chars.includes(line[0]) || linenum >= numrows) { + return false; + } + var row = $("<tr></tr>"); + line.split(formdata.separator) + .map((field) => { + var value = field.trim(); + if(navalues.includes(value)) { + return "[NO-VALUE]"; + } + return value; + }) + .filter((field) => { + return (field !== "" && field != undefined && field != null); + }) + .forEach((field) => { + if(linenum == 0) { + numheadings += 1; + var tablefield = $("<th></th>"); + tablefield.text(field); + row.append(tablefield); + } else { + add_class(row, "data-row"); + var tablefield = $("<td></td>"); + tablefield.text(field); + row.append(tablefield); + } + }); + + if(linenum == 0) { + tableheader.append(row); + } else { + tablebody.append(row); + } + linenum += 1; + }); + + if(table.find("tbody tr.data-row").length > 0) { + add_class(table.find(".data-row-template"), "visually-hidden"); + } else { + remove_class(table.find(".data-row-template"), "visually-hidden"); + } +}; + + +var makePreviewUpdater = (preview_table, preview_rows) => { + return (data) => { + updatePreview( + preview_table, + data, + CSVFilesMetadata(), + preview_rows); + }; +}; + + +var resumableDisplayFiles = (display_area, files) => { + files.forEach((file) => { + display_area.find(".file-display").remove(); + var display_element = display_area + .find(".file-display-template") + .clone(); + remove_class(display_element, "visually-hidden"); + remove_class(display_element, "file-display-template"); + add_class(display_element, "file-display"); + display_element.find(".filename").text(file.name + || file.fileName + || file.relativePath + || file.webkitRelativePath); + display_element.find(".filesize").text( + (file.size / (1024*1024)).toFixed(2) + "MB"); + display_element.find(".fileuniqueid").text(file.uniqueIdentifier); + display_element.find(".filemimetype").text(file.file.type); + display_area.append(display_element); + }); +}; + + +var indicateProgress = (resumable, progress_bar) => { + return () => {/*Has no event!*/ + var progress = (resumable.progress() * 100).toFixed(2); + var pbar = progress_bar.find(".progress-bar"); + remove_class(progress_bar, "visually-hidden"); + pbar.css("width", progress+"%"); + pbar.attr("aria-valuenow", progress); + pbar.text("Uploading: " + progress + "%"); + }; +}; + + +var retryUpload = (retry_button, cancel_button) => { + retry_button.on("click", (event) => { + resumable.files.forEach((file) => {file.retry();}); + add_class(retry_button, "visually-hidden"); + remove_class(cancel_button, "visually-hidden"); + add_class(browse_button, "visually-hidden"); + }); +}; + + +var cancelUpload = (cancel_button, retry_button) => { + cancel_button.on("click", (event) => { + resumable.files.forEach((file) => { + if(file.isUploading()) { + file.abort(); + } + }); + add_class(cancel_button, "visually-hidden"); + remove_class(retry_button, "visually-hidden"); + remove_class(browse_button, "visually-hidden"); + }); +}; + + +var startUpload = (browse_button, retry_button, cancel_button) => { + return (event) => { + remove_class(cancel_button, "visually-hidden"); + add_class(retry_button, "visually-hidden"); + add_class(browse_button, "visually-hidden"); + }; +}; + + +var uploadSuccess = (file_input_name) => { + return (file, message) => { + submitForm({...JSON.parse(message), "file-input-name": file_input_name}); + }; +}; + + +var uploadError = () => { + return (message, file) => { + $("#frm-add-phenotypes input[type=submit]").removeAttr("disabled"); + console.log("THE FILE:", file); + console.log("THE ERROR MESSAGE:", message); + }; +}; + +var makeResumableObject = (form_id, file_input_id, resumable_element_id, preview_table_id, filetypes=["csv", "tsv", "txt"], preview_rows=5) => { + var the_form = $("#" + form_id); + var file_input = $("#" + file_input_id); + var submit_button = the_form.find("input[type=submit]"); + if(file_input.length != 1) { + return false; + } + var r = errorHandler( + fileSuccessHandler( + uploadStartHandler( + filesAddedHandler( + markResumableDragAndDropElement( + makeResumableElement( + the_form.attr("data-resumable-target"), + file_input.parent(), + $("#" + resumable_element_id), + submit_button, + filetypes), + file_input.parent(), + $("#" + resumable_element_id), + $("#" + resumable_element_id + "-browse-button")), + (files) => { + // TODO: Also trigger preview! + resumableDisplayFiles( + $("#" + resumable_element_id + "-selected-files"), files); + files.forEach((file) => { + readFirstNLines( + file.file, + 100, + [makePreviewUpdater( + $("#" + preview_table_id), + preview_rows)]) + }); + }), + startUpload($("#" + resumable_element_id + "-browse-button"), + $("#" + resumable_element_id + "-retry-button"), + $("#" + resumable_element_id + "-cancel-button"))), + uploadSuccess(file_input.attr("name"))), + uploadError()); + + /** Setup progress indicator **/ + progressHandler( + r, + indicateProgress(r, $("#" + resumable_element_id + "-progress-bar"))); + + return r; +}; diff --git a/uploader/templates/genotypes/add-genotypes-records-base.html b/uploader/templates/genotypes/add-genotypes-records-base.html new file mode 100644 index 0000000..bf3812f --- /dev/null +++ b/uploader/templates/genotypes/add-genotypes-records-base.html @@ -0,0 +1,39 @@ +{%extends "genotypes/base.html"%} +{%from "flash_messages.html" import flash_all_messages%} + +{%block title%}Genotypes{%endblock%} + +{%block pagetitle%}Genotypes{%endblock%} + +{%block contents%} + +<div class="row"> + <form id="frm-add-genotypes-records" + method="POST" + enctype="multipart/form-data" + action="{{url_for( + 'species.populations.genotypes.add_genotype_records', + species_id=species.SpeciesId, population_id=population.Id, + dataset_id=dataset.Id)}}" + data-resumable-target="{{url_for('files.resumable_upload_post')}}"> + <legend>Add New Genotype Records</legend> + + {%block frm_add_genotypes_records_elements%}{%endblock%} + + <div class="form-group"> + <input type="submit" + value="upload genotypes" + class="btn btn-primary" /> + </div> + </form> +</div> + +<div class="row"> + <h2 class="heading" id="page-documentation">Help</h2> + {%block page_documentation%}{%endblock%} +</div> +{%endblock%} + + +{%block javascript%} +{%endblock%} diff --git a/uploader/templates/genotypes/add-genotypes-records-csv.html b/uploader/templates/genotypes/add-genotypes-records-csv.html new file mode 100644 index 0000000..58dbe81 --- /dev/null +++ b/uploader/templates/genotypes/add-genotypes-records-csv.html @@ -0,0 +1,146 @@ +{%extends "genotypes/add-genotypes-records-base.html"%} +{%from "phenotypes/macro-display-preview-table.html" import display_preview_table%} +{%from "macro-csv-fields.html" import display_csv_fields, display_csv_fields_documentation%} +{%from "phenotypes/macro-display-resumable-elements.html" import display_resumable_elements%} + +{%block frm_add_genotypes_records_elements%} +<div class="form-text help-block"> + <p>You can add new genotype records here.</p> +</div> + +{{display_csv_fields()}} + +<div class="form-group"> + <div class="non-resumable-elements"> + <label for="finput-genotypes-records-file" class="form-label"> + genotypes records</label> + <input id="finput-genotypes-records-file" + name="genotypes-records-file" + class="form-control" + type="file" + data-preview-table="tbl-preview-geno-records" + required="required" /> + <span class="form-text text-muted"> + Provide a file that contains only the genotypes records, + <a href="#docs-file-genotypes-records-csv" + title="Documentation of the genotypes records file format."> + the documentation for the expected format of the file</a>.</span> + </div> + {{display_resumable_elements( + "resumable-genotypes-records-file", + "Genotypes records", + '<p>Drag and drop the CSV file here, that contains the genotype records you + want to add.</p> + + <p>Please see the + <a href="#docs-file-genotypes-records" + title="Documentation of the genotypes records data file format."> + "Genotypes records" documentation</a> section below for more + information on the expected format of the file provided here.</p>')}} + {{display_preview_table("tbl-preview-geno-records", "genotypes records")}} +</div> + +<div class=""> + <h4 class="subheading">Genotype Encoding</h4> + <div class="form-text help-block"> + <p>The symbols in your genotype file need to be mapped to known values to + enable mapping.</p> + </div> + + <div class="form-group"> + <div class="row mb-3"> + <label for="txt-geno-encoding-mat" + class="col-form-label col-sm-2">Maternal</label> + <div class="col-sm-10"> + <div class="input-group"> + <input type="text" + maxlength="3" + id="txt-geno-encoding-mat" + name="geno_encoding_mat" + class="form-control" /> + <div class="input-group-append"> + <span class="input-group-text">Value = -1</span> + </div> + </div> + </div> + <span class="form-text text-muted col-sm-12"> + Enter the symbol in your file that represents the allele inherited from + the mother. This allele will be mapped to the value -1.</span> + </div> + </div> + + <div class="form-group"> + <div class="row mb-3"> + <label for="txt-geno-encoding-pat" + class="col-form-label col-sm-2">Paternal</label> + <div class="col-sm-10"> + <div class="input-group"> + <input type="text" + maxlength="3" + id="txt-geno-encoding-pat" + name="geno_encoding_pat" + class="form-control" /> + <div class="input-group-append"> + <span class="input-group-text">Value = 1</span> + </div> + </div> + </div> + <span class="form-text text-muted"> + Enter the symbol in your file that represents the allele inherited from + the father. This allele will be mapped to the value 1.</span> + </div> + </div> + + <div class="form-group"> + <div class="row mb-3"> + <label for="txt-geno-encoding-het" + class="col-form-label col-sm-2">Heterozygous (value = 0)</label> + <div class="col-sm-10"> + <div class="input-group"> + <input type="text" + maxlength="3" + id="txt-geno-encoding-het" + name="geno_encoding_het" + class="form-control" /> + <div class="input-group-append"> + <span class="input-group-text">Value = 0</span> + </div> + </div> + </div> + <span class="form-text text-muted"> + Enter the symbol in your file that represents the allele inherited from + both parents. This allele will be mapped to the value 0.</span> + </div> + </div> +</div> +{%endblock%} + +{%block page_documentation%} +{{super()}} + +<h3 class="sub-heading">CSV file metadata</h3> +{{display_csv_fields_documentation()}} +{%endblock%} + +{%block javascript%} +{{super()}} +<script src="{{url_for('base.node_modules', + filename='resumablejs/resumable.js')}}"></script> +<script src="/static/js/files.js"></script> + +<script type="text/javascript"> + $(function(evt) { + + var preview_tables_to_elements_map = { + "#tbl-preview-geno-records": "#finput-genotypes-records-file", + }; + + makeResumableObject( + form_id="frm-add-genotypes-records", + file_input_id="finput-genotypes-records-file", + resumable_element_id="resumable-genotypes-records-file", + preview_table_id="tbl-preview-geno-records", + filetypes=["csv", "tsv", "txt", "geno"]); + }); +</script> +{%endblock%} diff --git a/uploader/templates/genotypes/base.html b/uploader/templates/genotypes/base.html index 8d1b951..c2abc63 100644 --- a/uploader/templates/genotypes/base.html +++ b/uploader/templates/genotypes/base.html @@ -1,10 +1,11 @@ {%extends "populations/base.html"%} {%from "populations/macro-display-population-card.html" import display_sui_population_card%} +{%from "genotypes/macro-display-dataset-card.html" import display_dataset_card%} {%block breadcrumbs%} {{super()}} <li class="breadcrumb-item"> - <a href="{{url_for('species.populations.genotypes.list_genotypes', + <a href="{{url_for('species.populations.genotypes.index', species_id=species['SpeciesId'], population_id=population['Id'])}}"> genotype @@ -14,5 +15,9 @@ {%block sidebarcontents%} +{%if dataset is defined and dataset is not none%} +{{display_dataset_card(species, population, dataset)}} +{%else%} {{display_sui_population_card(species, population)}} +{%endif%} {%endblock%} diff --git a/uploader/templates/genotypes/create-dataset.html b/uploader/templates/genotypes/create-dataset.html index ff174fb..7f435a1 100644 --- a/uploader/templates/genotypes/create-dataset.html +++ b/uploader/templates/genotypes/create-dataset.html @@ -40,9 +40,7 @@ readonly="readonly" /> <small class="form-text text-muted"> <p>This is a short representative, but constrained name for the genotype - dataset.<br /> - It is used internally by the Genenetwork system. Do not change this - value.</p> + dataset. It is used internally by GeneNetwork.</p> </small> </div> diff --git a/uploader/templates/genotypes/index.html b/uploader/templates/genotypes/index.html new file mode 100644 index 0000000..1c3483d --- /dev/null +++ b/uploader/templates/genotypes/index.html @@ -0,0 +1,200 @@ +{%extends "genotypes/base.html"%} +{%from "flash_messages.html" import flash_all_messages%} + +{%block title%}Genotypes{%endblock%} + +{%block pagetitle%}Genotypes{%endblock%} + +{%block contents%} +{{flash_all_messages()}} + + +{%if dataset is defined and dataset is not none%} + +<div class="row"> + <h2>Genotype Data</h2> + + <div class="row"> + <div class="col"> + <p> + <a href="{{url_for( + 'species.populations.genotypes.add_genotype_records', + species_id=species.SpeciesId, population_id=population.Id, + dataset_id=dataset.Id)}}" + class="btn btn-primary"> + Add genotype records + </a> + </p> + </div> + </div> + + <div class="table-responsive"> + <table id="tbl-genotype-records" class="table compact stripe cell-border"> + <thead> + <tr> + <th title="">#</th> + <th title="">Index</th> + <th title="Locus of marker on the chromosome">Locus</th> + <th title="Chromosome">Chr</th> + <th title="Physical location of marker in centimorgans">cM</th> + <th title="Physical location of marker in megabasepairs">Mb</th> + {%for sample in samples%} + <th title="Data for sample {{sample}}">{{sample}}</th> + {%endfor%} + </tr> + </thead> + + <tbody> + {%for record in genotype_records%} + <tr> + <td> + <input type="checkbox" + id="chk-geno-record-{{record.Id}}" + name="geno_record_id" + value="{{record.Id}}" /> + </td> + <td>{{record.index}}</td> + <td>{{record.Name}}</td> + <td>{{record.Chr}}</td> + <td>{{record.cM}}</td> + <td>{{record.Mb}}</td> + {%for sample in samples%} + <td>{{record.data[sample]}}</td> + {%endfor%} + </tr> + {%else%} + <tr> + <td colspan="6" class="text-info"> + There are no records + </td> + </tr> + {%endfor%} + </tbody> + </table> + </div> +</div> + +<div class="row"> + <h2>Genotype Encoding</h2> + <p>The numerical values in the table above are mapped from the following allele symbols:</p> + + <table class="table"> + <thead> + <tr> + <th>Allele Type</th> + <th>Allele Symbol</th> + <th>Mapped To</th> + </tr> + </thead> + + <tbody> + {%for row in genocode%} + <tr> + <td {%if row.AlleleType == 'mat'%} + title="Maternal allele" + {%elif row.AlleleType == "pat"%} + title="Paternal allele" + {%elif row.AlleleType == "het"%} + title="Heterozygous allele" + {%else%} + title="Unknown allele" + {%endif%}> + {{row.AlleleType}}</td> + <td>{{row.AlleleSymbol}}</td> + <td>{{row.DatabaseValue if row.DatabaseValue is not none}}</td> + </tr> + {%else%} + <tr> + <td colspan="3" class="text-info"> + There is no genotype encoding defined for this data. + </td> + </tr> + {%endfor%} + </tbody> + </table> +</div> + +{%else%} + +<div class="row"> + <p>We need to create a dataset to hold the genotype information for this + species/population, before we can proceed to upload the genotype data.</p> + <p>Please click the button below to create the dataset.</p> + + <div class="col"> + <a href="{{url_for('species.populations.genotypes.create_dataset', species_id=species.SpeciesId, population_id=population.Id)}}" + class="btn btn-primary">create genotype dataset</a> + </div> +</div> + +{%endif%} + +{%endblock%} + + +{%block javascript%} +<script type="text/javascript"> + $(function() { + var genoRecordsUrl = "{{url_for('species.populations.genotypes.index', species_id=species.SpeciesId, population_id=population.Id)}}"; + + var dtGenotypeRecords = false; + fetch(genoRecordsUrl, { + method: "POST", + headers: { + "Accept": "application/json", + "Content-Type": "application/json" + }, + body: JSON.stringify({}) + }) + .then(response => response.json()) + .then(recordsData => { + var records = recordsData.genotype_records; + var samples = recordsData.samples_order; + var columns = [ + { + data: function(record) { + return `<input type="checkbox"` + + `id="chk-geno-record-` + record.Id + `"` + + `name="geno_record_id"` + + `value="` + record.Id + `"` + + ` />`; + } + }, + {data: "index"}, + {data: "Name"}, + {data: "Chr"}, + {data: "cM"}, + {data: "Mb"} + ].concat(samples.map((sample) => { + return {data: (record) => record.data[sample]}; + })); + + dtGenotypeRecords = buildDataTable( + "#tbl-genotype-records", + [], + columns, + { + serverSide: true, + ajax: { + url: genoRecordsUrl, + dataSrc: "genotype_records", + recordsTotal: "total_genotype_records", + recordsFiltered: "fetched_genotype_records" + }, + paging: true, + scroller: true, + scrollY: "50vh", + scrollCollapse: false, + layout: { + top: "info", + topStart: null, + topEnd: null, + bottom: null, + bottomStart: null, + bottomEnd: null + } + }); + }); + }); +</script> +{%endblock%} diff --git a/uploader/templates/genotypes/list-genotypes.html b/uploader/templates/genotypes/list-genotypes.html deleted file mode 100644 index 131576f..0000000 --- a/uploader/templates/genotypes/list-genotypes.html +++ /dev/null @@ -1,226 +0,0 @@ -{%extends "genotypes/base.html"%} -{%from "flash_messages.html" import flash_all_messages%} - -{%block title%}Genotypes{%endblock%} - -{%block pagetitle%}Genotypes{%endblock%} - -{%block contents%} -{{flash_all_messages()}} - -<div class="row"> - <h2>Genotype Encoding</h2> - <p> - The genotype encoding used for the "{{population.FullName}}" population from - the "{{species.FullName}}" species is as shown in the table below. - </p> - <table class="table"> - - <thead> - <tr> - <th>Allele Type</th> - <th>Allele Symbol</th> - <th>Allele Value</th> - </tr> - </thead> - - <tbody> - {%for row in genocode%} - <tr> - <td>{{row.AlleleType}}</td> - <td>{{row.AlleleSymbol}}</td> - <td>{{row.DatabaseValue if row.DatabaseValue is not none else "NULL"}}</td> - </tr> - {%else%} - <tr> - <td colspan="7" class="text-info"> - <span class="glyphicon glyphicon-exclamation-sign"></span> - There is no explicit genotype encoding defined for this population. - </td> - </tr> - {%endfor%} - </tbody> - </table> - - {%if genocode | length < 1%} - <div class="col"> - <a href="#add-genotype-encoding" - title="Add a genotype encoding system for this population" - class="btn btn-primary not-implemented"> - define genotype encoding - </a> - </div> - {%endif%} -</div> - -<div class="row"> - <h2>Genotype Dataset</h2> -</div> - -{%if dataset is not none%} - -<div class="row"> - <h3>Dataset Details</h3> - <table class="table"> - <thead> - <tr> - <th>Name</th> - <th>Full Name</th> - </tr> - </thead> - - <tbody> - <tr> - <td>{{dataset.Name}}</td> - <td><a href="{{url_for('species.populations.genotypes.view_dataset', - species_id=species.SpeciesId, - population_id=population.Id, - dataset_id=dataset.Id)}}" - title="View details regarding and manage dataset '{{dataset.FullName}}'" - target="_blank"> - {{dataset.FullName}}</a></td> - </tr> - </tbody> - </table> - - <p> - To see more information regarding this dataset (e.g. which markers have - sample allele data, the allele data itself, etc) click on the "Full Name" - link above.</p> -</div> - -<div class="row"> - <h3>Genotype Markers</h3> - - <div class="row"> - <p> - The table below lists all of the markers that exist for species - {{species.SpeciesName}} ({{species.FullName}}), regardless of whether - (or not) we have corresponding sample allele data for a particular marker. - </p> - <table id="tbl-genetic-markers" class="table compact stripe cell-border"> - <thead> - <tr> - <th title="">#</th> - <th title="">Index</th> - <th title="">Marker Name</th> - <th title="Chromosome">Chr</th> - <th title="Physical location of the marker in megabasepairs"> - Location (Mb)</th> - <th title="">Source</th> - <th title="">Source2</th> - </thead> - - <tbody> - {%for marker in markers%} - <tr> - <td></td> - <td></td> - <td></td> - <td></td> - <td></td> - <td></td> - <td></td> - </tr> - {%endfor%} - </tbody> - </table> -</div> - -{%else%} - -<div class="row"> - <p> - Your genotype data will need to be under a dataset. Unfortunately there is - currently no dataset defined for this population. - </p> - - <p class="text-warning"> - <span class="glyphicon glyphicon-exclamation-sign"></span> - Click the button below to define the genotype dataset for this population. - </p> - <p> - <a href="{{url_for('species.populations.genotypes.create_dataset', - species_id=species.SpeciesId, - population_id=population.Id)}}" - title="Create a new genotype dataset for the '{{population.FullName}}' population for the '{{species.FullName}}' species." - class="btn btn-primary"> - create new genotype dataset</a></p> -</div> - -{%endif%} - -<div class="row"> - <h2>Notes</h2> - <div class="row text-danger"> - <h3>Genetic Markers: Some Important Concepts to Consider/Remember</h3> - <ul> - <li>Reference vs. Non-reference alleles</li> - <li>In <em>GenoCode</em> table, items are ordered by <strong>InbredSet</strong></li> - </ul> - <h3>Possible references</h3> - <ul> - <li>https://mr-dictionary.mrcieu.ac.uk/term/genotype/</li> - <li>https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7363099/</li> - </ul> - </div> - - <div class="row text-warning"> - <h3>Genotype Dataset</h3> - <p> - <span class="glyphicon glyphicon-exclamation-sign"></span> - <strong>NOTE</strong>: Currently the GN2 (and related) system(s) expect a - single genotype dataset per population. If there is more than one, the - system apparently fails in unpredictable ways. - </p> - </div> -</div> - -{%endblock%} - - -{%block javascript%} -<script type="text/javascript"> - - $(function() { - var dtGeneticMarkers = buildDataTable( - "#tbl-genetic-markers", - [], - [ - { - data: function(marker) { - return `<input type="checkbox" name="selected-markers" ` + - `id="chk-selected-markers-${marker.Id}-${marker.GenoFreezeId}" ` + - `value="${marker.Id}_${marker.GenoFreezeId}" ` + - `class="chk-row-select" />`; - } - }, - {data: 'index'}, - {data: "Name", searchable: true}, - {data: "Chr", searchable: true}, - {data: "Mb", searchable: true}, - {data: "Source", searchable: true}, - {data: "Source2", searchable: true} - ], - { - ajax: { - url: "{{url_for('species.populations.genotypes.list_markers', species_id=species.SpeciesId, population_id=population.Id, dataset_id=dataset.Id)}}", - dataSrc: "markers" - }, - paging: true, - scroller: true, - scrollY: "50vh", - scrollCollapse: true, - layout: { - top: "info", - topStart: null, - topEnd: null, - bottom: null, - bottomStart: null, - bottomEnd: null - } - }); - }); - -</script> -{%endblock%} diff --git a/uploader/templates/genotypes/macro-display-dataset-card.html b/uploader/templates/genotypes/macro-display-dataset-card.html new file mode 100644 index 0000000..2b197d4 --- /dev/null +++ b/uploader/templates/genotypes/macro-display-dataset-card.html @@ -0,0 +1,24 @@ +{%from "populations/macro-display-population-card.html" import display_sui_population_card%} + +{%macro display_dataset_card(species, population, dataset)%} +{{display_sui_population_card(species, population)}} +<div class="row"> + <table class="table"> + <caption>Current genotype dataset</caption> + <tbody> + <tr> + <th>Name</th> + <td>{{dataset.Name}}</td> + </tr> + <tr> + <th>Full Name</th> + <td>{{dataset.FullName}}</td> + </tr> + <tr> + <th>Short Name</th> + <td>{{dataset.ShortName}}</td> + </tr> + </tbody> + </table> +</div> +{%endmacro%} diff --git a/uploader/templates/macro-csv-fields.html b/uploader/templates/macro-csv-fields.html new file mode 100644 index 0000000..d4b0f57 --- /dev/null +++ b/uploader/templates/macro-csv-fields.html @@ -0,0 +1,102 @@ +{%macro display_csv_fields()%} +<div class="form-group"> + <label for="txt-file-separator" class="form-label">File Separator</label> + <div class="input-group"> + <input id="txt-file-separator" + name="file-separator" + type="text" + value="	" + class="form-control" + maxlength="1" /> + <span class="input-group-btn"> + <button id="btn-reset-file-separator" class="btn btn-info">Reset Default</button> + </span> + </div> + <span class="form-text text-muted"> + Provide the character that separates the fields in your file(s). It should + be the same character for all files (if more than one is provided).<br /> + A tab character will be assumed if you leave this field blank. See + <a href="#docs-file-separator" + title="Documentation for file-separator characters"> + documentation for more information</a>. + </span> +</div> + +<div class="form-group"> + <label for="txt-file-comment-character" class="form-label">File Comment-Characters</label> + <div class="input-group"> + <input id="txt-file-comment-character" + name="file-comment-character" + type="text" + value="#" + class="form-control" /> + <span class="input-group-btn"> + <button id="btn-reset-file-comment-character" class="btn btn-info"> + Reset Default</button> + </span> + </div> + <span class="form-text text-muted"> + This specifies that lines that begin with the character(s) provided will be + considered comment lines and ignored in their entirety. See + <a href="#docs-file-comment-character" + title="Documentation for comment characters"> + documentation for more information</a>. + </span> +</div> + +<div class="form-group"> + <label for="txt-file-na" class="form-label">File "No-Value" Indicators</label> + <div class="input-group"> + <input id="txt-file-na" + name="file-na" + type="text" + value="- NA N/A" + class="form-control" /> + <span class="input-group-btn"> + <button id="btn-reset-file-na" class="btn btn-info">Reset Default</button> + </span> + </div> + <span class="form-text text-muted"> + This specifies strings in your file indicate that there is no value for a + particular cell (a cell is where a column and row intersect). Provide a + space-separated list of strings if you have more than one way of + indicating no values. See + <a href="#docs-file-na" title="Documentation for no-value fields"> + documentation for more information</a>.</span> +</div> +{%endmacro%} + + +{%macro display_csv_fields_documentation()%} +<dl> + <dt id="docs-file-separator">File separator</dt> + <dd>The files you provide should be character-separated value (CSV) files. + We need to know what character you used to separate the values in your + file. Some common ones are the Tab character, the comma, etc.<br /> + Providing that information makes it possible for the system to parse and + process your files correctly.<br> + <strong>NOTE:</strong> All the files you upload MUST use the same + separator.</dd> + + <dt id="docs-file-comment-character">Comment characters</dt> + <dd>We support use of comment lines in your files. We only support one type + of comment style, the <em>line comment</em>.<br /> + This mean the comment begins at the start of the line, and the end of that + line indicates the end of that comment. If you have a really long comment, + then you need to break it across multiple lines, marking each line a + comment line.<br /> + The "comment character" is the character at the start of the line that + indicates that the line is a line comment.<br /> + You can provide more than one comment character, separated by spaces.</dd> + + <dt id="docs-file-na">No-Value indicator(s)</dt> + <dd>Data in the real world is messy, and in some cases, entirely absent. You + need to indicate, in your files, that a particular field did not have a + value, and once you do that, you then need to let the system know how you + mark such fields. Common ways of indicating "empty values" are, leaving + the field blank, using a character such as '-', or using strings like + "NA", "N/A", "NULL", etc.<br /> + Providing this information will help with parsing and processing such + no-value fields the correct way.</dd> +</dl> +{%endmacro%} diff --git a/uploader/templates/phenotypes/view-dataset.html b/uploader/templates/phenotypes/view-dataset.html index 3bb2586..fc84757 100644 --- a/uploader/templates/phenotypes/view-dataset.html +++ b/uploader/templates/phenotypes/view-dataset.html @@ -148,14 +148,36 @@ return `<a href="${url.toString()}" target="_blank">` + `${pheno.InbredSetCode}_${pheno.xref_id}` + `</a>`; - } + }, + title: "Record", + visible: true, + searchable: true }, { data: function(pheno) { return (pheno.Post_publication_description || pheno.Original_description || pheno.Pre_publication_description); - } + }, + title: "Description", + visible: true, + searchable: true + }, + { + data: function(pheno) { + return pheno.publication.Title; + }, + title: "Publication Title", + visible: false, + searchable: true + }, + { + data: function(pheno) { + return pheno.publication.Authors; + }, + title: "Authors", + visible: false, + searchable: true } ], { diff --git a/uploader/templates/populations/view-population.html b/uploader/templates/populations/view-population.html index 29add29..6da4cd7 100644 --- a/uploader/templates/populations/view-population.html +++ b/uploader/templates/populations/view-population.html @@ -4,7 +4,7 @@ {%block contents%} <div class="row"> - <h2 class="heading">{{population.FullName}} ({{population.Name}})</h2> + <h2 class="heading">Population: {{population.FullName}} ({{population.Name}})</h2> </div> <div class="row"> @@ -58,14 +58,18 @@ aria-labelledby="samples-content-tab"> <p>Think of a <strong>"sample"</strong> as say a single case or individual in the experiment. It could even be a single strain (where applicable). + These are, effectively, identifiers for the organisms (plants, animals, + etc) that your data is collected from, and is about. </p> - <p>This is a convenience feature for when you want to upload phenotypes to - the system, but do not have the genotypes data ready yet.</p> + + <p>The samples should be uploaded before any of the other types of data + (genotype, phenotype, expression, etc.), or be bundled together with + them, since they all need references to the samples.</p> <a href="{{url_for('species.populations.samples.list_samples', species_id=species.SpeciesId, population_id=population.Id)}}" title="View and upload samples for population '{{population['Name']}}'" - class="btn btn-primary">Manage Samples</a> + class="btn btn-primary">manage samples</a> </div> <div class="tab-pane fade show active" @@ -74,9 +78,11 @@ aria-labelledby="phenotypes-content-tab"> <div class="row" style="margin-top: 1em;"> - <h3> Phenotypes in Population "{{population.FullName}} ({{population.Name}})"</h3> - - <p>To view existing phenotype traits, or upload new ones, click the button below:</p> + <p>Phenotype data measures the actual observable traits or + characteristics of an organism e.g. physical appearance, biochemical + properties, development, behaviour and/or disease states.</p> + <p>This section enables you to view existing and/or upload new phenotype + data.</p> <div class="row"> <div class="col"> @@ -85,7 +91,7 @@ species_id=species.SpeciesId, population_id=population.Id)}}" title="View and upload phenotype traits" - class="btn btn-primary">Phenotypes</a> + class="btn btn-primary">manage phenotypes</a> </div> </div> </div> @@ -95,17 +101,20 @@ id="genotypes-content" role="tabpanel" aria-labelledby="genotypes-content-tab"> - <p>Click the button to view and manage genetic data for individuals in - this population.</p> - <a href="{{url_for('species.populations.genotypes.list_genotypes', + <p>Genotype data records specific genetic variations (e.g. single + nucleotide polymorphisms (SNPs)) present at particular locations in an + individual's (see "Samples" section) DNA.</p> + <p>Click the button below to view existing and/or upload new genotype data + for this population.</p> + <a href="{{url_for('species.populations.genotypes.index', species_id=species.SpeciesId, population_id=population.Id)}}" title="Upload genotype information for the '{{population.FullName}}' population of the '{{species.FullName}}' species." class="btn btn-primary">manage genotypes</a> </div> <div class="tab-pane fade" id="expression-data-content" role="tabpanel" aria-labelledby="expression-data-content-tab"> - <p>Upload expression data (mRNA data) for this population.</p> - <a href="#" title="" class="btn btn-primary">upload genotypes</a> + <p>Expression data is data measuring how much genes are turned on or active.</p> + <a href="#" title="" class="btn btn-primary">manage expression data</a> </div> </div> </div> |
