From 6aaefdaae3a9fb068278d9b94d8cdf25d4f8d852 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Fri, 19 Jul 2013 16:13:47 -0500 Subject: Created file gen_group_samplelists that iterates through all genofiles and builds each groups' samplelist --- wqflask/maintenance/gen_select_dataset.py | 4 ++- wqflask/maintenance/get_group_samplelists.py | 43 ++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 wqflask/maintenance/get_group_samplelists.py (limited to 'wqflask/maintenance') diff --git a/wqflask/maintenance/gen_select_dataset.py b/wqflask/maintenance/gen_select_dataset.py index 8cb94f20..d4e47327 100644 --- a/wqflask/maintenance/gen_select_dataset.py +++ b/wqflask/maintenance/gen_select_dataset.py @@ -115,7 +115,7 @@ def build_types(species, group): (all types except phenotype/genotype are tissues) """ - Cursor.execute("""select distinct Tissue.Name, Tissue.Name + Cursor.execute("""select distinct Tissue.Name, concat(Tissue.Name, ' mRNA') from ProbeFreeze, ProbeSetFreeze, InbredSet, Tissue, Species where Species.Name = %s and Species.Id = InbredSet.SpeciesId and InbredSet.Name = %s and @@ -192,6 +192,8 @@ def main(): datasets=datasets, ) + print("data:", data) + output_file = """../wqflask/static/new/javascript/dataset_menu_structure.json""" with open(output_file, 'w') as fh: diff --git a/wqflask/maintenance/get_group_samplelists.py b/wqflask/maintenance/get_group_samplelists.py new file mode 100644 index 00000000..2434038e --- /dev/null +++ b/wqflask/maintenance/get_group_samplelists.py @@ -0,0 +1,43 @@ +from __future__ import absolute_import, print_function, division + +import os +import glob +import gzip + +from base import webqtlConfig + + +def get_sample_list_dir(geno_dir="/home/zas1024/gene/web/genotypes/"): + os.chdir(geno_dir) + + for group_file in glob.glob("*"): + if group_file.lower().endswith(('.geno', '.geno.gz')): + #group_name = genofilename.split('.')[0] + sample_list = get_sample_list(group_file) + print("\n\n{}\n\n".format(sample_list)) + + +def get_sample_list(group_file): + print(group_file) + genofilename = str(os.path.join(webqtlConfig.GENODIR, group_file)) + if genofilename.lower().endswith('.geno.gz'): + genofile = gzip.open(genofilename) + else: + genofile = open(genofilename) + for line in genofile: + line = line.strip() + if not line: + continue + if line.startswith(("#", "@")): + continue + headline = line + break + headers = headline.split("\t") + if headers[3] == "Mb": + samplelist = headers[4:] + else: + samplelist = headers[3:] + return samplelist + +if __name__ == '__main__': + get_sample_list_dir() -- cgit v1.2.3