Rename avg_lib_size to gel_cut_size, and add insert_size
authorDiane Trout <diane@caltech.edu>
Mon, 14 Jun 2010 21:11:32 +0000 (21:11 +0000)
committerDiane Trout <diane@caltech.edu>
Mon, 14 Jun 2010 21:11:32 +0000 (21:11 +0000)
to clear up the confusion about what was supposed to be
being recorded in avg_lib_size.

In addition, this patch adds in a per lane status field.

12 files changed:
docs/upgrade_v0.4.2_to_v0.4.3.py [new file with mode: 0644]
htsworkflow/frontend/experiments/admin.py
htsworkflow/frontend/experiments/experiments.py
htsworkflow/frontend/experiments/fixtures/test_flowcells.json
htsworkflow/frontend/experiments/models.py
htsworkflow/frontend/samples/admin.py
htsworkflow/frontend/samples/fixtures/test_samples.json
htsworkflow/frontend/samples/models.py
htsworkflow/frontend/samples/tests.py
htsworkflow/frontend/samples/views.py
htsworkflow/frontend/templates/experiments/flowcellSheet.html
htsworkflow/frontend/templates/samples/library_detail.html

diff --git a/docs/upgrade_v0.4.2_to_v0.4.3.py b/docs/upgrade_v0.4.2_to_v0.4.3.py
new file mode 100644 (file)
index 0000000..2c0cbab
--- /dev/null
@@ -0,0 +1,89 @@
+"""
+This renames avg_lib_size to gel_cut_size and adds an insert length field 
+to samples_library.
+"""
+
+import shutil
+import sqlite3
+import sys
+
+def main(cmdline=None):
+    if len(cmdline) == 1:
+       dest='/tmp/fctracker.db'
+    else:
+      dest = cmdline[1]
+    shutil.copy(cmdline[0], dest)
+    conn = sqlite3.connect(dest)
+    c = conn.cursor()
+    
+    
+    c.execute("""alter table samples_library rename to samples_library_temp;""")
+    c.execute("""CREATE TABLE "samples_library" (
+    "id" varchar(10) NOT NULL PRIMARY KEY,
+    "library_name" varchar(100) NOT NULL UNIQUE,
+    "library_species_id" integer NOT NULL REFERENCES "samples_species" ("id"),
+    "hidden" bool NOT NULL,
+    "account_number" varchar(100) NULL,
+    "cell_line_id" integer NULL REFERENCES "samples_cellline" ("id"),
+    "condition_id" integer NULL REFERENCES "samples_condition" ("id"),
+    "antibody_id" integer NULL REFERENCES "samples_antibody" ("id"),
+    "replicate" smallint unsigned NOT NULL,
+    "experiment_type_id" integer NOT NULL REFERENCES "samples_experimenttype" ("id"),
+    "library_type_id" integer NULL REFERENCES "samples_librarytype" ("id"),
+    "creation_date" date NULL,
+    "made_for" varchar(50) NOT NULL,
+    "made_by" varchar(50) NOT NULL,
+    "stopping_point" varchar(25) NOT NULL,
+    "amplified_from_sample_id" varchar(10) NULL,
+    "undiluted_concentration" decimal NULL,
+    "successful_pM" decimal NULL,
+    "ten_nM_dilution" bool NOT NULL,
+    "gel_cut_size" integer NULL,
+    "insert_size" integer NULL,
+    "notes" text NOT NULL
+);""")
+    c.execute("""INSERT INTO samples_library
+( id, library_name, library_species_id, hidden, account_number,
+  cell_line_id,  condition_id, antibody_id, replicate, 
+  experiment_type_id, library_type_id, creation_date, made_for,
+  made_by, stopping_point, amplified_from_sample_id, 
+  undiluted_concentration, successful_pM, ten_nM_dilution, 
+  gel_cut_size, notes )
+SELECT 
+  id, library_name, library_species_id, hidden, account_number,
+  cell_line_id,  condition_id, antibody_id, replicate, 
+  experiment_type_id, library_type_id, creation_date, made_for,
+  made_by, stopping_point, amplified_from_sample_id, 
+  undiluted_concentration, successful_pM, ten_nM_dilution, 
+  avg_lib_size, notes
+FROM samples_library_temp;
+""")    
+    c.execute('DROP TABLE samples_library_temp;')
+    
+
+    # modify experiments_lane
+    c.execute("""alter table experiments_lane rename to experiments_lane_temp;""")
+    c.execute('''
+CREATE TABLE "experiments_lane" (
+    "id" integer NOT NULL PRIMARY KEY,
+    "flowcell_id" integer NOT NULL REFERENCES "experiments_flowcell" ("id"),
+    "lane_number" integer NOT NULL,
+    "library_id" varchar(10) NOT NULL REFERENCES "samples_library" ("id"),
+    "pM" decimal NOT NULL,
+    "cluster_estimate" integer,
+    "status" integer,
+    "comment" text
+);''')
+
+    c.execute('''
+INSERT INTO experiments_lane
+( id,  flowcell_id, lane_number, library_id, pM, cluster_estimate, comment)
+SELECT 
+id, flowcell_id, lane_number, library_id, pM, cluster_estimate, comment
+FROM experiments_lane_temp;
+''')
+    c.execute('DROP TABLE experiments_lane_temp;')
+    conn.commit()
+
+if __name__ == "__main__":
+    main(sys.argv[1:])
index 0f00d0eea8732e7614c520f708e92c5665376dfd..f05643d6517f46369b4773f839b5dc63c31715e4 100644 (file)
@@ -57,7 +57,7 @@ class LaneInline(admin.StackedInline):
       (None, {
         'fields': ('lane_number', 'flowcell',
                    ('library',),
-                   ('pM', 'cluster_estimate'),
+                   ('pM', 'cluster_estimate', 'status'),
                    'comment',)
       }),
     )
