From cb696a0bd80ac220fc4aa6b3dc94ba6d0be67c82 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Tue, 21 Jan 2014 15:58:41 -0800 Subject: [PATCH] Add flowcell model type to the flowcell model The flowcell model type is supposed to indicate if its a traditional flowcell or one of the newer rapid run flowcells. The flowcell model type includes some information about how long a cycle is supposed to take. --- htsworkflow/frontend/experiments/admin.py | 12 +- .../experiments/fixtures/initial_data.json | 9 + .../experiments/fixtures/test_flowcells.json | 12 +- .../migrations/0002_auto__add_flowcelltype.py | 251 ++++++++++++++++++ htsworkflow/frontend/experiments/models.py | 25 ++ .../inventory/fixtures/test_harddisks.json | 9 +- .../samples/fixtures/test_samples.json | 3 +- 7 files changed, 311 insertions(+), 10 deletions(-) create mode 100644 htsworkflow/frontend/experiments/migrations/0002_auto__add_flowcelltype.py diff --git a/htsworkflow/frontend/experiments/admin.py b/htsworkflow/frontend/experiments/admin.py index 6cf7aeb..e9419dc 100644 --- a/htsworkflow/frontend/experiments/admin.py +++ b/htsworkflow/frontend/experiments/admin.py @@ -1,6 +1,6 @@ from itertools import chain from htsworkflow.frontend.experiments.models import \ - FlowCell, DataRun, DataFile, FileType, ClusterStation, Sequencer, Lane + FlowCell, FlowCellModel, DataRun, DataFile, FileType, ClusterStation, Sequencer, Lane from django.contrib import admin from django.contrib.admin.widgets import FilteredSelectMultiple from django.forms import ModelForm @@ -96,6 +96,14 @@ class LaneOptions(admin.ModelAdmin): ) admin.site.register(Lane, LaneOptions) +class FlowCellModelOptions(admin.ModelAdmin): + search_fields = ('name',) + list_display = ('name', 'fixed_time', 'per_cycle_time', 'isdefault') + fieldsets = ( + (None, { 'fields': ('name', 'fixed_time', 'per_cycle_time', 'isdefault') }), + ) +admin.site.register(FlowCellModel, FlowCellModelOptions) + class FlowCellOptions(admin.ModelAdmin): class Media: css = { 'all': ('css/admin_flowcell.css',) } @@ -111,7 +119,7 @@ class FlowCellOptions(admin.ModelAdmin): fieldsets = ( (None, { 'fields': ('run_date', ('flowcell_id','cluster_station','sequencer'), - ('read_length', 'control_lane', 'paired_end'),) + ('flowcell_model', 'read_length', 'paired_end', 'control_lane', ),) }), ('Notes:', { 'fields': ('notes',),}), ) diff --git a/htsworkflow/frontend/experiments/fixtures/initial_data.json b/htsworkflow/frontend/experiments/fixtures/initial_data.json index cf25976..3c585cd 100644 --- a/htsworkflow/frontend/experiments/fixtures/initial_data.json +++ b/htsworkflow/frontend/experiments/fixtures/initial_data.json @@ -206,5 +206,14 @@ { "model": "experiments.ClusterStation", "pk": 3, "fields": { "name": "new", "isdefault": false } + }, + { "model": "experiments.FlowCellModel", + "pk": 1, + "fields": { "name": "classic", "fixed_time": 800, "per_cycle_time": 5400 } + }, + { "model": "experiments.FlowCellModel", + "pk": 2, + "fields": { "name": "rapid-run", "fixed_time": 800, "per_cycle_time": 600 } } + ] diff --git a/htsworkflow/frontend/experiments/fixtures/test_flowcells.json b/htsworkflow/frontend/experiments/fixtures/test_flowcells.json index 15d00c6..de6baec 100644 --- a/htsworkflow/frontend/experiments/fixtures/test_flowcells.json +++ b/htsworkflow/frontend/experiments/fixtures/test_flowcells.json @@ -129,7 +129,8 @@ "control_lane": 2, "cluster_station": 3, "sequencer": 2, - "flowcell_id": "FC12150" + "flowcell_id": "FC12150", + "flowcell_model": 1 } }, {"pk": 1193, "model": "experiments.lane", @@ -494,7 +495,8 @@ "control_lane": 4, "cluster_station": 3, "sequencer": 1, - "flowcell_id": "42JTNAAXX" + "flowcell_id": "42JTNAAXX", + "flowcell_model": 1 } }, {"pk": 1185, "model": "experiments.lane", @@ -818,7 +820,8 @@ "control_lane": 5, "cluster_station": 3, "sequencer": 2, - "flowcell_id": "42JU1AAXX" + "flowcell_id": "42JU1AAXX", + "flowcell_model": 1 } }, {"pk": 1177, "model": "experiments.lane", @@ -1257,7 +1260,8 @@ "control_lane": 2, "cluster_station": 3, "sequencer": 2, - "flowcell_id": "30012AAXX (failed)" + "flowcell_id": "30012AAXX (failed)", + "flowcell_model": 1 } }, {"pk": 201, "model": "experiments.lane", diff --git a/htsworkflow/frontend/experiments/migrations/0002_auto__add_flowcelltype.py b/htsworkflow/frontend/experiments/migrations/0002_auto__add_flowcelltype.py new file mode 100644 index 0000000..de29943 --- /dev/null +++ b/htsworkflow/frontend/experiments/migrations/0002_auto__add_flowcelltype.py @@ -0,0 +1,251 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding model 'FlowCellModel' + db.create_table(u'experiments_flowcellmodel', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('name', self.gf('django.db.models.fields.TextField')()), + ('fixed_time', self.gf('django.db.models.fields.IntegerField')(default=0)), + ('per_cycle_time', self.gf('django.db.models.fields.IntegerField')(default=0)), + ('isdefault', self.gf('django.db.models.fields.BooleanField')(default=False)), + )) + db.send_create_signal(u'experiments', ['FlowCellModel']) + + # Adding field 'FlowCell.flowcell_model' + db.add_column(u'experiments_flowcell', 'flowcell_model', + self.gf('django.db.models.fields.related.ForeignKey')(default=1, to=orm['experiments.FlowCellModel']), + keep_default=False) + + + def backwards(self, orm): + # Deleting model 'FlowCellModel' + db.delete_table(u'experiments_flowcellmodel') + + # Deleting field 'FlowCell.flowcell_model' + db.delete_column(u'experiments_flowcell', 'flowcell_model_id') + + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + u'experiments.clusterstation': { + 'Meta': {'ordering': "['-isdefault', 'name']", 'object_name': 'ClusterStation'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'isdefault': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50'}) + }, + u'experiments.datafile': { + 'Meta': {'object_name': 'DataFile'}, + 'data_run': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['experiments.DataRun']"}), + 'file_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['experiments.FileType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'library': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['samples.Library']", 'null': 'True', 'blank': 'True'}), + 'random_key': ('django.db.models.fields.CharField', [], {'default': "'0bbbaa1c-82f1-11e3-82b3-f0def16fbea3'", 'max_length': '64', 'db_index': 'True'}), + 'relative_pathname': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}) + }, + u'experiments.datarun': { + 'Meta': {'object_name': 'DataRun'}, + 'alignment_software': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'alignment_version': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'basecall_software': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'basecall_version': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'comment': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'cycle_start': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'cycle_stop': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'flowcell': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['experiments.FlowCell']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'image_software': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'image_version': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'last_update_time': ('django.db.models.fields.DateTimeField', [], {}), + 'result_dir': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'run_start_time': ('django.db.models.fields.DateTimeField', [], {}), + 'run_status': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'runfolder_name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'experiments.filetype': { + 'Meta': {'object_name': 'FileType'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'mimetype': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'regex': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}) + }, + u'experiments.flowcell': { + 'Meta': {'ordering': "['-run_date']", 'object_name': 'FlowCell'}, + 'advanced_run': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'cluster_station': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['experiments.ClusterStation']"}), + 'control_lane': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'flowcell_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '20', 'db_index': 'True'}), + 'flowcell_model': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['experiments.FlowCellModel']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'notes': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'paired_end': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'read_length': ('django.db.models.fields.IntegerField', [], {'default': '32'}), + 'run_date': ('django.db.models.fields.DateTimeField', [], {}), + 'sequencer': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['experiments.Sequencer']"}) + }, + u'experiments.flowcellmodel': { + 'Meta': {'object_name': 'FlowCellModel'}, + 'fixed_time': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'isdefault': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'name': ('django.db.models.fields.TextField', [], {}), + 'per_cycle_time': ('django.db.models.fields.IntegerField', [], {'default': '0'}) + }, + u'experiments.lane': { + 'Meta': {'object_name': 'Lane'}, + 'cluster_estimate': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'flowcell': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['experiments.FlowCell']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'lane_number': ('django.db.models.fields.IntegerField', [], {}), + 'library': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['samples.Library']"}), + 'pM': ('django.db.models.fields.DecimalField', [], {'default': '5', 'max_digits': '5', 'decimal_places': '2'}), + 'status': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}) + }, + u'experiments.sequencer': { + 'Meta': {'ordering': "['-isdefault', '-active', 'name']", 'object_name': 'Sequencer'}, + 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'instrument_name': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}), + 'isdefault': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}), + 'serial_number': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}) + }, + u'samples.affiliation': { + 'Meta': {'ordering': "['name', 'contact']", 'unique_together': "(('name', 'contact'),)", 'object_name': 'Affiliation'}, + 'contact': ('django.db.models.fields.CharField', [], {'max_length': '256', 'null': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '256', 'db_index': 'True'}), + 'users': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['samples.HTSUser']", 'null': 'True', 'blank': 'True'}) + }, + u'samples.antibody': { + 'Meta': {'ordering': "['antigene']", 'object_name': 'Antibody'}, + 'antibodies': ('django.db.models.fields.CharField', [], {'max_length': '500', 'db_index': 'True'}), + 'antigene': ('django.db.models.fields.CharField', [], {'max_length': '500', 'db_index': 'True'}), + 'biology': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'catalog': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'nickname': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '20', 'null': 'True', 'blank': 'True'}), + 'notes': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'source': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '500', 'null': 'True', 'blank': 'True'}) + }, + u'samples.cellline': { + 'Meta': {'ordering': "['cellline_name']", 'object_name': 'Cellline'}, + 'cellline_name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100', 'db_index': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'nickname': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '20', 'null': 'True', 'blank': 'True'}), + 'notes': ('django.db.models.fields.TextField', [], {'blank': 'True'}) + }, + u'samples.condition': { + 'Meta': {'ordering': "['condition_name']", 'object_name': 'Condition'}, + 'condition_name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '2000', 'db_index': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'nickname': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '20', 'null': 'True', 'blank': 'True'}), + 'notes': ('django.db.models.fields.TextField', [], {'blank': 'True'}) + }, + u'samples.experimenttype': { + 'Meta': {'object_name': 'ExperimentType'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50'}) + }, + u'samples.htsuser': { + 'Meta': {'ordering': "['first_name', 'last_name', 'username']", 'object_name': 'HTSUser', '_ormbases': [u'auth.User']}, + u'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.User']", 'unique': 'True', 'primary_key': 'True'}) + }, + u'samples.library': { + 'Meta': {'ordering': "['-id']", 'object_name': 'Library'}, + 'account_number': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'affiliations': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'library_affiliations'", 'null': 'True', 'to': u"orm['samples.Affiliation']"}), + 'amplified_from_sample': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'amplified_into_sample'", 'null': 'True', 'to': u"orm['samples.Library']"}), + 'antibody': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['samples.Antibody']", 'null': 'True', 'blank': 'True'}), + 'bioanalyzer_concentration': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '5', 'decimal_places': '2', 'blank': 'True'}), + 'bioanalyzer_image_url': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}), + 'bioanalyzer_summary': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}), + 'cell_line': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['samples.Cellline']", 'null': 'True', 'blank': 'True'}), + 'condition': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['samples.Condition']", 'null': 'True', 'blank': 'True'}), + 'creation_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), + 'experiment_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['samples.ExperimentType']"}), + 'gel_cut_size': ('django.db.models.fields.IntegerField', [], {'default': '225', 'null': 'True', 'blank': 'True'}), + 'hidden': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'id': ('django.db.models.fields.CharField', [], {'max_length': '10', 'primary_key': 'True'}), + 'insert_size': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'library_name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'library_species': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['samples.Species']"}), + 'library_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['samples.LibraryType']", 'null': 'True', 'blank': 'True'}), + 'made_by': ('django.db.models.fields.CharField', [], {'default': "'Lorian'", 'max_length': '50', 'blank': 'True'}), + 'made_for': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}), + 'multiplex_id': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), + 'notes': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'replicate': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}), + 'stopping_point': ('django.db.models.fields.CharField', [], {'default': "'Done'", 'max_length': '25'}), + 'successful_pM': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '9', 'decimal_places': '1', 'blank': 'True'}), + 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'library_tags'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['samples.Tag']"}), + 'ten_nM_dilution': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'undiluted_concentration': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '5', 'decimal_places': '2', 'blank': 'True'}) + }, + u'samples.librarytype': { + 'Meta': {'ordering': "['-id']", 'object_name': 'LibraryType'}, + 'can_multiplex': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_paired_end': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) + }, + u'samples.species': { + 'Meta': {'ordering': "['scientific_name']", 'object_name': 'Species'}, + 'common_name': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'scientific_name': ('django.db.models.fields.CharField', [], {'max_length': '256', 'db_index': 'True'}) + }, + u'samples.tag': { + 'Meta': {'ordering': "['context', 'tag_name']", 'object_name': 'Tag'}, + 'context': ('django.db.models.fields.CharField', [], {'default': "'Library'", 'max_length': '50'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'tag_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'db_index': 'True'}) + } + } + + complete_apps = ['experiments'] diff --git a/htsworkflow/frontend/experiments/models.py b/htsworkflow/frontend/experiments/models.py index 6c952db..2232d96 100644 --- a/htsworkflow/frontend/experiments/models.py +++ b/htsworkflow/frontend/experiments/models.py @@ -128,6 +128,30 @@ class Sequencer(models.Model): pre_save.connect(Sequencer.update_isdefault, sender=Sequencer) +class FlowCellModel(models.Model): + name = models.TextField() + fixed_time = models.IntegerField(default=0, help_text='(seconds)') + per_cycle_time = models.IntegerField(default=0, help_text='(seconds)') + isdefault = models.BooleanField(default=False) + + @classmethod + def default(cls): + d = cls.objects.filter(isdefault=True).all() + if len(d) > 0: + return d[-1] + return None + + @staticmethod + def update_isdefault(sender, instance, **kwargs): + """Clear default if needed + """ + if instance.isdefault: + for s in FlowCellType.objects.filter(isdefault=True).all(): + if s.id != instance.id: + s.isdefault = False + s.save() + +pre_save.connect(FlowCellModel.update_isdefault, sender=FlowCellModel) class FlowCell(models.Model): flowcell_id = models.CharField(max_length=20, unique=True, db_index=True) @@ -149,6 +173,7 @@ class FlowCell(models.Model): cluster_station = models.ForeignKey(ClusterStation, default=ClusterStation.default) sequencer = models.ForeignKey(Sequencer, default=Sequencer.default) + flowcell_model = models.ForeignKey(FlowCellModel, default=FlowCellModel.default) notes = models.TextField(blank=True) diff --git a/htsworkflow/frontend/inventory/fixtures/test_harddisks.json b/htsworkflow/frontend/inventory/fixtures/test_harddisks.json index c990260..318ce4e 100644 --- a/htsworkflow/frontend/inventory/fixtures/test_harddisks.json +++ b/htsworkflow/frontend/inventory/fixtures/test_harddisks.json @@ -197,7 +197,8 @@ "notes": "", "advanced_run": false, "control_lane": 2, - "flowcell_id": "11ONEAAXX" + "flowcell_id": "11ONEAAXX", + "flowcell_model": 1 } }, {"pk": 2, "model": "experiments.flowcell", @@ -208,7 +209,8 @@ "notes": "", "advanced_run": false, "control_lane": 2, - "flowcell_id": "22TWOAAXX" + "flowcell_id": "22TWOAAXX", + "flowcell_model": 1 } }, {"pk": 3, "model": "experiments.flowcell", @@ -219,7 +221,8 @@ "notes": "", "advanced_run": false, "control_lane": 2, - "flowcell_id": "33THRAAXX (failed)" + "flowcell_id": "33THRAAXX (failed)", + "flowcell_model": 1 } }, {"pk": "10001", "model": "samples.library", diff --git a/htsworkflow/frontend/samples/fixtures/test_samples.json b/htsworkflow/frontend/samples/fixtures/test_samples.json index 41824e0..8a256f8 100644 --- a/htsworkflow/frontend/samples/fixtures/test_samples.json +++ b/htsworkflow/frontend/samples/fixtures/test_samples.json @@ -63,7 +63,8 @@ "control_lane": 2, "cluster_station": 3, "sequencer": 2, - "flowcell_id": "303TUAAXX" + "flowcell_id": "303TUAAXX", + "flowcell_model": 1 } }, {"pk": 1193, "model": "experiments.lane", -- 2.30.2