From b6ecd0888ccf51b1dd2bfcbbbc4e03b1c5a92699 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 1 Mar 2022 15:41:56 +0300 Subject: Extract a strain name given a csv string and it's header * gn3/csvcmp.py (extract_strain_name): New function. * gn3/db/sample_data (delete_sample_data): Use the aforementioned function. (insert_sample_data): Ditto. * tests/unit/test_csvcmp: Test cases for above. --- gn3/db/sample_data.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gn3/db') diff --git a/gn3/db/sample_data.py b/gn3/db/sample_data.py index 06b5767..a410978 100644 --- a/gn3/db/sample_data.py +++ b/gn3/db/sample_data.py @@ -1,3 +1,4 @@ +from gn3.csvcmp import extract_strain_name from typing import Any, Tuple, Union import MySQLdb @@ -200,7 +201,7 @@ def delete_sample_data(conn: Any, strain_id, data_id, inbredset_id = get_sample_data_ids( conn=conn, publishxref_id=trait_name, phenotype_id=phenotype_id, - strain_name=strain_name) + strain_name=extract_strain_name(csv_header, data)) none_case_attrs = { "Strain Name": lambda: 0, @@ -273,7 +274,7 @@ def insert_sample_data(conn: Any, # pylint: disable=[R0913] strain_id, data_id, inbredset_id = get_sample_data_ids( conn=conn, publishxref_id=trait_name, phenotype_id=phenotype_id, - strain_name=strain_name) + strain_name=extract_strain_name(csv_header, data)) none_case_attrs = { "Strain Name": lambda _: 0, -- cgit v1.2.3