index a156d7bdbe0198876f504b3f4b4276e115835787..882ea89c9961db701c3168f19efeb6910856a94c 100755 (executable)
@@ -15,7 +15,11 @@ from django.http import HttpResponse, Http404
 
 from htsworkflow.frontend.auth import require_api_key
 from htsworkflow.frontend import settings
-from htsworkflow.frontend.experiments.models import FlowCell, DataRun, Lane
+from htsworkflow.frontend.experiments.models import \
+    FlowCell, \
+    DataRun, \
+    Lane, \
+    LANE_STATUS_MAP
 from htsworkflow.frontend.samples.models import Library, HTSUser
 
 def flowcell_information(flowcell_id):
@@ -40,7 +44,9 @@ def flowcell_information(flowcell_id):
             'library_id': lane.library.id,
             'library_species': lane.library.library_species.scientific_name,
             'pM': unicode(lane.pM),
-            'read_length': lane.flowcell.read_length
+            'read_length': lane.flowcell.read_length,
+            'status_code': lane.status,
+            'status': LANE_STATUS_MAP[lane.status]
         }
 
     if fc.control_lane is None:
index 8ac03803d17b5f6abbeed3727e8fdcc345f9ecef..37adf5ed03a2645035286e6092f4d2200f54a1f6 100644 (file)
   {"pk": "10981", "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 400, 
+            "gel_cut_size": 400, 
             "library_name": "Paired End Multiplexed Sp-BAC", 
             "creation_date": "2009-07-21", 
             "cell_line": 1, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 325, 
+            "gel_cut_size": 325, 
             "library_name": "Paired End Pfl #3 MP 7/24/9 a", 
             "creation_date": "2009-08-06", 
             "cell_line": 1, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 300, 
+            "gel_cut_size": 300, 
             "library_name": "Paired ends 99 GM12892", 
             "creation_date": "2009-08-25", 
             "cell_line": 1, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 300, 
+            "gel_cut_size": 300, 
             "library_name": "Paired ends 100 VC_CN_4_M_MBB1185_s1", 
             "creation_date": "2009-09-01", 
             "cell_line": 1, 
     }, 
   {"pk": 1197, "model": "experiments.lane",
    "fields": {
-       "comment": "",
+       "comment": "stuff",
        "library": "11061",
        "cluster_estimate": 140000,
        "flowcell": 153,
        "lane_number": 5,
-       "pM": "7"
+       "pM": "7",
+       "status": 2
        }
    }, 
     {
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 300, 
+            "gel_cut_size": 300, 
             "library_name": "Paired ends 101 VC_CN_4_M_MBB1185_s2", 
             "creation_date": "2009-09-01", 
             "cell_line": 1, 
        "cluster_estimate": 2000,
        "flowcell": 153,
        "lane_number": 6,
-       "pM": "7"
+       "pM": "7",
+       "status": 0
        }
    }, 
     {
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 300, 
+            "gel_cut_size": 300, 
             "library_name": "Paired ends 102 VC_AU_8_M_MBB4721_s1", 
             "creation_date": "2009-09-01", 
             "cell_line": 1, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 300, 
+            "gel_cut_size": 300, 
             "library_name": "Paired ends 103 VC_AU_8_M_MBB4721_s2", 
             "creation_date": "2009-09-01", 
             "cell_line": 1, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 300, 
+            "gel_cut_size": 300, 
             "library_name": "Paired ends 104 VC_CN_7_M_MBB4898_s1", 
             "creation_date": "2009-09-01", 
             "cell_line": 1, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 300, 
+            "gel_cut_size": 300, 
             "library_name": "Paired ends 95 Gilberto_d3_control_LTA", 
             "creation_date": "2009-08-25", 
             "cell_line": 1, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 300, 
+            "gel_cut_size": 300, 
             "library_name": "Paired ends 97 Kuntz_PDHT", 
             "creation_date": "2009-08-25", 
             "cell_line": 1, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 250, 
+            "gel_cut_size": 250, 
             "library_name": "FLDN1 8/3/9 anti-AcH3 chip B6 a", 
             "creation_date": "2009-08-26", 
             "cell_line": null, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 250, 
+            "gel_cut_size": 250, 
             "library_name": "FLDN1 7/8/9 anti-DiMeH3K4 chip B6 a", 
             "creation_date": "2009-08-26", 
             "cell_line": null, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 225, 
+            "gel_cut_size": 225, 
             "library_name": "HNDHT HLH hnd-1 strain HT115 fed anti-hlh-1 2% fix plate a", 
             "creation_date": "2009-08-31", 
             "cell_line": null, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 225, 
+            "gel_cut_size": 225, 
             "library_name": "HNDM3 HLH hnd-1 strain mex-3 fed anti-hlh-1 2% fix plate a", 
             "creation_date": "2009-08-31", 
             "cell_line": null, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 225, 
+            "gel_cut_size": 225, 
             "library_name": "HNDM3 4H8 hnd-1 strain mex-3 fed 4H8 2% fix plate a", 
             "creation_date": "2009-08-31", 
             "cell_line": null, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 300, 
+            "gel_cut_size": 300, 
             "library_name": "Paired ends 105 Kuntz PDM3", 
             "creation_date": "2009-09-01", 
             "cell_line": 1, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 300, 
+            "gel_cut_size": 300, 
             "library_name": "Paired ends 96 Kuntz_PDE1", 
             "creation_date": "2009-08-25", 
             "cell_line": 1, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 300, 
+            "gel_cut_size": 300, 
             "library_name": "Paired ends 94 Gilberto_d3_denerv_LTA", 
             "creation_date": "2009-08-25", 
             "cell_line": 1, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 225, 
+            "gel_cut_size": 225, 
             "library_name": "p300 60h C2 FA KF 12/22/8 a", 
             "creation_date": "2009-08-26", 
             "cell_line": null, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 225, 
+            "gel_cut_size": 225, 
             "library_name": "p300 60h C2 FA KF 12/22/8 a", 
             "creation_date": "2009-08-26", 
             "cell_line": null, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 250, 
+            "gel_cut_size": 250, 
             "library_name": "FLDN1 7/8/9 anti-TriMeH3K27 chip B6 a", 
             "creation_date": "2009-08-26", 
             "cell_line": null, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 225, 
+            "gel_cut_size": 225, 
             "library_name": "HNDHT 4H8 hnd-1 strain HT115 fed 4H8 2% fix plate a", 
             "creation_date": "2009-08-31", 
             "cell_line": null, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 325, 
+            "gel_cut_size": 325, 
             "library_name": "Paired End SP-BAC Barcoding test 250-300 bp", 
             "creation_date": "2009-09-03", 
             "cell_line": 1, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 300, 
+            "gel_cut_size": 300, 
             "library_name": "Paired End AG-3d-1 AG domain of floral meristem day 3, rep 1", 
             "creation_date": "2009-09-02", 
             "cell_line": null, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 300, 
+            "gel_cut_size": 300, 
             "library_name": "Paired End AG-5d-1 AG domain of floral meristem day 5, rep 1", 
             "creation_date": "2009-09-02", 
             "cell_line": null, 
index 9329add350cf36dc14887dc68dd44981bcd8231d..40262618ef9e7e3cd1c6850ad291f7fdffb2260f 100755 (executable)
@@ -143,11 +143,17 @@ class DataRun(models.Model):
     return str
   Flowcell_Info.allow_tags = True
 
+LANE_STATUS_CODES = [(0, 'Failed'),
+                    (1, 'Marginal'),
+                    (2, 'Good'),]
+LANE_STATUS_MAP = dict((int(k),v) for k,v in LANE_STATUS_CODES )
+LANE_STATUS_MAP[None] = "Unknown"
 
 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)
