From: Diane Trout Date: Fri, 13 Aug 2010 22:49:09 +0000 (+0000) Subject: This patch adds in fields to support storing bioanalyzer results. [ticket:166] X-Git-Tag: 0.4.4~2 X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=145d10cddf64a7741bf755be3991f25056ca352a This patch adds in fields to support storing bioanalyzer results. [ticket:166] --- diff --git a/docs/upgrade_v0.4.3_to_v0.4.4.py b/docs/upgrade_v0.4.3_to_v0.4.4.py new file mode 100644 index 0000000..44e2baf --- /dev/null +++ b/docs/upgrade_v0.4.3_to_v0.4.4.py @@ -0,0 +1,37 @@ +""" +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 +add column "bioanalyzer_concentration" decimal; +""") + + c.execute(""" +alter table samples_library +add column "bioanalyzer_summary" text NOT NULL default ""; +""") + + c.execute(""" +alter table samples_library +add column "bioanalyzer_image_url" varchar(200) NOT NULL default ""; +""") + + conn.commit() + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/htsworkflow/frontend/samples/admin.py b/htsworkflow/frontend/samples/admin.py index 393bfa2..4b46a22 100644 --- a/htsworkflow/frontend/samples/admin.py +++ b/htsworkflow/frontend/samples/admin.py @@ -148,7 +148,14 @@ class LibraryOptions(admin.ModelAdmin): ('cell_line','condition','antibody'),) }), ('Creation Information:', { - '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',) + 'fields' : (('made_for', 'made_by', 'creation_date'), + ('stopping_point', 'amplified_from_sample'), + ('gel_cut_size', 'insert_size', + 'undiluted_concentration', 'ten_nM_dilution', + 'successful_pM'), + ('bioanalyzer_concentration','bioanalyzer_image_url'), + ('bioanalyzer_summary'), + ('account_number', 'notes',)) }), ('Library/Project Affiliation:', { 'fields' : (('affiliations'), ('tags'),) @@ -159,7 +166,6 @@ class LibraryOptions(admin.ModelAdmin): ] actions = ['action_print_library_labels'] - def action_print_library_labels(self, request, queryset): """ Django action which prints labels for the selected set of labels from the @@ -200,19 +206,20 @@ class LibraryOptions(admin.ModelAdmin): action_print_library_labels.short_description = "Print Labels" - - - # some post 1.0.2 version of django has formfield_overrides - # which would replace this code with: - # formfield_overrids = { - # models.ManyToMany: { 'widget': widgets.FilteredSelectMultiple } - #} def formfield_for_dbfield(self, db_field, **kwargs): - if db_field.name in ('affiliations', 'tags'): - kwargs['widget'] = widgets.FilteredSelectMultiple(db_field.verbose_name, - (db_field.name in self.filter_vertical)) - rv = super(LibraryOptions, self).formfield_for_dbfield(db_field, **kwargs) - return rv + # Override Field type + if db_field.name in ('affiliations', 'tags'): + kwargs['widget'] = widgets.FilteredSelectMultiple( + db_field.verbose_name, + (db_field.name in self.filter_vertical) + ) + field = super(LibraryOptions, self).formfield_for_dbfield(db_field, + **kwargs) + # Override field attributes + if db_field.name == "bioanalyzer_summary": + print field.widget.attrs.items() + field.widget.attrs["rows"] = "5" + return field class SpeciesOptions(admin.ModelAdmin): fieldsets = ( diff --git a/htsworkflow/frontend/samples/models.py b/htsworkflow/frontend/samples/models.py index b6fb4eb..0a65651 100644 --- a/htsworkflow/frontend/samples/models.py +++ b/htsworkflow/frontend/samples/models.py @@ -177,6 +177,12 @@ class Library(models.Model): gel_cut_size = models.IntegerField(default=225, blank=True, null=True) insert_size = models.IntegerField(blank=True, null=True) notes = models.TextField(blank=True) + + bioanalyzer_summary = models.TextField(blank=True,default="") + bioanalyzer_concentration = models.DecimalField(max_digits=5, + decimal_places=2, blank=True, null=True, + help_text=u"(ng/\u00b5l)") + bioanalyzer_image_url = models.URLField(blank=True,default="") def __unicode__(self): return u'#%s: %s' % (self.id, self.library_name)