6 <& /util/import_javascript.mas, entries => ["wizard"] &>
7 <& /util/import_css.mas, paths => ['wizard.css'] &>
9 <& /page/page_title.mas, title=>"Search Wizard" &>
12 <div class="col-md-12" style="margin-bottom:1em; text-align:right;">
13 Don't see your data? <button id="update_wizard_lists" class="btn btn-default">Refresh Lists</button>
14 <button id="update_wizard_show" class="btn btn-default">Update Wizard</button>
18 <& /breeders_toolbox/breeder_search_page_dataset_overlay.mas &>
20 <div id="wizard" class="row">
21 <span class="wizard-main">
22 <span class="wizard-columns"></span>
23 <div class="templates" style="display: none !important;">
25 <div class="wizard-unselected">
26 <div class="btn-group wizard-list-item">
27 <button type="button" class="btn btn-xs btn-success wizard-list-add">+</button>
28 <a target="_blank" class="btn btn-xs btn-default wizard-list-name"></a>
32 <div class="wizard-selected">
33 <div class="btn-group wizard-list-item">
34 <button type="button" class="btn btn-xs btn-danger wizard-list-rem">✕</button>
35 <a target="_blank" class="btn btn-xs btn-default wizard-list-name"></a>
39 <div class="wizard-column">
40 <div class="wizard-panel panel panel-default">
42 <span class="wizard-loader glyphicon glyphicon-refresh" aria-hidden="true"></span>
44 <div class="panel-heading">
45 <select class="wizard-type-select form-control input-sm form-inline">
46 <option value="" disabled selected>Select Column Type</option>
47 <optgroup class="wizard-types-group" label="--------------------"></optgroup>
48 <optgroup class="wizard-lists-group" label="Load Selection from List:"></optgroup>
52 <div class="panel-heading">
53 <input type="text" class="wizard-search form-control input-sm" placeholder="Search">
56 <div class="panel-body">
58 <div class="wizard-btn-center">
59 <div class="btn-group">
60 <button class="wizard-select-all btn btn-default btn-xs">Select All</button
61 ><button class="wizard-btn-tag btn btn-primary btn-xs">
62 <span class="wizard-count-selected">0</span>/<span class="wizard-count-all">0</span>
64 ><button class="wizard-select-clear btn btn-default btn-xs">Clear</button>
68 <ul class="wizard-list-unselected wizard-list well"></ul>
69 <ul class="wizard-list-selected wizard-list well"></ul>
71 <div class="wizard-btn-center wizard-union-toggle">
72 <div class="btn-group">
73 <button class="wizard-btn-tag btn btn-xs btn-default disabled">Match</button
74 ><button class="btn btn-xs btn-primary active">ANY</button
75 ><button class="btn btn-default btn-xs">ALL</button>
81 <table class="wizard-save-to-list table panel-footer">
82 <&| /util/user.mas:logged_in &>
85 <select class="wizard-add-to-list-id form-control input-sm">
86 <option selected value="" disabled>Add to List...</option>
87 <optgroup class="wizard-lists-group" label="--------------------"></optgroup>
91 <button class="wizard-add-to-list btn btn-sm btn-primary btn-block">Add</button>
96 <input class="wizard-create-list-name form-control input-sm" type="text" placeholder="Create New List..."></input>
99 <button class="wizard-create-list btn btn-primary btn-sm btn-block">Create</button>
103 <&| /util/user.mas:logged_out &>
105 <td><button class="btn btn-xs btn-primary" name="site_login_button">Log In</button> to save lists.</td>
116 <div class="clearfix col-xs-12"></div>
118 <div class="wizard-datasets panel-group col-sm-12 col-md-6">
119 <div class="panel panel-default wizard-panel">
120 <div class="panel-heading">
121 <&| /util/user.mas:logged_out &><button class="btn btn-xs btn-primary" name="site_login_button">Log In</button> to</&>
122 Load/Create Datasets using <button class="btn btn-xs btn-default disabled wizard-btn-tag">Match</button> Columns
124 <&| /util/user.mas:logged_in &>
125 <div class="panel-body">
126 <div class="input-group">
127 <select class="form-control input-sm wizard-dataset-select">
128 <option selected value="" disabled>Load Dataset</option>
129 <optgroup class="wizard-dataset-group" label="--------------------"></optgroup>
131 <span class="input-group-btn">
132 <span><button style="width:5em;margin-left:4px;" class="btn btn-sm btn-primary wizard-dataset-load">Load</button></span>
133 <span><button style="width:9em;margin-left:4px;" class="btn btn-sm btn-primary wizard-dataset-public">Make Public</button></span>
134 <span><button style="width:5em;margin-left:4px;" class="btn btn-sm btn-danger wizard-dataset-delete">Delete</button></span>
138 <div class="panel-body" style="margin-top:-1px;">
139 <div class="input-group">
140 <input type="text" placeholder="Create New Dataset" class="form-control input-sm wizard-dataset-name" />
141 <span class="input-group-btn">
142 <span><button style="width:5em;margin-left:4px;" class="btn btn-sm btn-primary wizard-dataset-create">Create</button></span>
150 <div class="wizard-downloads panel-group col-sm-12 col-md-6" id="wiz-down-group" role="tablist" aria-multiselectable="true">
151 <&| /util/user.mas:logged_out &>
152 <div class="panel panel-default">
153 <div class="panel-heading">
154 <button class="btn btn-xs btn-primary" name="site_login_button">Log In</button> to download related data.
158 <&| /util/user.mas:logged_in &>
159 <div class="panel panel-default">
160 <div class="panel-heading" role="button" data-toggle="collapse" data-parent="#wiz-down-group" href="#wiz-down-1-c" aria-controls="wiz-down-1-c">
161 <span class="btnn btn-link">Related Genotype Data</span>
163 <div id="wiz-down-1-c" class="panel-collapse collapse" role="tabpanel">
164 <table class="table">
167 <span class="glyphicon glyphicon-info-sign" title="To download related genotype data, select 1 or more Accessions and optionally no more than 1 Genotyping Protocol in the wizard. If no genotyping protocol is selected, the database default protocol will be used. Click the checkbox here to compute genotypes for the selected accessions from genotypes of parents; this works for downloading genotypes, downloading the GRM, and performing GWAS."></span>
168 <span>Download Genotype Data</span>
169 <input class="wizard-download-genotypes-info form-control input-sm" type="text" disabled></input>
172 <span>Compute From Parents</span><br/>
173 <input type="checkbox" class="wizard-download-genotypes-parents-compute">
176 <span>Include Duplicate Genotypes</span><br/>
177 <input type="checkbox" class="wizard-download-genotypes-duplicates-include">
181 <div class="panel-footer" style="border-top: 1px solid #ddd;">
182 <table class="table">
185 <span class="glyphicon glyphicon-info-sign" title="You can use either chromosome or markers (markerset) to filter genotyping data. You cannot use both criteria at the same time."></span>
186 <span>Filter by Chromosome or Markerset</span>
191 <span>Chromosome</span>
192 <select class="wizard-download-genotypes-chromosome-number form-control input-sm"></select>
195 <span>Start Position</span>
196 <input placeholder="" type="number" class="wizard-download-genotypes-start-position form-control input-sm">
199 <span>End Position</span>
200 <input placeholder="" type="number" class="wizard-download-genotypes-end-position form-control input-sm">
205 <span>Markerset Filter</span>
206 <select class="wizard-download-genotypes-marker-set-list-id form-control input-sm" id="wizard-download-genotypes-marker-set-list-id"></select>
210 <button class="btn btn-sm btn-default" onClick="window.open('/breeders/markers', '_blank');">Manage Markersets</button>
215 <span>Genotypes Download Format</span>
216 <select class="wizard-download-genotypes-format form-control input-sm" >
217 <option value="VCF">VCF File Format</option>
218 <option value="DosageMatrix">Dosage Matrix File Format (.tsv)</option>
226 <span class="glyphicon glyphicon-info-sign" title="Select accessions, and optionally a genotyping protocol. If no genotyping protocol is selected, the default genotyping protocol is used in your system. If you want to filter genotypes, use the chromosome, start position, end position, or markerset. Can compute genotypes from parents if the parents of the accessions you selected have genotypes by checking the checkbox. Genotypes can be downloaded in VCF and Dosage Matrix Formats."></span>
227 <span>Download Genotypes</span><br/>
228 <button class="wizard-download-genotypes btn btn-sm btn-primary">
229 <span class="glyphicon glyphicon-download" aria-hidden="true"></span>
238 <div class="panel-footer" style="border-top: 1px solid #ddd;">
239 <table class="table">
242 <span>Minor Allele Frequency</span>
243 <input placeholder="0.05" value="0.05" type="number" class="wizard-download-genotypes-grm-maf form-control input-sm">
246 <span>Marker Filter</span>
247 <input placeholder="0.60" value="0.60" type="number" class="wizard-download-genotypes-grm-marker-filter form-control input-sm">
250 <span>Individuals Filter</span>
251 <input placeholder="0.80" value="0.80" type="number" class="wizard-download-genotypes-grm-individuals-filter form-control input-sm">
256 <span>Genomic Relationship Matrix (GRM) Download Format</span>
257 <select class="wizard-download-genotypes-grm-format form-control input-sm" >
258 <!--option value="heatmap">Heatmap (.pdf)</option-->
259 <option value="matrix">Matrix (.tsv)</option>
260 <option value="three_column">3-Column Format (.tsv)</option>
263 <span class="glyphicon glyphicon-info-sign" title="Select accessions, and optionally a genotyping protocol. If no genotyping protocol is selected, the default genotyping protocol is used in your system. Specify minor allele frequency (MAF), marker filter, and individuals filter. Can compute genotypes from parents if the parents of the accessions you selected have genotypes by checking the checkbox. GRM can be downloaded in a matrix format (.tsv) and a three column format."></span>
264 <span>Download GRM</span><br/>
265 <button class="wizard-download-genetic-relationship-matrix btn btn-sm btn-primary">
266 <span class="glyphicon glyphicon-download" aria-hidden="true"></span>
273 <span>Genome Wide Association Study (GWAS) Download Format</span>
274 <select class="wizard-download-genotypes-gwas-format form-control input-sm" >
275 <option value="manhattan_qq_plots">Manhattan + QQ Plots (.pdf)</option>
276 <option value="results_tsv">GWAS Results (.tsv)</option>
279 <span>Selected Traits Are All Repeated Measurements</span>
280 <select class="wizard-download-genotypes-gwas-repeated-measurements form-control input-sm" >
281 <option value="no">No</option>
282 <option value="yes">Yes</option>
285 <span class="glyphicon glyphicon-info-sign" title="Select accessions, traits, and optionally a genotyping protocol. If no genotyping protocol is selected, the default genotyping protocol is used in your system. When many traits are selected and these traits are not treated as repeated measurements, the traits are treated separately and distinct results are returned e.g. several Manhattan plots are returned. If the selected traits are in fact repeated measurements, then select 'yes'; a single GWAS will be run against all of the phenotypes e.g. a single Manhattan plot is returned. Specify minor allele frequency (MAF), marker filter, and individuals filter. Can compute genotypes from parents if the parents of the accessions you selected have genotypes by checking the checkbox. GWAS uses a fixed effect for different field trials and a fixed effect for replicate. GWAS uses Kinship matrix calculated from the genotype data. MAF and missing data used to filter prior to GWAS and Kinship matrix calculation. Can select whether to return results in Manhattan and QQ Plot (.pdf) form or as the tabular results (.tsv)."></span>
286 <span>Run GWAS</span><br/>
287 <button class="wizard-download-gwas btn btn-sm btn-primary">
288 <span class="glyphicon glyphicon-download" aria-hidden="true"></span>
299 <div class="panel panel-default">
300 <div class="panel-heading" role="button" data-toggle="collapse" data-parent="#wiz-down-group" href="#wiz-down-2-c" aria-controls="wiz-down-2-c">
301 <span class="btnn btn-link">Related Trial Metadata</span>
303 <div id="wiz-down-2-c" class="panel-collapse collapse" role="tabpanel">
304 <table class="table">
307 <input class="wizard-download-tmetadata-info form-control input-sm" type="text" disabled value="No Trials Selected"></input>
310 <select class="wizard-download-tmetadata-format form-control input-sm">
311 <option value="" disabled>Format</option>
312 <option selected value="csv">CSV</option>
313 <option value="xls">XLS</option>
318 <div class="panel-footer" style="border-top: 1px solid #ddd;">
319 <button class="wizard-download-tmetadata btn btn-sm btn-primary">
320 <span class="glyphicon glyphicon-download" aria-hidden="true"></span>
327 <div class="panel panel-default">
328 <div class="panel-heading" role="button" data-toggle="collapse" data-parent="#wiz-down-group" href="#wiz-down-3-c" aria-controls="wiz-down-3-c">
329 <span class="btnn btn-link">Related Trial Phenotypes</span>
331 <div id="wiz-down-3-c" class="panel-collapse collapse" role="tabpanel">
332 <table class="table">
335 <input class="wizard-download-phenotypes-info form-control input-sm" type="text" disabled></input>
340 <select class="wizard-download-phenotypes-speed form-control input-sm">
341 <option value="" disabled>Download Type</option>
342 <option selected value="Native">Default</option>
343 <option value="MaterializedViewTable">Fast (Improves speed but may miss recent changes)</option>
347 <select class="wizard-download-phenotypes-format form-control input-sm">
348 <option value="" disabled>Download Format</option>
349 <option selected value="csv">CSV</option>
350 <option value="xls">XLS</option>
354 <select class="wizard-download-phenotypes-level form-control input-sm">
355 <option value="" disabled>Data Level</option>
356 <option selected value="all">All</option>
357 <option value="plot">Plots</option>
358 <option value="plant">Plants</option>
364 <div class="checkbox">
366 <input class="wizard-download-phenotypes-timestamp" type="checkbox">
372 <div class="checkbox">
374 <input class="wizard-download-phenotypes-entry-numbers" type="checkbox">
375 Include accession entry numbers
381 <td colspan="3" style="border-top: none; padding-top: 0">
382 <div class="checkbox">
384 <input class="wizard-download-phenotypes-outliers" type="checkbox">
385 Supress user defined phenotype outliers
392 <span>Trait Name Contains</span>
393 <input placeholder="" type="text" class="wizard-download-phenotypes-name form-control">
396 <span>Min Value</span>
397 <input placeholder="-∞" type="text" class="wizard-download-phenotypes-min form-control">
400 <span>Max Value</span>
401 <input placeholder="∞" type="text" class="wizard-download-phenotypes-max form-control">
405 <div class="panel-footer" style="border-top: 1px solid #ddd;">
406 <button class="wizard-download-phenotypes btn btn-sm btn-primary">
407 <span class="glyphicon glyphicon-download" aria-hidden="true"></span>
419 window.sWizard = jsMod['wizard'].WizardSetup("#wizard");
422 <div class="modal fade" id="update_wizard_dialog" name="update_wizard_dialog" tabindex="-1" role="dialog" aria-labelledby="updateWizardDialog">
423 <div class="modal-dialog" role="document">
424 <div class="modal-content">
425 <div class="modal-header">
426 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
427 <h3 class="modal-title" id="updateWizardDialog">Update Search Wizard</h3>
429 <div class="modal-body">
430 <div class="container-fluid">
431 <h4>How the wizard works</h4>
432 <p>For the search wizard to be fast and flexible, it avoids querying the database directly. Instead, it stores a copy of the data from the database in a temporary format that is optimized for the types of queries the wizard makes.</p><p>For this to be practical, the copy must be updated regularly. Updates usually start every time new data is uploaded, however users with submitter status or higher can also initiate them manually.</p><p>If an update isn't already in progress, you can initiate one below. It will run independently on the server without any additional input required from the user. Depending on the size of the database, it will take from a few minutes to a few hours to complete.</p>
433 <div><h4>Current status:</h4><p id="wizard_status"></p></div>
436 <div class="modal-footer">
437 <div class="well well-sm" id="update_wizard_error" style="display:none;"></div>
438 <button type="button" class="btn btn-primary wiz-update" name="update_wizard" data-loading-text="Working..." id="update_wizard">Update search wizard</button>
439 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
447 jQuery(document).ready(function (){
449 document.getElementsByClassName("wizard-dataset-select")[0].value = <% $dataset_id %>;
450 document.getElementsByClassName("wizard-dataset-load")[0].click();
454 d3.select('#update_wizard_show').on('click', function () {
455 $('#update_wizard_dialog').modal("show");
456 jsMod['wizard'].updateStatus("#wizard_status")
457 .then(function(isLoading){
459 d3.select("#update_wizard")
460 .attr("title","A search wizard update is already in progress...")
461 .attr("disabled",true);
464 d3.select("#update_wizard")
465 .attr("title","Refresh the search wizard to include newly uploaded data")
466 .attr("disabled",null)
471 d3.select("#update_wizard").on('click',function(){
472 jsMod['wizard'].refreshMatviews("fullview",this);
475 d3.select("#update_wizard_lists").on('click',function(){
476 window.sWizard.reload_lists();
480 // Wizard Callback: get chromosome names for a single selected genotyping protocol
481 var SELECTED_GENOTYPING_PROTOCOL = undefined;
482 window.sWizard.wizard.on_change(function(categories, selections, operations) {
483 var selected_genotyping_protocols = selections.hasOwnProperty('genotyping_protocols') ? selections.genotyping_protocols : [];
484 if ( selected_genotyping_protocols.length <= 1 ) {
485 var selected_genotyping_protocol = selected_genotyping_protocols.length === 1 ? selected_genotyping_protocols[0].id : "";
486 if ( selected_genotyping_protocol !== SELECTED_GENOTYPING_PROTOCOL ) {
487 SELECTED_GENOTYPING_PROTOCOL = selected_genotyping_protocol;
489 url: '/ajax/breeder/search/genotyping_protocol_chromosomes',
491 data: { 'genotyping_protocol': SELECTED_GENOTYPING_PROTOCOL },
492 error: function(response) {
493 console.log("ERROR: Could not get chromosome names for genotyping protocol #" + SELECTED_GENOTYPING_PROTOCOL);
494 console.log(response);
495 updateChromosomeNames();
497 success: function(response) {
498 if (response.error) {
499 console.log("ERROR: Server returned an error trying to get the chromosome names for genotyping protocol #" + SELECTED_GENOTYPING_PROTOCOL);
500 console.log(repsonse.error);
501 updateChromosomeNames();
504 updateChromosomeNames(response.chromosome_names);
511 SELECTED_GENOTYPING_PROTOCOL = "";
512 updateChromosomeNames();
515 updateChromosomeNames();
517 // Set the chromosome names for the select dropdown menu
518 function updateChromosomeNames(names) {
521 html += "<option value=''>All</option>";
522 for ( var i = 0; i < names.length; i++ ) {
523 html += "<option value='" + names[i] + "'>" + names[i] + "</option>";
526 $(".wizard-download-genotypes-chromosome-number").html(html);