Main Content

bioinfo.pipeline.block.BamSort

Bioinformatics pipeline block to sort BAM files

Since R2023a

  • bamsort block icon

Description

A 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 reference.

Creation

Description

b = bioinfo.pipeline.block.BamSort creates a BamSort block.

example

b = bioinfo.pipeline.block.BamSort(outFileName) also specifies the output file name.

Input Arguments

expand all

Sorted file name, specified as a string or character vector.

Data Types: char | string

Properties

expand all

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:

    FieldDescription
    identifierIdentifier of the error that occurred
    messageText of the error message
    indexLinear 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

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 BamSort block Inputs structure has the field named BAMFile. It is a required input port and must be satisfied to run the block.

Data Types: struct

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 BamSort block Outputs structure has the field named SortedBAMFile.

Data Types: struct

Sorted file name, specified as a string or character vector. The name must end with the extension .bam.

If OutFilename is empty (default), the output file has the same base name as the input BAM file with the extension .sorted.bam.

If you specify the file name, ensure the name has the .bam extension.

Data Types: char | string

Object Functions

compilePerform block-specific additional checks and validations
copyCopy array of handle objects
emptyInputsCreate input structure for use with run method
evalEvaluate block object
runRun block object

Examples

collapse all

Import the Pipeline and blocks objects needed for the example.

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

Create a pipeline object.

P = Pipeline;

Create a BamSort block and FileChooser block that takes in a sample BAM file.

bs = BamSort;
fc = FileChooser(which("ex1.bam"));

Add the blocks.

addBlock(P,[bs,fc]);

Connect the Files output port of the FileChooser block to the BAMFile input port of BamSort block.

connect(P,fc,bs,["Files","BAMFile"]);

Run the pipeline.

run(P);

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]

Use unwrap to see the stored location of the sorted BAM file.

unwrap(outBAM.SortedBAMFile)

Version History

Introduced in R2023a