This repository has been archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
models.py
708 lines (567 loc) · 29.8 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
import datetime
from django.db import models
from django import forms
from django.utils import timezone
from django.utils.encoding import python_2_unicode_compatible
from django.contrib.auth.models import User
from django_utils.models import Center
from django.utils.translation import ugettext_lazy as _
from . import wetlab_config
class RunErrors (models.Model):
errorCode = models.CharField(max_length=10)
errorText = models.CharField(max_length=255)
def __str__ (self):
return '%s' %(self.errorText)
class RunStates (models.Model):
runStateName = models.CharField(max_length=50)
def __str__ (self):
return '%s' %(self.runStateName)
class RunProcess(models.Model):
runName = models.CharField(max_length=45)
sampleSheet = models.FileField(upload_to='wetlab/SampleSheets')
generatedat = models.DateTimeField(auto_now_add=True)
run_date = models.DateField(auto_now = False, null=True)
run_finish_date = models.DateTimeField(auto_now = False, null=True, blank=True)
bcl2fastq_finish_date = models.DateTimeField(auto_now = False, null=True, blank=True)
run_completed_date = models.DateTimeField(auto_now = False, null=True, blank=True)
runState = models.CharField(max_length=25)
state = models.ForeignKey ( RunStates, on_delete = models.CASCADE, related_name = 'state_of_run', null = True, blank = True)
index_library = models.CharField(max_length=85)
samples= models.CharField(max_length=45,blank=True)
useSpaceImgMb=models.CharField(max_length=10, blank=True)
useSpaceFastaMb=models.CharField(max_length=10, blank=True)
useSpaceOtherMb=models.CharField(max_length=10, blank=True)
centerRequestedBy = models.ForeignKey (Center, on_delete=models.CASCADE)
sequencerModel = models.ForeignKey ('iSkyLIMS_drylab.Machines', on_delete=models.CASCADE, null=True, blank=True)
runError = models.ForeignKey( RunErrors, on_delete=models.CASCADE, null = True, blank = True)
stateBeforeError = models.ForeignKey ( RunStates, on_delete = models.CASCADE, null = True, blank = True)
def __str__(self):
return '%s' %(self.runName)
def get_run_id (self):
return '%s' %(self.id)
def get_run_date (self):
if self.run_date is None :
rundate = 'Run NOT started'
else :
rundate=self.run_date.strftime("%B %d, %Y")
return rundate
def get_error_text (self):
return '%s' %(self.runError)
def get_state(self):
return '%s' %(self.state)
def get_state_before_error(self):
return '%s' %(self.stateBeforeError)
def get_info_process (self):
generated_date=self.generatedat.strftime("%I:%M%p on %B %d, %Y")
requested_center = str(self.centerRequestedBy)
if self.run_date is None :
rundate = 'Run NOT started'
else :
rundate=self.run_date.strftime("%B %d, %Y")
if self.run_finish_date is None:
finish_date = 'Run multiplexation is not completed'
else:
finish_date = self.run_finish_date.strftime("%I:%M%p on %B %d, %Y")
if self.bcl2fastq_finish_date is None:
bcl2fastq_date = 'bcl2fastq process is not completed'
else:
bcl2fastq_date = self.bcl2fastq_finish_date.strftime("%I:%M%p on %B %d, %Y")
if self.run_completed_date is None:
completed_date = 'Run process is not completed'
else:
completed_date = self.run_completed_date.strftime("%I:%M%p on %B %d, %Y")
return '%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s' %(self.runName, self.state,
requested_center, generated_date, rundate,completed_date, bcl2fastq_date,
finish_date, self.useSpaceImgMb, self.useSpaceFastaMb,
self.useSpaceOtherMb )
def get_run_name (self):
return '%s' %(self.runName)
def get_disk_space_utilization (self):
image_size_str = '0' if self.useSpaceImgMb == '' else self.useSpaceImgMb
data_size_str = '0' if self.useSpaceFastaMb == '' else self.useSpaceFastaMb
other_size_str = '0' if self.useSpaceOtherMb == '' else self.useSpaceOtherMb
image_size = int(image_size_str.replace(',',''))
data_size = int(data_size_str.replace(',',''))
other_size = int(other_size_str.replace(',',''))
total_size = image_size + data_size + other_size
return '%s'%(total_size)
def get_run_sequencerModel (self):
return '%s' %(self.sequencerModel)
def get_run_platform (self):
return '%s' %self.sequencerModel.platformID
def get_machine_lanes(self):
number_of_lanes = self.sequencerModel.get_number_of_lanes()
return int(number_of_lanes)
def get_sample_file (self):
return '%s' %(self.sampleSheet)
def update_library (self, library_name):
self.index_library = library_name
self.save()
return True
def set_used_space (self, disk_utilization):
self.useSpaceFastaMb = disk_utilization ['useSpaceFastaMb']
self.useSpaceImgMb = disk_utilization ['useSpaceImgMb']
self.useSpaceOtherMb = disk_utilization ['useSpaceOtherMb']
self.save()
return True
def set_run_state (self, new_state):
if RunStates.objects.filter(runStateName__exact = new_state).exists():
self.state = RunStates.objects.get(runStateName__exact = new_state)
self.save()
else:
return False
return True
def set_run_date (self, run_date):
self.run_date = run_date
self.save()
return True
def set_run_bcl2fastq_finished_date (self, bcl2fastq_finish_date):
self.bcl2fastq_finish_date = bcl2fastq_finish_date
self.save()
return True
def set_run_error_code (self, error_code):
if RunErrors.objects.filter(errorCode__exact = error_code).exists():
self.runError = RunErrors.objects.get(errorCode__exact = error_code)
else:
self.runError = RunErrors.objects.get(errorText__exact = 'Undefined')
self.stateBeforeError = self.state
self.state = RunStates.objects.get(runStateName__exact = 'Error')
self.save()
return True
def set_run_completion_date (self, completion_date):
self.run_completed_date = completion_date
self.save()
return True
def set_run_finish_date (self, finish_date):
self.run_finish_date = finish_date
self.save()
return True
def set_sequencer (self, sequencer):
self.sequencerModel = sequencer
self.save()
return True
class LibraryKit (models.Model):
libraryName = models.CharField(max_length=125)
#sampleNumber = models.CharField(max_length = 25)
#indexNumber = models.CharField(max_length = 25)
generatedat = models.DateTimeField(auto_now_add=True)
## To be include in version 2.0
#class LibKitInformation (models.Model):
# librarykitId = models.ForeignKey(
# LibraryKit,
# on_delete= models.CASCADE)
# batch_id = models.CharField(max_length= 255)
# provider = models.CharField(max_length =150)
# sampleNumber = models.CharField(max_length = 25)
# indexNumber = models.CharField(max_length = 25)
# expirationDate = models.DateField(auto_now_add=False)
# generatedat = models.DateTimeField(auto_now_add=True, null=True)
class IndexLibraryKit (models.Model):
indexLibraryName = models.CharField(max_length=125)
version = models.CharField(max_length=80,null=True)
plateExtension = models.CharField(max_length=125, null=True)
adapter1 = models.CharField(max_length=125,null=True)
adapter2 = models.CharField(max_length=125, null=True)
indexLibraryFile = models.FileField(upload_to=wetlab_config.LIBRARY_KITS_DIRECTORY )
generatedat = models.DateTimeField(auto_now_add=True, null=True)
def __srt__ (self):
return '%s'(self.indexLibraryName)
def get_index_library_information (self):
if self.adapter2 =='':
adapter2 = 'Not used on this library'
else:
adapter2 = self.adapter2
return '%s;%s;%s;%s;%s;%s' %(self.indexLibraryName, self.version, self.plateExtension ,
self.adapter1 , adapter2, self.indexLibraryFile)
class IndexLibraryValues (models.Model):
indexLibraryKit_id = models.ForeignKey(
IndexLibraryKit,
on_delete=models.CASCADE)
indexNumber = models.CharField(max_length=12)
indexName = models.CharField(max_length=12)
indexBase = models.CharField(max_length=25)
def get_index_information (self):
return '%s;%s' %(self.indexName, self.indexBase)
class Projects(models.Model):
runprocess_id = models.ForeignKey(
RunProcess,
on_delete=models.CASCADE)
user_id= models.ForeignKey(User,on_delete=models.CASCADE, null = True)
LibraryKit_id = models.ForeignKey(
LibraryKit,
on_delete=models.CASCADE , null=True)
projectName= models.CharField(max_length=45)
libraryKit=models.CharField(max_length=125)
baseSpaceFile = models.CharField(max_length=255)
generatedat = models.DateTimeField(auto_now_add=True)
project_run_date = models.DateField(auto_now = False, null=True)
def __str__(self):
return '%s' %(self.projectName)
def get_state(self):
return '%s' %(self.runprocess_id.state.runStateName)
def get_project_info (self):
generated_date=self.generatedat.strftime("%I:%M%p on %B %d, %Y")
if self.project_run_date is None:
projectdate = 'Run NOT started'
else :
projectdate=self.project_run_date.strftime("%B %d, %Y")
return '%s;%s;%s;%s;%s' %(self.projectName, self.libraryKit,
self.baseSpaceFile, generated_date, projectdate )
def get_p_info_change_library (self):
run_name = self.runprocess_id.runName
user_name = self.user_id.username
if self.project_run_date is None:
projectdate = 'Run NOT started'
else :
projectdate=self.project_run_date.strftime("%B %d, %Y")
return '%s;%s;%s;%s;%s'%(run_name, self.projectName, projectdate, user_name, self.libraryKit)
def get_user_name (self):
user_name = self.user_id.username
return '%s' %(user_name)
def get_project_name (self):
return '%s' %(self.projectName)
def get_library_name (self):
return '%s' %(self.libraryKit)
def get_date (self):
if self.project_run_date is None:
projectdate = 'No Date'
else :
projectdate=self.project_run_date.strftime("%B %d, %Y")
return '%s' %(projectdate)
def get_project_id(self):
return '%s' %(self.id)
class RunningParametersManager (models.Manager) :
def create_running_parameters (self, running_data, run_object) :
if running_data['PlannedRead1Cycles'] == "":
running_data['PlannedRead1Cycles'] = 0
if running_data['PlannedRead2Cycles'] == "":
running_data['PlannedRead2Cycles'] = 0
if running_data['PlannedIndex1ReadCycles'] == "":
running_data['PlannedIndex1ReadCycles'] = 0
if running_data['PlannedIndex2ReadCycles'] == "":
running_data['PlannedIndex2ReadCycles'] = 0
if running_data['LibraryID'] == None:
running_data['LibraryID'] = " "
if running_data['AnalysisWorkflowType'] == None :
running_data['AnalysisWorkflowType'] = " "
running_parameters = self.create (runName_id = run_object,
RunID=running_data['RunID'], ExperimentName=running_data['ExperimentName'],
RTAVersion=running_data['RTAVersion'], SystemSuiteVersion= running_data['SystemSuiteVersion'],
LibraryID= running_data['LibraryID'], Chemistry= running_data['Chemistry'],
RunStartDate= running_data['RunStartDate'], AnalysisWorkflowType= running_data['AnalysisWorkflowType'],
RunManagementType= running_data['RunManagementType'], PlannedRead1Cycles= running_data['PlannedRead1Cycles'],
PlannedRead2Cycles= running_data['PlannedRead2Cycles'], PlannedIndex1ReadCycles= running_data['PlannedIndex1ReadCycles'],
PlannedIndex2ReadCycles= running_data['PlannedIndex2ReadCycles'], ApplicationVersion= running_data['ApplicationVersion'],
NumTilesPerSwath= running_data['NumTilesPerSwath'], ImageChannel= running_data['ImageChannel'],
Flowcell= running_data['Flowcell'], ImageDimensions= running_data['ImageDimensions'],
FlowcellLayout= running_data['FlowcellLayout'])
return running_parameters
class RunningParameters (models.Model):
runName_id = models.OneToOneField(
RunProcess,
on_delete=models.CASCADE,
primary_key=True,
)
RunID= models.CharField(max_length=255)
ExperimentName= models.CharField(max_length=255)
RTAVersion= models.CharField(max_length=255)
SystemSuiteVersion= models.CharField(max_length=255, null=True)
LibraryID= models.CharField(max_length=255, null=True)
Chemistry= models.CharField(max_length=255)
RunStartDate= models.CharField(max_length=255)
AnalysisWorkflowType= models.CharField(max_length=255)
RunManagementType= models.CharField(max_length=255)
PlannedRead1Cycles= models.CharField(max_length=255)
PlannedRead2Cycles= models.CharField(max_length=255)
PlannedIndex1ReadCycles= models.CharField(max_length=255)
PlannedIndex2ReadCycles= models.CharField(max_length=255)
ApplicationVersion= models.CharField(max_length=255)
NumTilesPerSwath= models.CharField(max_length=255)
ImageChannel= models.CharField(max_length=255,null=True)
Flowcell= models.CharField(max_length=255)
ImageDimensions= models.CharField(max_length=255,null=True)
FlowcellLayout= models.CharField(max_length=255)
def __str__(self):
return '%s' %(self.RunID)
#return '%s' %(self.runName_id)
def get_run_parameters_info (self):
#str_run_start_date=self.RunStartDate.strftime("%I:%M%p on %B %d, %Y")
run_parameters_data = []
if self.ImageChannel == None:
img_channel = 'None'
else:
img_channel=self.ImageChannel.strip('[').strip(']').replace("'","")
if self.ImageDimensions == None:
image_dimensions = ['None']
else:
image_dimensions = self.ImageDimensions.strip('{').strip('}').replace("'","").split(',')
flowcell_layout = self.FlowcellLayout.strip('{').strip('}').replace("'","").split(',')
run_parameters_data.append(self.RunID); run_parameters_data.append(self.ExperimentName)
run_parameters_data.append(self.RTAVersion); run_parameters_data.append(self.SystemSuiteVersion)
run_parameters_data.append(self.LibraryID); run_parameters_data.append(self.Chemistry)
run_parameters_data.append(self.RunStartDate); run_parameters_data.append(self.AnalysisWorkflowType)
run_parameters_data.append(self.RunManagementType); run_parameters_data.append(self.PlannedRead1Cycles)
run_parameters_data.append(self.PlannedRead2Cycles); run_parameters_data.append(self.PlannedIndex1ReadCycles)
run_parameters_data.append(self.PlannedIndex2ReadCycles); run_parameters_data.append(self.ApplicationVersion)
run_parameters_data.append(self.NumTilesPerSwath); run_parameters_data.append(img_channel)
run_parameters_data.append(self.Flowcell); run_parameters_data.append(image_dimensions)
run_parameters_data.append(flowcell_layout)
return run_parameters_data
def get_number_of_reads (self):
count = 0
if self.PlannedRead1Cycles != "0" :
count +=1
if self.PlannedRead2Cycles != "0" :
count +=1
if self.PlannedIndex1ReadCycles != "0" :
count +=1
if self.PlannedIndex2ReadCycles != "0" :
count +=1
return count
def get_number_of_cycles (self):
number_of_cycles = int(self.PlannedRead1Cycles) + int(self.PlannedRead2Cycles) + int(self.PlannedIndex1ReadCycles) + int(self.PlannedIndex2ReadCycles)
return number_of_cycles
def get_run_folder (self):
return '%s' %(self.RunID)
objects = RunningParametersManager ()
class StatsRunSummaryManager (models.Manager):
def create_stats_run_summary (self, stats_run_summary , experiment_name) :
run_process = RunProcess.objects.get(runName__exact = experiment_name)
s_run_summary = self.create(runprocess_id = run_process,
level=stats_run_summary['level'], yieldTotal = stats_run_summary['yieldTotal'],
projectedTotalYield= stats_run_summary['projectedTotalYield'],
aligned= stats_run_summary['aligned'], errorRate= stats_run_summary['errorRate'],
intensityCycle= stats_run_summary['intensityCycle'], biggerQ30= stats_run_summary['biggerQ30'],
stats_summary_run_date = run_process.run_date)
return s_run_summary
class StatsRunSummary (models.Model):
runprocess_id = models.ForeignKey(
RunProcess,
on_delete=models.CASCADE)
level= models.CharField(max_length=20)
yieldTotal= models.CharField(max_length=10)
projectedTotalYield = models.CharField(max_length=10)
aligned= models.CharField(max_length=10)
errorRate=models.CharField(max_length=10)
intensityCycle= models.CharField(max_length=10)
biggerQ30= models.CharField(max_length=10)
generatedat = models.DateTimeField(auto_now_add=True)
stats_summary_run_date = models.DateField(auto_now = False, null=True)
def __str__(self):
return '%s' %(self.level)
def get_bin_run_summary(self):
return '%s;%s;%s;%s;%s;%s' %( self.yieldTotal,
self.projectedTotalYield, self.aligned, self.errorRate,
self.intensityCycle, self.biggerQ30)
objects = StatsRunSummaryManager ()
class StatsRunReadManager (models.Manager):
def create_stats_run_read (self, stats_run_read, experiment_name):
run_process = RunProcess.objects.get(runName__exact = experiment_name)
s_run_read = self.create (runprocess_id = run_process,
read= stats_run_read['read'], lane = stats_run_read['lane'] ,
tiles= stats_run_read['tiles'], density= stats_run_read['density'] ,
cluster_PF= stats_run_read['cluster_PF'], phas_prephas= stats_run_read['phas_prephas'],
reads= stats_run_read['reads'], reads_PF= stats_run_read['reads_PF'],
q30= stats_run_read['q30'], yields= stats_run_read['yields'],
cyclesErrRated= stats_run_read['cyclesErrRated'], aligned= stats_run_read['aligned'],
errorRate= stats_run_read['errorRate'], errorRate35= stats_run_read['errorRate35'],
errorRate50= stats_run_read['errorRate50'] , errorRate75= stats_run_read['errorRate75'] ,
errorRate100= stats_run_read['errorRate100'] , intensityCycle= stats_run_read['intensityCycle'] ,
stats_read_run_date = run_process.run_date)
return s_run_read
class StatsRunRead (models.Model):
runprocess_id = models.ForeignKey(
RunProcess,
on_delete=models.CASCADE)
read= models.CharField(max_length=10)
lane = models.CharField(max_length=10)
tiles = models.CharField(max_length=10)
density = models.CharField(max_length=40)
cluster_PF = models.CharField(max_length=40)
phas_prephas = models.CharField(max_length=40)
reads = models.CharField(max_length=40)
reads_PF = models.CharField(max_length=40)
q30 = models.CharField(max_length=40)
yields = models.CharField(max_length=40)
cyclesErrRated = models.CharField(max_length=40)
aligned = models.CharField(max_length=40)
errorRate = models.CharField(max_length=40)
errorRate35 = models.CharField(max_length=40)
errorRate50 = models.CharField(max_length=40)
errorRate75 = models.CharField(max_length=40)
errorRate100 = models.CharField(max_length=40)
intensityCycle = models.CharField(max_length=40)
generatedat = models.DateTimeField(auto_now_add=True)
stats_read_run_date = models.DateField(auto_now = False, null=True)
def __str__(self):
return '%s' %(self.read)
def get_bin_run_read(self):
return '%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s' %( self.lane,self.tiles, self.density,
self.cluster_PF, self.phas_prephas, self.reads, self.reads_PF,
self.q30, self.yields, self.cyclesErrRated, self.aligned,
self.errorRate, self.errorRate35, self.errorRate50, self.errorRate75,
self.errorRate100, self.intensityCycle)
objects = StatsRunReadManager ()
class RawDemuxStatsManager(models.Manager) :
def create_stats_run_read (self, raw_demux_stats, run_object_name):
raw_stats = self.create(runprocess_id = run_object_name,
project_id = raw_demux_stats ['project_id'], defaultAll = raw_demux_stats ['defaultAll'],
rawYield= raw_demux_stats ['rawYield'], rawYieldQ30= raw_demux_stats ['rawYieldQ30'],
rawQuality= raw_demux_stats ['rawQuality'], PF_Yield= raw_demux_stats ['PF_Yield'],
PF_YieldQ30= raw_demux_stats ['PF_YieldQ30'], PF_QualityScore =raw_demux_stats ['PF_QualityScore'] )
return raw_stats
class RawDemuxStats (models.Model):
runprocess_id = models.ForeignKey(
RunProcess,
on_delete=models.CASCADE,)
project_id = models.ForeignKey(Projects, on_delete=models.CASCADE, null=True)
defaultAll =models.CharField(max_length=40, null=True)
rawYield = models.CharField(max_length=255)
rawYieldQ30= models.CharField(max_length=255)
rawQuality= models.CharField(max_length=255)
PF_Yield= models.CharField(max_length=255)
PF_YieldQ30= models.CharField(max_length=255)
PF_QualityScore= models.CharField(max_length=255)
generated_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return '%s' %(self.runprocess_id)
def get_raw_xml_stats(self):
return '%s;%s;%s;%s;%s;%s;%s;%s;%s;%s' %(self.project, self.barcodeCount,
self.perfectBarcodeCount, self.rawYield, self.PF_Yield,
self.rawYieldQ30, self.PF_YieldQ30, self.rawQuality,
self.PF_Quality, self.sampleNumber)
objects = RawDemuxStatsManager ()
class RawTopUnknowBarcodesManager(models.Manager) :
def create_unknow_barcode (self, unknow_barcode):
unknow_barcode = self.create (runprocess_id = unknow_barcode['runprocess_id'] , lane_number = unknow_barcode['lane_number'] ,
top_number = unknow_barcode['top_number'], count = unknow_barcode['count'],
sequence = unknow_barcode['sequence'] )
return unknow_barcode
class RawTopUnknowBarcodes (models.Model):
runprocess_id = models.ForeignKey(
RunProcess,
on_delete=models.CASCADE)
lane_number= models.CharField(max_length=4)
top_number = models.CharField(max_length=4)
count= models.CharField(max_length=40)
sequence = models.CharField(max_length=40)
generated_at = models.DateTimeField(auto_now_add=True)
def __str__ (self):
return '%s' %(self.lane_number)
def get_unknow_barcodes (self):
return '%s;%s' %(self.count, self.sequence)
objects = RawTopUnknowBarcodesManager ()
class StatsFlSummaryManager (models.Manager) :
def create_fl_summary (self, stats_fl_summary):
fl_summary = self.create (runprocess_id = stats_fl_summary ['runprocess_id'], project_id = stats_fl_summary ['project_id'],
defaultAll = stats_fl_summary ['defaultAll'], flowRawCluster = stats_fl_summary ['flowRawCluster'],
flowPfCluster = stats_fl_summary ['flowPfCluster'], flowYieldMb = stats_fl_summary ['flowYieldMb'],
sampleNumber = stats_fl_summary ['sampleNumber'] )
return fl_summary
class StatsFlSummary(models.Model):
runprocess_id = models.ForeignKey(
RunProcess,
on_delete=models.CASCADE)
project_id = models.ForeignKey(Projects, on_delete=models.CASCADE, null=True)
defaultAll =models.CharField(max_length=40, null=True)
flowRawCluster = models.CharField(max_length=40)
flowPfCluster= models.CharField(max_length=40)
flowYieldMb= models.CharField(max_length=40)
sampleNumber= models.CharField(max_length=40)
generated_at = models.DateTimeField(auto_now_add=True)
def get_fl_summary(self):
return '%s;%s;%s;%s' %(self.flowRawCluster, self.flowPfCluster,
self.flowYieldMb, self.sampleNumber)
objects = StatsFlSummaryManager ()
class StatsLaneSummaryManager (models.Manager) :
def create_lane_summary (self, l_summary) :
lane_summary = self.create (runprocess_id = l_summary['runprocess_id'], project_id = l_summary['project_id'],
defaultAll = l_summary['defaultAll'], lane = l_summary['lane'],
pfCluster = l_summary['pfCluster'], percentLane = l_summary['percentLane'],
perfectBarcode = l_summary['perfectBarcode'], oneMismatch = l_summary['oneMismatch'],
yieldMb = l_summary['yieldMb'], biggerQ30 = l_summary['biggerQ30'],
meanQuality = l_summary['meanQuality'] )
return lane_summary
class StatsLaneSummary (models.Model):
runprocess_id = models.ForeignKey(
RunProcess,
on_delete=models.CASCADE)
project_id = models.ForeignKey(Projects, on_delete=models.CASCADE, null=True)
defaultAll =models.CharField(max_length=40, null=True)
lane= models.CharField(max_length=10)
pfCluster = models.CharField(max_length=64)
percentLane = models.CharField(max_length=64)
perfectBarcode = models.CharField(max_length=64)
oneMismatch = models.CharField(max_length=64)
yieldMb = models.CharField(max_length=64)
biggerQ30 = models.CharField(max_length=64)
meanQuality = models.CharField(max_length=64)
generated_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return '%s' %(self.runprocess_id)
def get_flow_cell_summary (self):
return '%s' %(self.runprocess_id)
def get_lane_summary(self):
return '%s;%s;%s;%s;%s;%s;%s;%s' %(self.lane, self.pfCluster,
self.percentLane, self.perfectBarcode, self.oneMismatch,
self.yieldMb, self.biggerQ30, self.meanQuality)
def get_stats_info (self):
return'%s;%s;%s;%s' %(self.biggerQ30, self.meanQuality, self.yieldMb, self.pfCluster)
objects = StatsLaneSummaryManager ()
class GraphicsStats (models.Model):
runprocess_id = models.ForeignKey(
RunProcess,
on_delete=models.CASCADE)
folderRunGraphic= models.CharField(max_length=255)
cluserCountGraph= models.CharField(max_length=255)
flowCellGraph= models.CharField(max_length=255)
intensityByCycleGraph= models.CharField(max_length=255)
heatMapGraph= models.CharField(max_length=255)
histogramGraph= models.CharField(max_length=255)
sampleQcGraph= models.CharField(max_length=255)
## Fix 24/07/2018: null=True added at definition of "generated_at" to allow json load
generated_at = models.DateTimeField(auto_now_add=True, null=True)
def __str__(self):
return '%s' %(self.folderRunGraphic)
def get_graphics(self):
return '%s;%s;%s;%s;%s;%s'%(self.cluserCountGraph,
self.flowCellGraph, self.intensityByCycleGraph,
self.heatMapGraph, self.histogramGraph,
self.sampleQcGraph)
def get_folder_graphic(self):
return '%s' %(self.folderRunGraphic)
class SamplesInProjectManager (models.Manager):
def create_sample_project (self, s_project):
sample_project = self.create( project_id = s_project['project_id'] , sampleName = s_project['sampleName'],
barcodeName = s_project['barcodeName'], pfClusters = s_project['pfClusters'],
percentInProject = s_project['percentInProject'], yieldMb = s_project['yieldMb'],
qualityQ30 = s_project['qualityQ30'], meanQuality = s_project['meanQuality'] )
class SamplesInProject (models.Model):
project_id = models.ForeignKey(
Projects,
on_delete= models.CASCADE)
sampleName = models.CharField(max_length=255)
barcodeName = models.CharField(max_length=255)
pfClusters = models.CharField(max_length=55)
percentInProject = models.CharField(max_length=25)
yieldMb = models.CharField(max_length=55)
qualityQ30 = models.CharField(max_length=55)
meanQuality = models.CharField(max_length=55)
generated_at = models.DateTimeField(auto_now_add=True)
def __str__ (self):
return '%s' %(self.sampleName)
def get_sample_information(self):
return '%s;%s;%s;%s;%s;%s;%s' %(self.sampleName , self.barcodeName,
self.pfClusters ,self.percentInProject, self.yieldMb ,
self.qualityQ30 , self.meanQuality )
def get_sample_name(self):
return '%s' %(self.sampleName)
def get_project_name (self) :
#p_id = self.project_id
#project_name =Projects.objects.get(projectName=p_id).get_project_name()
project_name = self.project_id.get_project_name()
#Projects.objects.prefetch_related('user_id').filter(user_id = user_id)
return '%s' %(project_name)
def get_quality_sample (self):
return '%s' %(self.qualityQ30)
objects = SamplesInProjectManager()