Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render trait display names everywhere #472

Merged
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
776892d
Add launch config for `POPULATE_PHENOTYPES_DATABASE`
vlagrassa Feb 9, 2024
8a057e7
Merge branch 'development' into enhancement/phenotype-datastore-multi…
vlagrassa Feb 20, 2024
527b169
Add trait display names to Google Sheet > GCP db op
vlagrassa Feb 20, 2024
eec1ba4
Add trait display names to datastore entity class
vlagrassa Feb 20, 2024
8e01dd2
Better fallback behavior for display name
vlagrassa Feb 20, 2024
a31c172
Display tags column as `flex-row`
vlagrassa Feb 20, 2024
0cfa693
Render empty table cell if no short description
vlagrassa Feb 20, 2024
9918388
Remove unused "label" field from trait report & link with "View Repor…
vlagrassa Feb 21, 2024
7e8f463
Merge branch 'fix/trait-name-styling' into enhancement/phenotype-data…
vlagrassa Feb 23, 2024
1b258b8
Move trait multiline HTML to new utils file
vlagrassa Feb 23, 2024
efec6a9
Render trait display name in reports page w new macro
vlagrassa Feb 23, 2024
cd5736e
Move trait JSON query to util function
vlagrassa Feb 28, 2024
3d21dac
When selecting trait, query info from database directly
vlagrassa Feb 28, 2024
5f5c8e7
Render trait display name in trait selectors
vlagrassa Feb 28, 2024
ff72030
Remove repeat listings for display name fields
vlagrassa Feb 28, 2024
c356254
Reorganize TraitFile props a bit
vlagrassa Feb 28, 2024
7726bb9
Render trait display names in graph axes
vlagrassa Feb 28, 2024
efe677b
Move report list individual tool cols to Jinja
vlagrassa Feb 28, 2024
38127cd
Cache trait display names in report objects
vlagrassa Feb 28, 2024
84bcdf2
Render trait display names in reports list w custom renderer
vlagrassa Feb 28, 2024
881298d
Fix initial trait none check (again)
vlagrassa Feb 29, 2024
5cb6222
Sort out `PhenotypeReport` trait name fields (see desc)
vlagrassa Feb 29, 2024
7c3de83
Render report axis labels with styling (bold, italics, etc)
vlagrassa Feb 29, 2024
42741be
Add DbOp for recomputing cached phenotype report display names
vlagrassa Feb 29, 2024
958bd5a
Set full CaeNDR trait name as display name for Zhang traits
vlagrassa Feb 29, 2024
a547a41
Use trait display names in offcanvas header
vlagrassa Feb 29, 2024
230c61f
Fix: render axis labels as HTML in single-trait report
vlagrassa Feb 29, 2024
db868e2
Fix: move display name computation to Trait & use to initialize Zhang…
vlagrassa Feb 29, 2024
8d09fda
Merge branch 'development' into enhancement/phenotype-datastore-multi…
vlagrassa Feb 29, 2024
997252e
Merge branch 'development' into enhancement/phenotype-datastore-multi…
vlagrassa Apr 10, 2024
011de8d
Check Google Sheet columns before parsing rows
vlagrassa Apr 10, 2024
db31f33
Fix: trait lookup request data
vlagrassa Apr 10, 2024
75e9873
Flash error message if trait metadata request fails
vlagrassa Apr 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,28 @@
"SITE_BASE_URL": "https://localhost:8080"
}
},
{
"name": "Run POPULATE_PHENOTYPES_DATASTORE",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/src/modules/db_operations/main.py",
"console": "integratedTerminal",
"python": "${workspaceFolder}/src/modules/db_operations/venv/bin/python",
"justMyCode": true,
"envFile": "${workspaceFolder}/src/modules/db_operations/.env",
"env": {
"DATABASE_OPERATION": "POPULATE_PHENOTYPES_DATASTORE",
"USE_MEMOIZATION": "1",
// "MODULE_DB_OPERATIONS_CONNECTION_TYPE": "localhost",
// "MODULE_DB_OPERATIONS_CONNECTION_TYPE": "memory",
"MODULE_DB_OPERATIONS_CONNECTION_TYPE": "file",
"MODULE_DB_OPERATIONS_CONNECTION_FILE": "${workspaceFolder}/temp/local.db",
"MODULE_DB_TIMEOUT": "300",
"CAENDR_USE_SSL": "1",
"SENTRY_URL": "",
"SITE_BASE_URL": "https://localhost:8080",
},
},
{
"name": "DB_OP TEST_ECHO",
"type": "python",
Expand All @@ -348,6 +370,24 @@
"SITE_BASE_URL": "https://localhost:8080",
}
},
{
"name": "DbOp: Recompute Phenotype Report Cached Names",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/src/modules/db_operations/main.py",
"console": "integratedTerminal",
"python": "${workspaceFolder}/src/modules/db_operations/venv/bin/python",
"justMyCode": true,
"envFile": "${workspaceFolder}/src/modules/db_operations/.env",
"env": {
"DATABASE_OPERATION": "RECOMPUTE_PHENOTYPE_REPORT_CACHED_NAMES",
"RELOAD_FILES": "false",
"MODULE_DB_TIMEOUT": "300",
"CAENDR_USE_SSL": "1",
"SENTRY_URL": "",
"SITE_BASE_URL": "https://localhost:8080",
}
},
{
"name": "Test Indel Finder",
"type": "python",
Expand Down
5 changes: 4 additions & 1 deletion src/modules/db_operations/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from caendr.services.cloud.postgresql import health_database_status
from caendr.services.logger import logger

from caendr.models.datastore import Species
from caendr.models.datastore import Species, PhenotypeReport
from caendr.models.sql import DbOp, WormbaseGene, WormbaseGeneSummary, Strain, StrainAnnotatedVariant, PhenotypeDatabase, PhenotypeMetadata
from caendr.services.sql.db import backup_external_db
from caendr.services.sql.etl import ETLManager
Expand Down Expand Up @@ -49,6 +49,9 @@ def execute_operation(app, db, db_op: DbOp, species=None, reload_files=True):
logger.info("Using MOCK DATA")
drop_and_populate_all_tables(app, db, species)

elif db_op == DbOp.RECOMPUTE_PHENOTYPE_REPORT_CACHED_NAMES:
PhenotypeReport.recompute_cached_display_names()



def drop_and_populate_strains(app, db, species, reload_files=True):
Expand Down
9 changes: 6 additions & 3 deletions src/modules/db_operations/seed_trait_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ def populate_andersenlab_trait_files():
'species': get_field_from_record(record, 'Species', nullable=False),

# About trait
'description_short': get_field_from_record(record, 'Short_Description'),
'description_long': get_field_from_record(record, 'Long_Description'),
'units': get_field_from_record(record, 'Units'),
'trait_name_display_1': get_field_from_record(record, 'Trait_Name_Display1'),
r-vieira marked this conversation as resolved.
Show resolved Hide resolved
'trait_name_display_2': get_field_from_record(record, 'Trait_Name_Display2'),
'trait_name_display_3': get_field_from_record(record, 'Trait_Name_Display3'),
'description_short': get_field_from_record(record, 'Short_Description'),
'description_long': get_field_from_record(record, 'Long_Description'),
'units': get_field_from_record(record, 'Units'),

# Tag list (categories)
'tags': list(filter(
Expand Down
8 changes: 4 additions & 4 deletions src/modules/site-v2/base/static/js/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function render_scatterplot_histograms(container_selector, data, config={}) {
.attr('x', margin.left + (width / 2))
.attr('y', height + margin.top + hist_height + 36)
.attr('text-anchor', 'middle')
.text(config['x_label'])
.html(config['x_label'])
}

// Add label for y-axis, if one is provided
Expand All @@ -216,7 +216,7 @@ function render_scatterplot_histograms(container_selector, data, config={}) {
.attr('y', 0)
.attr('dy', '.75em')
.attr('text-anchor', 'middle')
.text(config['y_label'])
.html(config['y_label'])

}

Expand Down Expand Up @@ -349,7 +349,7 @@ function render_histogram(container_selector, data, config={}) {
.attr('x', margin.left + (width / 2))
.attr('y', height + margin.top + 36)
.attr('text-anchor', 'middle')
.text(config['x_label'])
.html(config['x_label'])
}

// Add the histogram
Expand Down Expand Up @@ -501,7 +501,7 @@ function render_ranked_barplot(container_selector, data, config={}) {
.attr('y', 0)
.attr('dy', '.75em')
.attr('text-anchor', 'middle')
.text(config['y_label'])
.html(config['y_label'])
}
//Render tooltips
setTooltips();
Expand Down
19 changes: 0 additions & 19 deletions src/modules/site-v2/base/views/tools/genetic_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,6 @@



def results_columns():
return [
{
'title': 'Description',
'class': 'label',
'field': 'label',
'width': 0.6,
'link_to_data': True,
},
{
'title': 'Trait',
'class': 'trait',
'field': 'trait',
'width': 0.4,
},
]


@genetic_mapping_bp.route('', methods=['GET'])
@jwt_required()
def genetic_mapping():
Expand Down Expand Up @@ -162,7 +144,6 @@ def list_results():
# Table info
'species_list': Species.all(),
'items': list_reports(NemascanReport, None if show_all else user, filter_errs),
'columns': results_columns(),

'JobStatus': JobStatus,
})
Expand Down
18 changes: 0 additions & 18 deletions src/modules/site-v2/base/views/tools/heritability_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,6 @@
)


