Index of /examples/bioinformatics/samtools

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory   -  
[DIR]qlog/ 2021-03-29 17:50 -  
[DIR]qsub/ 2021-03-29 17:50 -  
[DIR]sam_in/ 2021-03-29 17:50 -  
[DIR]sam_out/ 2021-03-29 17:50 -  

RCS SAMTOOLS Example

Directory Structure


Notes

To view all available versions of samtools on SCC, execute:
[scc1 ] module avail samtools

To run samtools view to convert sam to bam:
[scc1 ] module load samtools/1.10 # please specify version
[scc1 ] samtools view -bSu sam_in/example_aln.sam -o sam_out/example_aln.bam

The above command will run silently (no output on the screen). And it will generate a bam file in sam_out/example_aln.bam.

To then use 'sort' function of the samtools to sort the bam:
[scc1 ] samtools sort sam_out/example_aln.bam -o sam_out/example_aln_sorted.bam

The above command will execute silently and produce a sorted bam file in sam_out/example_aln_sorted.bam.

Please note, samtools can support multithreads automactically. To make use of the function, use '--threads' or '-@' option to specify the cores (threads) to use:
[scc1 ] module load samtools/1.10 # please specify version
[scc1 ] samtools view --threads 2 -bSu sam_in/example_aln.sam | samtools sort --threads 2 -o sam_out/example_aln_sorted_2.bam

The above command is a combination of the two samtools functions - view and sort, using '|' (pipe symbol) to feed the second command with the first command's output. This is a common technique used in Linux to simplify I/O and improve efficiency. And it specifies 2 threads for each command (--threads 2).

You can write a qsub to combine the above steps for a batch submission:
As prepared in qsub/samtools_job.qsub
[scc1 ] cd qsub # get into the qsub script location
[scc1 ] qsub samtoools_job.qsub

After the above job's completion, there will be two files in qlog/ looks like:

And there will be a sorted bam file newly generated in sam_out/:

Samtools links

Contact Information

Research Computing Services: help@scc.bu.edu

Note: RCS example programs are provided "as is" without any warranty of any kind. The user assumes the intire risk of quality, performance, and repair of any defect. You are welcome to copy and modify any of the given examples for your own use.