From df29a7160cb1a1b4d896e7c250d6b310cde3c2d4 Mon Sep 17 00:00:00 2001 From: Lorian Schaeffer Date: Fri, 9 Nov 2007 23:20:37 +0000 Subject: [PATCH] [project @ Massive change to DB structure; complete library table] Primary change to the DB is the library table and supporting changes to the flowcell table. They should both be properly linked now; you'll have to pull species information from the linked library field. In addition, I added a common name to the Species table. Most interface changes are via the meta and admin classes in each model, and are fairly straightforward. I also added databrowse support; go to /databrowse instead of /admin to play with it. --- elandifier/fctracker/models.py | 148 ++++++++++++++++++++++++--------- elandifier/settings.py | 5 +- elandifier/urls.py | 13 ++- 3 files changed, 120 insertions(+), 46 deletions(-) diff --git a/elandifier/fctracker/models.py b/elandifier/fctracker/models.py index 95ad1a5..099edb1 100644 --- a/elandifier/fctracker/models.py +++ b/elandifier/fctracker/models.py @@ -3,67 +3,133 @@ from elandifier import settings # Create your models here. - -class Specie(models.Model): - - class Admin: pass +class Species(models.Model): - scientific_name = models.CharField(maxlength=256, unique=True, db_index=True) - + scientific_name = models.CharField(max_length=256, unique=True, db_index=True, core=True) + common_name = models.CharField(max_length=256, blank=True) def __str__(self): - return self.scientific_name - -#class BedFilePack(models.Model): + return '%s (%s)' % (self.scientific_name, self.common_name) + + class Meta: + verbose_name_plural = "species" + ordering = ["scientific_name"] + + class Admin: + fields = ( + (None, { + 'fields': (('scientific_name', 'common_name'),) + }), + ) class Library(models.Model): - class Admin: pass - - library_id = models.IntegerField(unique=True, db_index=True) - library_name = models.CharField(maxlength=100, unique=True) - library_species = models.ForeignKey(Specie) - made_from_sample = models.ForeignKey('self', blank=True) + library_id = models.IntegerField(primary_key=True, db_index=True, core=True) + library_name = models.CharField(max_length=100, unique=True, core=True) + library_species = models.ForeignKey(Species, core=True) + RNAseq = models.BooleanField() - made_by = models.CharField(maxlength=50, blank=True) + made_by = models.CharField(max_length=50, blank=True, default="Lorian") creation_date = models.DateField(blank=True, null=True) + made_for = models.CharField(max_length=50, blank=True) + + PROTOCOL_END_POINTS = ( + ('?', 'Unknown'), + ('Sample', 'Raw sample'), + ('Gel', 'Ran gel'), + ('1A', 'Gel purification'), + ('2A', '2nd PCR'), + ('Progress', 'In progress'), + ) + stopping_point = models.CharField(max_length=50, choices=PROTOCOL_END_POINTS) + amplified_from_sample = models.ForeignKey('self', blank=True, null=True) + + undiluted_concentration = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True) + ten_nM_dilution = models.BooleanField() + successful_pM = models.IntegerField(blank=True, null=True) + notes = models.TextField(blank=True) def __str__(self): - return self.library_name - - -class FlowCell(models.Model): + return '#%s: %s' % (self.library_id, self.library_name) - class Admin: pass + class Meta: + verbose_name_plural = "libraries" + ordering = ["-library_id"] - flowcell_id = models.CharField(maxlength=20, unique=True, db_index=True) + class Admin: + date_hierarchy = "creation_date" + save_as = True + save_on_top = True + search_fields = ['library_name'] + list_display = ('library_id', 'library_name', 'made_for', 'creation_date', 'ten_nM_dilution', 'stopping_point', 'successful_pM') + list_display_links = ('library_id', 'library_name') + list_filter = ('stopping_point', 'ten_nM_dilution', 'library_species', 'made_for', 'made_by') + fields = ( + (None, { + 'fields': (('library_id', 'library_name'), ('library_species', 'RNAseq'),) + }), + ('Creation Information:', { + 'fields' : (('made_for', 'made_by', 'creation_date'), ('stopping_point', 'amplified_from_sample'), ('undiluted_concentration', 'ten_nM_dilution', 'successful_pM'), 'notes',) + }), + ) + +class FlowCell(models.Model): - run_date = models.DateTimeField() + flowcell_id = models.CharField(max_length=20, unique=True, db_index=True, core=True) + run_date = models.DateTimeField(core=True) - lane1_sample = models.CharField(maxlength=500) - lane1_species = models.ForeignKey(Specie, related_name="lane1_species") - lane2_sample = models.CharField(maxlength=500) - lane2_species = models.ForeignKey(Specie, related_name="lane2_species") - lane3_sample = models.CharField(maxlength=500) - lane3_species = models.ForeignKey(Specie, related_name="lane3_species") - lane4_sample = models.CharField(maxlength=500) - lane4_species = models.ForeignKey(Specie, related_name="lane4_species") + lane_1_library = models.ForeignKey(Library, related_name="lane_1_library") + lane_2_library = models.ForeignKey(Library, related_name="lane_2_library") + lane_3_library = models.ForeignKey(Library, related_name="lane_3_library") + lane_4_library = models.ForeignKey(Library, related_name="lane_4_library") + lane_5_library = models.ForeignKey(Library, related_name="lane_5_library") + lane_6_library = models.ForeignKey(Library, related_name="lane_6_library") + lane_7_library = models.ForeignKey(Library, related_name="lane_7_library") + lane_8_library = models.ForeignKey(Library, related_name="lane_8_library") + + lane_1_pM = models.IntegerField(default=4) + lane_2_pM = models.IntegerField(default=4) + lane_3_pM = models.IntegerField(default=4) + lane_4_pM = models.IntegerField(default=4) + lane_5_pM = models.IntegerField(default=4) + lane_6_pM = models.IntegerField(default=4) + lane_7_pM = models.IntegerField(default=4) + lane_8_pM = models.IntegerField(default=4) - lane5_sample = models.CharField(maxlength=500) - lane5_species = models.ForeignKey(Specie, related_name="lane5_species") - lane6_sample = models.CharField(maxlength=500) - lane6_species = models.ForeignKey(Specie, related_name="lane6_species") - lane7_sample = models.CharField(maxlength=500) - lane7_species = models.ForeignKey(Specie, related_name="lane7_species") - lane8_sample = models.CharField(maxlength=500) - lane8_species = models.ForeignKey(Specie, related_name="lane8_species") + lane_1_cluster_estimate = models.IntegerField(blank=True, null=True) + lane_2_cluster_estimate = models.IntegerField(blank=True, null=True) + lane_3_cluster_estimate = models.IntegerField(blank=True, null=True) + lane_4_cluster_estimate = models.IntegerField(blank=True, null=True) + lane_5_cluster_estimate = models.IntegerField(blank=True, null=True) + lane_6_cluster_estimate = models.IntegerField(blank=True, null=True) + lane_7_cluster_estimate = models.IntegerField(blank=True, null=True) + lane_8_cluster_estimate = models.IntegerField(blank=True, null=True) notes = models.TextField(blank=True) def __str__(self): - return self.flowcell_id - + return '%s (%s)' % (self.flowcell_id, self.run_date) + + class Meta: + ordering = ["run_date"] + + class Admin: + date_hierarchy = "run_date" + save_on_top = True + search_fields = ['lane_1_library', 'lane_2_library', 'lane_3_library', 'lane_4_library', 'lane_5_library', 'lane_6_library', 'lane_7_library', 'lane_8_library'] + list_display = ('flowcell_id', 'run_date', 'lane_1_library', 'lane_2_library', 'lane_3_library', 'lane_4_library', 'lane_5_library', 'lane_6_library', 'lane_7_library', 'lane_8_library') + fields = ( + (None, { + 'fields': ('run_date', 'flowcell_id',) + }), + ('Lanes:', { + 'fields' : (('lane_1_library', 'lane_1_pM', 'lane_1_cluster_estimate'), ('lane_2_library', 'lane_2_pM', 'lane_2_cluster_estimate'), ('lane_3_library', 'lane_3_pM', 'lane_3_cluster_estimate'), ('lane_4_library', 'lane_4_pM', 'lane_4_cluster_estimate'), ('lane_5_library', 'lane_5_pM', 'lane_5_cluster_estimate'), ('lane_6_library', 'lane_6_pM', 'lane_6_cluster_estimate'), ('lane_7_library', 'lane_7_pM', 'lane_7_cluster_estimate'), ('lane_8_library', 'lane_8_pM', 'lane_8_cluster_estimate'),) + }), + (None, { + 'fields' : ('notes',) + }), + ) class ElandResult(models.Model): diff --git a/elandifier/settings.py b/elandifier/settings.py index 860699a..778dae9 100644 --- a/elandifier/settings.py +++ b/elandifier/settings.py @@ -12,7 +12,7 @@ ADMINS = ( MANAGERS = ADMINS DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. -DATABASE_NAME = '/home/king/proj/solexa/elandifier/elandifier.db' # Or path to database file if using sqlite3. +DATABASE_NAME = '/home/lorian/Djangoproject/sequencer/elandifier/elandifier.db' # Or path to database file if using sqlite3. DATABASE_USER = '' # Not used with sqlite3. DATABASE_PASSWORD = '' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. @@ -82,7 +82,8 @@ INSTALLED_APPS = ( 'django.contrib.sessions', 'django.contrib.sites', 'elandifier.eland_config', - 'elandifier.fctracker' + 'elandifier.fctracker', + 'django.contrib.databrowse', ) # Project specific settings diff --git a/elandifier/urls.py b/elandifier/urls.py index 6e8b3b6..1267640 100644 --- a/elandifier/urls.py +++ b/elandifier/urls.py @@ -1,9 +1,16 @@ from django.conf.urls.defaults import * +# Databrowser: +from django.contrib import databrowse +from fctracker.models import Library, FlowCell +databrowse.site.register(Library) +databrowse.site.register(FlowCell) + urlpatterns = patterns('', - # Example: + # Base: (r'^elandifier/', include('elandifier.eland_config.urls')), - - # Uncomment this for admin: + # Admin: (r'^admin/', include('django.contrib.admin.urls')), + # Databrowser: + (r'^databrowse/(.*)', databrowse.site.root), ) -- 2.30.2