diff --git a/varfish_cli/cli/importer/__init__.py b/varfish_cli/cli/importer/__init__.py index f2a6106..e4a95fd 100644 --- a/varfish_cli/cli/importer/__init__.py +++ b/varfish_cli/cli/importer/__init__.py @@ -133,6 +133,14 @@ 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 affected member of the pedigree file.", + ), + ] = None, ): logger.info("Creating CaseImportInfo object...") common_options: CommonOptions = ctx.obj @@ -145,6 +153,7 @@ def cli_caseimportinfo_create( force_fresh=force_fresh, resubmit=resubmit, project_uuid=project_uuid, + index=index, ), common_options=common_options, ) diff --git a/varfish_cli/cli/importer/create.py b/varfish_cli/cli/importer/create.py index c3f0aa2..560a3fd 100644 --- a/varfish_cli/cli/importer/create.py +++ b/varfish_cli/cli/importer/create.py @@ -279,6 +279,7 @@ class CaseImportOptions(pydantic.BaseModel): resubmit: bool force_fresh: bool case_name_suffix: str + index: typing.Union[str, None] class CaseImporter: @@ -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) @@ -519,7 +521,13 @@ 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") + # use provided index member, first affected member or first general member as index + index = ( + self.index + or next(filter(lambda m: m.affected == 2, self.pedigree), self.pedigree[0]).name + ) name = strip_suffix(name) self._check_genotypes()