Turn the library_id back into the primary key for samples_library (SCHEMA CHANGE!)
authorDiane Trout <diane@caltech.edu>
Tue, 27 Oct 2009 22:07:44 +0000 (22:07 +0000)
committerDiane Trout <diane@caltech.edu>
Tue, 27 Oct 2009 22:07:44 +0000 (22:07 +0000)
Trying to make it possible to enter the 'library_id' instead of the
arbitrary auto-incrementing key when creating a flowcell was turning out
to be far too time consuming.

It was vastly easier to decide that the 'library id' was a sufficiently
unique short value that it could be used directly as the primary key.
Its now a char 10 field, unlike the integer primary key to support
stanford style library IDs like SL123.

Its possible to convert the previous database version to one compatible with
this code by running docs/conv_library_id_to_pk_v0.3.1.py

18 files changed:
docs/conv_library_id_to_pk_v0.3.1.py [new file with mode: 0644]
htsworkflow/frontend/analysis/admin.py
htsworkflow/frontend/analysis/main.py
htsworkflow/frontend/analysis/models.py
htsworkflow/frontend/eland_config/views.py
htsworkflow/frontend/experiments/admin.py
htsworkflow/frontend/experiments/experiments.py
htsworkflow/frontend/experiments/fixtures/test_flowcells.json
htsworkflow/frontend/experiments/tests.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/experiments/started_email.html
htsworkflow/frontend/templates/experiments/started_email.txt
htsworkflow/frontend/templates/samples/library_detail.html

