diff --git a/uploader/genotypes/views.py b/uploader/genotypes/views.py
index e475986..454fee7 100644
--- a/uploader/genotypes/views.py
+++ b/uploader/genotypes/views.py
@@ -1,5 +1,6 @@
"""Views for the genotypes."""
import logging
+from uuid import uuid4
from MySQLdb.cursors import DictCursor
from pymonad.either import Left, Right, Either
@@ -214,6 +215,12 @@ def create_dataset(species: dict, population: dict, **kwargs):# pylint: disable=
__success__)
+def genotype_csv_to_r_qtl2(uploadsdir: Path, csvfile, csv_meta: dict) -> Path:
+ """Convert given CSV genotype file into the R/qtl2 format."""
+ bundlepath = Path(uploadsdir, f"{uuid.uuid4()}.zip".replace("-", ""))
+ raise NotImplementedError("This is not implemented yet.")
+
+
@genotypesbp.route(
"/<int:species_id>/populations/<int:population_id>/genotypes/datasets/"
"<int:dataset_id>/add-records",
@@ -234,6 +241,22 @@ def add_genotype_records(species: dict, population: dict, dataset: dict, **kwarg
dataset=dataset,
activelink="add-genotypes-records")
+ # request.method is POST from here
+ # T0D0: Handle direct uploads (i.e. Not via javascript)
+ form = dict(request.form) # Request comes in as multipart/formdata
+
+ bundlepath = genotype_csv_to_r_qtl2(
+ # T0D0: Actually, rather than generating the R/qtl2 bundle here, first
+ # off, do basic check through the data to collect the alleles and other
+ # necessary information. Also do basic QC.
+ Path(uploads_dir(app)),
+ form["uploaded-file"],
+ csv_meta: {
+ "sep": form.get("file-separator", ","),
+ "comment.char": form.get("file-comment-char", "#"),
+ "na.strings": form.get("file-na", "- NA N/A").split(" ")
+ })
+
if "application/json" in request.headers.get("Accept"):
return make_response(
jsonify({
|