Exemplo n.º 1
0
def create_tool_analysis(validated_analysis_config):
    """
    Create an Analysis instance from a validated analysis config with
    Tool information
    :param validated_analysis_config: a dict including the necessary
    information to create an Analysis that has been validated prior by
    `analysis_manager.utils.validate_analysis_config`
    :return: an Analysis instance
    :raises: RuntimeError
    """

    # Input list for running analysis
    common_analysis_objects = (
        fetch_objects_required_for_analysis(validated_analysis_config))
    name = validated_analysis_config["name"]
    current_workflow = common_analysis_objects["current_workflow"]
    data_set = common_analysis_objects["data_set"]
    user = common_analysis_objects["user"]

    try:
        tool = Tool.objects.get(uuid=validated_analysis_config["toolUuid"])
    except (Tool.DoesNotExist, Tool.MultipleObjectsReturned) as e:
        raise RuntimeError("Couldn't fetch Tool from UUID: {}".format(e))

    analysis = AnalysisFactory(summary="Analysis run for: {}".format(tool),
                               name=name,
                               project=user.profile.catch_all_project,
                               data_set=data_set,
                               workflow=current_workflow,
                               time_start=timezone.now())
    analysis.set_owner(user)
    return analysis
Exemplo n.º 2
0
def create_analysis(project, dataset, workflow, user_instance):
    analysis_uuid = str(uuid_builtin.uuid4())
    analysis = AnalysisFactory(
        uuid=analysis_uuid,
        name="Test Analysis - {}".format(analysis_uuid),
        project=project,
        data_set=dataset,
        workflow=workflow
    )
    input_node = dataset.get_nodes().first()
    AnalysisNodeConnectionFactory(
        direction=INPUT_CONNECTION,
        node=input_node,
        name="Connection to {}".format(input_node),
        analysis=analysis,
        step=0,
        filename="Input filename",
        is_refinery_file=bool(input_node.get_file_store_item().datafile)
    )

    # create Analysis Output
    file_store_item_uuid = str(uuid_builtin.uuid4())
    FileStoreItemFactory(
        uuid=file_store_item_uuid,
        source="http://www.example.com/analysis_output.txt"
    )
    output_node = NodeFactory(
        analysis_uuid=analysis_uuid,
        study=dataset.get_latest_study(),
        assay=dataset.get_latest_assay(),
        file_uuid=file_store_item_uuid,
        type=Node.DERIVED_DATA_FILE
    )

    AnalysisNodeConnectionFactory(
        direction=OUTPUT_CONNECTION,
        node=output_node,
        name="Connection to {}".format(output_node),
        analysis=analysis,
        step=1,
        filename="Output filename",
        is_refinery_file=True
    )
    AnalysisResultFactory(
        analysis_uuid=analysis.uuid,
        file_store_uuid=file_store_item_uuid
    )

    # create AnalysisStatus
    AnalysisStatusFactory(analysis=analysis)

    analysis.set_owner(user_instance)
    analysis.save()
Exemplo n.º 3
0
def make_analyses_with_single_dataset(number_to_create, user_instance):
    """Create some minimal Analyses"""

    instance = GalaxyInstanceFactory()
    workflow_engine = WorkflowEngineFactory(instance=instance)
    workflow = WorkflowFactory(uuid=str(uuid_builtin.uuid4()),
                               workflow_engine=workflow_engine)
    project = ProjectFactory(is_catch_all=True)
    dataset = create_dataset_with_necessary_models()

    while number_to_create:
        analysis_uuid = str(uuid_builtin.uuid4())
        AnalysisFactory(uuid=analysis_uuid,
                        name="Test Analysis - {}".format(analysis_uuid),
                        project=project,
                        data_set=dataset,
                        workflow=workflow)

        number_to_create -= 1

    for dataset in DataSet.objects.all():
        dataset.set_owner(user_instance)
        dataset.save()

    for analysis in Analysis.objects.all():
        analysis.set_owner(user_instance)
        analysis.save()