diff --git a/docs/conv_library_id_to_pk_v0.3.1.py b/docs/conv_library_id_to_pk_v0.3.1.py
new file mode 100644 (file)
index 0000000..125e7b4
--- /dev/null
@@ -0,0 +1,194 @@
+import sqlite3
+
+def map_library_ids(c):
+    lib_ids = {}
+    c.execute("""select id, library_id from samples_library""")
+    for row in c:
+        surrogate_id = unicode(row[0]) # auto key
+        artificial_id = unicode(row[1]) # the id printed on the library tubes
+        lib_ids[surrogate_id] = artificial_id
+    return lib_ids
+
+def convert_experiments_lane(c, lib_ids):
+    """
+    Change Library ID in experiments_lane table
+    """
+    c.execute('alter table experiments_lane rename to old_experiments_lane')
+    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" ("library_id"),
+    "pM" decimal NOT NULL,
+    "cluster_estimate" integer,
+    "comment" text);""")
+
+    c.execute("""select id, flowcell_id, lane_number, library_id, pM, cluster_estimate, comment
+                 from old_experiments_lane;""")
+
+    new_rows = []
+    for row in c:
+        new_rows.append({'id':row[0], 'flowcell_id':row[1], 'lane_number':row[2],
+                         'library_id':lib_ids[unicode(row[3])], 'pM':row[4],
+                         'cluster_estimate':row[5],
+                         'comment':row[6]})
+
+    sql = '''insert into experiments_lane
+        (id, flowcell_id, lane_number, library_id, pM, cluster_estimate, comment)
+        values
+        (:id, :flowcell_id, :lane_number, :library_id, :pM, :cluster_estimate, :comment)'''
+    c.executemany(sql, new_rows)
+
+    c.execute('drop table old_experiments_lane')
+
+def convert_samples_library_affiliations(c, lib_ids):
+    """
+    Change Library ID in experiments_lane table
+    """
+    c.execute('alter table samples_library_affiliations rename to old_samples_library_affiliations')
+    c.execute('''CREATE TABLE "samples_library_affiliations" (
+    "id" integer NOT NULL PRIMARY KEY,
+    "library_id" varchar(10) NOT NULL REFERENCES "samples_library" ("id"),
+    "affiliation_id" integer NOT NULL REFERENCES "samples_affiliation" ("id"),
+    UNIQUE ("library_id", "affiliation_id")
+);''')
+
+    c.execute("""select id, library_id, affiliation_id
+                 from old_samples_library_affiliations;""")
+
+    new_rows = []
+    for row in c:
+        new_rows.append({'id':row[0], 'library_id': lib_ids[unicode(row[1])], 'affiliation_id':row[2],})
+
+    sql = '''insert into samples_library_affiliations
+        (id, library_id, affiliation_id)
+        values
+        (:id, :library_id, :affiliation_id)'''
+    c.executemany(sql, new_rows)
+
+    c.execute('drop table old_samples_library_affiliations;')
+
+def convert_samples_library_tags(c, lib_ids):
+    """
+    Change Library ID in samples_library_tags table
+    """
+    c.execute('alter table samples_library_tags rename to old_samples_library_tags')
+    c.execute('''CREATE TABLE "samples_library_tags" (
+    "id" integer NOT NULL PRIMARY KEY,
+    "library_id" varchar(10) NOT NULL REFERENCES "samples_library" ("id"),
+    "tag_id" integer NOT NULL REFERENCES "samples_tag" ("id"),
+    UNIQUE ("library_id", "tag_id")
+);''')
+
+    c.execute("""select id, library_id, tag_id
+                 from old_samples_library_tags;""")
+
+    new_rows = []
+    for row in c:
+        new_rows.append({'id':row[0], 'library_id': lib_ids[unicode(row[1])], 'tag_id':row[2]})
+
+    sql = '''insert into samples_library_tags
+        (id, library_id, tag_id)
+        values
+        (:id, :library_id, :tag_id)'''
+    c.executemany(sql, new_rows)
+
+    c.execute('drop table old_samples_library_tags;')    
+
+
+def convert_samples_library(c, lib_ids):
+    """
+    Change Library ID in samples_library_tags table
+    """
+    c.execute('alter table samples_library rename to old_samples_library')
+    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),
+    "cell_line_id" integer REFERENCES "samples_cellline" ("id"),
+    "condition_id" integer REFERENCES "samples_condition" ("id"),
+    "antibody_id" integer REFERENCES "samples_antibody" ("id"),
+    "replicate" smallint unsigned NOT NULL,
+    "experiment_type_id" integer NOT NULL REFERENCES "samples_experimenttype" ("id"),
+    "library_type_id" integer REFERENCES "samples_librarytype" ("id"),
+    "creation_date" date,
+    "made_for" varchar(50) NOT NULL,
+    "made_by" varchar(50) NOT NULL,
+    "stopping_point" varchar(25) NOT NULL,
+    "amplified_from_sample_id" varchar(10),
+    "undiluted_concentration" decimal,
+    "successful_pM" decimal,
+    "ten_nM_dilution" bool NOT NULL,
+    "avg_lib_size" integer,
+    "notes" text NOT NULL
+);''')
+
+    c.execute("""
+    select 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, avg_lib_size, notes
+    from old_samples_library;""")
+
+    new_rows = []
+    for row in c:
+        new_rows.append({
+        'id': row[0],
+        'library_name': row[1],
+        'library_species_id': row[2],
+        'hidden': row[3],
+        'account_number': row[4],
+        'cell_line_id': row[5],
+        'condition_id': row[6],
+        'antibody_id': row[7],
+        'replicate': row[8],
+        'experiment_type_id': row[9],
+        'library_type_id': row[10],
+        'creation_date': row[11],
+        'made_for': row[12],
+        'made_by': row[13],
+        'stopping_point': row[14],
+        'amplified_from_sample_id': row[15],
+        'undiluted_concentration': row[16],
+        'successful_pM': row[17],
+        'ten_nM_dilution': row[18],
+        'avg_lib_size': row[19],
+        'notes': row[20],
+            })
+
+    sql = '''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, avg_lib_size, notes)
+        values
+        (: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);
+         '''
+    c.executemany(sql, new_rows)
+
+    c.execute('drop table old_samples_library;')
+
+def convert_library_id(db_path):
+    conn = sqlite3.connect(db_path)
+    c = conn.cursor()
+
+    lib_ids = map_library_ids(c)
+
+    convert_experiments_lane(c, lib_ids)
+    convert_samples_library_affiliations(c, lib_ids)
+    convert_samples_library_tags(c, lib_ids)
+    convert_samples_library(c, lib_ids)
+    
+    conn.commit()
+
+def main():
+    db_path = '/Users/diane/proj/solexa/gaworkflow/svn/woldlab.db'
+    convert_library_id(db_path)
+
+if __name__ == "__main__":
+    main()
index d3f903ec9f013fd52b6cc218e25c5fad8de29813..87a8a8122ef32356ccadacd1e919555c213f2eb1 100644 (file)
@@ -5,7 +5,7 @@ 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']
+  search_fieldsets = ['project_name','=tasks__subject1__id','=tasks__subject2__id','tasks__subject1__library_name','tasks__subject2__library_name','project_notes']
   fieldsets = (
     (None, {
       'fields': (('project_name'),('tasks'),('project_notes'))}),
@@ -15,7 +15,7 @@ class ProjectOptions(admin.ModelAdmin):
 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']
+  search_fieldsets = ['task_name','id','=subject1__id','=subject2__id']
   fieldsets = (
       (None, {
         'fields': (('task_name'),('apply_calc'),('subject1'),('subject2'),('task_params'))
index b5217dc3b41a7e6f2b1778ecf53cf61fbff29b52..b57ad2050dcbca68c1b476d48570a3b2204fe715 100644 (file)
@@ -67,9 +67,9 @@ def getProjects(request):
           if (t.apply_calc == 'QuEST' or t.apply_calc == 'WingPeaks' or t.apply_calc == 'MACS'):
             outputfile += '\n<PeakCalling TaskId="'+t.id.__str__()+'" Name="'+t.task_name+'" Caller="'+t.apply_calc+'" Genome="'+t.subject1.library_species.use_genome_build+'">'
             if t.subject1:
-              outputfile += '\n<Signal Library="'+t.subject1.library_id+'"/>'
+              outputfile += '\n<Signal Library="'+t.subject1.id+'"/>'
               if t.subject2:
-                outputfile += '\n<Background Library="'+t.subject2.library_id+'"/>'
+                outputfile += '\n<Background Library="'+t.subject2.id+'"/>'
               else:
                 outputfile += '\n<Err>Background Library Missing</Err>'
             else:
@@ -80,9 +80,9 @@ def getProjects(request):
           if (t.apply_calc == 'Methylseq'):
             outputfile += '\n<Methylseq TaskId="'+t.id.__str__()+'" Name="'+t.task_name+'" Genome="'+t.subject1.library_species.use_genome_build+'">'
             if t.subject1:
-              outputfile += '\n<Hpa2 Library="'+t.subject1.library_id+'"/>'
+              outputfile += '\n<Hpa2 Library="'+t.subject1.id+'"/>'
               if t.subject2:
-                outputfile += '\n<Msp1 Library="'+t.subject2.library_id+'"/>'
+                outputfile += '\n<Msp1 Library="'+t.subject2.id+'"/>'
               else:
                 outputfile += '\n<Err>Msp1 Library Missing</Err>'
             else:
@@ -91,16 +91,16 @@ def getProjects(request):
             outputfile += '\n</Methylseq>' 
 
           if (t.apply_calc == 'ProfileReads' or t.apply_calc == 'qPCR'):
-            outputfile += '\n<'+t.apply_calc+' TaskId="'+t.id.__str__()+'" Name="'+t.task_name+'" Genome="'+t.subject1.library_species.use_genome_build+'" Library="'+t.subject1.library_id+'"/>'
+            outputfile += '\n<'+t.apply_calc+' TaskId="'+t.id.__str__()+'" Name="'+t.task_name+'" Genome="'+t.subject1.library_species.use_genome_build+'" Library="'+t.subject1.id+'"/>'
 
           if (t.apply_calc == 'CompareLibs'):
             outputfile += '\n<CompareLibraries TaskId="'+t.id.__str__()+'" TF="'+t.task_name+'" Genome="'+t.subject1.library_species.use_genome_build+'">'
             if t.subject1:
-              outputfile += '\n<Library Library="'+t.subject1.library_id+'"/>'
+              outputfile += '\n<Library Library="'+t.subject1.id+'"/>'
             else:
               outputfile += '\n<Err>Library Missing</Err>'
             if t.subject2:
-              outputfile += '\n<Library Library="'+t.subject2.library_id+'"/>'
+              outputfile += '\n<Library Library="'+t.subject2.id+'"/>'
             else:
               outputfile += '\n<Err>Library Missing</Err>'
             outputfile += '\n<params>'+t.task_params.__str__()+'</params>'
index e2ddff489b4e5a2f3b71f4bf68671394ad4498a6..41ecf424bc2d29902ce076e55bafad0feefbb792 100644 (file)
@@ -67,9 +67,9 @@ class Project(models.Model):
       tstr += '<table><tr><th>Tasks</th><th>Job Status</th>'
       isregistered = False
       for t in ptasks:
-        taskdesc = t.task_name+'<div style="font-size:80%">Details: '+t.apply_calc+' on '+t.subject1.library_id
+        taskdesc = t.task_name+'<div style="font-size:80%">Details: '+t.apply_calc+' on '+t.subject1.id
         if t.subject2 is not None:
-          taskdesc += ' and '+t.subject2.library_id
+          taskdesc += ' and '+t.subject2.id
         taskdesc += ' (TaskId:'+t.id.__str__()+')'
         tstr += '<tr><td width=250>%s</td><td>%s</td></tr>'  % (taskdesc,replace(t.task_status,'Complete','<span style="color:green;font-weight:bolder">Complete</span>'))
         if t.task_status != 'defined': isregistered = True
index 994a410cb5a3982472d465d5f0fad4d5ec85f7ee..6169f8a8d0e7b17dd8302a3fe58a92028f6db4c7 100644 (file)
@@ -273,7 +273,7 @@ def getElandConfig(flowcell, regenerate=False):
   #Convert all newline conventions to unix style
   for lane in fcObj.lane_set.all():
     data.append("# Lane%d: %s | %s" % \
-      (lane.lane_number, unicode(lane.library.library_id),  lane.library.library_name.replace('%', '%%')))
+      (lane.lane_number, unicode(lane.library.id),  lane.library.library_name.replace('%', '%%')))
   
   #data.append("GENOME_DIR %s" % (BASE_DIR))
   #data.append("CONTAM_DIR %s" % (BASE_DIR))
index ca3f7308f5827105643d2aed2f7be0c5a8801a4b..0f00d0eea8732e7614c520f708e92c5665376dfd 100644 (file)
@@ -11,14 +11,14 @@ class DataRunOptions(admin.ModelAdmin):
       'run_folder',
       'run_note',
       'config_params',
-      '=fcid__lane_1_library__library_id',
-      '=fcid__lane_2_library__library_id',
-      '=fcid__lane_3_library__library_id',
-      '=fcid__lane_4_library__library_id',
-      '=fcid__lane_5_library__library_id',
-      '=fcid__lane_6_library__library_id',
-      '=fcid__lane_7_library__library_id',
-      '=fcid__lane_8_library__library_id'
+      '=fcid__lane_1_library__id',
+      '=fcid__lane_2_library__id',
+      '=fcid__lane_3_library__id',
+      '=fcid__lane_4_library__id',
+      '=fcid__lane_5_library__id',
+      '=fcid__lane_6_library__id',
+      '=fcid__lane_7_library__id',
+      '=fcid__lane_8_library__id'
       'fcid__lane_1_library__library_name',
       'fcid__lane_2_library__library_name',
       'fcid__lane_3_library__library_name',
@@ -85,7 +85,7 @@ class FlowCellOptions(admin.ModelAdmin):
     search_fields = ('flowcell_id',
         'sequencer__name',
         'cluster_station__name',
-        '=lane__library__library_id',
+        '=lane__library__id',
         'lane__library__library_name')
     list_display = ('flowcell_id','run_date','Lanes')
     list_filter = ('sequencer','cluster_station')
@@ -94,7 +94,7 @@ class FlowCellOptions(admin.ModelAdmin):
             'fields': ('run_date', ('flowcell_id','cluster_station','sequencer'), ('read_length', 'control_lane', 'paired_end'),)
         }),
         #('Lanes:', {
-        #   'fields' : (('lane__library__library_id', 'lane__pM', 'lane__cluster_estimate'),)
+        #   'fields' : (('lane__library__id', 'lane__pM', 'lane__cluster_estimate'),)
         #}),
         ('Notes:', { 'fields': ('notes',),}),
     )
index e9a7ab760100b6846e48f1517484ef2c5e762b48..7e6c7343faec43204ef0640f99cb2d85d4ea2ef4 100755 (executable)
@@ -37,7 +37,7 @@ def flowcell_information(flowcell_id):
             'flowcell': lane.flowcell.flowcell_id,
             'lane_number': int(lane.lane_number),
             'library_name': lane.library.library_name,
-            'library_id': lane.library.library_id,
+            'library_id': lane.library.id,
             'library_species': lane.library.library_species.scientific_name,
             'pM': float(lane.pM),
             'read_length': fc.read_length
@@ -225,14 +225,14 @@ def getLaneLibs(req):
         mydate = year+month+day
         outputfile = '<?xml version="1.0" ?>'
         outputfile += '\n<SolexaResult Date="'+mydate+'" Flowcell="'+fcid+'" Client="'+settings.ALLOWED_IPS[ClIP]+'">'
-        outputfile += '\n<Lane Index="1" Name="'+rec.lane_1_library.library_name+'" Library="'+rec.lane_1_library.library_id+'" Genome="'+rec.lane_1_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
-        outputfile += '\n<Lane Index="2" Name="'+rec.lane_2_library.library_name+'" Library="'+rec.lane_2_library.library_id+'" Genome="'+rec.lane_2_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
-        outputfile += '\n<Lane Index="3" Name="'+rec.lane_3_library.library_name+'" Library="'+rec.lane_3_library.library_id+'" Genome="'+rec.lane_3_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
-        outputfile += '\n<Lane Index="4" Name="'+rec.lane_4_library.library_name+'" Library="'+rec.lane_4_library.library_id+'" Genome="'+rec.lane_4_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
-        outputfile += '\n<Lane Index="5" Name="'+rec.lane_5_library.library_name+'" Library="'+rec.lane_5_library.library_id+'" Genome="'+rec.lane_5_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
-        outputfile += '\n<Lane Index="6" Name="'+rec.lane_6_library.library_name+'" Library="'+rec.lane_6_library.library_id+'" Genome="'+rec.lane_6_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
-        outputfile += '\n<Lane Index="7" Name="'+rec.lane_7_library.library_name+'" Library="'+rec.lane_7_library.library_id+'" Genome="'+rec.lane_7_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
-        outputfile += '\n<Lane Index="8" Name="'+rec.lane_8_library.library_name+'" Library="'+rec.lane_8_library.library_id+'" Genome="'+rec.lane_8_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+        outputfile += '\n<Lane Index="1" Name="'+rec.lane_1_library.library_name+'" Library="'+rec.lane_1_library.id+'" Genome="'+rec.lane_1_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+        outputfile += '\n<Lane Index="2" Name="'+rec.lane_2_library.library_name+'" Library="'+rec.lane_2_library.id+'" Genome="'+rec.lane_2_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+        outputfile += '\n<Lane Index="3" Name="'+rec.lane_3_library.library_name+'" Library="'+rec.lane_3_library.id+'" Genome="'+rec.lane_3_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+        outputfile += '\n<Lane Index="4" Name="'+rec.lane_4_library.library_name+'" Library="'+rec.lane_4_library.id+'" Genome="'+rec.lane_4_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+        outputfile += '\n<Lane Index="5" Name="'+rec.lane_5_library.library_name+'" Library="'+rec.lane_5_library.id+'" Genome="'+rec.lane_5_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+        outputfile += '\n<Lane Index="6" Name="'+rec.lane_6_library.library_name+'" Library="'+rec.lane_6_library.id+'" Genome="'+rec.lane_6_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+        outputfile += '\n<Lane Index="7" Name="'+rec.lane_7_library.library_name+'" Library="'+rec.lane_7_library.id+'" Genome="'+rec.lane_7_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
+        outputfile += '\n<Lane Index="8" Name="'+rec.lane_8_library.library_name+'" Library="'+rec.lane_8_library.id+'" Genome="'+rec.lane_8_library.library_species.use_genome_build+'" PrimerName="" PrimerSeq=""/>'
         outputfile += '\n</SolexaResult>'
       except ObjectDoesNotExist:
         outputfile = 'Flowcell entry not found for: '+fcid
index 698813fdf7de4d07522e9c7fba23feee95bc2b3b..41c59f5ccf4f4f5c8ee23d6e6c3ea4b669083246 100644 (file)
   {"pk": 1193, "model": "experiments.lane",
    "fields": {
        "comment": "No change in cluster numbers, despite slight increase in pM",
-       "library": 10984,
+       "library": "10981",
        "cluster_estimate": 129000,
        "flowcell": 153,
        "lane_number": 1,
        "pM": "8"
        }
    }, 
-  {"pk": 10984, "model": "samples.library", 
+  {"pk": "10981", "model": "samples.library", 
         "fields": {
-            "library_id": "10981", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 400, 
             "library_name": "Paired End Multiplexed Sp-BAC", 
   {"pk": 1194, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11019,
+       "library": "11016",
        "cluster_estimate": 152000,
        "flowcell": 153,
        "lane_number": 2,
        }
    }, 
     {
-        "pk": 11019
+        "pk": "11016"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11016", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 325, 
             "library_name": "Paired End Pfl #3 MP 7/24/9 a", 
   {"pk": 1195, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11042,
+       "library": "SL039",
        "cluster_estimate": 162000,
        "flowcell": 153,
        "lane_number": 3,
        }
    },  
     {
-        "pk": 11042
+        "pk": "SL039"
         "model": "samples.library", 
         "fields": {
-            "library_id": "SL039", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 300, 
             "library_name": "Paired ends 99 GM12892", 
   {"pk": 1196, "model": "experiments.lane",
    "fields": {
        "comment": "This lane's library had the second lowest concentration of all the libraries built at the same time (2.05ng/ul)",
-       "library": 11063,
+       "library": "11060",
        "cluster_estimate": 24000,
        "flowcell": 153,
        "lane_number": 4,
        }
    }, 
     {
-        "pk": 11063
+        "pk": "11060"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11060", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 300, 
             "library_name": "Paired ends 100 VC_CN_4_M_MBB1185_s1", 
   {"pk": 1197, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11064,
+       "library": "11061",
        "cluster_estimate": 140000,
        "flowcell": 153,
        "lane_number": 5,
        }
    }, 
     {
-        "pk": 11064
+        "pk": "11061"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11061", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 300, 
             "library_name": "Paired ends 101 VC_CN_4_M_MBB1185_s2", 
   {"pk": 1198, "model": "experiments.lane",
    "fields": {
        "comment": "This lane's library had the lowest concentration of all the libraries built at the same time (1.2ng/ul)",
-       "library": 11065,
+       "library": "11062",
        "cluster_estimate": 2000,
        "flowcell": 153,
        "lane_number": 6,
        }
    }, 
     {
-        "pk": 11065
+        "pk": "11062"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11062", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 300, 
             "library_name": "Paired ends 102 VC_AU_8_M_MBB4721_s1", 
   {"pk": 1199, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11066,
+       "library": "11063",
        "cluster_estimate": 120000,
        "flowcell": 153,
        "lane_number": 7,
        }
    }, 
     {
-        "pk": 11066
+        "pk": "11063"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11063", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 300, 
             "library_name": "Paired ends 103 VC_AU_8_M_MBB4721_s2", 
   {"pk": 1200, "model": "experiments.lane",
    "fields": {
        "comment": "This lane's library had the third lowest concentration of all the libraries built at the same time (5.21ng/ul), but gave perfectly normal cluster numbers",
-       "library": 11067,
+       "library": "11064",
        "cluster_estimate": 157000,
        "flowcell": 153,
        "lane_number": 8,
        }
    },
     {
-        "pk": 11067
+        "pk": "11064"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11064", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 300, 
             "library_name": "Paired ends 104 VC_CN_7_M_MBB4898_s1", 
   {"pk": 1185, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11038,
+       "library": "11035",
        "cluster_estimate": 174000,
        "flowcell": 152,
        "lane_number": 1,
        }
    },
     {
-        "pk": 11038
+        "pk": "11035"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11035", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 300, 
             "library_name": "Paired ends 95 Gilberto_d3_control_LTA", 
   {"pk": 1186, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11040,
+       "library": "11037",
        "cluster_estimate": 173000,
        "flowcell": 152,
        "lane_number": 2,
        }
    },
     {
-        "pk": 11040
+        "pk": "11037"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11037", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 300, 
             "library_name": "Paired ends 97 Kuntz_PDHT", 
   {"pk": 1187, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11048,
+       "library": "11045",
        "cluster_estimate": 198000,
        "flowcell": 152,
        "lane_number": 3,
        }
    },
     {
-        "pk": 11048
+        "pk": "11045"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11045", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 250, 
             "library_name": "FLDN1 8/3/9 anti-AcH3 chip B6 a", 
   {"pk": 1188, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11049,
+       "library": "11046",
        "cluster_estimate": 212000,
        "flowcell": 152,
        "lane_number": 4,
        "pM": "7"}
    },
     {
-        "pk": 11049
+        "pk": "11046"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11046", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 250, 
             "library_name": "FLDN1 7/8/9 anti-DiMeH3K4 chip B6 a", 
   {"pk": 1189, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11057,
+       "library": "11054",
        "cluster_estimate": 49000,
        "flowcell": 152,
        "lane_number": 5,
        }
    }, 
     {
-        "pk": 11057
+        "pk": "11054"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11054", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 225, 
             "library_name": "HNDHT HLH hnd-1 strain HT115 fed anti-hlh-1 2% fix plate a", 
   {"pk": 1190, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11059,
+       "library": "11056",
        "cluster_estimate": 48000,
        "flowcell": 152,
        "lane_number": 6,
        }
    },
     {
-        "pk": 11059
+        "pk": "11056"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11056", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 225, 
             "library_name": "HNDM3 HLH hnd-1 strain mex-3 fed anti-hlh-1 2% fix plate a", 
   {"pk": 1191, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11060,
+       "library": "11057",
        "cluster_estimate": 4000,
        "flowcell": 152,
        "lane_number": 7,
        }
    }, 
     {
-        "pk": 11060
+        "pk": "11057"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11057", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 225, 
             "library_name": "HNDM3 4H8 hnd-1 strain mex-3 fed 4H8 2% fix plate a", 
   {"pk": 1192, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11068,
+       "library": "11065",
        "cluster_estimate": 5000,
        "flowcell": 152,
        "lane_number": 8,
        }
    }, 
     {
-        "pk": 11068
+        "pk": "11065"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11065", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 300, 
             "library_name": "Paired ends 105 Kuntz PDM3", 
   {"pk": 1177, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11037,
+       "library": "11034",
        "cluster_estimate": 177000,
        "flowcell": 151,
        "lane_number": 1,
   {"pk": 1178, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11039,
+       "library": "11036",
        "cluster_estimate": 169000,
        "flowcell": 151,
        "lane_number": 2,
        }
    }, 
     {
-        "pk": 11039
+        "pk": "11036"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11036", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 300, 
             "library_name": "Paired ends 96 Kuntz_PDE1", 
         }
     }, 
     {
-        "pk": 11037
+        "pk": "11034"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11034", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 300, 
             "library_name": "Paired ends 94 Gilberto_d3_denerv_LTA", 
         }
     }, 
     {
-        "pk": 11047
+        "pk": "11044"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11044", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 225, 
             "library_name": "p300 60h C2 FA KF 12/22/8 a", 
    "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11047,
+       "library": "11044",
        "cluster_estimate": 196000,
        "flowcell": 151,
        "lane_number": 3,
        }
    }, 
     {
-        "pk": 11047
+        "pk": "11044"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11044", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 225, 
             "library_name": "p300 60h C2 FA KF 12/22/8 a", 
   {"pk": 1180, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11050,
+       "library": "11047",
        "cluster_estimate": 200000,
        "flowcell": 151,
        "lane_number": 4,
        }
    }, 
     {
-        "pk": 11050
+        "pk": "11047"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11047", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 250, 
             "library_name": "FLDN1 7/8/9 anti-TriMeH3K27 chip B6 a", 
   {"pk": 1181, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11058,
+       "library": "11055",
        "cluster_estimate": 104000,
        "flowcell": 151,
        "lane_number": 5,
        }
    }, 
     {
-        "pk": 11058
+        "pk": "11055"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11055", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 225, 
             "library_name": "HNDHT 4H8 hnd-1 strain HT115 fed 4H8 2% fix plate a", 
   {"pk": 1182, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11070,
+       "library": "11067",
        "cluster_estimate": 168000,
        "flowcell": 151,
        "lane_number": 6,
        }
    }, 
     {
-        "pk": 11070
+        "pk": "11067"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11067", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 325, 
             "library_name": "Paired End SP-BAC Barcoding test 250-300 bp", 
   {"pk": 1183, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11072,
+       "library": "11069",
        "cluster_estimate": 184000,
        "flowcell": 151,
        "lane_number": 7,
        }
    }, 
     {
-        "pk": 11072
+        "pk": "11069"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11069", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 300, 
             "library_name": "Paired End AG-3d-1 AG domain of floral meristem day 3, rep 1", 
   {"pk": 1184, "model": "experiments.lane",
    "fields": {
        "comment": "",
-       "library": 11073,
+       "library": "11070",
        "cluster_estimate": 182000,
        "flowcell": 151,
        "lane_number": 8,
        }
    },
     {
-        "pk": 11073
+        "pk": "11070"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11070", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 300, 
             "library_name": "Paired End AG-5d-1 AG domain of floral meristem day 5, rep 1", 
index f9b7527696362953b2f448a0fb067f631854714e..a27023c3686fe3a75e63794ba9d94d3b620e4c8b 100644 (file)
@@ -1,4 +1,5 @@
 import re
+from BeautifulSoup import BeautifulSoup
 try:
     import json
 except ImportError, e:
@@ -11,6 +12,8 @@ from htsworkflow.frontend.experiments import models
 from htsworkflow.frontend.experiments import experiments
 from htsworkflow.frontend.auth import apidata
 
+LANE_SET = range(1,9)
+
 class ExperimentsTestCases(TestCase):
     fixtures = ['test_flowcells.json']
 
@@ -38,7 +41,7 @@ class ExperimentsTestCases(TestCase):
                 self.failUnlessEqual(lane_dict['flowcell'], lane.flowcell.flowcell_id)
                 self.failUnlessEqual(lane_dict['lane_number'], lane.lane_number)
                 self.failUnlessEqual(lane_dict['library_name'], lane.library.library_name)
-                self.failUnlessEqual(lane_dict['library_id'], lane.library.library_id)
+                self.failUnlessEqual(lane_dict['library_id'], lane.library.id)
                 self.failUnlessAlmostEqual(lane_dict['pM'], float(lane.pM))
                 self.failUnlessEqual(lane_dict['library_species'],
                                      lane.library.library_species.scientific_name)
@@ -60,7 +63,7 @@ class ExperimentsTestCases(TestCase):
                 self.failUnlessEqual(lane_dict['flowcell'], lane.flowcell.flowcell_id)
                 self.failUnlessEqual(lane_dict['lane_number'], lane.lane_number)
                 self.failUnlessEqual(lane_dict['library_name'], lane.library.library_name)
-                self.failUnlessEqual(lane_dict['library_id'], lane.library.library_id)
+                self.failUnlessEqual(lane_dict['library_id'], lane.library.id)
                 self.failUnlessAlmostEqual(lane_dict['pM'], float(lane.pM))
                 self.failUnlessEqual(lane_dict['library_species'],
                                      lane.library.library_species.scientific_name)
@@ -95,6 +98,32 @@ class ExperimentsTestCases(TestCase):
 
         self.failUnlessEqual(library_sl039['library_id'], 'SL039')
 
+    def test_raw_id_field(self):
+        """
+        Test ticket:147
+
+        Library's have IDs, libraries also have primary keys,
+        we eventually had enough libraries that the drop down combo box was too
+        hard to filter through, unfortnately we want a field that uses our library
+        id and not the internal primary key, and raw_id_field uses primary keys.
+
+        This tests to make sure that the value entered in the raw library id field matches
+        the library id looked up.
+        """
+        expected_ids = [u'10981',u'11016',u'SL039',u'11060',
+                        u'11061',u'11062',u'11063',u'11064']
+        self.client.login(username='supertest', password='BJOKL5kAj6aFZ6A5')
+        response = self.client.get('/admin/experiments/flowcell/153/')
+        soup = BeautifulSoup(response.content)
+        for i in range(0,8):
+            input_field = soup.find(id='id_lane_set-%d-library' % (i,))
+            library_field = input_field.findNext('strong')
+            library_id, library_name = library_field.string.split(':')
+            # strip leading '#' sign from name
+            library_id = library_id[1:]
+            self.failUnlessEqual(library_id, expected_ids[i])
+            self.failUnlessEqual(input_field['value'], library_id)
+
 class TestEmailNotify(TestCase):
     fixtures = ['test_flowcells.json']
 
index 074ad16fdfb55baf8021531a2e7adc6dd4b48468..ef815a25cc34bb21086be003e8c317b3c94051bf 100644 (file)
@@ -95,14 +95,14 @@ class LibraryOptions(admin.ModelAdmin):
     save_as = True
     save_on_top = True
     search_fields = (
-        'library_id',
+        'id',
         'library_name',
         'cell_line__cellline_name',
         'library_species__scientific_name',
         'library_species__common_name',
     )
     list_display = (
-        'library_id',
+        'id',
         #'aligned_reads',
         #'DataRun',
         'library_name',
@@ -133,11 +133,11 @@ class LibraryOptions(admin.ModelAdmin):
         'condition',
         'stopping_point',
         'hidden')
-    list_display_links = ('library_id', 'library_name',)
+    list_display_links = ('id', 'library_name',)
     fieldsets = (
       (None, {
         'fields': (
-          ('library_id','library_name','hidden'),
+          ('id','library_name','hidden'),
           ('library_species'),
           ('library_type', 'experiment_type', 'replicate'),
           ('cell_line','condition','antibody'),)
index ae998723b8588ea5e23b7a2201bb96ecd2b26c8e..edb76e1d5fb89e62a958ce4e428845b21c259509 100644 (file)
@@ -15,9 +15,8 @@
        "date_joined": "2009-01-01 00:01:01"
        }
    },
-  {"pk": 10984, "model": "samples.library", 
+  {"pk": "10981", "model": "samples.library", 
         "fields": {
-            "library_id": "10981", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 400, 
             "library_name": "Paired End Multiplexed Sp-BAC", 
         }
     }, 
     {
-        "pk": 11019
+        "pk": "11016"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11016", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 325, 
             "library_name": "Paired End Pfl #3 MP 7/24/9 a", 
         }
     }, 
     {
-        "pk": 11042
+        "pk": "11039"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11039", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 300, 
             "library_name": "Paired ends 99 GM12892", 
         }
     },
     {
-        "pk": 11006
+        "pk": "11003"
         "model": "samples.library", 
         "fields": {
-            "library_id": "11003", 
             "ten_nM_dilution": false, 
             "avg_lib_size": 325, 
             "library_name": "Paired End Pfl #3 MP 7/24/9", 
index 57c7888943aaf6c32b6d00e5e931c9b50437d81e..a5b3327047dab5faf5cbcb08668a3135a1fee020 100644 (file)
@@ -128,8 +128,7 @@ class LibraryType(models.Model):
     return unicode(self.name)
 
 class Library(models.Model):
-  id = models.AutoField(primary_key=True)
-  library_id = models.CharField(max_length=30, db_index=True, unique=True)
+  id = models.CharField(max_length=10, primary_key=True)
   library_name = models.CharField(max_length=100, unique=True)
   library_species = models.ForeignKey(Species)
   # new field 2008 Mar 5, alter table samples_library add column "hidden" NOT NULL default 0;
@@ -178,12 +177,12 @@ class Library(models.Model):
   notes = models.TextField(blank=True)
   
   def __unicode__(self):
-    return u'#%s: %s' % (self.library_id, self.library_name)
+    return u'#%s: %s' % (self.id, self.library_name)
   
   class Meta:
     verbose_name_plural = "libraries"
     #ordering = ["-creation_date"] 
-    ordering = ["-library_id"]
+    ordering = ["-id"]
   
   def antibody_name(self):
     str ='<a target=_self href="/admin/samples/antibody/'+self.antibody.id.__str__()+'/" title="'+self.antibody.__str__()+'">'+self.antibody.nickname+'</a>' 
@@ -218,15 +217,15 @@ class Library(models.Model):
     return u'%s' % ( ", ".join(ar))
 
   def DataRun(self):
-    str ='<a target=_self href="/admin/experiments/datarun/?q='+self.library_id+'" title="Check All Data Runs for This Specific Library ..." ">Data Run</a>' 
+    str ='<a target=_self href="/admin/experiments/datarun/?q='+self.id+'" title="Check All Data Runs for This Specific Library ..." ">Data Run</a>' 
     return str
   DataRun.allow_tags = True
 
   def aligned_m_reads(self):
-    return getLibReads(self.library_id)
+    return getLibReads(self.id)
 
   def aligned_reads(self):
-    res = getLibReads(self.library_id)
+    res = getLibReads(self.id)
 
     # Check data sanity
     if res[2] != "OK":
@@ -263,7 +262,7 @@ class Library(models.Model):
 
   @models.permalink
   def get_absolute_url(self):
-    return ('htsworkflow.frontend.samples.views.library_to_flowcells', [str(self.library_id)])
+    return ('htsworkflow.frontend.samples.views.library_to_flowcells', [str(self.id)])
 
 class HTSUser(User):
     """
