From: Diane Trout Date: Wed, 14 Jan 2009 01:12:47 +0000 (+0000) Subject: Merged much of the stanford htsworkflow frontend into trunk. X-Git-Tag: stanford.caltech-merged-database-2009-jan-15~1 X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=0ad05984f22876516044102c48fa4dac50ba7486 Merged much of the stanford htsworkflow frontend into trunk. Updated to be compatable with Django 1.0 A big change for the 1.0 compatibility is the Admin class that was attached to models was moved into a seperate file admin.py I probably munged some of the fieldset formatting in the conversion process. --- diff --git a/docs/Conv_CaltechDB_Nov112008.txt b/docs/Conv_CaltechDB_Nov112008.txt new file mode 100644 index 0000000..9d6997a --- /dev/null +++ b/docs/Conv_CaltechDB_Nov112008.txt @@ -0,0 +1,76 @@ +Conversion SQLs for Caltech DB (schema of 2008Aug08 @ 5:06 PM) +______________________________________________________________ + + +Step by step do the following: + +''' Note: Instead of '?' you can put one of your machine names. +sqlite> ALTER TABLE fctracker_flowcell ADD cluster_mac_id varchar(50) NOT NULL DEFAULT '?'; +sqlite> ALTER TABLE fctracker_flowcell ADD seq_mac_id varchar(50) NOT NULL DEFAULT '?'; +sqlite> ALTER TABLE fctracker_library RENAME TO PREV_fctracker_library; + +Now, do a syncdb. The output should look like this (assuming you have migrated to the new models.py): +sh-3.2# pym syncdb +Creating table fctracker_cellline +Creating table fctracker_library +Creating table fctracker_primer +Creating table fctracker_antibody +Creating table fctracker_condition +Creating table exp_track_datarun +Creating table exp_track_flowcell +Creating table analys_track_project +Creating table analys_track_task +Creating table htsw_reports_progressreport +Installing index for fctracker.Library model +Failed to install index for fctracker.Library model: index fctracker_library_library_species_id already existsInstalling index for fctracker.Primer model +Installing index for fctracker.Antibody model +Installing index for exp_track.DataRun model +Installing index for exp_track.FlowCell model +Installing index for analys_track.Task model +Installing index for htsw_reports.ProgressReport model +sh-3.2# + +''' Copy all records from "fctracker_flowcell" to "exp_track_flowcell" table. (Why? Because, Flowcell table moves now from the "fctracker" to the "exp_track" component). +sqlite> insert into experiments_flowcell select * from fctracker_flowcell; + +''' Now to fctracker_library, a bit more complex case + +'''Back to the sqlite prompt.. +sqlite> insert into samples_cellline (cellline_name,notes) values('Unknown','Unknown'); +sqlite> insert into samples_condition (condition_name,notes) values('Unknown','Unknown'); +''' Now we can put 1 in these fields for the Library insert. +''' Note: avg_lib_size field is missing in Caltech DB (although it's in the models.py Trac), so I put default value 225. + +''' Now the actual migration to the new fctracker_library table +''' (This version looses data, the current Nov 11, 2008 schema, has made_for as a one to many +''' relationship to the auth_user table, instead of being a text field. Here I just assigned +''' the made for to a (semi)-random user. +sqlite> INSERT INTO samples_library (library_id,library_name,library_species_id,experiment_type,cell_line_id,condition_id,replicate,made_by,creation_date,made_for_id,stopping_point,amplified_from_sample_id,undiluted_concentration,ten_nM_dilution,successful_pM,avg_lib_size,notes) select library_id,library_name,library_species_id,'unknown',1,1,1,made_by,creation_date,12,stopping_point,amplified_from_sample_id,undiluted_concentration,ten_nM_dilution,successful_pM,0,notes from PREV_fctracker_library; + +''' Set the right values for "experiment_type" +sqlite> update samples_library set experiment_type = "RNA-seq" where library_idin (select library_id from prev_fctracker_library where RNASeq = 1); +''' YOU CAN ADD SIMILAR SQL CMD TO SET THE VALUE FOR "avg_lib_size" FIELD (WHICH IS NOW SET TO 0) ... + +---------------------------------------------------------------------------------------- +THAT SHOULD BE IT --- NOW YOUR WEB SITE SHOULD SUCESSFULY LOAD THE NEW DB WITH YOUR DATA. + +2009 Jan 13 + +I had a working database and then merged in a few more changes from +stanford. I ended up needing to do the following: + +alter table analysis_task add task_params varchar(200) null; +alter table samples_cellline add nickname varchar(20) null; +alter table samples_condition add nickname varchar(20) null; + +Those changes might happen automatically when reconverting from our +original database, or they might not. + +CREATE TABLE "samples_library_tags" ( + "id" integer NOT NULL PRIMARY KEY, + "library_id" varchar(30) NOT NULL REFERENCES "samples_library" ("library_id"), + "tag_id" integer NOT NULL REFERENCES "samples_tag" ("id"), + UNIQUE ("library_id", "tag_id") +) +; + diff --git a/htsworkflow/frontend/analysis/admin.py b/htsworkflow/frontend/analysis/admin.py new file mode 100644 index 0000000..d3f903e --- /dev/null +++ b/htsworkflow/frontend/analysis/admin.py @@ -0,0 +1,31 @@ +from htsworkflow.frontend.analysis.models import Task, Project +from django.contrib import admin +from django.utils.translation import ugettext_lazy as _ + +class ProjectOptions(admin.ModelAdmin): + list_display = ('ProjTitle','ProjectTasks') + list_filter = () + search_fieldsets = ['project_name','=tasks__subject1__library_id','=tasks__subject2__library_id','tasks__subject1__library_name','tasks__subject2__library_name','project_notes'] + fieldsets = ( + (None, { + 'fields': (('project_name'),('tasks'),('project_notes'))}), + ) + filter_horizontal = ('tasks',) + +class TaskOptions(admin.ModelAdmin): + list_display = ('task_name','apply_calc','subject1','subject2','task_params','InProjects','submitted_on','task_status') + list_filter = ('apply_calc',) + search_fieldsets = ['task_name','id','=subject1__library_id','=subject2__library_id'] + fieldsets = ( + (None, { + 'fields': (('task_name'),('apply_calc'),('subject1'),('subject2'),('task_params')) + }), + ('system fields', { + 'classes': ('collapse',), + 'fields': (('submitted_on'),('task_status','run_note')) + }), + ) + +admin.site.register(Project, ProjectOptions) +admin.site.register(Task, TaskOptions) + diff --git a/htsworkflow/frontend/analysis/models.py b/htsworkflow/frontend/analysis/models.py index 4b1c72d..b98cfac 100644 --- a/htsworkflow/frontend/analysis/models.py +++ b/htsworkflow/frontend/analysis/models.py @@ -18,6 +18,7 @@ class Task(models.Model): ) apply_calc = models.CharField(max_length=50,choices=CALCS,verbose_name='Applied Calculation') ## userid = # logged in user + task_params = models.CharField(max_length=200,blank=True,null=True,default="") task_status = models.CharField(max_length=500,blank=True,null=True,default='defined') results_location = models.CharField(max_length=2000,blank=True,null=True) submitted_on = models.DateTimeField(default=datetime.now()) @@ -35,24 +36,10 @@ class Task(models.Model): pstr += '%s, ' % (p.project_name) return pstr - class Admin: - list_display = ('task_name','apply_calc','subject1','subject2','InProjects','submitted_on','task_status') - list_filter = ('apply_calc',) - search_fields = ['task_name','id','=subject1__library_id','=subject2__library_id'] - fields = ( - (None, { - 'fields': (('task_name'),('apply_calc'),('subject1'),('subject2')) - }), - ('system fields', { - 'classes': 'collapse', - 'fields': (('submitted_on'),('task_status','run_note')) - }), - ) - class Project(models.Model): project_name = models.CharField(max_length=50,unique=True, db_index=True) - tasks = models.ManyToManyField(Task,related_name='project_tasks',null=True,filter_interface=models.HORIZONTAL) + tasks = models.ManyToManyField(Task,related_name='project_tasks',null=True) project_notes = models.CharField(max_length=500,blank=True,null=True) def __str__(self): @@ -60,7 +47,7 @@ class Project(models.Model): def ProjectTasks(self): ptasks = self.tasks.all().order_by('id') - surl = 'http://m304-apple-server.stanford.edu/projects/' + surl = settings.ANALYSIS_SERVER+'/projects/' tstr = '