annotate samtoolshelper.py @ 7:bc65a465caed default tip

Merge heads at 5:09a576e512cc and 6:e994caf2503d which were created as a result of a recently fixed bug.
author devteam <devteam@galaxyproject.org>
date Mon, 13 Jan 2014 12:40:18 -0500
parents dc3b3b88fbab
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
1 import sys
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
2 import subprocess as sp
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
3 import os
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
4
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
5 # Creates the sorted and indexed bam/bai files that are requried for both bam2wig and RSEQC_count
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
6 def samtools_sorted(bam):
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
7 sortedbam = bam + ".sorted"
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
8 indexedbam = ".".join([sortedbam,"bam.bai"])
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
9 sp.call(['samtools', 'sort', '-m 1000000000', bam, sortedbam])
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
10 sortedbam = sortedbam + '.bam'
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
11 sp.call(['samtools', 'index', sortedbam, indexedbam])
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
12 return sortedbam
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
13
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
14 def main(args):
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
15 args[2] = samtools_sorted(args[2])
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
16 sp.call(args)
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
17
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
18
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
19 if __name__ == "__main__":
dc3b3b88fbab first commit
nilesh
parents:
diff changeset
20 main(sys.argv[1:])