Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
147 changes: 145 additions & 2 deletions magma_smaht/commands/create_meta_workflow_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
mwfr_sample_identity_check,
mwfr_bam_to_cram,
)
from magma_smaht.create_metawfr_variant_calling import (
mwfrs_somatic_snv_callers,
mwfrs_somatic_snv_callers_by_core,
mwfr_germline_snv_caller,
mwfr_somatic_snv_filtering,
mwfrs_somatic_sv_callers,
)
from magma_smaht.utils import get_auth_key


Expand Down Expand Up @@ -452,7 +459,6 @@ def conversion_bam_to_cram(fileset_accessions, auth_env):
"""Conversion MWFR for final output BAMs to CRAM"""
smaht_key = get_auth_key(auth_env)
mwfr_bam_to_cram(fileset_accessions, smaht_key)



@cli.command()
Expand All @@ -461,7 +467,7 @@ def conversion_bam_to_cram(fileset_accessions, auth_env):
"-f", "--files", required=True, type=str, multiple=True, help="BAM file accessions"
)
@click.option(
"-d", "--donor", required=True, type=str, help="Accession of the associated donor"
"-d", "--donor", required=False, type=str, help="Accession of the associated donor"
)
@click.option(
"-e",
Expand All @@ -476,5 +482,142 @@ def sample_identity_check(files, donor, auth_env):
mwfr_sample_identity_check(files, donor, smaht_key)


@cli.command()
@click.help_option("--help", "-h")
@click.option("-d", "--donor", required=True, type=str, help="Accession of the donor")
@click.option(
"-t",
"--tissue",
required=False,
default=None,
type=str,
help="Accession of the donor-specific tissue used for variant calling (optional)",
)
@click.option(
"-a",
"--analysis-run",
required=False,
default=None,
type=str,
help="Accession of an existing analysis run (optional)",
)
@click.option(
"-e",
"--auth-env",
required=True,
type=str,
help="Name of environment in smaht-keys file",
)
def call_germline_snv(donor, tissue, analysis_run, auth_env):
"""Call germline variants for a given donor. This is a prerequesite for somatic SNV calling."""
smaht_key = get_auth_key(auth_env)
mwfr_germline_snv_caller(donor, tissue, analysis_run, smaht_key)


@cli.command()
@click.help_option("--help", "-h")
@click.option(
"-t", "--tissue", required=True, type=str, help="Accession of donor specific tissue"
)
@click.option(
"-a",
"--analysis-run",
required=False,
default=None,
type=str,
help="Accession of an existing analysis run (optional)",
)
@click.option(
"-e",
"--auth-env",
required=True,
type=str,
help="Name of environment in smaht-keys file",
)
def call_somatic_snv_by_core(tissue, analysis_run, auth_env):
"""Call SNV on a given tissue sample. Create the individual caller MWFRs by core. If an analysis run is provided, the MWFRs will be added to it."""
smaht_key = get_auth_key(auth_env)
mwfrs_somatic_snv_callers_by_core(tissue, analysis_run, smaht_key)


@cli.command()
@click.help_option("--help", "-h")
@click.option(
"-t", "--tissue", required=True, type=str, help="Accession of donor specific tissue"
)
@click.option(
"-a",
"--analysis-run",
required=False,
default=None,
type=str,
help="Accession of an existing analysis run (optional)",
)
@click.option(
"-e",
"--auth-env",
required=True,
type=str,
help="Name of environment in smaht-keys file",
)
def call_somatic_snv_step1(tissue, analysis_run, auth_env):
"""Call SNV on a given tissue sample. Step 1 will create the individual caller MWFRs. If an analysis run is provided, the MWFRs will be added to it."""
smaht_key = get_auth_key(auth_env)
mwfrs_somatic_snv_callers(tissue, analysis_run, smaht_key)



@cli.command()
@click.help_option("--help", "-h")
@click.option(
"-t", "--tissue", required=True, type=str, help="Accession of donor specific tissue"
)
@click.option(
"-a",
"--analysis-run",
required=False,
default=None,
type=str,
help="Accession of an existing analysis run (optional)",
)
@click.option(
"-e",
"--auth-env",
required=True,
type=str,
help="Name of environment in smaht-keys file",
)
def call_somatic_sv(tissue, analysis_run, auth_env):
"""Call somatic SV on a given tissue sample. This will create individual caller MWFRs. If an analysis run is provided, the MWFRs will be added to it."""
smaht_key = get_auth_key(auth_env)
mwfrs_somatic_sv_callers(tissue, analysis_run, smaht_key)


@cli.command()
@click.help_option("--help", "-h")
@click.option(
"-t", "--tissue", required=True, type=str, help="Accession of donor specific tissue"
)
@click.option(
"-a",
"--analysis-run",
required=False,
default=None,
type=str,
help="Accession of an existing analysis run",
)
@click.option(
"-e",
"--auth-env",
required=True,
type=str,
help="Name of environment in smaht-keys file",
)
def call_somatic_snv_step2(tissue, analysis_run, auth_env):
"""Create filtered SNV on a given tissue sample. It will use the outputs of the caller MWFRs created in step 1. This step requires an existing analysis run with the caller MWFRs already added."""
smaht_key = get_auth_key(auth_env)
mwfr_somatic_snv_filtering(tissue, analysis_run, smaht_key)


if __name__ == "__main__":
cli()
75 changes: 73 additions & 2 deletions magma_smaht/commands/wrangler_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,30 @@ def cli():
pass


@cli.command()
@click.help_option("--help", "-h")
@click.option(
"-d",
"--donor",
required=True,
type=str,
help="External ID of the donor (e.g. SMHT001)",
)
@click.option(
"-e",
"--auth-env",
required=True,
type=str,
help="Name of environment in smaht-keys file",
)
def analysis_overview(donor, auth_env):
"""
Check which files need to be checked for sample identity.
"""
smaht_key = get_auth_key(auth_env)
wrangler_utils.analysis_overview(donor, smaht_key)


@cli.command()
@click.help_option("--help", "-h")
@click.option(
Expand Down Expand Up @@ -78,6 +102,45 @@ def reset_mwfrs(mwfr_uuids, auth_env):
wrangler_utils.reset_mwfrs(mwfr_uuids, smaht_key)


@cli.command()
@click.help_option("--help", "-h")
@click.option(
"-m",
"--mwfr-uuids",
required=True,
type=str,
multiple=True,
help="List of MWFRs to reset",
)
@click.option(
"-p",
"--steps",
required=True,
type=str,
help="Steps to reset (comma-separated)",
)
@click.option(
"-s",
"--status",
required=True,
type=str,
help="Status to reset to",
)
@click.option(
"-e",
"--auth-env",
required=True,
type=str,
help="Name of environment in smaht-keys file",
)
def reset_status_mwfrs(mwfr_uuids, steps, status, auth_env):
"""Reset a list of failed MetaWorkflowRuns to a desired status"""
smaht_key = get_auth_key(auth_env)
steps_list = steps.split(",")
for mwfr_uuid in mwfr_uuids:
wrangler_utils.reset_status_mwfr(mwfr_uuid, steps_list, status, smaht_key)


@cli.command()
@click.help_option("--help", "-h")
@click.option(
Expand All @@ -87,17 +150,25 @@ def reset_mwfrs(mwfr_uuids, auth_env):
type=str,
help="Name of environment in smaht-keys file",
)
@click.option(
"-l",
"--limit",
required=False,
default=100,
type=int,
help="Limit of failed MWFRs to reset",
)
@click.option(
"--ignore-md5",
default=False,
is_flag=True,
show_default=True,
help="Ignore MD5 checksum runs",
)
def reset_all_failed_mwfrs(auth_env, ignore_md5):
def reset_all_failed_mwfrs(auth_env, ignore_md5, limit):
"""Reset all failed MetaWorkflowRuns on the portal"""
smaht_key = get_auth_key(auth_env)
wrangler_utils.reset_all_failed_mwfrs(smaht_key, ignore_md5)
wrangler_utils.reset_all_failed_mwfrs(smaht_key, ignore_md5, limit)


@cli.command()
Expand Down
24 changes: 23 additions & 1 deletion magma_smaht/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@
MWF_NAME_ULTRA_LONG_BAMQC = "ultra-long_reads_BAM_quality_metrics_GRCh38"
MWF_NAME_LONG_READ_BAMQC = "long_reads_BAM_quality_metrics_GRCh38"
MWF_SAMPLE_IDENTITY_CHECK = "sample_identity_check"
# Variant callering
MWF_NAME_TNHAPLOTYPER = "paired-end_short_reads_variant_calling_TNhaplotyper2_distributed_TNfilter_GRCh38"
MWF_NAME_LONGCALLD = "PacBio_variant_calling_longcallD_GRCh38"
MWF_NAME_LONGCALLD_SINGLE_FILE = "PacBio_variant_calling_longcallD_single_file_GRCh38"
MWF_NAME_STRELKA2 = "paired-end_short_reads_variant_calling_Strelka2_distributed_GRCh38"
MWF_NAME_RUFUS = "paired-end_short_reads_variant_calling_RUFUS_distributed_GRCh38"
MWF_NAME_DNASCOPEHYBRID = "paired-end_short_plus_PacBio_variant_calling_DNAscopeHybrid_GRCh38"
MWF_NAME_SNIFFLES = "PacBio_ONT_variant_calling_Sniffles_GRCh38"
MWF_NAME_SEVERUS = "PacBio_ONT_variant_calling_Severus_GRCh38"
MWF_NAME_DELLY = "PacBio_ONT_variant_calling_Delly_GRCh38"
MWF_NAME_SNV_FILTERING_LONGCALLD = "SNV_filtering_longcallD_GRCh38"
MWF_NAME_SNV_FILTERING = "SNV_filtering_GRCh38"

HMS_DAC_UUID = "9626d82e-8110-4213-ac75-0a50adf890ff"

# Input argument names
INPUT_FILES_R1_FASTQ_GZ = "input_files_r1_fastq_gz"
Expand All @@ -28,6 +42,8 @@
INPUT_FILES = "input_files"
INPUT_FILES_FASTQ_GZ = "input_files_fastq_gz"
INPUT_FILES_CRAM = "input_files_cram"
INPUT_FILE_CRAM = "input_file_cram"
ADDITIONAL_INPUT_FILES_CRAM = "additional_input_files_cram"
GENOME_REFERENCE_FASTA = "genome_reference_fasta"
SAMPLE_NAME = "sample_name"
SAMPLE_NAMES = "sample_names"
Expand All @@ -46,7 +62,9 @@
SEQUENCING_CENTER = "sequencing_center"
CONSORTIA = "consortia"
FILE_SETS = "file_sets"
META_WORFLOW_RUN = "MetaWorkflowRun"
ANALYSIS_RUNS = "analysis_runs"
META_WORKFLOW_RUN = "MetaWorkflowRun"
ANALYSIS_RUN = "AnalysisRun"
ACCESSION = "accession"
DISPLAY_TITLE = "display_title"
ALIASES = "aliases"
Expand All @@ -63,6 +81,10 @@
FIRST_STRANDED = "First Stranded"
SECOND_STRANDED = "Second Stranded"
FAILED_JOBS = "failed_jobs"
SOMATIC_SNV_CALLING = "Somatic SNV calling"
SOMATIC_SNV_CALLING_CORE_SPECIFIC = "Somatic SNV calling (core specific)"
SOMATIC_SV_CALLING = "Somatic SV calling"
GERMLINE_SNV_CALLING = "Germline SNV calling"

# Assays
WGS = "WGS"
Expand Down
Loading
Loading