def results_columns():
return [
{
'title': 'Description',
'class': 'label',
'field': 'label',
'width': 0.6,
'link_to_data': True,
},
{
'title': 'Trait',
'class': 'trait',
'field': 'trait',
'width': 0.4,
},
]


@heritability_calculator_bp.route('')
@jwt_required()
Expand Down Expand Up @@ -136,7 +119,6 @@ def list_results():
# Table info
'species_list': Species.all(),
'items': list_reports(HeritabilityReport, None if show_all else user, filter_errs),
'columns': results_columns(),

'JobStatus': JobStatus,
})
Expand Down
25 changes: 0 additions & 25 deletions src/modules/site-v2/base/views/tools/pairwise_indel_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,6 @@



def results_columns():
return [
{
'title': 'Site',
'class': 'site',
'field': 'site',
'width': 0.5,
'link_to_data': True,
'data_order': lambda e: e['site'],
},
{
'title': 'Strain 1',
'class': 's1',
'field': 'strain_1',
'width': 0.25,
},
{
'title': 'Strain 2',
'class': 's2',
'field': 'strain_2',
'width': 0.25,
},
]

def try_get_sv_strains(species):
try:
return get_sv_strains(species)
Expand Down Expand Up @@ -185,7 +161,6 @@ def list_results():
# Table info
'species_list': Species.all(),
'items': list_reports(IndelPrimerReport, None if show_all else user, filter_errs),
'columns': results_columns(),

