diff options
author | zsloan | 2022-03-09 19:13:59 +0000 |
---|---|---|
committer | zsloan | 2022-03-16 14:41:09 -0500 |
commit | 743a4623c53d30779cb884a69d0cf2c7ff411f0a (patch) | |
tree | 671274c44dc5117ffd7b9adb8f2987aba3b440cc | |
parent | 45694eb46fa0c337d8b2f1be945bdb96c4a2af44 (diff) | |
download | genenetwork2-743a4623c53d30779cb884a69d0cf2c7ff411f0a.tar.gz |
Add function for getting strain name from sample name
-rw-r--r-- | wqflask/maintenance/gen_ind_genofiles.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/wqflask/maintenance/gen_ind_genofiles.py b/wqflask/maintenance/gen_ind_genofiles.py index abca4a4a..6e818945 100644 --- a/wqflask/maintenance/gen_ind_genofiles.py +++ b/wqflask/maintenance/gen_ind_genofiles.py @@ -7,9 +7,7 @@ import MySQLdb from wqflask import app -from gn3.db.datasets import retrieve_group_samples - -def db_conn(): +def conn(): return MySQLdb.Connect(db=app.config.get("DB_NAME"), user=app.config.get("DB_USER"), passwd=app.config.get("DB_PASS"), @@ -32,6 +30,17 @@ def main(args): # Generate the output .geno files generate_new_genofiles(strain_genotypes(source_genofile), target_groups) +def get_strain_for_sample(sample): + query = ( + "SELECT CaseAttributeXRefNew.Value " + "FROM CaseAttributeXRefNew, Strain " + "WHERE CaseAttributeXRefNew.CaseAttributeId=11 " + "AND CaseAttributeXRef.New.StrainId = Strain.Id " + "AND Strain.Name = %(name)s" ) + + with conn.cursor() as cursor: + return cursor.execute(query, {"name": name}).fetchone()[0] + def group_samples(target_group: str) -> List: """ Get the group samples from its "dummy" .geno file (which still contains the sample list) @@ -115,3 +124,4 @@ def strain_genotypes(strain_genofile: str) -> List: if __name__ == "__main__": print("command line arguments:\n\t%s" % sys.argv) main(sys.argv) + |