aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/base')
-rw-r--r--wqflask/base/data_set.py56
-rw-r--r--wqflask/base/trait.py34
-rw-r--r--wqflask/base/webqtlConfig.py6
3 files changed, 70 insertions, 26 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index b324ac74..41de8492 100644
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -46,6 +46,8 @@ from utility import chunks
from utility import gen_geno_ob
from utility.tools import locate, locate_ignore_error, flat_files
+from wqflask.api import gen_menu
+
from maintenance import get_group_samplelists
from MySQLdb import escape_string as escape
@@ -92,7 +94,7 @@ Publish or ProbeSet. E.g.
"""
self.datasets = {}
if USE_GN_SERVER:
- data = menu_main()
+ data = gen_menu.gen_dropdown_json()
else:
file_name = "wqflask/static/new/javascript/dataset_menu_structure.json"
with open(file_name, 'r') as fh:
@@ -289,7 +291,6 @@ class DatasetGroup(object):
self.parlist = None
self.get_f1_parent_strains()
- self.accession_id = self.get_accession_id()
self.mapping_id, self.mapping_names = self.get_mapping_methods()
self.species = webqtlDatabaseFunction.retrieve_species(self.name)
@@ -299,20 +300,6 @@ class DatasetGroup(object):
self._datasets = None
self.genofile = None
- def get_accession_id(self):
- results = g.db.execute("""select InfoFiles.GN_AccesionId from InfoFiles, PublishFreeze, InbredSet where
- InbredSet.Name = %s and
- PublishFreeze.InbredSetId = InbredSet.Id and
- InfoFiles.InfoPageName = PublishFreeze.Name and
- PublishFreeze.public > 0 and
- PublishFreeze.confidentiality < 1 order by
- PublishFreeze.CreateTime desc""", (self.name)).fetchone()
-
- if results != None:
- return str(results[0])
- else:
- return "None"
-
def get_mapping_methods(self):
mapping_id = g.db.execute("select MappingMethodId from InbredSet where Name= '%s'" % self.name).fetchone()[0]
@@ -384,7 +371,7 @@ class DatasetGroup(object):
[result.extend(l) for l in lists if l]
return result
- def read_genotype_file(self):
+ def read_genotype_file(self, use_reaper=False):
'''Read genotype from .geno file instead of database'''
#genotype_1 is Dataset Object without parents and f1
#genotype_2 is Dataset Object with parents and f1 (not for intercross)
@@ -396,9 +383,12 @@ class DatasetGroup(object):
full_filename = str(locate(self.genofile, 'genotype'))
else:
full_filename = str(locate(self.name + '.geno', 'genotype'))
- #genotype_1.read(full_filename)
- genotype_1 = gen_geno_ob.genotype(full_filename)
+ if use_reaper:
+ genotype_1 = reaper.Dataset()
+ genotype_1.read(full_filename)
+ else:
+ genotype_1 = gen_geno_ob.genotype(full_filename)
if genotype_1.type == "group" and self.parlist:
genotype_2 = genotype_1.add(Mat=self.parlist[0], Pat=self.parlist[1]) #, F1=_f1)
@@ -445,7 +435,7 @@ def datasets(group_name, this_group = None):
and InbredSet.Name like %s
and ProbeSetFreeze.public > %s
and ProbeSetFreeze.confidentiality < 1
- ORDER BY Tissue.Name)
+ ORDER BY Tissue.Name, ProbeSetFreeze.OrderList DESC)
''' % (group_name, webqtlConfig.PUBLICTHRESH,
group_name, webqtlConfig.PUBLICTHRESH,
"'" + group_name + "'", webqtlConfig.PUBLICTHRESH))
@@ -507,6 +497,7 @@ class DataSet(object):
self.check_confidentiality()
self.retrieve_other_names()
self.group = DatasetGroup(self) # sets self.group and self.group_id and gets genotype
+ self.accession_id = self.get_accession_id()
if get_samplelist == True:
self.group.get_samplelist()
self.species = species.TheSpecies(self)
@@ -521,6 +512,31 @@ class DataSet(object):
def riset():
Weve_Renamed_This_As_Group
+ def get_accession_id(self):
+ if self.type == "Publish":
+ results = g.db.execute("""select InfoFiles.GN_AccesionId from InfoFiles, PublishFreeze, InbredSet where
+ InbredSet.Name = %s and
+ PublishFreeze.InbredSetId = InbredSet.Id and
+ InfoFiles.InfoPageName = PublishFreeze.Name and
+ PublishFreeze.public > 0 and
+ PublishFreeze.confidentiality < 1 order by
+ PublishFreeze.CreateTime desc""", (self.group.name)).fetchone()
+ elif self.type == "Geno":
+ results = g.db.execute("""select InfoFiles.GN_AccesionId from InfoFiles, GenoFreeze, InbredSet where
+ InbredSet.Name = %s and
+ GenoFreeze.InbredSetId = InbredSet.Id and
+ InfoFiles.InfoPageName = GenoFreeze.ShortName and
+ GenoFreeze.public > 0 and
+ GenoFreeze.confidentiality < 1 order by
+ GenoFreeze.CreateTime desc""", (self.group.name)).fetchone()
+ else:
+ results = None
+
+ if results != None:
+ return str(results[0])
+ else:
+ return "None"
+
def retrieve_other_names(self):
"""This method fetches the the dataset names in search_result.
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 6fecf725..58169b5c 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -3,6 +3,7 @@ from __future__ import absolute_import, division, print_function
import string
import resource
import codecs
+import requests
import redis
Redis = redis.StrictRedis()
@@ -120,11 +121,34 @@ class GeneralTrait(object):
@property
def alias_fmt(self):
'''Return a text formatted alias'''
+
+ alias = 'Not available'
if self.alias:
alias = string.replace(self.alias, ";", " ")
alias = string.join(string.split(alias), ", ")
- else:
- alias = 'Not available'
+
+ return alias
+
+ @property
+ def wikidata_alias_fmt(self):
+ '''Return a text formatted alias'''
+
+ alias = 'Not available'
+ if self.symbol:
+ human_response = requests.get("http://gn2.genenetwork.org/gn3/gene/aliases/" + self.symbol.upper())
+ mouse_response = requests.get("http://gn2.genenetwork.org/gn3/gene/aliases/" + self.symbol.capitalize())
+ other_response = requests.get("http://gn2.genenetwork.org/gn3/gene/aliases/" + self.symbol.lower())
+ alias_list = json.loads(human_response.content) + json.loads(mouse_response.content) + json.loads(other_response.content)
+
+ filtered_aliases = []
+ seen = set()
+ for item in alias_list:
+ if item in seen:
+ continue
+ else:
+ filtered_aliases.append(item)
+ seen.add(item)
+ alias = "; ".join(filtered_aliases)
return alias
@@ -396,8 +420,10 @@ def retrieve_trait_info(trait, dataset, get_qtl_info=False):
#XZ: assign SQL query result to trait attributes.
for i, field in enumerate(dataset.display_fields):
holder = trait_info[i]
- if isinstance(trait_info[i], basestring):
- holder = unicode(trait_info[i], "utf-8", "ignore")
+ # if isinstance(trait_info[i], basestring):
+ # logger.debug("HOLDER:", holder)
+ # logger.debug("HOLDER2:", holder.decode(encoding='latin1'))
+ # holder = unicode(trait_info[i], "utf-8", "ignore")
setattr(trait, field, holder)
if dataset.type == 'Publish':
diff --git a/wqflask/base/webqtlConfig.py b/wqflask/base/webqtlConfig.py
index b14cc4b0..0b884815 100644
--- a/wqflask/base/webqtlConfig.py
+++ b/wqflask/base/webqtlConfig.py
@@ -43,6 +43,7 @@ HOMOLOGENE_ID = "http://www.ncbi.nlm.nih.gov/homologene/?term=%s"
GENOTATION_URL = "http://www.genotation.org/Getd2g.pl?gene_list=%s"
GTEX_URL = "https://www.gtexportal.org/home/gene/%s"
GENEBRIDGE_URL = "https://www.systems-genetics.org/modules_by_gene/%s?organism=%s"
+GENEMANIA_URL = "https://genemania.org/search/%s/%s"
UCSC_REFSEQ = "http://genome.cse.ucsc.edu/cgi-bin/hgTracks?db=%s&hgg_gene=%s&hgg_chrom=chr%s&hgg_start=%s&hgg_end=%s"
BIOGPS_URL = "http://biogps.org/?org=%s#goto=genereport&id=%s"
STRING_URL = "http://string-db.org/newstring_cgi/show_network_section.pl?identifier=%s"
@@ -52,7 +53,9 @@ ABA_URL = "http://mouse.brain-map.org/search/show?search_type=gene&search_term=%
EBIGWAS_URL = "https://www.ebi.ac.uk/gwas/search?query=%s"
WIKI_PI_URL = "http://severus.dbmi.pitt.edu/wiki-pi/index.php/search?q=%s"
ENSEMBLETRANSCRIPT_URL="http://useast.ensembl.org/Mus_musculus/Transcript/Idhistory?t=%s"
-DBSNP = 'http://www.ncbi.nlm.nih.gov/SNP/snp_ref.cgi?type=rs&rs=%s'
+DBSNP = 'http://ensembl.org/Mus_musculus/Variation/Population?v=%s'
+PROTEIN_ATLAS_URL = "http://www.proteinatlas.org/search/%s"
+OPEN_TARGETS_URL = "https://genetics.opentargets.org/gene/%s"
# Temporary storage (note that this TMPDIR can be set as an
# environment variable - use utility.tools.TEMPDIR when you
@@ -87,4 +90,3 @@ if not valid_path(JSON_GENODIR):
PORTADDR = "http://50.16.251.170"
INFOPAGEHREF = '/dbdoc/%s.html'
CGIDIR = '/webqtl/' #XZ: The variable name 'CGIDIR' should be changed to 'PYTHONDIR'
-SCRIPTFILE = 'main.py'