'JobStatus': JobStatus,
})
Expand Down
28 changes: 1 addition & 27 deletions src/modules/site-v2/base/views/tools/phenotype_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,6 @@ def check_bp_enabled():



def results_columns():
return [
{
'title': 'Description',
'class': 'label',
'field': 'label',
'width': 0.2,
'link_to_data': True,
},
{
'title': 'Trait 1',
'class': 's1',
'field': 'trait_1_name',
'width': 0.4,
},
{
'title': 'Trait 2',
'class': 's2',
'field': 'trait_2_name',
'width': 0.4,
},
]



#
# Main Endpoint
#
Expand Down Expand Up @@ -253,7 +228,7 @@ def submit():
# Read & clean fields from JSON data
data = {
field: bleach.clean(request.json.get(field))
for field in {'label', 'species', 'trait_1', 'trait_1_dataset'}
for field in {'species', 'trait_1', 'trait_1_dataset'}
}

# Read & clean values for trait 2, if given
Expand Down Expand Up @@ -312,7 +287,6 @@ def list_results():
# Table info
'species_list': Species.all(),
'items': list_reports(PhenotypeReport, user = None if show_all else user, filter_errs=filter_errs),
'columns': results_columns(),

'JobStatus': JobStatus,
})
Expand Down
5 changes: 0 additions & 5 deletions src/modules/site-v2/templates/_includes/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,3 @@
<em>Unable to retrieve files.</em>
{%- endif %}
{%- endmacro %}


