aboutsummaryrefslogtreecommitdiff
path: root/gn3/db/traits.py
diff options
context:
space:
mode:
authorBonfaceKilz2021-11-24 11:32:49 +0300
committerBonfaceKilz2021-11-24 11:36:04 +0300
commit6675388cfee2fb85b78f9310dd72f2c95c8ea41b (patch)
tree8291f1067027e246db8669de2db3881fe8864998 /gn3/db/traits.py
parenta6d61f58dc07ba307698c90befab28bcaf691966 (diff)
downloadgenenetwork3-6675388cfee2fb85b78f9310dd72f2c95c8ea41b.tar.gz
db: traits: Remove trailing ".0" in int values
Diffstat (limited to 'gn3/db/traits.py')
-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)