Commit 8bf4f6cd authored by Nijveen, Harm's avatar Nijveen, Harm
Browse files

added the creation of the settings.json file per experiment

parent 49d77805
Pipeline #1700 skipped
......@@ -13,6 +13,8 @@ from django.db import models
class Species(models.Model):
species_name = models.CharField(max_length=50)
url = models.CharField(max_length=255)
class Meta:
managed = False
......@@ -63,10 +65,10 @@ class Line(models.Model):
class Marker(models.Model):
marker_name = models.CharField(max_length=15)
marker_chr = models.CharField(max_length=10, blank=True, null=True)
marker_start = models.IntegerField(blank=True, null=True)
marker_end = models.IntegerField(blank=True, null=True)
name = models.CharField(max_length=15)
chromosome = models.ForeignKey(Chromosome)
start = models.IntegerField(blank=True, null=True)
end = models.IntegerField(blank=True, null=True)
experiment = models.ForeignKey(Experiment)
class Meta:
......
import json
import os
import urllib
import sys
from main.models import Experiment, GeneGO,ArraySpot,Transcript,Marker, Species, Chromosome, GeneInfo
......@@ -45,7 +46,46 @@ def getSpeciesForExperiment(experiment_name):
def getMarkerNames(experiment_name):
return Marker.objects.filter(experiment__experiment_name = experiment_name).values_list("marker_name", flat=True)
def outputJsonForExperiment(experiment_name,qtl_file,output):
def createSettingsJsonForExperiment(experiment_name):
output_dic = dict()
species_name = getSpeciesForExperiment(experiment_name)
output_dic['species'] = species_name
url = Species.objects.filter(species_name=species_name).values_list('url', flat=True)
if len(url) == 1:
output_dic['url'] = url[0]
else:
output_dic['url'] = ""
output_dic['chrnames'] = sorted(Chromosome.objects.filter(species__species_name=species_name).values_list('name', flat=True))
chromosomes = Chromosome.objects.filter(species__species_name=species_name)
chr_dic = dict()
for chromosome in chromosomes:
chr_dic[chromosome.name] = {"start": chromosome.start, "end": chromosome.end}
output_dic["chr"] = chr_dic
output_dic["pmarknames"] = dict()
for chromosome in chromosomes:
markers = Marker.objects.filter(experiment__experiment_name = experiment_name, chromosome__name = chromosome.name)
marker_dic = {}
for marker in markers:
marker_dic[marker.name] = marker.start
output_dic["pmarknames"][chromosome.name] = sorted(marker_dic, key=lambda k: marker_dic[k])
out_file = os.path.join(settings.MEDIA_ROOT,'data/%s/%s.json' % (experiment_name,"settings"))
with open(out_file, 'w') as fo:
json.dump(output_dic, fo, indent=4, ensure_ascii=True)
def createGeneJsonForExperiment(experiment_name,qtl_file):
'''
description: parse upload information into JSON file format later which later will be used for multiexperimentplot plot.
......@@ -65,16 +105,8 @@ def outputJsonForExperiment(experiment_name,qtl_file,output):
in_path = os.path.join(settings.MEDIA_ROOT,'data/%s/%s' % (experiment_name,qtl_file))
output_dic = {}
species_name = getSpeciesForExperiment(experiment_name)
output_dic['chrnames'] = Chromosome.objects.filter(species__species_name=species_name).values_list('name', flat=True)
output_dic['chr'] = Chromosome.objects.filter(species__species_name=species_name).count()
#define KEY spec
output_dic['species'] = species_name
with open(in_path) as fi:
first_line = fi.readline().rstrip()
markers = first_line.split('\t')[1:]
......
......@@ -283,4 +283,4 @@ draw = (data) ->
q.awaitAll(draw_probe);
# load json file and call draw function
d3.json("../media/data/Joosen_etal_2012/arabidopsis.json", draw)
d3.json("../media/data/"+experiment_name+"/settings.json", draw)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment