From: Diane Trout Date: Mon, 14 Jun 2010 21:11:32 +0000 (+0000) Subject: Rename avg_lib_size to gel_cut_size, and add insert_size X-Git-Tag: 0.4.3~1 X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=13e0e053840acbd9284a86ff5cf35fcc0253f40f Rename avg_lib_size to gel_cut_size, and add insert_size 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. --- 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 index 0000000..2c0cbab --- /dev/null +++ b/docs/upgrade_v0.4.2_to_v0.4.3.py @@ -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:]) diff --git a/htsworkflow/frontend/experiments/admin.py b/htsworkflow/frontend/experiments/admin.py index 0f00d0e..f05643d 100644 --- a/htsworkflow/frontend/experiments/admin.py +++ b/htsworkflow/frontend/experiments/admin.py @@ -57,7 +57,7 @@ class LaneInline(admin.StackedInline): (None, { 'fields': ('lane_number', 'flowcell', ('library',), - ('pM', 'cluster_estimate'), + ('pM', 'cluster_estimate', 'status'), 'comment',) }), ) diff --git a/htsworkflow/frontend/experiments/experiments.py b/htsworkflow/frontend/experiments/experiments.py index a156d7b..882ea89 100755 --- a/htsworkflow/frontend/experiments/experiments.py +++ b/htsworkflow/frontend/experiments/experiments.py @@ -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: diff --git a/htsworkflow/frontend/experiments/fixtures/test_flowcells.json b/htsworkflow/frontend/experiments/fixtures/test_flowcells.json index 8ac0380..37adf5e 100644 --- a/htsworkflow/frontend/experiments/fixtures/test_flowcells.json +++ b/htsworkflow/frontend/experiments/fixtures/test_flowcells.json @@ -128,7 +128,7 @@ {"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, @@ -167,7 +167,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, @@ -206,7 +206,7 @@ "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, @@ -245,7 +245,7 @@ "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, @@ -271,12 +271,13 @@ }, {"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 } }, { @@ -284,7 +285,7 @@ "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, @@ -315,7 +316,8 @@ "cluster_estimate": 2000, "flowcell": 153, "lane_number": 6, - "pM": "7" + "pM": "7", + "status": 0 } }, { @@ -323,7 +325,7 @@ "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, @@ -362,7 +364,7 @@ "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, @@ -401,7 +403,7 @@ "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, @@ -453,7 +455,7 @@ "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, @@ -492,7 +494,7 @@ "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, @@ -531,7 +533,7 @@ "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, @@ -569,7 +571,7 @@ "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, @@ -608,7 +610,7 @@ "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, @@ -647,7 +649,7 @@ "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, @@ -686,7 +688,7 @@ "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, @@ -725,7 +727,7 @@ "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, @@ -787,7 +789,7 @@ "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, @@ -816,7 +818,7 @@ "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, @@ -845,7 +847,7 @@ "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, @@ -885,7 +887,7 @@ "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, @@ -924,7 +926,7 @@ "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, @@ -963,7 +965,7 @@ "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, @@ -1002,7 +1004,7 @@ "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, @@ -1041,7 +1043,7 @@ "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, @@ -1080,7 +1082,7 @@ "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, diff --git a/htsworkflow/frontend/experiments/models.py b/htsworkflow/frontend/experiments/models.py index 9329add..4026261 100755 --- a/htsworkflow/frontend/experiments/models.py +++ b/htsworkflow/frontend/experiments/models.py @@ -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) diff --git a/htsworkflow/frontend/samples/admin.py b/htsworkflow/frontend/samples/admin.py index 9295175..393bfa2 100644 --- a/htsworkflow/frontend/samples/admin.py +++ b/htsworkflow/frontend/samples/admin.py @@ -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'),) diff --git a/htsworkflow/frontend/samples/fixtures/test_samples.json b/htsworkflow/frontend/samples/fixtures/test_samples.json index 9a549c5..4dbf371 100644 --- a/htsworkflow/frontend/samples/fixtures/test_samples.json +++ b/htsworkflow/frontend/samples/fixtures/test_samples.json @@ -15,10 +15,44 @@ "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, @@ -76,7 +110,7 @@ "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, @@ -107,7 +141,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", "creation_date": "2009-08-05", "cell_line": 1, @@ -136,7 +170,7 @@ "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, diff --git a/htsworkflow/frontend/samples/models.py b/htsworkflow/frontend/samples/models.py index cce9619..b6fb4eb 100644 --- a/htsworkflow/frontend/samples/models.py +++ b/htsworkflow/frontend/samples/models.py @@ -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): diff --git a/htsworkflow/frontend/samples/tests.py b/htsworkflow/frontend/samples/tests.py index d1689f1..6f5182b 100644 --- a/htsworkflow/frontend/samples/tests.py +++ b/htsworkflow/frontend/samples/tests.py @@ -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() + diff --git a/htsworkflow/frontend/samples/views.py b/htsworkflow/frontend/samples/views.py index 3b8fecc..20b6837 100644 --- a/htsworkflow/frontend/samples/views.py +++ b/htsworkflow/frontend/samples/views.py @@ -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, diff --git a/htsworkflow/frontend/templates/experiments/flowcellSheet.html b/htsworkflow/frontend/templates/experiments/flowcellSheet.html index fb43753..103b045 100644 --- a/htsworkflow/frontend/templates/experiments/flowcellSheet.html +++ b/htsworkflow/frontend/templates/experiments/flowcellSheet.html @@ -60,9 +60,9 @@ TD First time run? -Average Library Size (bp) +Gel Cut Size (bp) {% for lane in fc.lane_set.all %} -{{ lane.library.avg_lib_size }} +{{ lane.library.gel_cut_size }} {% endfor %} diff --git a/htsworkflow/frontend/templates/samples/library_detail.html b/htsworkflow/frontend/templates/samples/library_detail.html index ac100ee..26eba68 100644 --- a/htsworkflow/frontend/templates/samples/library_detail.html +++ b/htsworkflow/frontend/templates/samples/library_detail.html @@ -54,7 +54,8 @@ Name: {{ lib.library_name }}
Species: {{ lib.library_species.scientific_name }}
Concentration: {{ lib.undiluted_concentration }} ng/µl
- Gel Cut Size: {{ lib.avg_lib_size }}
+ Gel Cut Size: {{ lib.gel_cut_size }}
+ Insert Size: {{ lib.insert_size }}
Made By: {{ lib.made_by }}
Affiliations: