12
12
from cg .apps .scout .scoutapi import ScoutAPI
13
13
from cg .constants import HK_MULTIQC_HTML_TAG , Workflow
14
14
from cg .constants .constants import FileFormat , PrepCategory
15
- from cg .constants .housekeeper_tags import AlignmentFileTag
15
+ from cg .constants .housekeeper_tags import AlignmentFileTag , AnalysisTag
16
16
from cg .constants .scout import ScoutCustomCaseReportTags
17
17
from cg .exc import CgDataError , HousekeeperBundleVersionMissingError
18
18
from cg .io .controller import WriteFile
@@ -132,18 +132,18 @@ def get_multiqc_html_report(
132
132
def get_fusion_report (self , case_id : str , research : bool ) -> File | None :
133
133
"""Return a fusion report for a case in housekeeper."""
134
134
135
- tags = {"fusion" }
135
+ tags = {AnalysisTag . FUSION }
136
136
if research :
137
- tags .add ("research" )
137
+ tags .add (AnalysisTag . RESEARCH )
138
138
else :
139
- tags .add ("clinical" )
139
+ tags .add (AnalysisTag . CLINICAL )
140
140
141
141
return self .housekeeper .get_file_from_latest_version (bundle_name = case_id , tags = tags )
142
142
143
143
def get_splice_junctions_bed (self , case_id : str , sample_id : str ) -> File | None :
144
144
"""Return a splice junctions bed file for a case in Housekeeper."""
145
145
146
- tags : set [str ] = {"junction" , "bed" , sample_id }
146
+ tags : set [str ] = {AnalysisTag . JUNCTION , AnalysisTag . BED , sample_id }
147
147
splice_junctions_bed : File | None = None
148
148
try :
149
149
splice_junctions_bed = self .housekeeper .get_file_from_latest_version (
@@ -156,11 +156,22 @@ def get_splice_junctions_bed(self, case_id: str, sample_id: str) -> File | None:
156
156
157
157
def get_rna_coverage_bigwig (self , case_id : str , sample_id : str ) -> File | None :
158
158
"""Return an RNA coverage bigwig file for a case in Housekeeper."""
159
+ tags : set [str ] = {AnalysisTag .COVERAGE , AnalysisTag .BIGWIG , sample_id }
160
+ return self .housekeeper .get_file_from_latest_version (bundle_name = case_id , tags = tags )
161
+
162
+
163
+ def get_rna_omics_fraser (self , case_id : str , sample_id : str ) -> File | None :
164
+ """Return an fraser file for a case in Housekeeper."""
165
+ tags : set [str ] = {AnalysisTag .COVERAGE , AnalysisTag .FRASER , sample_id }
166
+ return self .housekeeper .get_file_from_latest_version (bundle_name = case_id , tags = tags )
159
167
160
- tags : set [str ] = {"coverage" , "bigwig" , sample_id }
161
168
169
+ def get_rna_omics_outrider (self , case_id : str , sample_id : str ) -> File | None :
170
+ """Return an outrider file for a case in Housekeeper."""
171
+ tags : set [str ] = {AnalysisTag .COVERAGE , AnalysisTag .OUTRIDER , sample_id }
162
172
return self .housekeeper .get_file_from_latest_version (bundle_name = case_id , tags = tags )
163
173
174
+
164
175
def get_unique_dna_cases_related_to_rna_case (self , case_id : str ) -> set [str ]:
165
176
"""Return a set of unique DNA cases related to an RNA case."""
166
177
case : Case = self .status_db .get_case_by_internal_id (case_id )
@@ -326,6 +337,82 @@ def upload_rna_coverage_bigwig_to_scout(self, case_id: str, dry_run: bool) -> No
326
337
LOG .info (upload_statement )
327
338
LOG .info ("Upload RNA coverage bigwig file finished!" )
328
339
340
+
341
+ def upload_rna_fraser_to_scout (self , dry_run : bool , case_id : str ) -> None :
342
+ """Upload omics fraser file for a case to Scout."""
343
+ status_db : Store = self .status_db
344
+ rna_case = status_db .get_case_by_internal_id (case_id )
345
+ rna_dna_collections : list [RNADNACollection ] = self .create_rna_dna_collections (rna_case )
346
+ for rna_dna_collection in rna_dna_collections :
347
+ rna_sample_internal_id : str = rna_dna_collection .rna_sample_internal_id
348
+ dna_sample_name : str = rna_dna_collection .dna_sample_name
349
+ rna_fraser : File | None = self .get_rna_omics_fraser (
350
+ case_id = case_id , sample_id = rna_sample_internal_id
351
+ )
352
+
353
+ if not rna_fraser :
354
+ raise FileNotFoundError (
355
+ f"No RNA fraser file was found in housekeeper for { rna_sample_internal_id } ."
356
+ )
357
+
358
+ LOG .debug (f"RNA fraser file { rna_fraser .path } found." )
359
+ for dna_case_id in rna_dna_collection .dna_case_ids :
360
+ LOG .info (
361
+ f"Uploading RNA fraser file for sample { dna_sample_name } "
362
+ f"in case { dna_case_id } in Scout."
363
+ )
364
+
365
+ if dry_run :
366
+ continue
367
+
368
+ self .scout_api .upload_rna_fraser (
369
+ file_path = rna_fraser .full_path ,
370
+ case_id = dna_case_id ,
371
+ customer_sample_id = dna_sample_name ,
372
+ )
373
+
374
+ for upload_statement in self .get_rna_fraser_upload_summary (rna_dna_collections ):
375
+ LOG .info (upload_statement )
376
+ LOG .info ("Upload RNA fraser file finished!" )
377
+
378
+
379
+ def upload_rna_outrider_to_scout (self , dry_run : bool , case_id : str ) -> None :
380
+ """Upload omics outrider file for a case to Scout."""
381
+ status_db : Store = self .status_db
382
+ rna_case = status_db .get_case_by_internal_id (case_id )
383
+ rna_dna_collections : list [RNADNACollection ] = self .create_rna_dna_collections (rna_case )
384
+ for rna_dna_collection in rna_dna_collections :
385
+ rna_sample_internal_id : str = rna_dna_collection .rna_sample_internal_id
386
+ dna_sample_name : str = rna_dna_collection .dna_sample_name
387
+ rna_outrider : File | None = self .get_rna_omics_outrider (
388
+ case_id = case_id , sample_id = rna_sample_internal_id
389
+ )
390
+ if not rna_outrider :
391
+ raise FileNotFoundError (
392
+ f"No RNA outrider file was found in housekeeper for { rna_sample_internal_id } ."
393
+ )
394
+
395
+ LOG .debug (f"RNA outrider file { rna_outrider .path } found." )
396
+ for dna_case_id in rna_dna_collection .dna_case_ids :
397
+ LOG .info (
398
+ f"Uploading RNA outrider file for sample { dna_sample_name } "
399
+ f"in case { dna_case_id } in Scout."
400
+ )
401
+
402
+ if dry_run :
403
+ continue
404
+
405
+ self .scout_api .upload_rna_outrider (
406
+ file_path = rna_outrider .full_path ,
407
+ case_id = dna_case_id ,
408
+ customer_sample_id = dna_sample_name ,
409
+ )
410
+ for upload_statement in self .get_rna_outrider_upload_summary (rna_dna_collections ):
411
+ LOG .info (upload_statement )
412
+ LOG .info ("Upload RNA outrider file finished!" )
413
+
414
+
415
+
329
416
def upload_splice_junctions_bed_to_scout (self , dry_run : bool , case_id : str ) -> None :
330
417
"""Upload splice_junctions_bed file for a case to Scout."""
331
418
@@ -400,11 +487,42 @@ def get_rna_bigwig_coverage_upload_summary(
400
487
)
401
488
return upload_summary
402
489
490
+ @staticmethod
491
+ def get_rna_fraser_upload_summary (
492
+ rna_dna_collections : list [RNADNACollection ],
493
+ ) -> list [str ]:
494
+ upload_summary : list [str ] = []
495
+ for rna_dna_collection in rna_dna_collections :
496
+ upload_summary .extend (
497
+ f"Uploaded fraser coverage file for sample { rna_dna_collection .dna_sample_name } in case { dna_case } ."
498
+ for dna_case in rna_dna_collection .dna_case_ids
499
+ )
500
+ return upload_summary
501
+
502
+ @staticmethod
503
+ def get_rna_outrider_upload_summary (
504
+ rna_dna_collections : list [RNADNACollection ],
505
+ ) -> list [str ]:
506
+ upload_summary : list [str ] = []
507
+ for rna_dna_collection in rna_dna_collections :
508
+ upload_summary .extend (
509
+ f"Uploaded outrider coverage file for sample { rna_dna_collection .dna_sample_name } in case { dna_case } ."
510
+ for dna_case in rna_dna_collection .dna_case_ids
511
+ )
512
+ return upload_summary
513
+
403
514
def upload_rna_junctions_to_scout (self , dry_run : bool , case_id : str ) -> None :
404
515
"""Upload RNA junctions splice files to Scout."""
405
516
self .upload_splice_junctions_bed_to_scout (dry_run = dry_run , case_id = case_id )
406
517
self .upload_rna_coverage_bigwig_to_scout (case_id = case_id , dry_run = dry_run )
407
518
519
+
520
+ def upload_omics_to_scout (self , dry_run : bool , case_id : str ) -> None :
521
+ """Upload RNA omics files to Scout."""
522
+ self .upload_rna_fraser_to_scout (dry_run = dry_run , case_id = case_id )
523
+ self .upload_rna_outrider_to_scout (case_id = case_id , dry_run = dry_run )
524
+
525
+
408
526
def get_config_builder (self , analysis , hk_version ) -> ScoutConfigBuilder :
409
527
config_builders = {
410
528
Workflow .BALSAMIC : BalsamicConfigBuilder (
0 commit comments