index d85a46672ebc4e8902bce1a53fad6078b604ec34..f8eaf0ff0fe11e016df65f0d47586d880fab5979 100644 (file)
@@ -71,7 +71,7 @@ def create_db(obj):
 
     Library.objects.all().delete()
     obj.library_10001 = Library(
-        library_id = 10001,
+        id = "10001",
         library_name = 'C2C12 named poorly',
         library_species = obj.species_human,
         experiment_type = obj.experiment_rna_seq,
@@ -83,7 +83,7 @@ def create_db(obj):
     )
     obj.library_10001.save()
     obj.library_10002 = Library(
-        library_id = 10002,
+        id = "10002",
         library_name = 'Worm named poorly',
         library_species = obj.species_human,
         experiment_type = obj.experiment_rna_seq,
@@ -124,15 +124,15 @@ class SampleWebTestCase(TestCase):
     def test_library_info(self):
 
         for lib in Library.objects.all():
-            lib_dict = library_dict(lib.library_id)
-            url = '/samples/library/%s/json' % (lib.library_id,)
+            lib_dict = library_dict(lib.id)
+            url = '/samples/library/%s/json' % (lib.id,)
             lib_response = self.client.get(url, apidata)
             self.failUnlessEqual(lib_response.status_code, 200)
             lib_json = json.loads(lib_response.content)
 
             for d in [lib_dict, lib_json]:
                 # amplified_from_sample is a link to the library table,
-                # I want to use the "library_id" for the data lookups not
+                # I want to use the "id" for the data lookups not
                 # the embedded primary key.
                 # It gets slightly confusing on how to implement sending the right id
                 # since amplified_from_sample can be null
@@ -144,7 +144,6 @@ class SampleWebTestCase(TestCase):
                 self.failUnlessEqual(d['experiment_type'], lib.experiment_type.name)
                 self.failUnlessEqual(d['experiment_type_id'], lib.experiment_type_id)
                 self.failUnlessEqual(d['id'], lib.id)
-                self.failUnlessEqual(d['library_id'], lib.library_id)
                 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)
