Skip to content

Commit

Permalink
output panel as tsv file
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpru committed Jan 28, 2025
1 parent bce78a4 commit eebcda7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cg/cli/workflow/nallo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ def panel(context: CGConfig, case_id: str, dry_run: bool) -> None:
if dry_run:
echo_lines(lines=bed_lines)
return
analysis_api.write_panel(case_id=case_id, content=bed_lines)
analysis_api.write_panel_as_tsv(case_id=case_id, content=bed_lines)
1 change: 1 addition & 0 deletions cg/constants/scout.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class GenomeBuild(StrEnum):
class ScoutExportFileName(StrEnum):
MANAGED_VARIANTS: str = f"managed_variants{FileExtensions.VCF}"
PANELS: str = f"gene_panels{FileExtensions.BED}"
PANELS_TSV: str = f"gene_panels{FileExtensions.TSV}"


class UploadTrack(StrEnum):
Expand Down
15 changes: 15 additions & 0 deletions cg/meta/workflow/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,17 @@ def _write_panel(out_dir: Path, content: list[str]) -> None:
file_path=Path(out_dir, ScoutExportFileName.PANELS),
)

@staticmethod
def _write_panel_as_tsv(out_dir: Path, content: list[str]) -> None:
"""Write the gene panel to case dir while omitted the commented BED lines."""
filtered_content = [line for line in content if not line.startswith("##")]
out_dir.mkdir(parents=True, exist_ok=True)
WriteFile.write_file_from_content(
content="\n".join(filtered_content),
file_format=FileFormat.TXT,
file_path=Path(out_dir, ScoutExportFileName.PANELS_TSV),
)

def _get_gene_panel(self, case_id: str, genome_build: str, dry_run: bool = False) -> list[str]:
"""Create and return the aggregated gene panel file."""
case: Case = self.status_db.get_case_by_internal_id(internal_id=case_id)
Expand All @@ -725,6 +736,10 @@ def write_panel(self, case_id: str, content: list[str]) -> None:
"""Write the gene panel to case dir."""
self._write_panel(out_dir=Path(self.root, case_id), content=content)

def write_panel_as_tsv(self, case_id: str, content: list[str]) -> None:
"""Write the gene panel to case dir."""
self._write_panel_as_tsv(out_dir=Path(self.root, case_id), content=content)

@staticmethod
def get_aggregated_panels(customer_id: str, default_panels: set[str]) -> list[str]:
"""Check if customer is collaborator for gene panel master list
Expand Down

0 comments on commit eebcda7

Please sign in to comment.