Skip to content

Commit

Permalink
adding gene analysis and variant analysis arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
yaseminbridges committed Sep 21, 2023
1 parent d235475 commit e0d62db
Showing 1 changed file with 59 additions and 20 deletions.
79 changes: 59 additions & 20 deletions src/pheval_lirical/prepare/prepare_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,46 +61,58 @@ def get_vcf_assembly(self) -> str:
phenopacket_path=self.phenopacket_path, vcf_dir=self.vcf_dir
).file_attributes["genomeAssembly"]

def add_manual_cli_arguments(self) -> LiricalManualCommandLineArguments:
def add_manual_cli_arguments(
self, gene_analysis: bool, variant_analysis: bool
) -> LiricalManualCommandLineArguments:
"""Return all CLI arguments to run LIRICAL in manual mode."""
return LiricalManualCommandLineArguments(
lirical_jar_file=self.lirical_jar,
observed_phenotypes=self.get_list_observed_phenotypic_features(),
negated_phenotypes=self.get_list_negated_phenotypic_features(),
assembly=self.get_vcf_assembly(),
vcf_file_path=self.get_vcf_path(),
assembly=self.get_vcf_assembly() if gene_analysis or variant_analysis else None,
vcf_file_path=self.get_vcf_path() if gene_analysis or variant_analysis else None,
lirical_data=self.input_dir,
exomiser_data=self.exomiser_data_dir,
sample_id=self.phenopacket_util.sample_id(),
output_dir=self.results_dir,
output_prefix=self.phenopacket_path.stem,
exomiser_hg19_data_path=self.exomiser_hg19_data_path,
exomiser_hg38_data_path=self.exomiser_hg38_data_path,
exomiser_hg19_data_path=self.exomiser_hg19_data_path
if gene_analysis or variant_analysis
else None,
exomiser_hg38_data_path=self.exomiser_hg38_data_path
if gene_analysis or variant_analysis
else None,
)

def add_phenopacket_cli_arguments(self) -> LiricalPhenopacketCommandLineArguments:
def add_phenopacket_cli_arguments(
self, gene_analysis: bool, variant_analysis: bool
) -> LiricalPhenopacketCommandLineArguments:
"""Return all CLI arguments to run LIRICAL in phenopacket mode."""
return LiricalPhenopacketCommandLineArguments(
lirical_jar_file=self.lirical_jar,
phenopacket_path=self.phenopacket_path,
vcf_file_path=self.get_vcf_path(),
assembly=self.get_vcf_assembly(),
vcf_file_path=self.get_vcf_path() if gene_analysis or variant_analysis else None,
assembly=self.get_vcf_assembly() if gene_analysis or variant_analysis else None,
lirical_data=self.input_dir,
exomiser_data=self.exomiser_data_dir,
output_dir=self.results_dir,
output_prefix=self.phenopacket_path.stem,
exomiser_hg19_data_path=self.exomiser_hg19_data_path,
exomiser_hg38_data_path=self.exomiser_hg38_data_path,
exomiser_hg19_data_path=self.exomiser_hg19_data_path
if gene_analysis or variant_analysis
else None,
exomiser_hg38_data_path=self.exomiser_hg38_data_path
if gene_analysis or variant_analysis
else None,
)

def add_cli_arguments(
self,
self, gene_analysis: bool, variant_analysis: bool
) -> LiricalManualCommandLineArguments or LiricalManualCommandLineArguments:
"""Return all CLI arguments."""
if self.mode.lower() == "phenopacket":
return self.add_phenopacket_cli_arguments()
return self.add_phenopacket_cli_arguments(gene_analysis, variant_analysis)
elif self.mode.lower() == "manual":
return self.add_manual_cli_arguments()
return self.add_manual_cli_arguments(gene_analysis, variant_analysis)


def create_command_arguments(
Expand All @@ -113,6 +125,8 @@ def create_command_arguments(
mode: str,
exomiser_hg19_data: Path,
exomiser_hg38_data: Path,
gene_analysis: bool,
variant_analysis: bool,
) -> list[LiricalManualCommandLineArguments] or list[LiricalPhenopacketCommandLineArguments]:
"""Return a list of LIRICAL command line arguments for a directory of phenopackets."""
phenopacket_paths = files_with_suffix(phenopacket_dir, ".json")
Expand All @@ -131,7 +145,7 @@ def create_command_arguments(
mode=mode,
exomiser_hg19_data_path=exomiser_hg19_data,
exomiser_hg38_data_path=exomiser_hg38_data,
).add_cli_arguments()
).add_cli_arguments(gene_analysis, variant_analysis)
)
return commands

Expand Down Expand Up @@ -184,12 +198,13 @@ def write_vcf_file_properties(
or LiricalPhenopacketCommandLineArguments,
) -> None:
"""Write related VCF arguments to command."""
self.file.write(
" --vcf "
+ str(command_arguments.vcf_file_path)
+ " --assembly "
+ command_arguments.assembly
)
if command_arguments.vcf_file_path is not None:
self.file.write(
" --vcf "
+ str(command_arguments.vcf_file_path)
+ " --assembly "
+ command_arguments.assembly
)

def write_sample_id(self, command_arguments: LiricalManualCommandLineArguments) -> None:
"""Write the sample id."""
Expand Down Expand Up @@ -312,6 +327,8 @@ def prepare_commands(
lirical_version: str,
exomiser_hg19_data: Path,
exomiser_hg38_data: Path,
gene_analysis: bool,
variant_analysis: bool,
) -> None:
"""Prepare command batch files to run LIRICAL."""
command_arguments = create_command_arguments(
Expand All @@ -324,6 +341,8 @@ def prepare_commands(
mode,
exomiser_hg19_data,
exomiser_hg38_data,
gene_analysis,
variant_analysis,
)
write_all_commands(
command_arguments, tool_input_commands_dir, file_prefix, mode, lirical_version
Expand Down Expand Up @@ -362,6 +381,22 @@ def prepare_commands(
@click.option(
"--exomiser-hg38", "-e38", required=False, help="Exomiser hg38 variant database.", type=Path
)
@click.option(
"--gene-analysis/--no-gene-analysis",
default=False,
required=False,
type=bool,
show_default=True,
help="Specify analysis for gene prioritisation",
)
@click.option(
"--variant-analysis/--no-variant-analysis",
default=False,
required=False,
type=bool,
show_default=True,
help="Specify analysis for variant prioritisation",
)
def prepare_commands_command(
lirical_jar: Path,
input_dir: Path,
Expand All @@ -375,6 +410,8 @@ def prepare_commands_command(
lirical_version: str,
exomiser_hg19: Path,
exomiser_hg38: Path,
gene_analysis: bool,
variant_analysis: bool,
):
"""Prepare command batch files to run LIRICAL."""
output_dir.joinpath("tool_input_commands").mkdir(parents=True, exist_ok=True)
Expand All @@ -391,4 +428,6 @@ def prepare_commands_command(
lirical_version,
exomiser_hg19,
exomiser_hg38,
gene_analysis,
variant_analysis,
)

0 comments on commit e0d62db

Please sign in to comment.