bioinfo.pipeline.block.Save
Description
A Save
block enables you to save output variables from your
pipeline to a MAT-file.
Creation
Description
creates a
b
= bioinfo.pipeline.block.SaveSave
block.
specifies additional options using one or more name-value arguments. The name-value
arguments set the property names and values of a b
= bioinfo.pipeline.block.Save(Name=Value
)Save
block.
Properties
ErrorHandler
— Function to handle errors from run
method
[]
(default) | function handle
Function to handle errors from the run
method of the block, specified as a function handle. The handle specifies the function to call
if the run method encounters an error within a pipeline. For the pipeline to continue after a
block fails, ErrorHandler
must return a structure that is compatible with
the output ports of the block. The error handling function is called with the following two inputs:
Structure with these fields:
Field Description identifier Identifier of the error that occurred message Text of the error message index Linear index indicating which block process failed in the parallel run. By default, the index is 1 because there is only one run per block. For details on how block inputs can be split across different dimensions for multiple run calls, see Bioinformatics Pipeline SplitDimension. Input structure passed to the
run
method when it fails
Data Types: function_handle
Inputs
— Input ports
structure
This property is read-only.
Input ports of the block, specified as a structure. The field
names of the structure are the names of the block input ports, and the field values are bioinfo.pipeline.Input
objects. These objects describe the input port behaviors.
The input port names are the expected field names of the input structure that you pass to the
block run
method.
The Save
block Inputs
structure has the field
named Var1
, which is a bioinfo.pipeline.datatype.Unset
object. This input is required and must be
satisfied. If
you specify variables in the Variables
property, the
Inputs
structure contains fields named after the
variables.
Data Types: struct
Outputs
— Output ports
structure
This property is read-only.
Output ports of the block, specified as a structure. The field
names of the structure are the names of the block output ports, and the field values are bioinfo.pipeline.Output
objects. These objects describe the output port behaviors.
The field names of the output structure returned by the block run
method
are the same as the output port names.
The Save
block Outputs
structure has a field
named SaveFile
, and the value is a bioinfo.pipeline.Output
object.
Data Types: struct
Variables
— Names of variables to save
"Var1"
(default) | character vector | string scalar | ...
Names of variables to save to the MAT-file, specified as a character vector, string scalar, string vector, or cell array of character vectors. The variable names must be valid and unique.
Setting this property specify the input ports of the block. For instance, if the
property value is ["X","Y"]
, then the block has two input ports named
X
and Y
, and the inputs to these ports are saved
as variables named "X"
and "Y"
in the
MAT-file.
FromStruct
— Flag to save input structure fields as variables
false
or 0 (default) | true
or 1
Flag to save the input structure fields as variables, specified as numeric or
logical true
(1) or false
(0).
The value of true
indicates that the Save
block
expects a single input port accepting a scalar structure and its fields are saved as
separate variables, instead of saving the structure itself. In other words,
FromStruct=true
has the same as behavior as calling
save("filename.mat","-struct","S")
. For details, see variables.
OutputFilename
— Name of output MAT-file
"savedVariables.mat"
(default) | character vector | string scalar
Name of the output MAT-file to save, specified as a character vector or string scalar.
Object Functions
compile | Perform block-specific additional checks and validations |
copy | Copy array of handle objects |
emptyInputs | Create input structure for use with run method |
eval | Evaluate block object |
run | Run block object |
Examples
Save Filtered Sequence Data to MAT-file in Bioinformatics Pipeline
Create a Bioinformatics pipeline.
P = bioinfo.pipeline.Pipeline;
Select an input FASTQ file using a FileChooser
block.
fastqfile = bioinfo.pipeline.block.FileChooser(which("SRR005164_1_50.fastq"));
Create a SeqFilter
block.
sequencefilter = bioinfo.pipeline.block.SeqFilter;
Define the filtering threshold value. Specifically, filter out sequences with a total of more than 10 low-quality bases, where a base is considered a low-quality base if its quality score is less than 20.
sequencefilter.Options.Threshold = [10 20];
Add the blocks to the pipeline.
addBlock(P,[fastqfile,sequencefilter]);
Connect the output port of fastqfile
to the input port of sequencefilter
.
out_port = string(fieldnames(fastqfile.Outputs)); in_port = string(fieldnames(sequencefilter.Inputs)); connect(P,fastqfile,sequencefilter,[out_port,in_port]);
Create a Save
block to save the filtered sequence data to a MAT-file.
sb = bioinfo.pipeline.block.Save;
Set the Variables
property of the Save
block to the output variables of the sequencefilter
block. When you run the pipeline, these variables are saved to the specified MAT-file.
vars2Save = string(fieldnames(sequencefilter.Outputs)); sb.Variables = vars2Save; sb.OutputFilename = "seqfilter_results.mat"; addBlock(P,sb); connect(P,sequencefilter,sb,["FilteredFASTQFiles","FilteredFASTQFiles"; ... "NumFilteredIn","NumFilteredIn"; ... "NumFilteredOut","NumFilteredOut"]); run(P);
To see the location of the saved MAT-file, use unwrap
.
r = results(P,sb); unwrap(r.SaveFile)
Version History
Introduced in R2024b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)