diff options
author | BonfaceKilz | 2022-03-01 15:41:56 +0300 |
---|---|---|
committer | BonfaceKilz | 2022-03-12 15:33:09 +0300 |
commit | b6ecd0888ccf51b1dd2bfcbbbc4e03b1c5a92699 (patch) | |
tree | 59801fba61b68fb9d3f21e6441d033a57ac592b0 /gn3/db | |
parent | 59d2d0a8175c4a06c5363a8a3d3addd683ef9a8d (diff) | |
download | genenetwork3-b6ecd0888ccf51b1dd2bfcbbbc4e03b1c5a92699.tar.gz |
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.
Diffstat (limited to 'gn3/db')
-rw-r--r-- | gn3/db/sample_data.py | 5 |
1 files changed, 3 insertions, 2 deletions
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, |