Project Analysis

Functions

wrapica.project_analysis.abort_analysis(project_id, analysis_id)

Abort an analysis

Parameters:
  • project_id (Union[UUID, str]) – The project id the analysis was run in

  • analysis_id (Union[UUID, str]) – The analysis id to abort

Raises:

ApiException

Returns:

None

Return type:

None

Examples:

:linenos:
from pathlib import Path
from wrapica.project_analysis import abort_analysis

# Set params
# Use wrapica.project.get_project_id_from_project_name
# If you need to convert a project_name to a project_id
project_id = "project_id"
analysis_id = "analysis_id"
wrapica.project_analysis.add_tag_to_analysis(project_id, analysis_id, tag, tag_type)
wrapica.project_analysis.analysis_step_to_dict(analysis_step)

Convert an analysis step object to a dictionary

Returns the following attributes * name: str -> remove preceding ‘#’ values * status: WorkflowStep.Status -> The workflow step status * queue_date: Datetime object * start_date: Datetime object * end_date: Datetime object

Parameters:

analysis_step (AnalysisStep) – The AnalysisStep object

Returns:

The analysis step as a dict

Return type:

Dict

wrapica.project_analysis.coerce_analysis_id_or_user_reference_to_analysis_id(project_id, analysis_id_or_user_reference)

Given either an analysis id or user reference, coerce to an analysis id

Parameters:
  • project_id (Union[UUID, str])

  • analysis_id_or_user_reference (str)

Return type:

str

Returns:

wrapica.project_analysis.coerce_analysis_id_or_user_reference_to_analysis_obj(project_id, analysis_id_or_user_reference)

Given either an analysis id or user reference, coerce to an analysis object

Parameters:
  • project_id (Union[UUID, str])

  • analysis_id_or_user_reference (Union[UUID, str])

Returns:

The analysis object

Return type:

Analysis

Raises:

ValueError

Examples:

:linenos:
from wrapica.project_analysis import coerce_analysis_id_or_user_reference_to_analysis_obj

# Set params
analysis_id_or_user_reference = "analysis_id"

analysis = coerce_analysis_id_or_user_reference_to_analysis_obj(analysis_id_or_user_reference)
wrapica.project_analysis.get_analysis_input_object_from_analysis_input_code(project_id, analysis_id, analysis_input_code)

Given an analysis input code for an analysis id, collect the analysis input object Confirm the input has either analysis or external data attributes

Parameters:
  • project_id (Union[UUID, str]) – The project context the analysis was run in

  • analysis_id (Union[UUID, str]) – The analysis id to query

  • analysis_input_code (str) – The analysis input code to query

Returns:

The analysis input object

Return type:

AnalysisInput

Raises:

StopIteration, ValueError, ApiException

Examples:

:linenos:
from wrapica.project_analysis import get_analysis_input_object_from_analysis_code

# Set params
project_id = "project_id"
analysis_id = "analysis_id"
analysis_code = "run_folder"

run_folder_input_data_id = get_analysis_input_object_from_analysis_code(
    project_id, analysis_id, analysis_code
).analysis_data[0].data_id
wrapica.project_analysis.get_analysis_log_from_analysis_step(analysis_step)

Get the logs for a given analysis step

Parameters:

analysis_step (AnalysisStep)

Returns:

Get the logs attribute of an analysis step

Return type:

AnalysisStepLogs

Examples:

:linenos:
from wrapica.project_analysis import get_analysis_steps

# Set params
project_id = "project_id"
analysis_id = "analysis_id"

analysis_step_list = get_analysis_steps(project_id, analysis_id)

step_logs = list(map(get_analysis_log_from_analysis_step, analysis_step_list))
wrapica.project_analysis.get_analysis_obj_from_analysis_id(project_id, analysis_id)

Get an analysis object given a project id and analysis id

Parameters:
  • project_id (Union[UUID, str]) – The project context the analysis was run in

  • analysis_id (Union[UUID, str]) – The analysis id to query

Returns:

The analysis object

Return type:

Analysis

Raises:

ApiException

Examples:

:linenos:
from wrapica.project_analysis import get_analysis_obj_from_analysis_id

# Set params
project_id = "project_id"
analysis_id = "analysis_id"

analysis = get_analysis_obj_from_analysis_id(project_id, analysis_id)
wrapica.project_analysis.get_analysis_obj_from_user_reference(project_id, user_reference)

Given a user reference, get the analysis object

Will fail if more than one analysis is found for a given user reference. Will also fail if no analysis is found for the user reference.

Parameters:
  • project_id (Union[UUID, str])

  • user_reference (str)

Return type:

Union[AnalysisV3, AnalysisV4]

Returns:

wrapica.project_analysis.get_analysis_output_object_from_analysis_output_code(project_id, analysis_id, analysis_output_code)

Given an analysis code for an analysis id, collect the analysis output object

Parameters:
  • project_id (Union[UUID, str]) – The project context the analysis was run in

  • analysis_id (Union[UUID, str]) – The analysis id to query

  • analysis_output_code (str) – The analysis output code to collect

Returns:

The analysis output object

Return type:

AnalysisOutput

Raises:

StopIteration, ValueError, ApiException

Examples:

:linenos:
from wrapica.project_analysis import get_analysis_output_object_from_analysis_code

# Set params
project_id = "project_id"
analysis_id = "analysis_id"
analysis_code = "Output"

analysis_folder_output_id = get_analysis_output_object_from_analysis_code(
    project_id, analysis_id, analysis_code
).data[0].data_id
wrapica.project_analysis.get_analysis_steps(project_id, analysis_id, include_technical_steps=False)

Get the workflow steps for a given analysis

Parameters:
  • project_id (Union[UUID, str])

  • analysis_id (Union[UUID, str])

  • include_technical_steps (bool)

Returns:

List of analysis steps

Return type:

List[AnalysisStep]

Raises:

ApiException

Examples:

:linenos:
from wrapica.project_analysis import get_analysis_steps

# Set params
project_id = "project_id"
analysis_id = "analysis_id"

analysis_step_list = get_analysis_steps(project_id, analysis_id)
wrapica.project_analysis.get_analysis_usage(project_id, analysis_id)

Given a project id and analysis id, collect the analysis usage details

Parameters:
Returns:

The analysis usage details for the given analysis

Return type:

AnalysisUsageDetails

Raises:

ApiException

Examples:

:linenos:
from wrapica.project_analysis import get_analysis_usage

# Set params
project_id = "project_id"
analysis_id = "analysis_id"

usage = get_analysis_usage(project_id, analysis_id)
wrapica.project_analysis.get_cwl_analysis_input_json(project_id, analysis_id)

Get the CWL Analysis Input JSON

Parameters:
  • project_id (Union[UUID, str]) – The project id the analysis was run in

  • analysis_id (Union[UUID, str]) – The analysis id

Returns:

The CWL Analysis Input JSON As a dictionary

Return type:

Dict

Raises:

ApiException

Examples:

 1# Imports
 2import json
 3from wrapica.project_analysis import get_cwl_analysis_input_json
 4
 5# Set params
 6project_id = "project_id"
 7analysis_id = "analysis_id"
 8
 9# Print the input json
10print(
11    json.dumps(
12        get_cwl_analysis_input_json(project_id, analysis_id),
13        indent=4
14    )
15)
wrapica.project_analysis.get_cwl_analysis_output_json(project_id, analysis_id)

Get the CWL Analysis Input JSON

Parameters:
  • project_id (Union[UUID, str]) – The project id the analysis was run in

  • analysis_id (Union[UUID, str]) – The analysis id

Returns:

The CWL Analysis Output JSON As a dictionary

Return type:

Dict

Raises:

ApiException

Examples:

 1# Imports
 2import json
 3from wrapica.project_analysis import get_cwl_analysis_output_json
 4
 5# Set params
 6project_id = "project_id"
 7analysis_id = "analysis_id"
 8
 9# Print the output json
10print(
11    json.dumps(
12        get_cwl_analysis_output_json(project_id, analysis_id),
13        indent=4
14    )
15)
wrapica.project_analysis.get_cwl_outputs_json_from_analysis_id(project_id, analysis_id)

Query the outputs object from the analysis id

Parameters:
  • project_id (Union[UUID, str]) – The project context the analysis was run in

  • analysis_id (Union[UUID, str]) – The analysis id to query

Returns:

List of analysis outputs

Return type:

Dict[str, Any]

Raises:

ApiException

Examples:

:linenos:
from wrapica.project_analysis import get_cwl_outputs_json_from_analysis_id

# Set params
project_id = "project_id"
analysis_id = "analysis_id"

cwl_json_output = get_cwl_outputs_json_from_analysis_id(project_id, analysis_id)
wrapica.project_analysis.get_outputs_object_from_analysis_id(project_id, analysis_id)

Query the outputs object from the analysis id

Parameters:
  • project_id (Union[UUID, str]) – The project context the analysis was run in

  • analysis_id (Union[UUID, str]) – The analysis id to query

Returns:

List of analysis outputs

Return type:

List[AnalysisOutput]

Raises:

ApiException

Examples:

:linenos:
from wrapica.project_analysis import get_outputs_object_from_analysis_id

# Set params
project_id = "project_id"
analysis_id = "analysis_id"