+  cluster_estimate = models.IntegerField(blank=True, null=True)                                       
+  status = models.IntegerField(choices=LANE_STATUS_CODES, null=True, blank=True) 
   comment = models.TextField(null=True, blank=True)
index 9295175c3f0cfe43fb96ada1ab64bdcac4cdb8ac..393bfa253a19d5831f69780eb1c06a226e0b0007 100644 (file)
@@ -148,7 +148,7 @@ class LibraryOptions(admin.ModelAdmin):
           ('cell_line','condition','antibody'),)
          }),
          ('Creation Information:', {
-             'fields' : (('made_for', 'made_by', 'creation_date'), ('stopping_point', 'amplified_from_sample'), ('avg_lib_size','undiluted_concentration', 'ten_nM_dilution', 'successful_pM'), 'account_number', 'notes',)
+             'fields' : (('made_for', 'made_by', 'creation_date'), ('stopping_point', 'amplified_from_sample'), ('gel_cut_size', 'insert_size', 'undiluted_concentration', 'ten_nM_dilution', 'successful_pM'), 'account_number', 'notes',)
          }),
          ('Library/Project Affiliation:', {
              'fields' : (('affiliations'), ('tags'),)
index 9a549c5a02dc5d247bde3947706562fcae4b18f6..4dbf37167fa231ecfdb16ff391c7c59ace5c6293 100644 (file)
        "date_joined": "2009-01-01 00:01:01"
        }
    },
