about summary refs log tree commit diff
path: root/uploader/phenotypes
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-07-01 13:14:36 -0500
committerFrederick Muriuki Muriithi2025-07-01 13:14:36 -0500
commitc2e33c39570191bec82076fe2394263f60add281 (patch)
tree4718599a494682d90613c9b12bcd5470e552739c /uploader/phenotypes
parent151358c5fcc8771f558f93497e6ae88bfa708294 (diff)
downloadgn-uploader-c2e33c39570191bec82076fe2394263f60add281.tar.gz
Remove unused feature
The feature is implemented elsewhere (GN2) in a better way.
Diffstat (limited to 'uploader/phenotypes')
-rw-r--r--uploader/phenotypes/views.py150
1 files changed, 0 insertions, 150 deletions
diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py
index bc15f2d..97bcafe 100644
--- a/uploader/phenotypes/views.py
+++ b/uploader/phenotypes/views.py
@@ -987,156 +987,6 @@ def edit_phenotype_data(# pylint: disable=[unused-argument]
             xref_id=xref_id))
 
 
-def process_phenotype_data_for_download(pheno: dict) -> dict:
-    """Sanitise data for download."""
-    return {
-        "UniqueIdentifier": f"phId:{pheno['Id']}::xrId:{pheno['xref_id']}",
-        **{
-            key: val for key, val in pheno.items()
-            if key not in ("Id", "xref_id", "data", "Units")
-        },
-        **{
-            data_item["StrainName"]: data_item["value"]
-            for data_item in pheno.get("data", {}).values()
-        }
-    }
-
-
-BULK_EDIT_COMMON_FIELDNAMES = [
-    "UniqueIdentifier",
-    "Post_publication_description",
-    "Pre_publication_abbreviation",
-    "Pre_publication_description",
-    "Original_description",
-    "Post_publication_abbreviation",
-    "PubMed_ID"
-]
-
-
-@phenotypesbp.route(
-    "<int:species_id>/populations/<int:population_id>/phenotypes/datasets"
-    "/<int:dataset_id>/edit-download",
-    methods=["POST"])
-@require_login
-@with_dataset(
-    species_redirect_uri="species.populations.phenotypes.index",
-    population_redirect_uri="species.populations.phenotypes.select_population",
-    redirect_uri="species.populations.phenotypes.list_datasets")
-def edit_download_phenotype_data(# pylint: disable=[unused-argument]
-        species: dict,
-        population: dict,
-        dataset: dict,
-        **kwargs
-):
-    formdata = request.json
-    with database_connection(app.config["SQL_URI"]) as conn:
-        samples_list = [
-            sample["Name"] for sample in samples_by_species_and_population(
-                conn, species["SpeciesId"], population["Id"])]
-        data = (
-            process_phenotype_data_for_download(pheno)
-            for pheno in phenotypes_data_by_ids(conn, tuple({
-                    "population_id": population["Id"],
-                    "phenoid": row["phenotype_id"],
-                    "xref_id": row["xref_id"]
-            } for row in formdata)))
-
-        with (tempfile.TemporaryDirectory(
-                prefix=app.config["TEMPORARY_DIRECTORY"]) as tmpdir):
-            filename = Path(tmpdir).joinpath("tempfile.tsv")
-            with open(filename, mode="w") as outfile:
-                outfile.write(
-                    "# **DO NOT** delete the 'UniqueIdentifier' row. It is used "
-                    "by the system to identify and edit the correct rows and "
-                    "columns in the database.\n")
-                outfile.write(
-                    "# The '…_description' fields are useful for you to figure out "
-                    "what row you are working on. Changing any of this fields will "
-                    "also update the database, so do be careful.\n")
-                outfile.write(
-                    "# Leave a field empty to delete the value in the database.\n")
-                outfile.write(
-                    "# Any line beginning with a '#' character is considered a "
-                    "comment line. This line, and all the lines above it, are "
-                    "all comment lines. Comment lines will be ignored.\n")
-                writer = csv.DictWriter(outfile,
-                                        fieldnames= (
-                                            BULK_EDIT_COMMON_FIELDNAMES +
-                                            samples_list),
-                                        dialect="excel-tab")
-                writer.writeheader()
-                writer.writerows(data)
-                outfile.flush()
-
-            return send_file(
-                filename,
-                mimetype="text/csv",
-                as_attachment=True,
-                download_name=secure_filename(f"{dataset['Name']}_data"))
-
-
-@phenotypesbp.route(
-    "<int:species_id>/populations/<int:population_id>/phenotypes/datasets"
-    "/<int:dataset_id>/edit-upload",
-    methods=["GET", "POST"])
-@require_login
-@with_dataset(
-    species_redirect_uri="species.populations.phenotypes.index",
-    population_redirect_uri="species.populations.phenotypes.select_population",
-    redirect_uri="species.populations.phenotypes.list_datasets")
-def edit_upload_phenotype_data(# pylint: disable=[unused-argument]
-        species: dict,
-        population: dict,
-        dataset: dict,
-        **kwargs
-):
-    if request.method == "GET":
-        return render_template(
-            "phenotypes/bulk-edit-upload.html",
-            species=species,
-            population=population,
-            dataset=dataset,
-            activelink="edit-phenotype")
-
-    edit_file = save_file(request.files["file-upload-bulk-edit-upload"],
-                          Path(app.config["UPLOAD_FOLDER"]))
-
-    jobs_db = app.config["ASYNCHRONOUS_JOBS_SQLITE_DB"]
-    with sqlite3.connection(jobs_db) as conn:
-        job_id = uuid.uuid4()
-        job_cmd = [
-            sys.executable, "-u",
-            "-m", "scripts.phenotypes_bulk_edit",
-            app.config["SQL_URI"],
-            jobs_db,
-            str(job_id),
-            "--log-level",
-            logging.getLevelName(
-                app.logger.getEffectiveLevel()
-            ).lower()
-        ]
-        app.logger.debug("Phenotype-edit, bulk-upload command: %s", job_cmd)
-        _job = gnlibs_jobs.launch_job(
-            gnlibs_jobs.initialise_job(conn,
-                                       job_id,
-                                       job_cmd,
-                                       "phenotype-bulk-edit",
-                                       extra_meta = {
-                                           "edit-file": str(edit_file),
-                                           "species-id": species["SpeciesId"],
-                                           "population-id": population["Id"],
-                                           "dataset-id": dataset["Id"]
-                                       }),
-            jobs_db,
-            f"{app.config['UPLOAD_FOLDER']}/job_errors",
-            worker_manager="gn_libs.jobs.launcher")
-
-
-    return redirect(url_for("background-jobs.job_status",
-                            job_id=job_id,
-                            job_type="phenotype-bulk-edit"))
-
-
 @phenotypesbp.route(
     "<int:species_id>/populations/<int:population_id>/phenotypes/datasets"
     "/<int:dataset_id>/load-data-success/<uuid:job_id>",