Sam/Bam Manipulation

java -jar picard.jar
Function: Adds comments to the header of a BAM file.This tool makes a copy of the input bam file, with a modified header that includes the comments specified at the command line (prefixed by @CO). Use double quotes to wrap comments that include whitespace or special characters. Note that this tool cannot be run on SAM files.
Usage: java -jar picard.jar AddCommentsToBam I=input.bam O=modified_bam.bam C=comment_1 C="comment 2"
java -jar picard.jar
Function: Compare two metrics files.This tool compares the metrics and histograms generated from metric tools to determine if the generated results are identical. This tool is useful to test and compare outputs when code changes are implemented. It is not meant for use by end-users of this toolkit. The tool's output simply indicates whether two metrics files are equal or not equal.
Usage: java -jar picard.jar CompareMetrics metricfile1.txt metricfile2.txt
java -jar picard.jar
Function: Create BFQ files from a BAM file for use by the maq aligner. BFQ is a binary version of the FASTQ file format. This tool creates bfq files from a BAM file for use by the maq aligner.
Usage: java -jar picard.jar BamToBfq I=input.bam ANALYSIS_DIR=analysis_dir OUTPUT_FILE_PREFIX=output_file_1 PAIRED_RUN=false
java -jar picard.jar
Function: Not to be confused with SortSam which sorts a SAM or BAM file with a valid sequence dictionary, ReorderSam reorders reads in a SAM/BAM file to match the contig ordering in a provided reference file, as determined by exact name matching of contigs. Reads mapped to contigs absent in the new reference are dropped. Runs substantially faster if the input is an indexed BAM file.
Usage: java -jar picard.jar ReorderSam
read_quality.py
Function: According to SAM specification, if Q is the character to represent “base calling quality” in SAM file, then Phred Quality Score = ord(Q) - 33. Here ord() is python function that returns an integer representing the Unicode code point of the character when the argument is a unicode object, for example, ord(‘a’) returns 97. Phred quality score is widely used to measure “reliability” of base-calling, for example, phred quality score of 20 means there is 1/100 chance that the base-calling is wrong, phred quality score of 30 means there is 1/1000 chance that the base-calling is wrong. In general: Phred quality score = -10xlog(10)P, here P is probability that base-calling is wrong.
Usage: read_quality.py -i Pairend_nonStrandSpecific_36mer_Human_hg19.bam -o output
samtools reheader
Function: Copies header from source dataset into target dataset using samtools reheader command.
Usage: samtools reheader [-iP] in.header.sam in.bam
java -jar picard.jar
Function: Generates a BAM index ".bai" file. This tool creates an index file for the input BAM that allows fast look-up of data in a BAM file, lke an index on a database. Note that this tool cannot be run on SAM files, and that the input BAM file must be sorted in coordinate order.
Usage: java -jar picard.jar BuildBamIndex I=input.bam
java -jar picard.jar
Function: Collects per-sample and aggregate (spanning all samples) metrics from the provided VCF file.
Usage: java -jar picard.jar CollectVariantCallingMetrics
java -jar picard.jar
Function: Collects metrics from reduced representation bisulfite sequencing (Rrbs) data.
Usage: java -jar picard.jar CollectRrbsMetrics R=reference_sequence.fasta I=input.bam M=basename_for_metrics_files
java -jar picard.jar
Function: Prints a SAM or BAM file to the screen.
Usage: java -jar picard.jar ViewSam
bamtools
Function: The command bamtools revert removes duplicate marks and restores original base qualities.
Usage: bamtools revert -in input_alignments.bam -out output_alignments_reverted.bam
java -jar picard.jar
Function: Cleans the provided SAM/BAM, soft-clipping beyond-end-of-reference alignments and setting MAPQ to 0 for unmapped reads
Usage: java -jar picard.jar CleanSam
java -jar picard.jar
Function: Transforms raw Illumina sequencing data into an unmapped SAM or BAM file.
Usage: java -jar picard.jar IlluminaBasecallsToSam BASECALLS_DIR=/BaseCalls/ LANE=001 READ_STRUCTURE=25T8B25T RUN_BARCODE=run15 IGNORE_UNEXPECTED_BARCODES=true LIBRARY_PARAMS=library.params
bamtools
Function: Print header from BAM file(s)
Usage: bamtools header -in input_alignments.bam -out output_alignments_header.txt
java -jar picard.jar
Function: Sorts a SAM or BAM file. This tool sorts the input SAM or BAM file by coordinate, queryname (QNAME), or some other property of the SAM record. The SortOrder of a SAM/BAM file is found in the SAM file header tag @HD in the field labeled SO.
Usage: java -jar picard.jar SortSam I=input.bam O=sorted.bam SORT_ORDER=coordinate