index b0a61f42117db2c1758b933041e64f0cb2377cb4..20c3d98bd5171821dedc8e535eccab73b101b2dd 100644 (file)
@@ -41,11 +41,11 @@ def create_library_context(cl):
     #for lib in library_items.object_list:
     for lib in cl.result_list:
        summary = {}
-       summary['library_id'] = lib.library_id
+       summary['library_id'] = lib.id
        summary['library_name'] = lib.library_name
        summary['species_name' ] = lib.library_species.scientific_name
        if lib.amplified_from_sample is not None:
-           summary['amplified_from'] = lib.amplified_from_sample.library_id
+           summary['amplified_from'] = lib.amplified_from_sample.id
        else:
            summary['amplified_from'] = ''
        lanes_run = 0
@@ -63,7 +63,7 @@ def library(request):
    # build changelist
     fcl = ChangeList(request, Library,
         list_filter=['affiliations', 'library_species'],
-        search_fields=['library_id', 'library_name', 'amplified_from_sample__library_id'],
+        search_fields=['id', 'library_name', 'amplified_from_sample__id'],
         list_per_page=200,
         queryset=Library.objects.filter(hidden__exact=0)
     )
@@ -90,7 +90,7 @@ def library_to_flowcells(request, lib_id):
     """
     
     try:
-      lib = Library.objects.get(library_id=lib_id)
+      lib = Library.objects.get(id=lib_id)
     except:
       return HttpResponse("Library %s does not exist" % (lib_id))
    
@@ -446,7 +446,7 @@ def _files(flowcell_id, lane):
     return '(' + '|'.join(output) + ')'
 
 def library_id_to_admin_url(request, lib_id):
-    lib = Library.objects.get(library_id=lib_id)
+    lib = Library.objects.get(id=lib_id)
     return HttpResponseRedirect('/admin/samples/library/%s' % (lib.id,))
 
 def library_dict(library_id):
@@ -455,7 +455,7 @@ def library_dict(library_id):
     return None if nothing was found
     """
     try:
-        lib = Library.objects.get(library_id = library_id)
+        lib = Library.objects.get(id = library_id)
     except Library.DoesNotExist, e:
         return None
 
@@ -472,7 +472,7 @@ def library_dict(library_id):
         'experiment_type': lib.experiment_type.name,
         'experiment_type_id': lib.experiment_type_id,
         'id': lib.id,
-        'library_id': lib.library_id,
+        'library_id': lib.id,
         'library_name': lib.library_name,
         'library_species': lib.library_species.scientific_name,
         'library_species_id': lib.library_species_id,
index f639ff680a139341aba98e4c868c81b5cafd0651..fb43753b064fd53e5de06202fc44393f9eec40de 100644 (file)
@@ -35,7 +35,7 @@ TD
 </tr>
 <tr><td valign=middle nowrap>Solexa Library Number</td>
 {% for lane in fc.lane_set.all %}
-<td bgcolor=#CCFFCC>{{ lane.library.library_id }}</td>
+<td bgcolor=#CCFFCC>{{ lane.library.id }}</td>
 {% endfor %}
 </tr>
 
index 9434c93ed173d348267c060cfbb4574c657090de..d75e4f1cc9f0ca89368a5a9fdeac75790f8450b5 100644 (file)
@@ -4,8 +4,8 @@ which is a {{ flowcell.read_length }} base pair {% if flowcell.paired_end %}pair
 </p>
 <p>{% for lane in lanes %}
 Lane #{{ lane.lane_number }} : 