workflow_outputs = get_outputs_object_from_analysis_id(project_id, analysis_id)
wrapica.project_analysis.get_project_analysis_inputs(project_id, analysis_id)

Get the analysis inputs for a given analysis

Parameters:
  • project_id (Union[UUID, str]) – The project context the analysis was run in

  • analysis_id (Union[UUID, str]) – The analysis id to query

Returns:

List of analysis inputs

Return type:

List[AnalysisInput]

Raises:

ApiException

Examples:

:linenos:
from wrapica.project_analysis import get_project_analysis_inputs

# Set params
project_id = "project_id"
analysis_id = "analysis_id"

workflow_inputs = get_project_analysis_inputs(project_id, analysis_id)
wrapica.project_analysis.list_analyses(project_id, pipeline_id=None, user_reference=None, status=None, creation_date_before=None, creation_date_after=None, modification_date_before=None, modification_date_after=None, sort=None, max_items=None)

List analyses

Parameters:
  • project_id (Union[UUID, str]) – The project id

  • pipeline_id (Union[UUID, str, None]) – The pipeline id

  • user_reference (Optional[str]) – The full user reference (regex optional)

  • status (Union[Literal['REQUESTED', 'QUEUED', 'INITIALIZING', 'PREPARING_INPUTS', 'IN_PROGRESS', 'GENERATING_OUTPUTS', 'SUCCEEDED', 'ABORTING', 'FAILED', 'FAILED_FINAL', 'ABORTED', 'AWAITING_INPUT'], List[Literal['REQUESTED', 'QUEUED', 'INITIALIZING', 'PREPARING_INPUTS', 'IN_PROGRESS', 'GENERATING_OUTPUTS', 'SUCCEEDED', 'ABORTING', 'FAILED', 'FAILED_FINAL', 'ABORTED', 'AWAITING_INPUT']], None]) – The status of the analysis

  • creation_date_before (Optional[datetime]) – Return only analyses created before this date

  • creation_date_after (Optional[datetime]) – Return only analyses created after this date

  • modification_date_before (Optional[datetime]) – Return only analyses modified before this date

  • modification_date_after (Optional[datetime]) – Return only analyses modified after this date

  • sort (Union[Literal['reference', '-reference', 'userReference', '-userReference', 'pipeline', '-pipeline', 'status', '-status', 'startDate', '-startDate', 'endDate', '-endDate', 'summary', '-summary'], List[Literal['reference', '-reference', 'userReference', '-userReference', 'pipeline', '-pipeline', 'status', '-status', 'startDate', '-startDate', 'endDate', '-endDate', 'summary', '-summary']], None]) – A parameter, or list of parameters to sort by

  • max_items (Optional[int])

Raises:

ApiException

Returns:

List of analyses

Return type:

List[Analysis]

Examples:

:linenos:
from pathlib import Path
from wrapica.project_analysis import list_analyses

# Set params
# Use wrapica.project.get_project_id_from_project_name
# If you need to convert a project_name to a project_id
project_id = "project_id"

analysis_list = list_analyses(project_id)
wrapica.project_analysis.update_analysis_obj(project_id, analysis_id, analysis_obj)

Given an analysis id, update the analysis object :type project_id: Union[UUID, str] :param project_id: :type analysis_id: Union[UUID, str] :param analysis_id: :type analysis_obj: Union[AnalysisV3, AnalysisV4] :param analysis_obj: :rtype: Union[AnalysisV3, AnalysisV4] :return:

wrapica.project_analysis.write_analysis_step_logs(project_id, step_logs, log_name, output_path, is_cwltool_log=False)

Write the analysis step logs to a file

Parameters:
  • project_id (Union[UUID, str]) – The project id the analysis was run in

  • step_logs (AnalysisStepLogs) – Required, the step logs object

  • log_name (Literal['stdout', 'stderr']) – Required, One of stdout or stderr

  • output_path (Union[Path, TextIOWrapper]) – Required, The output path to write the file to

  • is_cwltool_log (Optional[bool]) – Required, If the log is a cwltool log we convert from html to text format

Raises:

ApiException, NotADirectoryError

Returns:

None

Return type:

None

Examples:

:linenos:
from pathlib import Path
from wrapica.project_analysis import get_analysis_steps

# Set params
project_id = "project_id"
analysis_id = "analysis_id"

# Get analysis steps and logs
analysis_step_list = get_analysis_steps(project_id, analysis_id)
step_logs = list(map(get_analysis_log_from_analysis_step, analysis_step_list))

# Write first step logs to file
write_analysis_step_logs(
    project_id=project_id,
    step_logs=step_logs[0],
    log_name="stderr",
    output_path=Path("stderr.log")
)