aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/base')
-rw-r--r--wqflask/base/data_set.py37
-rw-r--r--wqflask/base/trait.py16
-rw-r--r--wqflask/base/webqtlConfig.py2
3 files changed, 34 insertions, 21 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 54dd3c4b..4959457a 100644
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -61,14 +61,17 @@ logger = getLogger(__name__ )
# Each subclass will add to this
DS_NAME_MAP = {}
-def create_dataset(dataset_name, dataset_type = None, get_samplelist = True):
+def create_dataset(dataset_name, dataset_type = None, get_samplelist = True, group_name = None):
if not dataset_type:
dataset_type = Dataset_Getter(dataset_name)
logger.debug("dataset_type", dataset_type)
dataset_ob = DS_NAME_MAP[dataset_type]
dataset_class = globals()[dataset_ob]
- return dataset_class(dataset_name, get_samplelist)
+ if dataset_type == "Temp":
+ return dataset_class(dataset_name, get_samplelist, group_name)
+ else:
+ return dataset_class(dataset_name, get_samplelist)
class Dataset_Types(object):
@@ -261,10 +264,13 @@ class DatasetGroup(object):
has multiple datasets associated with it.
"""
- def __init__(self, dataset):
+ def __init__(self, dataset, name=None):
"""This sets self.group and self.group_id"""
#logger.debug("DATASET NAME2:", dataset.name)
- self.name, self.id, self.genetic_type = fetchone(dataset.query_for_group)
+ if name == None:
+ self.name, self.id, self.genetic_type = fetchone(dataset.query_for_group)
+ else:
+ self.name, self.id, self.genetic_type = fetchone("SELECT InbredSet.Name, InbredSet.Id, InbredSet.GeneticType FROM InbredSet where Name='%s'" % name)
if self.name == 'BXD300':
self.name = "BXD"
@@ -304,7 +310,7 @@ class DatasetGroup(object):
elif mapping_id == "2":
mapping_names = ["GEMMA"]
elif mapping_id == "4":
- mapping_names = ["PLINK"]
+ mapping_names = ["GEMMA", "PLINK"]
else:
mapping_names = []
@@ -319,9 +325,7 @@ class DatasetGroup(object):
def check_plink_gemma():
if flat_file_exists("mapping"):
MAPPING_PATH = flat_files("mapping")+"/"
- if (os.path.isfile(MAPPING_PATH+self.name+".bed") and
- (os.path.isfile(MAPPING_PATH+self.name+".map") or
- os.path.isfile(MAPPING_PATH+self.name+".bim"))):
+ if os.path.isfile(MAPPING_PATH+self.name+".bed"):
return True
return False
@@ -481,7 +485,7 @@ class DataSet(object):
"""
- def __init__(self, name, get_samplelist = True):
+ def __init__(self, name, get_samplelist = True, group_name = None):
assert name, "Need a name"
self.name = name
@@ -493,11 +497,12 @@ class DataSet(object):
self.setup()
- self.check_confidentiality()
-
- self.retrieve_other_names()
-
- self.group = DatasetGroup(self) # sets self.group and self.group_id and gets genotype
+ if self.type == "Temp": #Need to supply group name as input if temp trait
+ self.group = DatasetGroup(self, group_name) # sets self.group and self.group_id and gets genotype
+ else:
+ self.check_confidentiality()
+ self.retrieve_other_names()
+ self.group = DatasetGroup(self) # sets self.group and self.group_id and gets genotype
if get_samplelist == True:
self.group.get_samplelist()
self.species = species.TheSpecies(self)
@@ -888,7 +893,7 @@ class GenotypeDataSet(DataSet):
def retrieve_sample_data(self, trait):
query = """
SELECT
- Strain.Name, GenoData.value, GenoSE.error, GenoData.Id, Sample.Name2
+ Strain.Name, GenoData.value, GenoSE.error, GenoData.Id, Strain.Name2
FROM
(GenoData, GenoFreeze, Strain, Geno, GenoXRef)
left join GenoSE on
@@ -1156,6 +1161,8 @@ class MrnaAssayDataSet(DataSet):
class TempDataSet(DataSet):
'''Temporary user-generated data set'''
+ DS_NAME_MAP['Temp'] = 'TempDataSet'
+
def setup(self):
self.search_fields = ['name',
'description']
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index bf87e879..e22a51e4 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -62,6 +62,11 @@ class GeneralTrait(object):
self.strand_probe = None
self.symbol = None
+ self.LRS_score_repr = "N/A"
+ self.LRS_score_value = 0
+ self.LRS_location_repr = "N/A"
+ self.LRS_location_value = 1000000
+
if kw.get('fullname'):
name2 = value.split("::")
if len(name2) == 2:
@@ -72,9 +77,10 @@ class GeneralTrait(object):
# Todo: These two lines are necessary most of the time, but perhaps not all of the time
# So we could add a simple if statement to short-circuit this if necessary
- self = retrieve_trait_info(self, self.dataset, get_qtl_info=get_qtl_info)
- if get_sample_info != False:
- self = retrieve_sample_data(self, self.dataset)
+ if self.dataset.type != "Temp":
+ self = retrieve_trait_info(self, self.dataset, get_qtl_info=get_qtl_info)
+ if get_sample_info != False:
+ self = retrieve_sample_data(self, self.dataset)
def get_name(self):
@@ -315,12 +321,12 @@ def get_sample_data():
#
#return jsonable_sample_data
-def jsonable(trait, dataset_name):
+def jsonable(trait):
"""Return a dict suitable for using as json
Actual turning into json doesn't happen here though"""
- dataset = create_dataset(dataset_name)
+ dataset = create_dataset(dataset_name = trait.dataset.name, dataset_type = trait.dataset.type, group_name = trait.dataset.group.name)
if dataset.type == "ProbeSet":
return dict(name=trait.name,
diff --git a/wqflask/base/webqtlConfig.py b/wqflask/base/webqtlConfig.py
index e5f10edf..1e47e183 100644
--- a/wqflask/base/webqtlConfig.py
+++ b/wqflask/base/webqtlConfig.py
@@ -65,7 +65,7 @@ ENSEMBLETRANSCRIPT_URL="http://useast.ensembl.org/Mus_musculus/Lucene/Details?sp
# want to reach this base dir
assert_writable_dir(TEMPDIR)
-TMPDIR = mk_dir(TEMPDIR+'/gn2/')
+TMPDIR = mk_dir(TEMPDIR+'gn2')
assert_writable_dir(TMPDIR)
CACHEDIR = mk_dir(TMPDIR+'/cache/')