Main Content

completed

Get indices of completed processes

Since R2024b

Description

LIP = completed(results) returns an array containing logical 1 (true) for completed processes and 0 otherwise after you run a pipeline block.

example

Examples

collapse all

Import the pipeline and block objects needed for the example.

import bioinfo.pipeline.Pipeline
import bioinfo.pipeline.block.*

Create a pipeline.

P = Pipeline;

Create a SeqTrim block and add it to the pipeline.

seqTrimBlock = SeqTrim;
addBlock(P,seqTrimBlock);

Specify two FASTQ files as the block inputs.

file1 = string(fullfile(which("SRR6008575_10k_1.fq")));
file2 = string(fullfile(which("SRR6008575_10k_2.fq")));
seqTrimBlock.Inputs.FASTQFiles.Value = [file1,file2];

Set SplitDimension to 2 so that each file is processed independently using one process for each file.

seqTrimBlock.Inputs.FASTQFiles.SplitDimension = 2;

Run the pipeline.

run(P);

Get the block results. The block returns completed results for both files.

r1 = results(P,seqTrimBlock)
r1 = struct with fields:
    TrimmedFASTQFiles: [1×2 bioinfo.pipeline.datatype.File]
           NumTrimmed: [1495 1602]
         NumUntrimmed: [8505 8398]

Display the total number of trimmed sequences for each file.

r1.NumTrimmed
ans = 1×2

        1495        1602

Next specify a third FASTQ file, which is invalid. When you run the pipeline, the block returns partial results: two completed results for two valid files and one error for the invalid file.

file3 = "sample.fastq";
seqTrimBlock.Inputs.FASTQFiles.Value = [file1,file2,file3];
run(P);
r2 = results(P,seqTrimBlock)
r2 = 
  Incomplete result (1x3) with the following outputs:

    TrimmedFASTQFiles
    NumTrimmed
    NumUntrimmed


  Not Run:  0
  Complete: 2
  Error:    1

Access the completed results of the valid files. First, use the completed function first to get the indices of the completed processes, and then use those indices to extract the results.

validIdx = completed(r2);
r2.NumTrimmed(validIdx)
ans = 1×2

        1495        1602

You can use unwrap to see the location of the trimmed FASTQ files.

unwrap(r2.TrimmedFASTQFiles(validIdx))'

Input Arguments

collapse all

Partial block results, specified as a bioinfo.pipeline.datatype.Incomplete object. The object is returned when you call the results function of a pipeline after you run the pipeline.

Output Arguments

collapse all

Logical index for completed processes, returned as a logical array. A logical value of 1 in the array indicates that the corresponding process is completed and a value of 0 indicates otherwise.

Data Types: logical

Version History

Introduced in R2024b