1 from django.db import models
2 from django.contrib.auth.models import User
3 from htsworkflow.frontend import settings
5 # Create your models here.
7 class Antibody(models.Model):
8 antigene = models.CharField(max_length=500, db_index=True)
9 catalog = models.CharField(max_length=50, unique=True, db_index=True)
10 antibodies = models.CharField(max_length=500, db_index=True)
11 source = models.CharField(max_length=500, blank=True, db_index=True)
12 biology = models.TextField(blank=True)
13 notes = models.TextField(blank=True)
15 return '%s - %s (%s)' % (self.antigene, self.antibodies, self.catalog)
17 verbose_name_plural = "antibodies"
18 ordering = ["antigene"]
20 list_display = ('antigene','antibodies','catalog','source','biology','notes')
21 list_filter = ('antibodies','source')
24 'fields': (('antigene','antibodies'),('catalog','source'),('biology'),('notes'))
28 class Cellline(models.Model):
29 cellline_name = models.CharField(max_length=100, unique=True, db_index=True)
30 notes = models.TextField(blank=True)
32 return '%s' % (self.cellline_name)
35 ordering = ["cellline_name"]
40 'fields': (('cellline_name'),('notes'),)
44 class Condition(models.Model):
45 condition_name = models.CharField(max_length=2000, unique=True, db_index=True)
46 notes = models.TextField(blank=True)
48 return '%s' % (self.condition_name)
51 ordering = ["condition_name"]
56 'fields': (('condition_name'),('notes'),)
60 class Species(models.Model):
62 scientific_name = models.CharField(max_length=256, unique=False, db_index=True, core=True)
63 common_name = models.CharField(max_length=256, blank=True)
64 use_genome_build = models.CharField(max_length=100, blank=False, null=False)
67 return '%s (%s)|%s' % (self.scientific_name, self.common_name, self.use_genome_build)
70 verbose_name_plural = "species"
71 ordering = ["scientific_name"]
76 'fields': (('scientific_name', 'common_name'), ('use_genome_build'))
80 class Lab(models.Model):
82 name = models.CharField(max_length=100, blank=False, unique=True)
90 class UserProfile(models.Model):
92 # This allows you to use user.get_profile() to get this object
93 user = models.ForeignKey(User, unique=True)
95 lab = models.ForeignKey(Lab)
96 #email = models.CharField(max_length=50, blank=True, null=True)
99 return '%s (%s lab)' % (self.user, self.lab)
102 #verbose_name_plural = "people"
109 # 'fields': (('email', 'lab'), ('email'))
115 class Library(models.Model):
117 library_id = models.CharField(max_length=30, primary_key=True, db_index=True, core=True)
118 library_name = models.CharField(max_length=100, unique=True, core=True)
119 library_species = models.ForeignKey(Species, core=True)
120 cell_line = models.ForeignKey(Cellline,core=True)
121 condition = models.ForeignKey(Condition,core=True)
122 antibody = models.ForeignKey(Antibody,blank=True,null=True,core=True)
125 ('INPUT_RXLCh','INPUT_RXLCh'),
126 ('ChIP-seq', 'ChIP-seq'),
127 ('Sheared', 'Sheared'),
128 ('RNA-seq', 'RNA-seq'),
129 ('Methyl-seq', 'Methyl-seq'),
130 ('DIP-seq', 'DIP-seq'),
132 experiment_type = models.CharField(max_length=50, choices=EXPERIMENT_TYPES,
135 creation_date = models.DateField(blank=True, null=True)
136 made_for = models.ForeignKey(User)
137 made_by = models.CharField(max_length=50, blank=True, default="Lorian")
139 PROTOCOL_END_POINTS = (
141 ('Sample', 'Raw sample'),
142 ('Progress', 'In progress'),
143 ('1A', 'Ligation, then gel'),
144 ('PCR', 'Ligation, then PCR'),
145 ('1Ab', 'Ligation, PCR, then gel'),
146 ('1Aa', 'Ligation, gel, then PCR'),
147 ('2A', 'Ligation, PCR, gel, PCR'),
148 ('Done', 'Completed'),
150 stopping_point = models.CharField(max_length=25, choices=PROTOCOL_END_POINTS, default='Done')
151 amplified_from_sample = models.ForeignKey('self', blank=True, null=True)
153 undiluted_concentration = models.DecimalField("Undiluted concentration (ng/ul)", max_digits=5, decimal_places=2, default=0, blank=True, null=True)
154 successful_pM = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True)
155 ten_nM_dilution = models.BooleanField()
156 avg_lib_size = models.IntegerField(default=225, blank=True, null=True)
157 notes = models.TextField(blank=True)
160 return '#%s: %s' % (self.library_id, self.library_name)
163 verbose_name_plural = "libraries"
164 ordering = ["-library_id"]
167 date_hierarchy = "creation_date"
170 search_fields = ['library_name', 'library_id']
171 list_display = ('library_id', 'library_name', 'made_for', 'creation_date', 'stopping_point')
172 list_display_links = ('library_id', 'library_name')
173 list_filter = ('stopping_point', 'library_species', 'made_for', 'made_by', 'experiment_type')
176 'fields': (('library_id', 'library_name'), ('library_species', 'experiment_type'),)
178 ('Creation Information:', {
179 'fields' : (('made_for', 'made_by', 'creation_date'), ('stopping_point', 'amplified_from_sample'), ('undiluted_concentration', 'library_size'), 'notes',)
181 ('Run Information:', {
182 'fields' : (('ten_nM_dilution','successful_pM'),)
186 class FlowCell(models.Model):
188 flowcell_id = models.CharField(max_length=20, unique=True, db_index=True, core=True)
189 run_date = models.DateTimeField(core=True)
190 advanced_run = models.BooleanField(default=False)
191 read_length = models.IntegerField(default=32)
194 FLOWCELL_STATUSES = (
197 ('Del', 'Data deleted'),
198 ('A', 'Data available'),
199 ('In', 'In progress'),
201 flowcell_status = models.CharField(max_length=10, choices=FLOWCELL_STATUSES)
203 lane_1_library = models.ForeignKey(Library, related_name="lane_1_library")
204 lane_2_library = models.ForeignKey(Library, related_name="lane_2_library")
205 lane_3_library = models.ForeignKey(Library, related_name="lane_3_library")
206 lane_4_library = models.ForeignKey(Library, related_name="lane_4_library")
207 lane_5_library = models.ForeignKey(Library, related_name="lane_5_library")
208 lane_6_library = models.ForeignKey(Library, related_name="lane_6_library")
209 lane_7_library = models.ForeignKey(Library, related_name="lane_7_library")
210 lane_8_library = models.ForeignKey(Library, related_name="lane_8_library")
212 lane_1_pM = models.DecimalField(max_digits=5, decimal_places=2, default=4)
213 lane_2_pM = models.DecimalField(max_digits=5, decimal_places=2, default=4)
214 lane_3_pM = models.DecimalField(max_digits=5, decimal_places=2, default=4)
215 lane_4_pM = models.DecimalField(max_digits=5, decimal_places=2, default=4)
216 lane_5_pM = models.DecimalField(max_digits=5, decimal_places=2, default=4)
217 lane_6_pM = models.DecimalField(max_digits=5, decimal_places=2, default=4)
218 lane_7_pM = models.DecimalField(max_digits=5, decimal_places=2, default=4)
219 lane_8_pM = models.DecimalField(max_digits=5, decimal_places=2, default=4)
221 lane_1_cluster_estimate = models.CharField(max_length=25, blank=True, null=True)
222 lane_2_cluster_estimate = models.CharField(max_length=25, blank=True, null=True)
223 lane_3_cluster_estimate = models.CharField(max_length=25, blank=True, null=True)
224 lane_4_cluster_estimate = models.CharField(max_length=25, blank=True, null=True)
225 lane_5_cluster_estimate = models.CharField(max_length=25, blank=True, null=True)
226 lane_6_cluster_estimate = models.CharField(max_length=25, blank=True, null=True)
227 lane_7_cluster_estimate = models.CharField(max_length=25, blank=True, null=True)
228 lane_8_cluster_estimate = models.CharField(max_length=25, blank=True, null=True)
230 kit_1000148 = models.IntegerField(blank=True, null=True)
231 kit_1000147 = models.IntegerField(blank=True, null=True)
232 kit_1000183 = models.IntegerField(blank=True, null=True)
233 kit_1001625 = models.IntegerField(blank=True, null=True)
235 cluster_station_id = models.CharField(max_length=50, blank=True, null=True)
236 sequencer_id = models.CharField(max_length=50, blank=True, null=True)
238 notes = models.TextField(blank=True)
241 return '%s (%s)' % (self.flowcell_id, self.run_date)
244 ordering = ["-run_date"]
247 date_hierarchy = "run_date"
250 search_fields = ['flowcell_id', 'lane_1_library__library_id', 'lane_1_library__library_name', 'lane_2_library__library_id', 'lane_2_library__library_name', 'lane_3_library__library_id', 'lane_3_library__library_name', 'lane_4_library__library_id', 'lane_4_library__library_name', 'lane_5_library__library_id', 'lane_5_library__library_name', 'lane_6_library__library_id', 'lane_6_library__library_name', 'lane_7_library__library_id', 'lane_7_library__library_name', 'lane_8_library__library_id', 'lane_8_library__library_name']
251 list_display = ('run_date', 'flowcell_status', 'flowcell_id', 'lane_1_library', 'lane_2_library', 'lane_3_library', 'lane_4_library', 'lane_5_library', 'lane_6_library', 'lane_7_library', 'lane_8_library')
252 list_display_links = ('run_date', 'flowcell_id', 'lane_1_library', 'lane_2_library', 'lane_3_library', 'lane_4_library', 'lane_5_library', 'lane_6_library', 'lane_7_library', 'lane_8_library')
255 'fields': ('run_date', ('flowcell_id', 'flowcell_status'), ('read_length', 'advanced_run'),)
258 'fields' : (('lane_1_library', 'lane_1_pM'), ('lane_2_library', 'lane_2_pM'), ('lane_3_library', 'lane_3_pM'), ('lane_4_library', 'lane_4_pM'), ('lane_5_library', 'lane_5_pM'), ('lane_6_library', 'lane_6_pM'), ('lane_7_library', 'lane_7_pM'), ('lane_8_library', 'lane_8_pM'),)
261 'fields' : ('notes',)
263 ('Kits & Machines:', {
264 'classes': 'collapse',
265 'fields' : (('kit_1000148', 'kit_1000147', 'kit_1000183', 'kit_1001625'), ('cluster_station_id', 'sequencer_id'),)
267 ('Cluster Estimates:', {
268 'classes': 'collapse',
269 'fields' : (('lane_1_cluster_estimate', 'lane_2_cluster_estimate'), ('lane_3_cluster_estimate', 'lane_4_cluster_estimate'), ('lane_5_cluster_estimate', 'lane_6_cluster_estimate'), ('lane_7_cluster_estimate', 'lane_8_cluster_estimate',),)
273 # Did not finish implementing, removing to avoid further confusion.
274 #class ElandResult(models.Model):
278 # flow_cell = models.ForeignKey(FlowCell)
279 # config_file = models.FileField(upload_to=settings.UPLOADTO_CONFIG_FILE)
280 # eland_result_pack = models.FileField(upload_to=settings.UPLOADTO_ELAND_RESULT_PACKS)
281 # bed_file_pack = models.FileField(upload_to=settings.UPLOADTO_BED_PACKS)
283 # notes = models.TextField(blank=True)