From 6f48b86e5a3d963507efec83bea56868773dc6e7 Mon Sep 17 00:00:00 2001 From: Brandon King Date: Fri, 7 Aug 2009 22:43:06 +0000 Subject: [PATCH] New Lane Table migration progress. --- htsworkflow/frontend/experiments/admin.py | 15 ++- htsworkflow/frontend/experiments/models.py | 12 ++ htsworkflow/frontend/samples/admin.py | 8 ++ htsworkflow/frontend/samples/models.py | 2 +- scripts/migrate_to_lane_table.py | 141 +++++++++++++++++++++ scripts/upgrade_from_v0.2.6_to_trunk.sh | 8 ++ 6 files changed, 184 insertions(+), 2 deletions(-) create mode 100755 scripts/migrate_to_lane_table.py create mode 100755 scripts/upgrade_from_v0.2.6_to_trunk.sh diff --git a/htsworkflow/frontend/experiments/admin.py b/htsworkflow/frontend/experiments/admin.py index 4e9074b..c97322f 100644 --- a/htsworkflow/frontend/experiments/admin.py +++ b/htsworkflow/frontend/experiments/admin.py @@ -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) diff --git a/htsworkflow/frontend/experiments/models.py b/htsworkflow/frontend/experiments/models.py index 0ddcf61..690c18b 100755 --- a/htsworkflow/frontend/experiments/models.py +++ b/htsworkflow/frontend/experiments/models.py @@ -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 += '' 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) diff --git a/htsworkflow/frontend/samples/admin.py b/htsworkflow/frontend/samples/admin.py index ee6a9e2..1e01c88 100644 --- a/htsworkflow/frontend/samples/admin.py +++ b/htsworkflow/frontend/samples/admin.py @@ -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: diff --git a/htsworkflow/frontend/samples/models.py b/htsworkflow/frontend/samples/models.py index 5b8f6a7..8650061 100644 --- a/htsworkflow/frontend/samples/models.py +++ b/htsworkflow/frontend/samples/models.py @@ -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 index 0000000..13eb789 --- /dev/null +++ b/scripts/migrate_to_lane_table.py @@ -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 index 0000000..c75ee55 --- /dev/null +++ b/scripts/upgrade_from_v0.2.6_to_trunk.sh @@ -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 + -- 2.30.2