{%- macro label_string_units(name, units=null) %}
{%- if units -%} "{{ name }} ({{ units }})" {%- else -%} "{{ name }}" {%- endif -%}
{%- endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@
<div class="offcanvas offcanvas-end offcanvasPhenotype" tabindex="-1" id="offcanvas1"
aria-labelledby="offcanvas1Label">
<div class="offcanvas-header">
<h1 class="h5" id="offcanvas1Label"></h5>
<div>
<h1 class="h5">
<span id="offcanvas1-header-1" class="d-block mb-1"></span>
<span id="offcanvas1-header-2" class="d-block text-dark fw-normal"></span>
<span class="d-block text-dark fw-normal"><em id="offcanvas1-header-3"></em></span>
</h1>
</div>
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body p-4">
Expand All @@ -114,7 +120,8 @@ <h1 class="h5" id="offcanvas1Label"></h5>

{% block script %}
<script>
{% include '_scripts/utils.js' %} {#/* defines: flash_message */#}
{% include '_scripts/utils.js' %} {#/* defines: flash_message */#}
{% include '_scripts/trait_utils.js' %} {#/* defines: traitNameHTML, queryTraitByName */#}

$(document).ready(function() {

Expand Down Expand Up @@ -168,7 +175,7 @@ <h1 class="h5" id="offcanvas1Label"></h5>
const trait_name = row.trait_name_caendr;
const url = '{{ analyze_link | safe }}'.replace("TRAIT_NAME", trait_name).replace("TRAIT_SET", 'zhang');
return `
<div id="trait-data-${row.trait_name_caendr}" class="ps-3 pt-0" data-description="${row.description_short || row.description_long}" data-species="${row.species_name}">
<div id="trait-data-${row.trait_name_caendr}" class="ps-3 pt-0">
<a href='${url}'><i class="bi bi-arrow-right-circle-fill" aria-hidden="true"></i>Analyze</a>
</div>`
},
Expand All @@ -185,17 +192,11 @@ <h1 class="h5" id="offcanvas1Label"></h5>

// Fetch data for a trait and fill out side bar for non-bulk traits
$(document).on('click','#traitDetails', function() {
const data = {csrf_token: $('#csrf_token').val(), trait_name: $(this).data('value')}
$.ajax({
type: "POST",
url: "{{ url_for('phenotype_database.get_traits_json') }}",
data: JSON.stringify(data),
contentType: "application/json",
dataType: "json",
success: function(response) {
queryTraitByName($(this).data('value'), $('#csrf_token').val())
.then((response) => {
fillOutModal(response)
},
error: function(error){
})
.fail((error) => {
console.error(error)
$('#offcanvas1 .btn-close').click()
$('html').animate({
Expand All @@ -204,9 +205,8 @@ <h1 class="h5" id="offcanvas1Label"></h5>
if (error.responseJSON && error.responseJSON.message) {
$('.alert').remove()
flash_message(error.responseJSON.message)
}
}
})
}
})
})


Expand Down Expand Up @@ -321,16 +321,14 @@ <h1 class="h5" id="offcanvas1Label"></h5>
class="bi bi-chevron-right" aria-hidden="true"></i><em>${speciesName}</em></a>
</td>
<td id="accordionHeading-${i+1}">
<strong>${arr[i].trait_name_display_1 || arr[i].trait_name_caendr}</strong>
<p class="mb-0">${arr[i].trait_name_display_1 ? arr[i].trait_name_display_2 : ''}</p>
<em>${arr[i].trait_name_display_1 ? arr[i].trait_name_display_3 : ''}</em>
${traitNameHTML( arr[i].trait_name_display_1, arr[i].trait_name_display_2, arr[i].trait_name_display_3 )}
</td>
<td>${arr[i].description_short}.</td>
<td>${arr[i].description_short ? (arr[i].description_short + '.') : ''}</td>
<td>${arr[i].source_lab}</td>
<td>${createdOn}</td>
<td class="d-flex flex-column" id="tags">${tagsHTML}</td>
<td class="d-flex-row flex-column" id="tags">${tagsHTML}</td>
<td class="optionsToolbar">
<div class="ps-3 pt-0" id="trait-data-${arr[i].trait_name_caendr}" data-description="${arr[i].description_short || arr[i].description_long}" data-species="${arr[i].species_name}"><a href='${url}'><i class="bi bi-arrow-right-circle-fill"
<div class="ps-3 pt-0" id="trait-data-${arr[i].trait_name_caendr}"><a href='${url}'><i class="bi bi-arrow-right-circle-fill"
aria-hidden="true"></i>Analyze</a></div>
</td>
</tr>
Expand Down Expand Up @@ -422,7 +420,9 @@ <h3 class="h5 text-dark">Full Description</h3>
}

function fillOutModal(trait) {
$('#offcanvas1Label').text(trait.trait_name_caendr)
$('#offcanvas1-header-1').text(trait.trait_name_display_1)
$('#offcanvas1-header-2').text(trait.trait_name_display_2)
$('#offcanvas1-header-3').text(trait.trait_name_display_3)
manageVal(trait.capture_date, '#captureDate', true)
manageVal(trait.created_on, '#createdOn', true)
manageVal(trait.modified_on, '#modifiedOn', true)
Expand Down
Loading