Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add index option to case import #136

Merged
merged 6 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions varfish_cli/cli/importer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ def cli_caseimportinfo_create(
help="The genome build (GRCh37/GRCh38) of this case, defaults to GRCh37.",
),
] = GenomeBuild.GRCH37.value,
index: typing.Annotated[
str,
typer.Option(
"--index",
help="Name of the index case in the pedigree, defaults to the first case.",
tedil marked this conversation as resolved.
Show resolved Hide resolved
),
] = None,
):
logger.info("Creating CaseImportInfo object...")
common_options: CommonOptions = ctx.obj
Expand All @@ -145,6 +152,7 @@ def cli_caseimportinfo_create(
force_fresh=force_fresh,
resubmit=resubmit,
project_uuid=project_uuid,
index=index,
),
common_options=common_options,
)
Expand Down
6 changes: 5 additions & 1 deletion varfish_cli/cli/importer/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ class CaseImportOptions(pydantic.BaseModel):
resubmit: bool
force_fresh: bool
case_name_suffix: str
index: typing.Union[str, None]


class CaseImporter:
Expand Down Expand Up @@ -315,6 +316,7 @@ def __init__(self, options: CaseImportOptions, common_options: CommonOptions):

#: The pedigree members.
self.pedigree: typing.List[PedigreeMember] = None
self.index: typing.Union[str, None] = options.index

def _log_exception(self, e):
logger.exception(e, exc_info=self.common_options.verbose)
Expand Down Expand Up @@ -519,7 +521,9 @@ def strip_suffix(x):
return x

name, self.pedigree = self._load_pedigree()
index = self.pedigree[0].name
if self.index and self.index not in {member.name for member in self.pedigree}:
raise ValueError(f"Specified index case '{self.index}' not found in pedigree")
index = self.index or self.pedigree[0].name
tedil marked this conversation as resolved.
Show resolved Hide resolved
name = strip_suffix(name)

self._check_genotypes()
Expand Down
Loading