aboutsummaryrefslogtreecommitdiff
path: root/uploader/phenotypes/views.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-03-24 16:29:04 -0500
committerFrederick Muriuki Muriithi2025-03-24 16:29:04 -0500
commit0d62da83bd54af33545712c88da68c023b780752 (patch)
tree10099728ae266c3e7e5d3d9ba867e260eab9ece5 /uploader/phenotypes/views.py
parent168b179a03b011dee8af3a32116f4b0c80c491ce (diff)
downloadgn-uploader-0d62da83bd54af33545712c88da68c023b780752.tar.gz
Begin processing the uploadeded bulk-edit file.
Diffstat (limited to 'uploader/phenotypes/views.py')
-rw-r--r--uploader/phenotypes/views.py63
1 files changed, 62 insertions, 1 deletions
diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py
index a50a8e7..00da78b 100644
--- a/uploader/phenotypes/views.py
+++ b/uploader/phenotypes/views.py
@@ -958,4 +958,65 @@ def edit_upload_phenotype_data(# pylint: disable=[unused-argument]
dataset=dataset,
activelink="edit-phenotype")
- return "NOT Implemented: Would do actual edit."
+ edit_file = save_file(request.files["file-upload-bulk-edit-upload"],
+ Path(app.config["UPLOAD_FOLDER"]))
+
+ from gn_libs import jobs as gnlibs_jobs
+ from gn_libs import sqlite3
+ jobs_db = app.config["ASYNCHRONOUS_JOBS_SQLITE_DB"]
+ with sqlite3.connection(jobs_db) as conn:
+ job_id = uuid.uuid4()
+ _job = gnlibs_jobs.launch_job(
+ gnlibs_jobs.initialise_job(conn,
+ job_id,
+ [
+ sys.executable,
+ "-m",
+ "scripts.phenotypes_bulk_edit",
+ jobs_db,
+ str(job_id)
+ ],
+ "phenotype-bulk-edit",
+ extra_meta = {
+ "edit-file": str(edit_file)
+ }),
+ jobs_db,
+ f"{app.config['UPLOAD_FOLDER']}/job_errors",
+ worker_manager="gn_libs.scripts.worker")
+
+
+ return """
+ <p>The following steps need to be performed:
+ <ol>
+ <li>Check that all IDs exist</li>
+ <li>Check for mandatory values</li>
+ <li>Update descriptions in the database (where changed)</li>
+ <li>Update publications in the database (where changed):
+ <ol>
+ <li>If <strong>PubMed_ID</strong> exists in our database, simply update the
+ 'PublicationId' value in the 'PublishXRef' table.</li>
+ <li>If <strong>PubMed_ID</strong> does not exists in our database:
+ <ol>
+ <li>fetch the publication's details from PubMed using the new
+ <strong>PubMed_ID</strong> value.</li>
+ <li>create a new publication in our database using the fetched data</li>
+ <li>Update 'PublicationId' value in 'PublishXRef' with ID of newly created
+ publication</li>
+ </ol>
+ </ol>
+ </li>
+ <li>Update values in the database (where changed)</li>
+ </ol>
+ </p>
+
+ <p><strong>Note:</strong>
+ <ul>
+ <li>If a strain that did not have a value is given a value, then we need to
+ add a new cross-reference for the new DataId created.</li>
+ <li>If a strain that had a value has its value deleted and left blank, we
+ need to remove the cross-reference for the existing DataId — or, should we
+ enter the NULL value instead? Removing the cross-reference might be more
+ trouble than it is worth.</li>
+ </ul>
+ </p>
+ """