using samtools commands within python
Commands available in csamtools are available as simple function calls. For example:
pysam.sort( "ex1.bam", "output" )
corresponds to the command line:
samtools sort ex1.bam output
Command line options can be provided as arguments:
pysam.sort( "-n", "ex1.bam", "output" )
or:
pysam.sort( "-m", "1000000", "ex1.bam", "output" )
In order to get usage information, try:
print pysam.sort.usage()
Argument errors raise a pysam.SamtoolsError:
pysam.sort()
Traceback (most recent call last):
File "x.py", line 12, in <module>
pysam.sort()
File "/home/andreas/pysam/build/lib.linux-x86_64-2.6/pysam/__init__.py", line 37, in __call__
if retval: raise SamtoolsError( "\n".join( stderr ) )
pysam.SamtoolsError: ‘Usage: samtools sort [-n] [-m <maxMem>] <in.bam> <out.prefix>\n‘
Messages from csamtools on stderr are captured and are available using the getMessages() method:
pysam.sort.getMessage()
Note that only the output from the last invocation of a command is stored.
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。