Bioinformatics pipeline block to sort BAM files
BamSort block enables you to sort BAM files. The block sorts
the alignment records by the reference sequence name first, and then by position within the
outFileName — Sorted file name
string | character vector
Sorted file name, specified as a string or character vector.
ErrorHandler — Function to handle errors from
Function to handle errors from the
run method of the block, specified as a function handle. It specifies the function to call if the run method encounters an error within a pipeline. In order for the pipeline to continue after a block fails,
ErrorHandler must return a structure compatible with the output ports of the block. The error handling function is called with the following two input arguments:
Structure with the following 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 always 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
runmethod when it failed.
Inputs — Input ports
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 in for the block
Inputs structure has the
BAMFile. It is a required input port and must be satisfied to
run the block.
Outputs — Output ports
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 output structure returned by the block
run method has the field names
that are the same as the output port names.
Outputs structure has the
OutFilename — Sorted BAM file name
empty string array (default) | string | character vector
Sorted file name, specified as a string or character vector. The name must end with
OutFilename is empty (default), the output file has the same
base name as the input BAM file with the extension
If you specify the file name, ensure the name has the
Sort BAM File Using Bioinformatics Pipeline
Import the Pipeline and blocks objects needed for the example.
import bioinfo.pipeline.Pipeline import bioinfo.pipeline.block.*
Create a pipeline object.
P = Pipeline;
BamSort block and
FileChooser block that takes in a sample BAM file.
bs = BamSort;
fc = FileChooser(which("ex1.bam"));
Add the blocks.
Files output port of the
FileChooser block to the
BAMFile input port of
Run the pipeline.
Get the block result, which is a sorted BAM file.
outBAM = fetchResults(P,bs)
outBAM = struct with fields:
SortedBAMFile: [1×1 bioinfo.pipeline.datatype.File]
unwrap to see the stored location of the sorted BAM file.
Introduced in R2023a