diff options
author | Zachary Sloan | 2013-08-14 17:25:52 -0500 |
---|---|---|
committer | Zachary Sloan | 2013-08-14 17:25:52 -0500 |
commit | 26b1883a8fe4053b59833178f44e047157f2fc9c (patch) | |
tree | d2359e5952f6062d75ba1f43f1804a7b6df284c9 /wqflask/maintenance/get_group_samplelists.py | |
parent | eea1c38a9851f31011787b27c14365211a06ea51 (diff) | |
parent | 6379959af53b2ec595b85ccdc099c6f14adf0381 (diff) | |
download | genenetwork2-26b1883a8fe4053b59833178f44e047157f2fc9c.tar.gz |
Merge branch 'master' of https://github.com/zsloan/genenetwork
Diffstat (limited to 'wqflask/maintenance/get_group_samplelists.py')
-rw-r--r-- | wqflask/maintenance/get_group_samplelists.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/wqflask/maintenance/get_group_samplelists.py b/wqflask/maintenance/get_group_samplelists.py new file mode 100644 index 00000000..c9ec3872 --- /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 process_genofiles(geno_dir=webqtlConfig.GENODIR): + print("Yabba") + #sys.exit("Dabba") + os.chdir(geno_dir) + for geno_file in glob.glob("*"): + if geno_file.lower().endswith(('.geno', '.geno.gz')): + #group_name = genofilename.split('.')[0] + sample_list = get_samplelist(geno_file) + + +def get_samplelist(geno_file): + genofilename = os.path.join(webqtlConfig.GENODIR, geno_file) + if os.path.isfile(genofilename + '.gz'): + genofilename += '.gz' + genofile = gzip.open(genofilename) + else: + genofile = open(genofilename) + + for line in genofile: + line = line.strip() + if not line: + continue + if line.startswith(("#", "@")): + continue + break + + headers = line.split() + + if headers[3] == "Mb": + samplelist = headers[4:] + else: + samplelist = headers[3:] + return samplelist + |