about summary refs log tree commit diff
path: root/uploader/templates/phenotypes/add-phenotypes-raw-files.html
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/templates/phenotypes/add-phenotypes-raw-files.html')
-rw-r--r--uploader/templates/phenotypes/add-phenotypes-raw-files.html375
1 files changed, 246 insertions, 129 deletions
diff --git a/uploader/templates/phenotypes/add-phenotypes-raw-files.html b/uploader/templates/phenotypes/add-phenotypes-raw-files.html
index d9a8424..67b56e3 100644
--- a/uploader/templates/phenotypes/add-phenotypes-raw-files.html
+++ b/uploader/templates/phenotypes/add-phenotypes-raw-files.html
@@ -105,111 +105,213 @@
   </div>
 </fieldset>
 
-<fieldset id="fldset-data-files">
+<fieldset id="fldset-files">
   <legend>Data File(s)</legend>
 
-  <div class="form-group non-resumable-elements">
-    <label for="finput-phenotype-descriptions" class="form-label">
-      Phenotype Descriptions</label>
-    <input id="finput-phenotype-descriptions"
-           name="phenotype-descriptions"
-           class="form-control"
-           type="file"
-           data-preview-table="tbl-preview-pheno-desc"
-           required="required"  />
-    <span class="form-text text-muted">
-      Provide a file that contains only the phenotype descriptions,
-      <a href="#docs-file-phenotype-description"
-         title="Documentation of the phenotype data file format.">
-        the documentation for the expected format of the file</a>.</span>
-  </div>
-
-  {{display_resumable_elements(
-  "resumable-phenotype-descriptions",
-  "phenotype descriptions",
-  '<p>You can drop a CSV file that contains the phenotype descriptions here,
-    or you can click the "Browse" button (below and to the right) to select it
-    from your computer.</p>
-  <p>The CSV file must conform to some standards, as documented in the
-    <a href="#docs-file-phenotype-description"
-       title="Documentation of the phenotype data file format.">
-      "Phenotypes Descriptions" documentation</a> section below.</p>')}}
-
-
-  <div class="form-group non-resumable-elements">
-    <label for="finput-phenotype-data" class="form-label">Phenotype Data</label>
-    <input id="finput-phenotype-data"
-           name="phenotype-data"
-           class="form-control"
-           type="file"
-           data-preview-table="tbl-preview-pheno-data"
-           required="required"  />
-    <span class="form-text text-muted">
-      Provide a file that contains only the phenotype data. See
-      <a href="#docs-file-phenotype-data"
-         title="Documentation of the phenotype data file format.">
-        the documentation for the expected format of the file</a>.</span>
-  </div>
-
-  {{display_resumable_elements(
-  "resumable-phenotype-data",
-  "phenotype data",
-  '<p>You can drop a CSV file that contains the phenotype data here,
-    or you can click the "Browse" button (below and to the right) to select it
-    from your computer.</p>
-  <p>The CSV file must conform to some standards, as documented in the
-    <a href="#docs-file-phenotype-data"
-       title="Documentation of the phenotype data file format.">
-      "Phenotypes Data" documentation</a> section below.</p>')}}
-
-  {%if population.Family in families_with_se_and_n%}
-  <div class="form-group non-resumable-elements">
-    <label for="finput-phenotype-se" class="form-label">Phenotype: Standard Errors</label>
-    <input id="finput-phenotype-se"
-           name="phenotype-se"
-           class="form-control"
-           type="file"
-           data-preview-table="tbl-preview-pheno-se"
-           required="required"  />
-    <span class="form-text text-muted">
-      Provide a file that contains only the standard errors for the phenotypes,
-      computed from the data above.</span>
-  </div>
-  {{display_resumable_elements(
-  "resumable-phenotype-se",
-  "standard errors",
-  '<p>You can drop a CSV file that contains the computed standard-errors data
-    here, or you can click the "Browse" button (below and to the right) to
-    select it from your computer.</p>
-  <p>The CSV file must conform to some standards, as documented in the
-    <a href="#docs-file-phenotype-se"
-       title="Documentation of the phenotype data file format.">
-      "Phenotypes Data" documentation</a> section below.</p>')}}
+  <fieldset id="fldset-descriptions-file">
+    <div class="form-group">
+      <div class="form-check">
+        <input id="chk-phenotype-descriptions-transposed"
+               name="phenotype-descriptions-transposed"
+               type="checkbox"
+               class="form-check-input"
+               style="border: solid #8EABF0" />
+        <label for="chk-phenotype-descriptions-transposed"
+               class="form-check-label">
+          Description file transposed?</label>
+      </div>
+
+      <div class="non-resumable-elements">
+        <label for="finput-phenotype-descriptions" class="form-label">
+          Phenotype Descriptions</label>
+        <input id="finput-phenotype-descriptions"
+               name="phenotype-descriptions"
+               class="form-control"
+               type="file"
+               data-preview-table="tbl-preview-pheno-desc"
+               required="required"  />
+        <span class="form-text text-muted">
+          Provide a file that contains only the phenotype descriptions,
+          <a href="#docs-file-phenotype-description"
+             title="Documentation of the phenotype data file format.">
+            the documentation for the expected format of the file</a>.</span>
+      </div>
+      {{display_resumable_elements(
+      "resumable-phenotype-descriptions",
+      "phenotype descriptions",
+      '<p>Drag and drop the CSV file that contains the descriptions of your
+        phenotypes here.</p>
+
+      <p>The CSV file should be a matrix of
+        <strong>phenotypes × descriptions</strong> i.e. The first column
+        contains the phenotype names/identifiers whereas the first row is a list
+        of metadata fields like, "description", "units", etc.</p>
+
+      <p>If the format is transposed (i.e.
+        <strong>descriptions × phenotypes</strong>) select the checkbox above.
+      </p>
+
+      <p>Please see the
+        <a href="#docs-file-phenotype-description"
+           title="Documentation of the phenotype data file format.">
+          "Phenotypes Descriptions" documentation</a> section below for more
+        information on the expected format of the file provided here.</p>')}}
+      {{display_preview_table(
+      "tbl-preview-pheno-desc", "phenotype descriptions")}}
+    </div>
+  </fieldset>
+
+
+  <fieldset id="fldset-data-file">
+    <div class="form-group">
+      <div class="form-check">
+        <input id="chk-phenotype-data-transposed"
+               name="phenotype-data-transposed"
+               type="checkbox"
+               class="form-check-input"
+               style="border: solid #8EABF0" />
+        <label for="chk-phenotype-data-transposed" class="form-check-label">
+          Data file transposed?</label>
+      </div>
+
+      <div class="non-resumable-elements">
+        <label for="finput-phenotype-data" class="form-label">Phenotype Data</label>
+        <input id="finput-phenotype-data"
+               name="phenotype-data"
+               class="form-control"
+               type="file"
+               data-preview-table="tbl-preview-pheno-data"
+               required="required"  />
+        <span class="form-text text-muted">
+          Provide a file that contains only the phenotype data. See
+          <a href="#docs-file-phenotype-data"
+             title="Documentation of the phenotype data file format.">
+            the documentation for the expected format of the file</a>.</span>
+      </div>
+
+      {{display_resumable_elements(
+      "resumable-phenotype-data",
+      "phenotype data",
+      '<p>Drag and drop a CSV file that contains the phenotypes numerical data
+        here. You can click the "Browse" button (below and to the right) to
+        select the file from your computer.</p>
+
+      <p>The CSV should be a matrix of <strong>samples × phenotypes</strong>,
+        i.e. The first column contains the samples identifiers while the first
+        row is the list of phenotypes identifiers occurring in the phenotypes
+        descriptions file.</p>
+
+      <p>If the format is transposed (i.e <strong>phenotypes × samples</strong>)
+        select the checkbox above.</p>
+      <p>Please see the
+        <a href="#docs-file-phenotype-data"
+           title="Documentation of the phenotype data file format.">
+          "Phenotypes Data" documentation</a> section below for more information
+        on the expected format for the file provided here.</p>')}}
+      {{display_preview_table("tbl-preview-pheno-data", "phenotype data")}}
+    </div>
+  </fieldset>
 
   
-  <div class="form-group non-resumable-elements">
-    <label for="finput-phenotype-n" class="form-label">Phenotype: Number of Samples/Individuals</label>
-    <input id="finput-phenotype-n"
-           name="phenotype-n"
-           class="form-control"
-           type="file"
-           data-preview-table="tbl-preview-pheno-n"
-           required="required"  />
-    <span class="form-text text-muted">
-      Provide a file that contains only the number of samples/individuals used in
-      the computation of the standard errors above.</span>
-  </div>
-  {{display_resumable_elements(
-  "resumable-phenotype-n",
-  "number of samples/individuals",
-  '<p>You can drop a CSV file that contains the number of samples/individuals
-    used in computation of the standard-errors here, or you can click the
-    "Browse" button (below and to the right) to select it from your computer.
-  </p>
-  <p>The CSV file must conform to some standards, as documented in the
-    <a href="#docs-file-phenotype-n"
-       title="Documentation of the phenotype data file format.">
-      "Phenotypes Data" documentation</a> section below.</p>')}}
+  {%if population.Family in families_with_se_and_n%}
+  <fieldset id="fldset-se-file">
+    <div class="form-group">
+      <div class="form-check">
+        <input id="chk-phenotype-se-transposed"
+               name="phenotype-se-transposed"
+               type="checkbox"
+               class="form-check-input"
+               style="border: solid #8EABF0" />
+        <label for="chk-phenotype-se-transposed" class="form-check-label">
+          Standard-Errors file transposed?</label>
+      </div>
+      <div class="group non-resumable-elements">
+        <label for="finput-phenotype-se" class="form-label">Phenotype: Standard Errors</label>
+        <input id="finput-phenotype-se"
+               name="phenotype-se"
+               class="form-control"
+               type="file"
+               data-preview-table="tbl-preview-pheno-se"
+               required="required"  />
+        <span class="form-text text-muted">
+          Provide a file that contains only the standard errors for the phenotypes,
+          computed from the data above.</span>
+      </div>
+
+      {{display_resumable_elements(
+      "resumable-phenotype-se",
+      "standard errors",
+      '<p>Drag and drop a CSV file that contains the phenotypes standard-errors
+        data here. You can click the "Browse" button (below and to the right) to
+        select the file from your computer.</p>
+
+      <p>The CSV should be a matrix of <strong>samples × phenotypes</strong>,
+        i.e. The first column contains the samples identifiers while the first
+        row is the list of phenotypes identifiers occurring in the phenotypes
+        descriptions file.</p>
+
+      <p>If the format is transposed (i.e <strong>phenotypes × samples</strong>)
+        select the checkbox above.</p>
+
+      <p>Please see the
+        <a href="#docs-file-phenotype-se"
+           title="Documentation of the phenotype data file format.">
+          "Phenotypes Data" documentation</a> section below for more information
+        on the expected format of the file provided here.</p>')}}
+
+      {{display_preview_table("tbl-preview-pheno-se", "standard errors")}}
+    </div>
+  </fieldset>
+
+
+  <fieldset id="fldset-n-file">
+    <div class="form-group">
+      <div class="form-check">
+        <input id="chk-phenotype-n-transposed"
+               name="phenotype-n-transposed"
+               type="checkbox"
+               class="form-check-input"
+               style="border: solid #8EABF0" />
+        <label for="chk-phenotype-n-transposed" class="form-check-label">
+          Counts file transposed?</label>
+      </div>
+      <div class="non-resumable-elements">
+        <label for="finput-phenotype-n" class="form-label">Phenotype: Number of Samples/Individuals</label>
+        <input id="finput-phenotype-n"
+               name="phenotype-n"
+               class="form-control"
+               type="file"
+               data-preview-table="tbl-preview-pheno-n"
+               required="required"  />
+        <span class="form-text text-muted">
+          Provide a file that contains only the number of samples/individuals used in
+          the computation of the standard errors above.</span>
+      </div>
+
+      {{display_resumable_elements(
+      "resumable-phenotype-n",
+      "number of samples/individuals",
+      '<p>Drag and drop a CSV file that contains the samples\' phenotypes counts
+        data here. You can click the "Browse" button (below and to the right) to
+        select the file from your computer.</p>
+
+      <p>The CSV should be a matrix of <strong>samples × phenotypes</strong>,
+        i.e. The first column contains the samples identifiers while the first
+        row is the list of phenotypes identifiers occurring in the phenotypes
+        descriptions file.</p>
+
+      <p>If the format is transposed (i.e <strong>phenotypes × samples</strong>)
+        select the checkbox above.</p>
+
+      <p>Please see the
+        <a href="#docs-file-phenotype-se"
+           title="Documentation of the phenotype data file format.">
+          "Phenotypes Data" documentation</a> section below for more information
+        on the expected format of the file provided here.</p>')}}
+
+      {{display_preview_table("tbl-preview-pheno-n", "number of samples/individuals")}}
+    </div>
+  </fieldset>
 </fieldset>
 {%endif%}
 {%endblock%}
@@ -322,15 +424,15 @@
   <span id="docs-file-phenotype-data"></span>
   <span id="docs-file-phenotype-se"></span>
   <span id="docs-file-phenotype-n"></span>
-  <p>The data is a matrix of <em>phenotypes × individuals</em>, e.g.</p>
+  <p>The data is a matrix of <em>samples(or individuals) × phenotypes</em>, e.g.</p>
   <code>
     # num-cases: 2549
     # num-phenos: 13
-    id,IND001,IND002,IND003,IND004,…<br />
-    pheno10001,61.400002,54.099998,483,49.799999,…<br />
-    pheno10002,49,50.099998,403,45.5,…<br />
-    pheno10003,62.5,53.299999,501,62.900002,…<br />
-    pheno10004,53.099998,55.099998,403,NA,…<br />
+    id,pheno10001,pheno10002,pheno10003,pheno10004,53.099998,…<br />
+    IND001,61.400002,49,62.5,55.099998,…<br />
+    IND002,54.099998,50.099998,53.299999,55.099998,…<br />
+    IND003,483,403,501,403,…<br />
+    IND004,49.799999,45.5,62.900002,NA,…<br />
     ⋮<br /></code>
 
   <p>where <code>IND001,IND002,IND003,IND004,…</code> are the
@@ -346,12 +448,6 @@
 {%endblock%}
 
 {%block sidebarcontents%}
-{{display_preview_table("tbl-preview-pheno-desc", "descriptions")}}
-{{display_preview_table("tbl-preview-pheno-data", "data")}}
-{%if population.Family in families_with_se_and_n%}
-{{display_preview_table("tbl-preview-pheno-se", "standard errors")}}
-{{display_preview_table("tbl-preview-pheno-n", "number of samples")}}
-{%endif%}
 {{display_pheno_dataset_card(species, population, dataset)}}
 {%endblock%}
 
@@ -429,9 +525,9 @@
       });
 
       if(table.find("tbody tr.data-row").length > 0) {
-          add_class(table.find(".data-row-template"), "hidden");
+          add_class(table.find(".data-row-template"), "visually-hidden");
       } else {
-          remove_class(table.find(".data-row-template"), "hidden");
+          remove_class(table.find(".data-row-template"), "visually-hidden");
       }
   };
 
@@ -467,13 +563,24 @@
       Object.entries(preview_tables_to_elements_map).forEach((mapentry) => {
           var preview_table = $(mapentry[0]);
           var file_input = $(mapentry[1]);
-          if(file_input.length === 1) {
+          if(file_input[0].files.length > 0) {
               readFirstNLines(
                   file_input[0].files[0],
                   10,
                   [makePreviewUpdater(preview_table)]);
           }
       });
+
+      if(typeof(resumables) !== "undefined") {
+          resumables.forEach((resumable) => {
+              if(resumable.files.length > 0) {
+                  readFirstNLines(
+                      resumable.files[0].file,
+                      10,
+                      [makePreviewUpdater(resumable.preview_table)]);
+              }
+          });
+      }
   };
 
   [
@@ -506,7 +613,7 @@
           var display_element = display_area
               .find(".file-display-template")
               .clone();
-          remove_class(display_element, "hidden");
+          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
@@ -526,7 +633,7 @@
       return () => {/*Has no event!*/
           var progress = (resumable.progress() * 100).toFixed(2);
           var pbar = progress_bar.find(".progress-bar");
-          remove_class(progress_bar, "hidden");
+          remove_class(progress_bar, "visually-hidden");
           pbar.css("width", progress+"%");
           pbar.attr("aria-valuenow", progress);
           pbar.text("Uploading: " + progress + "%");
@@ -536,9 +643,9 @@
   var retryUpload = (retry_button, cancel_button) => {
       retry_button.on("click", (event) => {
           resumable.files.forEach((file) => {file.retry();});
-          add_class(retry_button, "hidden");
-          remove_class(cancel_button, "hidden");
-          add_class(browse_button, "hidden");
+          add_class(retry_button, "visually-hidden");
+          remove_class(cancel_button, "visually-hidden");
+          add_class(browse_button, "visually-hidden");
       });
   };
 
@@ -549,18 +656,18 @@
                   file.abort();
               }
           });
-          add_class(cancel_button, "hidden");
-          remove_class(retry_button, "hidden");
-          remove_class(browse_button, "hidden");
+          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, "hidden");
-          add_class(retry_button, "hidden");
-          add_class(browse_button, "hidden");
+          remove_class(cancel_button, "visually-hidden");
+          add_class(retry_button, "visually-hidden");
+          add_class(browse_button, "visually-hidden");
       };
   };
 
@@ -574,6 +681,7 @@
           }));
       });
       formdata.append("resumable-upload", "true");
+      formdata.append("publication-id", $("#txt-publication-id").val());
       return formdata;
   }
 
@@ -600,10 +708,12 @@
                   console.log("SUCCESS DATA: ", data);
                   console.log("SUCCESS STATUS: ", textstatus);
                   console.log("SUCCESS jqXHR: ", jqxhr);
+                  window.location.assign(window.location.origin + data["redirect-to"]);
               },
           });
           return false;
       }
+      return false;
   };
 
   var uploadSuccess = (file_input_name) => {
@@ -640,7 +750,7 @@
                               file_input.parent(),
                               $("#" + resumable_element_id),
                               submit_button,
-                              ["csv", "tsv"]),
+                              ["csv", "tsv", "txt"]),
                           file_input.parent(),
                           $("#" + resumable_element_id),
                           $("#" + resumable_element_id + "-browse-button")),
@@ -676,13 +786,20 @@
       ["frm-add-phenotypes", "finput-phenotype-se", "resumable-phenotype-se", "tbl-preview-pheno-se"],
       ["frm-add-phenotypes", "finput-phenotype-n", "resumable-phenotype-n", "tbl-preview-pheno-n"],
   ].map((row) => {
-      return makeResumableObject(row[0], row[1], row[2], row[3]);
+      r = makeResumableObject(row[0], row[1], row[2], row[3]);
+      r.preview_table = $("#" + row[3]);
+      return r;
   }).filter((val) => {
       return Boolean(val);
   });
 
   $("#frm-add-phenotypes input[type=submit]").on("click", (event) => {
       event.preventDefault();
+      console.debug();
+      if ($("#txt-publication-id").val() == "") {
+          alert("You MUST provide a publication for the phenotypes.");
+          return false;
+      }
       // TODO: Check all the relevant files exist
       // TODO: Verify that files are not duplicated
       var filenames = [];