+ {"pk": 153, "model": "experiments.flowcell", 
+  "fields": {
+      "paired_end": true, 
+      "run_date": "2009-09-11 22:12:13", 
+      "read_length": 75, 
+      "notes": "",
+      "advanced_run": false,
+      "control_lane": 2,
+      "cluster_station": 3,
+      "sequencer": 2,
+      "flowcell_id": "303TUAAXX"
+      }
+  }, 
+  {"pk": 1193, "model": "experiments.lane",
+   "fields": {
+       "comment": "No change in cluster numbers, despite slight increase in pM",
+       "library": "10981",
+       "cluster_estimate": 129000,
+       "flowcell": 153,
+       "lane_number": 1,
+       "pM": "8"
+       }
+   }, 
+  {"pk": 1197, "model": "experiments.lane",
+   "fields": {
+       "comment": "stuff",
+       "library": "11016",
+       "cluster_estimate": 140000,
+       "flowcell": 153,
+       "lane_number": 5,
+       "pM": "7",
+       "status": 2
+       }
+   }, 
   {"pk": "10981", "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 400, 
+            "gel_cut_size": 400, 
             "library_name": "Paired End Multiplexed Sp-BAC", 
             "creation_date": "2009-07-21", 
             "cell_line": 1, 
@@ -47,7 +81,7 @@
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 325, 
+            "gel_cut_size": 325, 
             "library_name": "Paired End Pfl #3 MP 7/24/9 a", 
             "creation_date": "2009-08-06", 
             "cell_line": 1, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 300, 
+            "gel_cut_size": 300, 
             "library_name": "Paired ends 99 GM12892", 
             "creation_date": "2009-08-25", 
             "cell_line": 1, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 325, 
+            "gel_cut_size": 325, 
             "library_name": "Paired End Pfl #3 MP 7/24/9", 
             "creation_date": "2009-08-05", 
             "cell_line": 1, 
         "model": "samples.library", 
         "fields": {
             "ten_nM_dilution": false, 
-            "avg_lib_size": 325, 
+            "gel_cut_size": 325, 
             "library_name": "null cell line", 
             "creation_date": "2009-08-05", 
             "cell_line": null, 
index cce961918138a1e7f57a1f300be3f3078d594159..b6fb4ebcf052cd6eaa9538b32909e7940f65510f 100644 (file)
@@ -174,7 +174,8 @@ class Library(models.Model):
       # note \u00b5 is the micro symbol in unicode
   successful_pM = models.DecimalField(max_digits=9, decimal_places=1, blank=True, null=True)
   ten_nM_dilution = models.BooleanField()
-  avg_lib_size = models.IntegerField(default=225, blank=True, null=True)
+  gel_cut_size = models.IntegerField(default=225, blank=True, null=True)
+  insert_size = models.IntegerField(blank=True, null=True)
   notes = models.TextField(blank=True)
   
   def __unicode__(self):
index d1689f1968700aa5a00b85474dc4643075c3de2d..6f5182bb28687f31258d7121623c20f9b0d1e0e3 100644 (file)
@@ -21,83 +21,7 @@ from htsworkflow.frontend.samples.views import \
 from htsworkflow.frontend.auth import apidata
 from htsworkflow.util.conversion import unicode_or_none
 
-# The django test runner flushes the database between test suites not cases,
-# so to be more compatible with running via nose we flush the database tables
-# of interest before creating our sample data.
-def create_db(obj):
-    Species.objects.all().delete()
-    obj.species_human = Species(
-        scientific_name = 'Homo Sapeins',
-        common_name = 'human',
-    )
-    obj.species_human.save()
-    obj.species_worm = Species(
-        scientific_name = 'C. Elegans',
-        common_name = 'worm',
-    )
-    obj.species_worm.save()
-    obj.species_phix = Species(
-        scientific_name = 'PhiX',
-        common_name = 'PhiX'
-    )
-    obj.species_phix.save()
-
-    ExperimentType.objects.all().delete()
-    obj.experiment_de_novo = ExperimentType(
-        name = 'De Novo',
-    )
-    obj.experiment_de_novo.save()
-    obj.experiment_chip_seq = ExperimentType(
-        name = 'ChIP-Seq'
-    )
-    obj.experiment_chip_seq.save()
-    obj.experiment_rna_seq = ExperimentType(
-        name = 'RNA-Seq'
-    )
-    obj.experiment_rna_seq.save()
-
-    Affiliation.objects.all().delete()
-    obj.affiliation_alice = Affiliation(
-        name = 'Alice',
-        contact = 'Lab Boss',
-        email = 'alice@some.where.else.'
-    )
-    obj.affiliation_alice.save()
-    obj.affiliation_bob = Affiliation(
-        name = 'Bob',
-        contact = 'Other Lab Boss',
-        email = 'bob@some.where.else',
-    )
-    obj.affiliation_bob.save()
 
-    Library.objects.all().delete()
-    obj.library_10001 = Library(
-        id = "10001",
-        library_name = 'C2C12 named poorly',
-        library_species = obj.species_human,
-        experiment_type = obj.experiment_rna_seq,
-        creation_date = datetime.datetime.now(),
-        made_for = 'scientist unit 2007',
-        made_by = 'microfludics system 7321',
-        stopping_point = '2A',
-        undiluted_concentration = '5.01',
-        hidden = False,
-    )
-    obj.library_10001.save()
-    obj.library_10002 = Library(
-        id = "10002",
-        library_name = 'Worm named poorly',
-        library_species = obj.species_human,
-        experiment_type = obj.experiment_rna_seq,
-        creation_date = datetime.datetime.now(),
-        made_for = 'scientist unit 2007',
-        made_by = 'microfludics system 7321',
-        stopping_point = '2A',
-        undiluted_concentration = '5.01',
-        hidden = False,
-    )
-    obj.library_10002.save()
 class LibraryTestCase(TestCase):
     def setUp(self):
         create_db(self)
@@ -117,6 +41,7 @@ class LibraryTestCase(TestCase):
         self.failUnless(len(self.library_10002.affiliations.all()), 2)
         self.failUnless(self.library_10001.affiliation(), 'Alice, Bob')
 
+
 class SampleWebTestCase(TestCase):
     """
     Test returning data from our database in rest like ways.
@@ -132,6 +57,7 @@ class SampleWebTestCase(TestCase):
             lib_response = self.client.get(url, apidata)
             self.failUnlessEqual(lib_response.status_code, 200)
             lib_json = json.loads(lib_response.content)
+            print lib_json
 
             for d in [lib_dict, lib_json]:
                 # amplified_from_sample is a link to the library table,
@@ -141,13 +67,14 @@ class SampleWebTestCase(TestCase):
                 # since amplified_from_sample can be null
                 #self.failUnlessEqual(d['amplified_from_sample'], lib.amplified_from_sample)
                 self.failUnlessEqual(d['antibody_id'], lib.antibody_id)
-                self.failUnlessEqual(d['avg_lib_size'], lib.avg_lib_size)
                 self.failUnlessEqual(d['cell_line_id'], lib.cell_line_id)
                 self.failUnlessEqual(d['cell_line'], unicode_or_none(lib.cell_line))
                 self.failUnlessEqual(d['experiment_type'], lib.experiment_type.name)
                 self.failUnlessEqual(d['experiment_type_id'], lib.experiment_type_id)
+                self.failUnlessEqual(d['gel_cut_size'], lib.gel_cut_size)
                 self.failUnlessEqual(d['hidden'], lib.hidden)
                 self.failUnlessEqual(d['id'], lib.id)
+                self.failUnlessEqual(d['insert_size'], lib.insert_size)
                 self.failUnlessEqual(d['library_name'], lib.library_name)
                 self.failUnlessEqual(d['library_species'], lib.library_species.scientific_name)
                 self.failUnlessEqual(d['library_species_id'], lib.library_species_id)
@@ -164,6 +91,17 @@ class SampleWebTestCase(TestCase):
                     self.failUnlessEqual(d['successful_pM'], lib.successful_pM)
                     self.failUnlessEqual(d['undiluted_concentration'],
                                          unicode(lib.undiluted_concentration))
+                # some specific tests
+                if lib.id == '10981':
+                    # test a case where there is no known status
+                    lane_set = {u'status': u'Unknown', u'lane_number': 1, u'flowcell': u'303TUAAXX', u'status_code': None}
+                    self.failUnlessEqual(len(d['lane_set']), 1)
+                    self.failUnlessEqual(d['lane_set'][0], lane_set)
+                elif lib.id == '11016':
+                    # test a case where there is a status
+                    lane_set = {'status': 'Good', 'lane_number': 5, 'flowcell': u'303TUAAXX', 'status_code': 2}
+                    self.failUnlessEqual(len(d['lane_set']), 1)
+                    self.failUnlessEqual(d['lane_set'][0], lane_set)
 
     def test_invalid_library(self):
         """
@@ -181,3 +119,81 @@ class SampleWebTestCase(TestCase):
         self.failUnlessEqual(response.status_code, 403)
         response = self.client.get('/samples/library/10981/json', apidata)
         self.failUnlessEqual(response.status_code, 200)
+
+# The django test runner flushes the database between test suites not cases,
+# so to be more compatible with running via nose we flush the database tables
+# of interest before creating our sample data.
+def create_db(obj):
+    Species.objects.all().delete()
+    obj.species_human = Species(
+        scientific_name = 'Homo Sapeins',
+        common_name = 'human',
+    )
+    obj.species_human.save()
+    obj.species_worm = Species(
+        scientific_name = 'C. Elegans',
+        common_name = 'worm',
+    )
+    obj.species_worm.save()
+    obj.species_phix = Species(
+        scientific_name = 'PhiX',
+        common_name = 'PhiX'
+    )
+    obj.species_phix.save()
+
+    ExperimentType.objects.all().delete()
+    obj.experiment_de_novo = ExperimentType(
+        name = 'De Novo',
+    )
+    obj.experiment_de_novo.save()
+    obj.experiment_chip_seq = ExperimentType(
+        name = 'ChIP-Seq'
+    )
+    obj.experiment_chip_seq.save()
+    obj.experiment_rna_seq = ExperimentType(
+        name = 'RNA-Seq'
+    )
+    obj.experiment_rna_seq.save()
+
+    Affiliation.objects.all().delete()
+    obj.affiliation_alice = Affiliation(
+        name = 'Alice',
+        contact = 'Lab Boss',
+        email = 'alice@some.where.else.'
+    )
+    obj.affiliation_alice.save()
+    obj.affiliation_bob = Affiliation(
+        name = 'Bob',
+        contact = 'Other Lab Boss',
+        email = 'bob@some.where.else',
+    )
+    obj.affiliation_bob.save()
+
+    Library.objects.all().delete()
+    obj.library_10001 = Library(
+        id = "10001",
+        library_name = 'C2C12 named poorly',
+        library_species = obj.species_human,
+        experiment_type = obj.experiment_rna_seq,
+        creation_date = datetime.datetime.now(),
+        made_for = 'scientist unit 2007',
+        made_by = 'microfludics system 7321',
+        stopping_point = '2A',
+        undiluted_concentration = '5.01',
+        hidden = False,
+    )
+    obj.library_10001.save()
+    obj.library_10002 = Library(
+        id = "10002",
+        library_name = 'Worm named poorly',
+        library_species = obj.species_human,
+        experiment_type = obj.experiment_rna_seq,
+        creation_date = datetime.datetime.now(),
+        made_for = 'scientist unit 2007',
+        made_by = 'microfludics system 7321',
+        stopping_point = '2A',
+        undiluted_concentration = '5.01',
+        hidden = False,
+    )
+    obj.library_10002.save()
index 3b8feccfafd2dec7b4fec09990d8ffd1cfc7439a..20b6837ea41f4f6f7e9564daba0ee0e169be5551 100644 (file)
@@ -10,7 +10,7 @@ except ImportError, e:
     import simplejson as json
 
 from htsworkflow.frontend.auth import require_api_key
-from htsworkflow.frontend.experiments.models import FlowCell, Lane
+from htsworkflow.frontend.experiments.models import FlowCell, Lane, LANE_STATUS_MAP
 from htsworkflow.frontend.samples.changelist import ChangeList
 from htsworkflow.frontend.samples.models import Library, HTSUser
 from htsworkflow.frontend.samples.results import get_flowcell_result_dict, parse_flowcell_id
@@ -512,7 +512,9 @@ def library_dict(library_id):
     lane_info = []
     for lane in lib.lane_set.all():
         lane_info.append( {'flowcell':lane.flowcell.flowcell_id,
-                           'lane_number': lane.lane_number} )
+                           'lane_number': lane.lane_number,
+                           'status_code': lane.status,
+                           'status': LANE_STATUS_MAP[lane.status]} )
         
     info = {
         # 'affiliations'?
@@ -521,13 +523,14 @@ def library_dict(library_id):
         #'amplified_from_sample_id': lib.amplified_from_sample, 
         #'antibody_name': lib.antibody_name(), # we have no antibodies.
         'antibody_id': lib.antibody_id,
-        'avg_lib_size': lib.avg_lib_size,
         'cell_line_id': lib.cell_line_id,
         'cell_line': unicode_or_none(lib.cell_line),
         'experiment_type': lib.experiment_type.name,
         'experiment_type_id': lib.experiment_type_id,
+        'gel_cut_size': lib.gel_cut_size,
         'hidden': lib.hidden,
         'id': lib.id,
+        'insert_size': lib.insert_size,
         'lane_set': lane_info,
         'library_id': lib.id,
         'library_name': lib.library_name,
index fb43753b064fd53e5de06202fc44393f9eec40de..103b0451e8ad5254c7162953ff6b676e150ab1c5 100644 (file)
@@ -60,9 +60,9 @@ TD
 
 <tr><td valign=middle nowrap>First time run?</td><td bgcolor=#CCFFCC></td><td bgcolor=#CCFFCC></td><td bgcolor=#CCFFCC></td><td bgcolor=#CCFFCC></td><td bgcolor=#CCFFCC></td><td bgcolor=#CCFFCC></td><td bgcolor=#CCFFCC></td><td bgcolor=#CCFFCC></td></tr>
 
-<tr><td valign=middle nowrap>Average Library Size (bp)</td>
+<tr><td valign=middle nowrap>Gel Cut Size (bp)</td>
 {% for lane in fc.lane_set.all %}
-<td bgcolor=#CCFFCC>{{ lane.library.avg_lib_size }}</td>
+<td bgcolor=#CCFFCC>{{ lane.library.gel_cut_size }}</td>
 {% endfor %}
 </tr>  
 
index ac100ee987153f0dbc59101b47fd06d34fd5e1b1..26eba6887f82ff7a91e7952f187d9f4dbd8b92bc 100644 (file)
@@ -54,7 +54,8 @@
   <b>Name</b>: {{ lib.library_name }}<br/>
   <b>Species</b>: {{ lib.library_species.scientific_name }}<br/>
   <b>Concentration</b>: {{ lib.undiluted_concentration }} ng/µl<br/>
-  <b>Gel Cut Size</b>: {{ lib.avg_lib_size }}<br/>
+  <b>Gel Cut Size</b>: {{ lib.gel_cut_size }}<br/>
+  <b>Insert Size</b>: {{ lib.insert_size }}<br/>
   <b>Made By</b>: {{ lib.made_by }} <br/>
   <b>Affiliations</b>:
   <ul>