Created
April 12, 2013 10:55
-
-
Save shujishigenobu/5371237 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| !/bin/ruby | |
| #=== config | |
| MAX_MEMORY = 30000000000 | |
| #=== | |
| $sam = ARGV[0] | |
| bam_unsorted = File.basename($sam, '.sam') + '.unsorted.bam' | |
| STDERR.puts "# converting sam to bam" | |
| cmd = "samtools view -bS #{$sam} -o #{bam_unsorted}" | |
| IO.popen(cmd){} | |
| STDERR.puts "# sorting bam" | |
| bam_sorted_prefix = File.basename(bam_unsorted, '.unsorted.bam') | |
| cmd = "samtools sort -m #{MAX_MEMORY} #{bam_unsorted} #{bam_sorted_prefix}" | |
| IO.popen(cmd){} | |
| STDERR.puts "# indexing bam" | |
| bam_sorted = bam_sorted_prefix + ".bam" | |
| cmd = "samtools index #{bam_sorted}" | |
| IO.popen(cmd) | |
| File.delete(bam_unsorted) | |
| STDERR.puts "# completed" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment