- 1 bam Executable
- 1.1 Read and Validate a SAM/BAM file
- 1.2 Read a SAM/BAM file and write as a SAM/BAM file
- 1.3 Dump a BAM index file
- 1.4 Read & Write indexed BAM file
When the pipeline is compiled, the SAM/BAM executable, "bam" is generated in the pipeline/bam/ directory.
The software reads the beginning of an input file to determine if it is SAM/BAM. To determine the format (SAM/BAM) of the output file, the software checks the output file's extension. If the extension is ".bam" it writes a BAM file, otherwise it writes a SAM file.
The bam executable has the following functions.
- Read and Validate a SAM/BAM file
- Read a SAM/BAM file and write as a SAM/BAM file
- Dump a BAM index file into an easy to read text version
- Read an indexed BAM file reference by reference id -1 to 22 and write it out as a SAM/BAM file
This executable is built using the bam library.
Read and Validate a SAM/BAM file
validate option on the bam executable validates a SAM/BAM file.
The validation checks that the file is sorted as specified in the user options. Default is unsorted, in which case, no order validation is done.
SAM fields are validated against: SAM Validation Criteria
NOTE: Currently only minimal validation is currently done.
Required Parameters: --in : the SAM/BAM file to be validated Optional Parameters: --noeof : do not expect an EOF block on a bam file. --so_flag : validate the file is sorted based on the header's @HD SO flag. --so_coord : validate the file is sorted based on the coordinate. --so_query : validate the file is sorted based on the query name. --quitAfterErrorNum : Number of records with errors/invalids to allow before quiting. -1 (default) indicates to not quit until the entire file is validated. 0 indicates not to read/validate anything. --maxReportedErrors : Maximum number of errors to print (defaults to 100)
./bam validate --in <inputFile> [--noeof] [--so_flag|--so_coord|--so_query] [--quitAfterErrorNum <numErrors>] [--maxReportedErrors <numReportedErrors>]
- 0: all records are successfully read, are valid, and are properly sorted.
- non-0: at least one record was not successfully read, not valid, or not properly sorted.
The following parameters are in effect: Input Parameters --in [t.sam], --noeof, --quitAfterErrorNum [-1], --maxReportedErrors  SortOrder : --so_flag, --so_coord, --so_query Record 1 FAIL_PARSE: Too few columns in the Record Record 2 FAIL_PARSE: Too few columns in the Record Number of records read = 2 Number of valid records = 0 Returning: 5 (FAIL_PARSE)
Read a SAM/BAM file and write as a SAM/BAM file
This executable takes 2/3 arguments. The first argument is the input file. The second argument is the output file. The executable converts the first file into the format of the second file. So if you want to convert a BAM file to a SAM file, from the pipeline/bam/ directory you just call:
./bam <bamFile>.bam <newSamFile>.sam
Don't forget to put in the paths to the executable and your test files.
The third argument,
NOEOF, specifies that the End-Of-File Block should not be checked for when opening the file.
./bam <inputFile> <outputFile.sam/bam/ubam (ubam is uncompressed bam)> [NOEOF]
Returns the SamStatus for the reads/writes.
Number of records read = 10 Number of records written = 10
Dump a BAM index file
./bam dump_index <bamIndexFile>
- -1 if the bam index file could not be opened.
- 0 if the bam index file could be opened.
Read & Write indexed BAM file
./bam read_indexed_bam <inputFilename> <outputFile.sam/bam> <bamIndexFile>