aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
authorBonfaceKilz2021-11-24 11:32:49 +0300
committerFrederick Muriuki Muriithi2021-11-29 12:05:16 +0300
commit8210007122c26daffcfbbb159ff846b928dfb18d (patch)
treee698ea1caffe8d194b4f41a6a042500236803838 /gn3
parentb8067b3a5e4c6891d0a0a99e23e03ac12d68d649 (diff)
downloadgenenetwork3-8210007122c26daffcfbbb159ff846b928dfb18d.tar.gz
db: traits: Remove trailing ".0" in int values
Diffstat (limited to 'gn3')
-rw-r--r--gn3/db/traits.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/gn3/db/traits.py b/gn3/db/traits.py
index 56258e2..ebb7e3c 100644
--- a/gn3/db/traits.py
+++ b/gn3/db/traits.py
@@ -79,6 +79,11 @@ def export_trait_data(
def get_trait_csv_sample_data(conn: Any,
trait_name: int, phenotype_id: int):
"""Fetch a trait and return it as a csv string"""
+
+ def __float_strip(n):
+ if str(n)[-2:] == ".0":
+ return str(int(n))
+ return str(n)
sql = ("SELECT DISTINCT Strain.Id, PublishData.Id, Strain.Name, "
"PublishData.value, "
"PublishSE.error, NStrain.count FROM "
@@ -100,7 +105,7 @@ def get_trait_csv_sample_data(conn: Any,
(strain_id, publishdata_id,
strain_name, value, error, count) = record
csv_data.append(
- ",".join([str(val) if val else "x"
+ ",".join([__float_strip(val) if val else "x"
for val in (strain_id, strain_name,
value, error, count)]))
return f"# Publish Data Id: {publishdata_id}\n" + "\n".join(csv_data)