From 6fbbfe5e8bcc3b57c4177687bbf67bf041da3cba Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Wed, 26 Jun 2013 21:35:07 +0000 Subject: Got code that creates DataSets object running Fixed one genofile that had extra quotation marks in the comments that caused an error Defaults mb_graph_interval to 1 for species without chromosome lengths in megabases --- web/genotypes/B6D2F2-PSU.geno | 8 +++--- wqflask/base/data_set.py | 55 +++++++++++++++++++++------------------ wqflask/base/species.py | 10 +++++-- wqflask/wqflask/search_results.py | 2 -- wqflask/wqflask/views.py | 3 ++- 5 files changed, 43 insertions(+), 35 deletions(-) diff --git a/web/genotypes/B6D2F2-PSU.geno b/web/genotypes/B6D2F2-PSU.geno index 2c8876a0..a0c1728f 100755 --- a/web/genotypes/B6D2F2-PSU.geno +++ b/web/genotypes/B6D2F2-PSU.geno @@ -1,5 +1,5 @@ -"#This is B6D2F2-PSU genotype file, it should be tab-delimited" -"#the first three/four columns should be ""Chr, Locus, cM, [Mb]"" (case sensitive)" +#This is B6D2F2-PSU genotype file, it should be tab-delimited +#the first three/four columns should be ""Chr, Locus, cM, [Mb]"" (case sensitive) #please save as Unix format text file. #comment line always start with a '#' #type riset or intercross @@ -8,9 +8,9 @@ #abbreviation of maternal or paternal parents @mat:B @pat:D -"#heterozygous , optional, default is ""H""" +#heterozygous , optional, default is ""H"" @het:H -"#Unknown , optional, default is ""U""" +#Unknown , optional, default is ""U"" @unk:U Chr Locus cM Mb PSU0001 PSU0004 PSU0007 PSU0022 PSU0024 PSU0042 PSU0044 PSU0045 PSU0046 PSU0048 PSU0049 PSU0050 PSU0052 PSU0053 PSU0054 PSU0055 PSU0056 PSU0057 PSU0058 PSU0059 PSU0060 PSU0061 PSU0062 PSU0063 PSU0066 PSU0067 PSU0068 PSU0069 PSU0070 PSU0071 PSU0072 PSU0074 PSU0077 PSU0079 PSU0080 PSU0082 PSU0083 PSU0084 PSU0085 PSU0086 PSU0087 PSU0089 PSU0090 PSU0091 PSU0092 PSU0093 PSU0094 PSU0095 PSU0096 PSU0097 PSU0098 PSU0099 PSU0100 PSU0102 PSU0103 PSU0104 PSU0107 PSU0108 PSU0109 PSU0110 PSU0112 PSU0113 PSU0114 PSU0116 PSU0117 PSU0118 PSU0119 PSU0122 PSU0124 PSU0126 PSU0128 PSU0130 PSU0131 PSU0132 PSU0133 PSU0134 PSU0135 PSU0136 PSU0137 PSU0138 PSU0139 PSU0140 PSU0141 PSU0142 PSU0143 PSU0146 PSU0147 PSU0148 PSU0152 PSU0153 PSU0155 PSU0158 PSU0159 PSU0163 PSU0164 PSU0165 PSU0166 PSU0167 PSU0168 PSU0169 PSU0170 PSU0172 PSU0173 PSU0174 PSU0175 PSU0177 PSU0178 PSU0179 PSU0180 PSU0182 PSU0183 PSU0187 PSU0188 PSU0190 PSU0191 PSU0193 PSU0194 PSU0196 PSU0197 PSU0198 PSU0199 PSU0205 PSU0206 PSU0207 PSU0208 PSU0209 PSU0210 PSU0211 PSU0212 PSU0213 PSU0214 PSU0216 PSU0218 PSU0219 PSU0220 PSU0222 PSU0223 PSU0225 PSU0226 PSU0227 PSU0229 PSU0230 PSU0231 PSU0234 PSU0235 PSU0236 PSU0238 PSU0239 PSU0241 PSU0242 PSU0243 PSU0244 PSU0246 PSU0247 PSU0248 PSU0250 PSU0251 PSU0255 PSU0257 PSU0258 PSU0260 PSU0261 PSU0262 PSU0263 PSU0264 PSU0271 PSU0272 PSU0273 PSU0274 PSU0275 PSU0276 PSU0278 PSU0280 PSU0282 PSU0283 PSU0285 PSU0286 PSU0287 PSU0288 PSU0289 PSU0291 PSU0292 PSU0293 PSU0295 PSU0296 PSU0299 PSU0300 PSU0301 PSU0302 PSU0304 PSU0305 PSU0306 PSU0308 PSU0309 PSU0310 PSU0311 PSU0312 PSU0313 PSU0314 PSU0315 PSU0316 PSU0317 PSU0318 PSU0319 PSU0320 PSU0321 PSU0323 PSU0325 PSU0326 PSU0327 PSU0328 PSU0329 PSU0330 PSU0331 PSU0334 PSU0336 PSU0337 PSU0338 PSU0339 PSU0340 PSU0341 PSU0342 PSU0343 PSU0344 PSU0346 PSU0349 PSU0351 PSU0352 PSU0353 PSU0355 PSU0356 PSU0357 PSU0358 PSU0359 PSU0360 PSU0361 PSU0362 PSU0363 PSU0366 PSU0367 PSU0369 PSU0370 PSU0371 PSU0372 PSU0373 PSU0374 PSU0375 PSU0376 PSU0378 PSU0379 PSU0381 PSU0382 PSU0383 PSU0384 PSU0385 PSU0388 PSU0390 PSU0391 PSU0392 PSU0393 PSU0395 PSU0397 PSU0399 PSU0400 PSU0401 PSU0403 PSU0405 PSU0406 PSU0408 PSU0410 PSU0412 PSU0413 PSU0414 PSU0416 PSU0417 PSU0418 PSU0420 PSU0421 PSU0423 PSU0425 PSU0426 PSU0430 PSU0431 PSU0434 PSU0435 PSU0437 PSU0438 PSU0441 PSU0445 PSU0449 PSU0450 PSU0451 PSU0452 PSU0454 PSU0455 PSU0458 PSU0461 PSU0462 PSU0464 PSU0466 PSU0468 PSU0470 PSU0472 PSU0478 PSU0479 PSU0480 PSU0482 PSU0483 PSU0487 PSU0488 PSU0490 PSU0492 PSU0493 PSU0494 PSU0495 PSU0499 PSU0501 PSU0502 PSU0503 PSU0504 PSU0505 PSU0506 PSU0508 PSU0511 PSU0513 PSU0514 PSU0517 PSU0519 PSU0521 PSU0522 PSU0523 PSU0524 PSU0527 PSU0529 PSU0531 PSU0533 PSU0535 PSU0536 PSU0537 PSU0540 PSU0542 PSU0543 PSU0545 PSU0546 PSU0549 PSU0551 PSU0553 PSU0554 PSU0557 PSU0561 PSU0562 PSU0565 PSU0566 PSU0568 PSU0569 PSU0570 PSU0571 PSU0575 PSU0576 PSU0586 PSU0593 PSU0597 PSU0598 PSU0603 PSU0604 PSU0606 PSU0609 PSU0610 PSU0612 PSU0616 PSU0617 PSU0620 PSU0621 PSU0623 PSU0624 PSU0626 PSU0629 PSU0630 PSU0631 PSU0632 PSU0634 PSU0637 PSU0639 PSU0641 PSU0642 PSU0643 PSU0645 PSU0646 PSU0647 PSU0648 PSU0649 PSU0650 PSU0651 PSU0652 PSU0654 PSU0655 PSU0659 PSU0661 PSU0662 PSU0663 PSU0665 PSU0667 PSU0668 PSU0669 PSU0671 PSU0672 PSU0673 PSU0674 PSU0675 PSU0677 PSU0680 PSU0682 PSU0683 PSU0684 PSU0686 PSU0687 PSU0689 PSU0690 PSU0691 PSU0696 PSU0697 PSU0699 PSU0701 PSU0702 PSU0704 PSU0705 PSU0706 PSU0709 PSU0710 PSU0712 PSU0714 PSU0716 PSU0717 PSU0718 PSU0719 PSU0720 PSU0721 PSU0724 PSU0725 PSU0727 PSU0728 PSU0729 PSU0730 PSU0731 PSU0733 PSU0734 PSU0736 PSU0737 PSU0738 PSU0741 PSU0742 PSU0743 PSU0744 PSU0745 PSU0749 PSU0750 PSU0751 PSU0753 PSU0756 PSU0757 PSU0758 PSU0759 PSU0760 PSU0763 PSU0764 PSU0765 PSU0766 PSU0767 PSU0769 PSU0770 PSU0771 PSU0772 PSU0773 PSU0776 PSU0780 PSU0781 PSU0782 PSU0783 PSU0784 PSU0787 PSU0788 PSU0789 PSU0790 PSU0791 PSU0792 PSU0794 PSU0798 PSU0799 PSU0804 PSU0806 PSU0807 PSU0808 PSU0810 PSU0811 PSU0813 PSU0814 PSU0815 PSU0816 PSU0818 PSU0821 PSU0822 PSU0824 PSU0825 PSU0828 PSU0830 PSU0831 PSU0833 PSU0834 PSU0837 PSU0840 PSU0843 PSU0844 PSU0847 PSU0849 PSU0851 PSU0853 PSU0855 PSU0856 PSU0858 PSU0860 PSU0862 PSU0863 PSU0864 PSU1060 PSU1095 PSU1372 PSU1373 PSU1374 PSU1381 PSU1392 PSU1399 PSU1414 PSU1421 PSU1422 PSU1430 PSU1432 PSU1470 PSU1473 PSU1490 PSU1526 PSU1540 PSU1549 PSU1553 PSU1556 PSU1561 PSU1564 PSU1576 PSU1591 PSU1609 PSU1613 PSU1625 PSU1626 PSU1630 PSU1638 PSU1639 1 rs13475697 0.01 3.385827 U H H H H B D B H B H H D H H H H H H H H B H H H H D H D B B D H H B H D H B H H H B B B D B H H D H D B H H H B H B B B B B B H H B D D H H D D H D D H H B D D B B D B B D B B H B B H D B H H H D H D B D B D H H D B D D H H H D B H B H D H D H D B D D D H H D H B B H H B H B H B D H D D D D H D H H H D B D H D H H D B D B B B D H H B D H H H H D H D H D H D H D D B H D B H D H D D H H H H H D D B H H D B H H H H D H H H D H B D D D H H H H B D H H H D H B B B D B H H H H B H H B H B D D D D H D H D H D B H H H B B B B B H U B H H B D H D H D H H B B B H H H H H D B H H H B H D H D B B D B H H B D H H H B B H H H D H B H B D H B H D B H B H H H B H B H D D B H D B H H D H H D D H H H H B B H D H D H H D D B D D H H D D H H B H H H H B H H D H D H B H D D H H D D B H H H H H H D B D H H B H B H H H H H D H B B D H H D D D B B H H B H H B H B B H B D H H H B B H D B B B D D B D H H B H D D H H H B H H D B D H B H D D B H H D H D H B H H H H H D H B D B H H H D H H B H H B D H D D B H D H D B H H H D H D H D D H B B D B H D B H D H H B B H H H H B H D H H B D B D H D D H B D H B H H H D D H D H diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index f301cc05..e4bdb5c3 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -46,17 +46,18 @@ from pprint import pformat as pf # Used by create_database to instantiate objects DS_NAME_MAP = {} -def create_dataset(dataset_name): +def create_dataset(dataset_name, dataset_type = None): #print("dataset_name:", dataset_name) - query = """ - SELECT DBType.Name - FROM DBList, DBType - WHERE DBList.Name = '{}' and - DBType.Id = DBList.DBTypeId - """.format(escape(dataset_name)) - #print("query is: ", pf(query)) - dataset_type = g.db.execute(query).fetchone().Name + if not dataset_type: + query = """ + SELECT DBType.Name + FROM DBList, DBType + WHERE DBList.Name = '{}' and + DBType.Id = DBList.DBTypeId + """.format(escape(dataset_name)) + #print("query is: ", pf(query)) + dataset_type = g.db.execute(query).fetchone().Name #dataset_type = cursor.fetchone()[0] #print("[blubber] dataset_type:", pf(dataset_type)) @@ -228,16 +229,17 @@ class DataSets(object): def __init__(self): self.datasets = list() - type_dict = {'phenotype': 'PublishFreeze', - 'mrna_assay': 'ProbeSetFreeze', - 'genotype': 'GenoFreeze'} + type_dict = {'Publish': 'PublishFreeze', + 'ProbeSet': 'ProbeSetFreeze', + 'Geno': 'GenoFreeze'} for dataset_type in type_dict: query = "SELECT Name FROM {}".format(type_dict[dataset_type]) for result in g.db.execute(query).fetchall(): #The query at the beginning of this function isn't necessary here, but still would #rather just reuse it - create_dataset(result.Name) + print("type: {}\tname: {}".format(dataset_type, result.Name)) + create_dataset(result.Name, dataset_type) #query = """SELECT Name FROM ProbeSetFreeze @@ -265,6 +267,8 @@ class DataSet(object): assert name, "Need a name" self.name = name self.id = None + self.shortname = None + self.fullname = None self.type = None self.setup() @@ -324,7 +328,7 @@ class DataSet(object): self.name, self.name, self.name)) - #print("query_args are:", query_args) + print("query_args are:", query_args) #print(""" # SELECT Id, Name, FullName, ShortName @@ -332,17 +336,17 @@ class DataSet(object): # WHERE public > %s AND # (Name = '%s' OR FullName = '%s' OR ShortName = '%s') # """ % (query_args)) - - self.id, self.name, self.fullname, self.shortname = g.db.execute(""" - SELECT Id, Name, FullName, ShortName - FROM %s - WHERE public > %s AND - (Name = '%s' OR FullName = '%s' OR ShortName = '%s') - """ % (query_args)).fetchone() - - #self.cursor.execute(query) - #self.id, self.name, self.fullname, self.shortname = self.cursor.fetchone() + try: + self.id, self.name, self.fullname, self.shortname = g.db.execute(""" + SELECT Id, Name, FullName, ShortName + FROM %s + WHERE public > %s AND + (Name = '%s' OR FullName = '%s' OR ShortName = '%s') + """ % (query_args)).fetchone() + except TypeError: + print("Dataset {} is not yet available in GeneNetwork.".format(self.name)) + pass class PhenotypeDataSet(DataSet): DS_NAME_MAP['Publish'] = 'PhenotypeDataSet' @@ -971,6 +975,5 @@ def geno_mrna_confidentiality(ob): authorized_users) = result.fetchall()[0] if confidential: - # Allow confidential data later - NoConfindetialDataForYouTodaySorry + return True diff --git a/wqflask/base/species.py b/wqflask/base/species.py index 191f4535..ebc2bfed 100644 --- a/wqflask/base/species.py +++ b/wqflask/base/species.py @@ -56,6 +56,7 @@ class Chromosomes(object): InbredSet.Name = %s Order by OrderId """, self.dataset.group.name).fetchall() + print("group: ", self.dataset.group.name) print("bike:", results) for item in results: @@ -68,9 +69,14 @@ class Chromosomes(object): def set_mb_graph_interval(self): """Empirical megabase interval""" + if self.chromosomes: + self.mb_graph_interval = self.get_genome_mb_length()/(len(self.chromosomes)*12) + else: + self.mb_graph_interval = 1 + #if self.chromosomes: - assert self.chromosomes, "Have to add some code back in apparently to set it to 1" - self.mb_graph_interval = self.get_genome_mb_length()/(len(self.chromosomes)*12) + #assert self.chromosomes, "Have to add some code back in apparently to set it to 1" + #self.mb_graph_interval = self.get_genome_mb_length()/(len(self.chromosomes)*12) #else: #self.mb_graph_interval = 1 diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index f76af374..504a67ce 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -162,8 +162,6 @@ class SearchResultPage(object): import redis Redis = redis.Redis() - - #def get_group_species_tree(self): # self.species_groups = collections.default_dict(list) # for key in self.results: diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index fcb34d31..e48506ab 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -54,7 +54,8 @@ def connect_db(): @app.route("/") def index_page(): print("Sending index_page") - ds = DataSets() + with Bench("Creating DataSets object"): + ds = DataSets() print("[orange] ds:", ds.datasets) return render_template("index_page.html") -- cgit v1.2.3