aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2023-05-22 17:30:27 +0000
committerzsloan2023-05-22 17:30:27 +0000
commit68dd9d55cf41e057658b7e2ed3bdd7c5dfadf354 (patch)
tree638485828a524db5dbcd50e0172c8665073c580d
parent92d159423f7a64de3bb3140626322a51a64b4f48 (diff)
downloadgenenetwork3-68dd9d55cf41e057658b7e2ed3bdd7c5dfadf354.tar.gz
Use 'with open()' syntax
Initialize samplelist variable
-rw-r--r--gn3/db/datasets.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/gn3/db/datasets.py b/gn3/db/datasets.py
index 48cd195..470e430 100644
--- a/gn3/db/datasets.py
+++ b/gn3/db/datasets.py
@@ -12,25 +12,25 @@ def retrieve_sample_list(group: str):
the "official" sample list is stored
"""
+ samplelist = []
genofile_path = os.environ.get("GENENETWORK_FILES") + "/genotype/" + group + ".geno"
if os.path.isfile(genofile_path):
- genofile = open(genofile_path)
+ with open(genofile_path, "r") as genofile:
+ for line in genofile:
+ line = line.strip()
+ if not line:
+ continue
+ if line.startswith(("#", "@")):
+ continue
+ break
- for line in genofile:
- line = line.strip()
- if not line:
- continue
- if line.startswith(("#", "@")):
- continue
- break
+ headers = line.split("\t")
- headers = line.split("\t")
-
- if headers[3] == "Mb":
- samplelist = headers[4:]
- else:
- samplelist = headers[3:]
- return samplelist
+ if headers[3] == "Mb":
+ samplelist = headers[4:]
+ else:
+ samplelist = headers[3:]
+ return samplelist
def retrieve_group_name(
group_id: int, connection: any):