Exemplo n.º 4
0
def create_tool_analysis(validated_analysis_config):
    """
    Create an Analysis instance from a validated analysis config with
    Tool information
    :param validated_analysis_config: a dict including the necessary
    information to create an Analysis that has been validated prior by
    `analysis_manager.utils.validate_analysis_config`
    :return: an Analysis instance
    :raises: RuntimeError
    """
    common_analysis_objects = (
        fetch_objects_required_for_analysis(validated_analysis_config)
    )
    current_workflow = common_analysis_objects["current_workflow"]
    data_set = common_analysis_objects["data_set"]
    user = common_analysis_objects["user"]

    try:
        tool = WorkflowTool.objects.get(
            uuid=validated_analysis_config["toolUuid"]
        )
    except (WorkflowTool.DoesNotExist,
            WorkflowTool.MultipleObjectsReturned) as e:
        raise RuntimeError("Couldn't fetch Tool from UUID: {}".format(e))

    analysis = AnalysisFactory(
        uuid=str(uuid.uuid4()),
        summary="Galaxy workflow execution for: {}".format(tool.name),
        name="{} - {} - {}".format(
            tool.get_tool_name(),
            get_aware_local_time().strftime("%Y/%m/%d %H:%M:%S"),
            tool.get_owner_username().title()
        ),
        project=user.profile.catch_all_project,
        data_set=data_set,
        workflow=current_workflow,
        time_start=timezone.now()
    )
    analysis.set_owner(user)
    return analysis
def create_analysis(project, dataset, workflow, user_instance):
    analysis_uuid = str(uuid_builtin.uuid4())
    analysis = AnalysisFactory(
        uuid=analysis_uuid,
        name="Test Analysis - {}".format(analysis_uuid),
        project=project,
        data_set=dataset,
        workflow=workflow
    )
    input_node = dataset.get_nodes().first()
    AnalysisNodeConnectionFactory(
        direction=INPUT_CONNECTION,
        node=input_node,
        name="Connection to {}".format(input_node),
        analysis=analysis,
        step=0,
        filename="Input filename",
        is_refinery_file=input_node.get_file_store_item().is_local()
    )

    # create Analysis Output
    file_store_item_uuid = str(uuid_builtin.uuid4())
    FileStoreItemFactory(
        uuid=file_store_item_uuid,
        source="http://www.example.com/analysis_output.txt"
    )
    output_node = NodeFactory(
        analysis_uuid=analysis_uuid,
        study=dataset.get_latest_study(),
        assay=dataset.get_latest_assay(),
        file_uuid=file_store_item_uuid,
        type=Node.DERIVED_DATA_FILE
    )

    AnalysisNodeConnectionFactory(
        direction=OUTPUT_CONNECTION,
        node=output_node,
        name="Connection to {}".format(output_node),
        analysis=analysis,
        step=1,
        filename="Output filename",
        is_refinery_file=True
    )
    AnalysisResultFactory(
        analysis_uuid=analysis.uuid,
        file_store_uuid=file_store_item_uuid
    )

    # create AnalysisStatus
    AnalysisStatusFactory(analysis=analysis)

    analysis.set_owner(user_instance)
    analysis.save()
Exemplo n.º 6
0
def create_analysis(project, dataset, workflow, user_instance):
    analysis_uuid = str(uuid_lib.uuid4())
    analysis = AnalysisFactory(uuid=analysis_uuid,
                               name='Test Analysis - {}'.format(analysis_uuid),
                               project=project,
                               data_set=dataset,
                               workflow=workflow)
    input_node = dataset.get_nodes().first()
    AnalysisNodeConnectionFactory(analysis=analysis,
                                  node=input_node,
                                  step=0,
                                  name='Connection to {}'.format(input_node),
                                  filename='Input filename',
                                  direction=INPUT_CONNECTION,
                                  is_refinery_file=bool(
                                      input_node.file_item.datafile))
    # create Analysis Output
    file_store_item_uuid = str(uuid_lib.uuid4())
    file_store_item = FileStoreItemFactory(
        uuid=file_store_item_uuid,
        source='http://www.example.com/analysis_output.txt')
    output_node = NodeFactory(analysis_uuid=analysis_uuid,
                              study=dataset.get_latest_study(),
                              assay=dataset.get_latest_assay(),
                              file_item=file_store_item,
                              type=Node.DERIVED_DATA_FILE)
    AnalysisNodeConnectionFactory(direction=OUTPUT_CONNECTION,
                                  node=output_node,
                                  name='Connection to {}'.format(output_node),
                                  analysis=analysis,
                                  step=1,
                                  filename='Output filename',
                                  is_refinery_file=True)
    AnalysisResultFactory(analysis=analysis,
                          file_store_uuid=file_store_item_uuid)
    AnalysisStatusFactory(analysis=analysis)
    analysis.set_owner(user_instance)
    analysis.save()