annotate samtoolshelper.py @ 4:9195f99fecdd

Uploaded
author nilesh
date Mon, 08 Jul 2013 22:05:14 -0400
parents 4d701c67592a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
4d701c67592a Uploaded
nilesh
parents:
diff changeset
1 import sys
4d701c67592a Uploaded
nilesh
parents:
diff changeset
2 import subprocess as sp
4d701c67592a Uploaded
nilesh
parents:
diff changeset
3 import os
4d701c67592a Uploaded
nilesh
parents:
diff changeset
4
4d701c67592a Uploaded
nilesh
parents:
diff changeset
5 # Creates the sorted and indexed bam/bai files that are requried for both bam2wig and RSEQC_count
4d701c67592a Uploaded
nilesh
parents:
diff changeset
6 def samtools_sorted(bam):
4d701c67592a Uploaded
nilesh
parents:
diff changeset
7 sortedbam = bam + ".sorted"
4d701c67592a Uploaded
nilesh
parents:
diff changeset
8 indexedbam = ".".join([sortedbam,"bam.bai"])
4d701c67592a Uploaded
nilesh
parents:
diff changeset
9 sp.call(['samtools', 'sort', '-m 1000000000', bam, sortedbam])
4d701c67592a Uploaded
nilesh
parents:
diff changeset
10 sortedbam = sortedbam + '.bam'
4d701c67592a Uploaded
nilesh
parents:
diff changeset
11 sp.call(['samtools', 'index', sortedbam, indexedbam])
4d701c67592a Uploaded
nilesh
parents:
diff changeset
12 return sortedbam
4d701c67592a Uploaded
nilesh
parents:
diff changeset
13
4d701c67592a Uploaded
nilesh
parents:
diff changeset
14 def main(args):
4d701c67592a Uploaded
nilesh
parents:
diff changeset
15 args[2] = samtools_sorted(args[2])
4d701c67592a Uploaded
nilesh
parents:
diff changeset
16 sp.call(args)
4d701c67592a Uploaded
nilesh
parents:
diff changeset
17
4d701c67592a Uploaded
nilesh
parents:
diff changeset
18
4d701c67592a Uploaded
nilesh
parents:
diff changeset
19 if __name__ == "__main__":
4d701c67592a Uploaded
nilesh
parents:
diff changeset
20 main(sys.argv[1:])