Skip to content

Commit

Permalink
small arg fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rannick committed Sep 3, 2024
1 parent 71e1e39 commit 4e0163f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 25 deletions.
14 changes: 3 additions & 11 deletions cg/apps/scout/scoutapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,7 @@ def upload_rna_coverage_bigwig(
"Something went wrong when uploading rna coverage bigwig file"
) from error


def upload_rna_fraser(
self, file_path: str, case_id: str, customer_sample_id: str
) -> None:
def upload_rna_fraser(self, file_path: str, case_id: str, customer_sample_id: str) -> None:
"""Load a rna fraser file into a case in the database."""

upload_command: list[str] = [
Expand All @@ -298,13 +295,9 @@ def upload_rna_fraser(
LOG.info(f"Uploading rna fraser file {file_path} to case {case_id}")
self.process.run_command(upload_command)
except CalledProcessError as error:
raise ScoutUploadError(
"Something went wrong when uploading rna fraser file"
) from error
raise ScoutUploadError("Something went wrong when uploading rna fraser file") from error

def upload_rna_outrider(
self, file_path: str, case_id: str, customer_sample_id: str
) -> None:
def upload_rna_outrider(self, file_path: str, case_id: str, customer_sample_id: str) -> None:
"""Load a rna outrider file into a case in the database."""

upload_command: list[str] = [
Expand All @@ -325,7 +318,6 @@ def upload_rna_outrider(
"Something went wrong when uploading rna outrider file"
) from error


def upload_rna_alignment_file(
self, case_id: str, customer_sample_id: str, file_path: str
) -> None:
Expand Down
2 changes: 1 addition & 1 deletion cg/cli/upload/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def upload(context: click.Context, case_id: str | None, restart: bool):
upload_api = RarediseaseUploadAPI(config_object)
elif case.data_analysis in {
Workflow.RNAFUSION,
Workflow.TOMTE,
Workflow.TAXPROFILER,
Workflow.TOMTE,
}:
upload_api = NfAnalysisUploadAPI(config_object, case.data_analysis)

Expand Down
7 changes: 4 additions & 3 deletions cg/cli/upload/scout.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ def validate_case_samples_are_rna(context: CGConfig, case_id: str) -> None:
@click.option("-r", "--research", is_flag=True, help="Upload research report instead of clinical")
@click.argument("case_id")
@click.pass_context
def upload_rna_to_scout(context, case_id: str, dry_run: bool, research: bool, analysis: str) -> None:
"""Upload an RNA case's gene fusion report and junction splice files for all samples connect via subject ID."""
def upload_rna_to_scout(
context, case_id: str, dry_run: bool, research: bool, analysis: str
) -> None:
"""Upload an RNA case's gene fusion report and junction splice files for all samples connected via subject ID."""
LOG.info("----------------- UPLOAD RNA TO SCOUT -----------------------")

context.invoke(validate_case_samples_are_rna, case_id=case_id)
Expand Down Expand Up @@ -244,7 +246,6 @@ def upload_omics_to_scout(context: CGConfig, case_id: str, dry_run: bool) -> Non
scout_upload_api.upload_omics_to_scout(dry_run=dry_run, case_id=case_id)



@click.command(name="multiqc-to-scout")
@DRY_RUN
@click.argument("case_id")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% macro tomte_scout_files(scout_files, case_id, case_name) %}
<table class="table w-auto align-middle" aria-describedby="tomte-scout-table">
<tbody>
{% if scout_files.snv_vcf != "N/A" %}
<tr>
<th scope="row">Kliniskt relevanta SNVs och INDELs</th>
<td>{{ scout_files.snv_vcf.replace(case_id, case_name) }}</td>
</tr>
{% endif %}
{% if scout_files.snv_research_vcf != "N/A" %}
<tr>
<th scope="row">SNVs och INDELs för forskning</th>
<td>{{ scout_files.snv_research_vcf.replace(case_id, case_name) }}</td>
</tr>
{% endif %}
{% if scout_files.fraser_tsv != "N/A" %}
<tr>
<th scope="row">Kliniskt avvikande splitsningar</th>
<td>{{ scout_files.fraser_tsv.replace(case_id, case_name) }}</td>
</tr>
{% endif %}
{% if scout_files.outrider_tsv != "N/A" %}
<tr>
<th scope="row">Kliniskt avvikande genuttryck</th>
<td>{{ scout_files.outrider_tsv.replace(case_id, case_name) }}</td>
</tr>
{% endif %}
</tbody>
</table>
{% endmacro %}
4 changes: 3 additions & 1 deletion cg/meta/upload/nf_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def upload(self, ctx: click.Context, case: Case, restart: bool) -> None:
# Scout specific upload
if DataDelivery.SCOUT in case.data_delivery:
if case.data_analysis == Workflow.TOMTE:
ctx.invoke(upload_rna_to_scout, case_id=case.internal_id, re_upload=restart, analysis=case.data_analysis)
ctx.invoke(
upload_rna_to_scout, case_id=case.internal_id, analysis=case.data_analysis
)
else:
ctx.invoke(upload_to_scout, case_id=case.internal_id, re_upload=restart)
LOG.info(
Expand Down
16 changes: 7 additions & 9 deletions cg/meta/upload/scout/uploadscoutapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,16 @@ def get_rna_coverage_bigwig(self, case_id: str, sample_id: str) -> File | None:
tags: set[str] = {AnalysisTag.COVERAGE, AnalysisTag.BIGWIG, sample_id}
return self.housekeeper.get_file_from_latest_version(bundle_name=case_id, tags=tags)


def get_rna_omics_fraser(self, case_id: str, sample_id: str) -> File | None:
"""Return an fraser file for a case in Housekeeper."""
tags: set[str] = {AnalysisTag.COVERAGE, AnalysisTag.FRASER, sample_id}
return self.housekeeper.get_file_from_latest_version(bundle_name=case_id, tags=tags)


def get_rna_omics_outrider(self, case_id: str, sample_id: str) -> File | None:
"""Return an outrider file for a case in Housekeeper."""
tags: set[str] = {AnalysisTag.COVERAGE, AnalysisTag.OUTRIDER, sample_id}
return self.housekeeper.get_file_from_latest_version(bundle_name=case_id, tags=tags)


def get_unique_dna_cases_related_to_rna_case(self, case_id: str) -> set[str]:
"""Return a set of unique DNA cases related to an RNA case."""
case: Case = self.status_db.get_case_by_internal_id(case_id)
Expand Down Expand Up @@ -337,7 +334,6 @@ def upload_rna_coverage_bigwig_to_scout(self, case_id: str, dry_run: bool) -> No
LOG.info(upload_statement)
LOG.info("Upload RNA coverage bigwig file finished!")


def upload_rna_fraser_to_scout(self, dry_run: bool, case_id: str) -> None:
"""Upload omics fraser file for a case to Scout."""
status_db: Store = self.status_db
Expand Down Expand Up @@ -375,7 +371,6 @@ def upload_rna_fraser_to_scout(self, dry_run: bool, case_id: str) -> None:
LOG.info(upload_statement)
LOG.info("Upload RNA fraser file finished!")


def upload_rna_outrider_to_scout(self, dry_run: bool, case_id: str) -> None:
"""Upload omics outrider file for a case to Scout."""
status_db: Store = self.status_db
Expand Down Expand Up @@ -411,8 +406,6 @@ def upload_rna_outrider_to_scout(self, dry_run: bool, case_id: str) -> None:
LOG.info(upload_statement)
LOG.info("Upload RNA outrider file finished!")



def upload_splice_junctions_bed_to_scout(self, dry_run: bool, case_id: str) -> None:
"""Upload splice_junctions_bed file for a case to Scout."""

Expand Down Expand Up @@ -516,13 +509,11 @@ def upload_rna_junctions_to_scout(self, dry_run: bool, case_id: str) -> None:
self.upload_splice_junctions_bed_to_scout(dry_run=dry_run, case_id=case_id)
self.upload_rna_coverage_bigwig_to_scout(case_id=case_id, dry_run=dry_run)


def upload_omics_to_scout(self, dry_run: bool, case_id: str) -> None:
"""Upload RNA omics files to Scout."""
self.upload_rna_fraser_to_scout(dry_run=dry_run, case_id=case_id)
self.upload_rna_outrider_to_scout(case_id=case_id, dry_run=dry_run)


def get_config_builder(self, analysis, hk_version) -> ScoutConfigBuilder:
config_builders = {
Workflow.BALSAMIC: BalsamicConfigBuilder(
Expand All @@ -548,6 +539,13 @@ def get_config_builder(self, analysis, hk_version) -> ScoutConfigBuilder:
Workflow.RNAFUSION: RnafusionConfigBuilder(
hk_version_obj=hk_version, analysis_obj=analysis, lims_api=self.lims
),
Workflow.TOMTE: TomteConfigBuilder(
hk_version_obj=hk_version,
analysis_obj=analysis,
mip_analysis_api=self.mip_analysis_api,
lims_api=self.lims,
madeline_api=self.madeline_api,
),
}

return config_builders[analysis.workflow]
Expand Down

0 comments on commit 4e0163f

Please sign in to comment.