-<a href="https://jumpgate.caltech.edu/library/{{lane.library.library_id}}">
-{{ lane.library.library_id }}</a>
+<a href="https://jumpgate.caltech.edu/library/{{lane.library.id}}">
+{{ lane.library.id }}</a>
 {{ lane.library.library_name }}<br/>
 {% endfor %}</p>
 <p>
index 5a2c1ca5dc86c52edddc04dfc821b5a51f1e0bba..9b11a748825c4f0d4f45c0045ab4501c7c96ff36 100644 (file)
@@ -3,8 +3,8 @@ which is a {{ flowcell.read_length }} base pair {% if flowcell.paired_end %}pair
 
 Lane : (Library Id) Library Name (Cluster Estimate)
 {% for lane in lanes %}
-Lane #{{ lane.lane_number }} : ({{ lane.library.library_id }}) {{ lane.library.library_name }} ({{ lane.cluster_estimate }})
-     http://jumpgate.caltech.edu/library/{{ lane.library.library_id }}
+Lane #{{ lane.lane_number }} : ({{ lane.library.id }}) {{ lane.library.library_name }} ({{ lane.cluster_estimate }})
+     http://jumpgate.caltech.edu/library/{{ lane.library.id }}
 {% endfor %}
 
 The raw data should be available at the following link when
index c457bdaf65613e5dc519a6049983299d8aa073cc..947691c5050deeebaf1c1c53af652b96c135af5b 100644 (file)
@@ -30,7 +30,7 @@
 {% block content %}
 <div id="librarydetail">
   <h2>About this library</h2>
-  <b>Library ID</b>: {{ lib.library_id }}<br/>
+  <b>Library ID</b>: {{ lib.id }}<br/>
   <b>Name</b>: {{ lib.library_name }}<br/>
   <b>Species</b>: {{ lib.library_species.scientific_name }}<br/>
   <b>Affiliations</b>: