首页 > 代码库 > using samtools commands within python
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.
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。