New Lane Table migration progress.
authorBrandon King <kingb@caltech.edu>
Fri, 7 Aug 2009 22:43:06 +0000 (22:43 +0000)
committerBrandon King <kingb@caltech.edu>
Fri, 7 Aug 2009 22:43:06 +0000 (22:43 +0000)
htsworkflow/frontend/experiments/admin.py
htsworkflow/frontend/experiments/models.py
htsworkflow/frontend/samples/admin.py
htsworkflow/frontend/samples/models.py
scripts/migrate_to_lane_table.py [new file with mode: 0755]
scripts/upgrade_from_v0.2.6_to_trunk.sh [new file with mode: 0755]

index 4e9074b0fbd1c01fa4553d93654ff6278e6f0e60..c97322f14acf02493dd35a2d36c6aed71128423d 100644 (file)
@@ -1,7 +1,12 @@
-from htsworkflow.frontend.experiments.models import FlowCell, DataRun, ClusterStation, Sequencer
+from htsworkflow.frontend.experiments.models import FlowCell, DataRun, ClusterStation, Sequencer, Lane
 from django.contrib import admin
 from django.utils.translation import ugettext_lazy as _
 
+class LaneInline(admin.StackedInline):
+  model = Lane
+  max_num = 8
+  extra = 8
+
 class DataRunOptions(admin.ModelAdmin):
   search_fields = [
       'run_folder',
@@ -65,6 +70,9 @@ class FlowCellOptions(admin.ModelAdmin):
         }),
         ('Notes:', { 'fields': ('notes',),}),
     )
+    inlines = [
+      LaneInline,
+    ]
 
 class ClusterStationOptions(admin.ModelAdmin):
     list_display = ('name', )
@@ -73,8 +81,13 @@ class ClusterStationOptions(admin.ModelAdmin):
 class SequencerOptions(admin.ModelAdmin):
     list_display = ('name', )
     fieldsets = ( ( None, { 'fields': ( 'name', ) } ), )
+    
+class LaneOptions(admin.ModelAdmin):
+    list_display = ('flowcell', 'lane_number', 'library', 'comment')
+    
 
 admin.site.register(DataRun, DataRunOptions)
 admin.site.register(FlowCell, FlowCellOptions)
 admin.site.register(ClusterStation, ClusterStationOptions)
 admin.site.register(Sequencer, SequencerOptions)
+admin.site.register(Lane, LaneOptions)
index 0ddcf61d831847f49a668073fe846f18b52b71e1..690c18bdc99c824da8fedd31fec5ad2914ffa404 100755 (executable)
@@ -22,6 +22,9 @@ try:
 except ValueError,e:
   logging.error("invalid value for frontend.default_pm")
 
+
+  
+
 class FlowCell(models.Model):
   
   flowcell_id = models.CharField(max_length=20, unique=True, db_index=True)
@@ -159,3 +162,12 @@ class DataRun(models.Model):
     str += '</div>'    
     return str
   Flowcell_Info.allow_tags = True
+
+
+class Lane(models.Model):
+  flowcell = models.ForeignKey(FlowCell)
+  lane_number = models.IntegerField(choices=[(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8)])
+  library = models.ForeignKey(Library)
+  pm = models.DecimalField(max_digits=5, decimal_places=2,blank=False, null=False,default=default_pM)
+  cluster_estimate = models.IntegerField(blank=True, null=True)
+  comment = models.TextField(null=True, blank=True)
index ee6a9e2f3c152b73ee893abd8e2a19f691c2c33f..1e01c88ecaaac214345fd1d3eff9c46f19714219 100644 (file)
@@ -4,6 +4,11 @@ from django.db import models
 from django.utils.translation import ugettext_lazy as _
 
 from htsworkflow.frontend.samples.models import Antibody, Cellline, Condition, ExperimentType, LibraryType, Species, Affiliation, Library, Tag
+from htsworkflow.frontend.experiments.models import Lane
+
+class LaneLibraryInline(admin.StackedInline):
+  model = Lane
+  extra = 0
 
 class Library_Inline(admin.TabularInline):
   model = Library
@@ -84,6 +89,9 @@ class LibraryOptions(admin.ModelAdmin):
              'fields' : (('affiliations'), ('tags'),)
          }),
          )
+    inlines = [
+      LaneLibraryInline,
+    ]
 
     # some post 1.0.2 version of django has formfield_overrides 
     # which would replace this code with:
index 5b8f6a7da74d9e4631e064ee9f0f093aebb5b2f7..8650061e9550cc82ed80a09ecd63602c63d83475 100644 (file)
@@ -138,7 +138,7 @@ class Library(models.Model):
   REPLICATE_NUM = ((1,1),(2,2),(3,3),(4,4))
   replicate =  models.PositiveSmallIntegerField(choices=REPLICATE_NUM,default=1) 
   experiment_type = models.ForeignKey(ExperimentType)
-  library_type = models.ForeignKey(LibraryType, null=True)
+  library_type = models.ForeignKey(LibraryType, blank=True, null=True)
   creation_date = models.DateField(blank=True, null=True)
   made_for = models.CharField(max_length=50, blank=True, 
       verbose_name='ChIP/DNA/RNA Made By')
diff --git a/scripts/migrate_to_lane_table.py b/scripts/migrate_to_lane_table.py
new file mode 100755 (executable)
index 0000000..13eb789
--- /dev/null
@@ -0,0 +1,141 @@
+#!/usr/bin/env python
+
+from htsworkflow.frontend.experiments.models import FlowCell, Lane
+
+
+if __name__ == '__main__':
+    
+    print "Migration starting..."
+    
+    #Get all flowcells
+    for flowcell in FlowCell.objects.all():
+        
+        ##################
+        # Lane 1
+        lane1 = Lane()
+        
+        # ForeignKey Links
+        lane1.flowcell = flowcell
+        lane1.library = flowcell.lane_1_library
+        
+        # Meta Data
+        lane1.lane_number = 1
+        lane1.pm = flowcell.lane_1_pM
+        lane1.cluster_estimate = flowcell.lane_1_cluster_estimate
+        
+        # Save
+        lane1.save()
+        
+        ##################
+        # Lane 2
+        lane2 = Lane()
+        
+        # ForeignKey Links
+        lane2.flowcell = flowcell
+        lane2.library = flowcell.lane_2_library
+        
+        # Meta Data
+        lane2.lane_number = 2
+        lane2.pm = flowcell.lane_2_pM
+        lane2.cluster_estimate = flowcell.lane_2_cluster_estimate
+        
+        # Save
+        lane2.save()
+        
+        ##################
+        # Lane 3
+        lane3 = Lane()
+        
+        # ForeignKey Links
+        lane3.flowcell = flowcell
+        lane3.library = flowcell.lane_3_library
+        
+        # Meta Data
+        lane3.lane_number = 3
+        lane3.pm = flowcell.lane_3_pM
+        lane3.cluster_estimate = flowcell.lane_3_cluster_estimate
+        
+        # Save
+        lane3.save()
+        
+        ##################
+        # Lane 4
+        lane4 = Lane()
+        
+        # ForeignKey Links
+        lane4.flowcell = flowcell
+        lane4.library = flowcell.lane_4_library
+        
+        # Meta Data
+        lane4.lane_number = 4
+        lane4.pm = flowcell.lane_4_pM
+        lane4.cluster_estimate = flowcell.lane_4_cluster_estimate
+        
+        # Save
+        lane4.save()
+        
+        ##################
+        # Lane 5
+        lane5 = Lane()
+        
+        # ForeignKey Links
+        lane5.flowcell = flowcell
+        lane5.library = flowcell.lane_5_library
+        
+        # Meta Data
+        lane5.lane_number = 5
+        lane5.pm = flowcell.lane_5_pM
+        lane5.cluster_estimate = flowcell.lane_5_cluster_estimate
+        
+        # Save
+        lane5.save()
+        
+        ##################
+        # Lane 6
+        lane6 = Lane()
+        
+        # ForeignKey Links
+        lane6.flowcell = flowcell
+        lane6.library = flowcell.lane_6_library
+        
+        # Meta Data
+        lane6.lane_number = 6
+        lane6.pm = flowcell.lane_6_pM
+        lane6.cluster_estimate = flowcell.lane_6_cluster_estimate
+        
+        # Save
+        lane6.save()
+        
+        ##################
+        # Lane 7
+        lane7 = Lane()
+        
+        # ForeignKey Links
+        lane7.flowcell = flowcell
+        lane7.library = flowcell.lane_7_library
+        
+        # Meta Data
+        lane7.lane_number = 7
+        lane7.pm = flowcell.lane_7_pM
+        lane7.cluster_estimate = flowcell.lane_7_cluster_estimate
+        
+        # Save
+        lane7.save()
+        
+        ##################
+        # Lane 8
+        lane8 = Lane()
+        
+        # ForeignKey Links
+        lane8.flowcell = flowcell
+        lane8.library = flowcell.lane_8_library
+        
+        # Meta Data
+        lane8.lane_number = 8
+        lane8.pm = flowcell.lane_1_pM
+        lane8.cluster_estimate = flowcell.lane_8_cluster_estimate
+        
+        # Save
+        lane8.save()
+
+    print "Migration Complete."
\ No newline at end of file
diff --git a/scripts/upgrade_from_v0.2.6_to_trunk.sh b/scripts/upgrade_from_v0.2.6_to_trunk.sh
new file mode 100755 (executable)
index 0000000..c75ee55
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+export DJANGO_SETTINGS_MODULE=htsworkflow.frontend.settings
+scp king@jumpgate.caltech.edu:/home/www/gaworkflow/fctracker.db /home/king/proj/htsworkflow/trunk/fctracker.db
+cd htsworkflow/frontend/
+python manage.py syncdb
+cd ../..
+./scripts/migrate_to_lane_table.py
+