X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=pysam.git;a=blobdiff_plain;f=pysam%2F__init__.py;h=8454f8e4b0739581a463484d1799ba2b2a43a1ad;hp=9f257c210eca878b0f0039b40f724f3482937284;hb=ca46ef4ba4a883c57cea62d5bf1bc021f1185109;hpb=6a7c3f175b210cc16d09a5e8e4c1d47333dbe1c6 diff --git a/pysam/__init__.py b/pysam/__init__.py index 9f257c2..8454f8e 100644 --- a/pysam/__init__.py +++ b/pysam/__init__.py @@ -2,6 +2,8 @@ from csamtools import * from ctabix import * import csamtools import ctabix +from cvcf import * +import cvcf import Pileup import sys import os @@ -42,8 +44,8 @@ class SamtoolsDispatcher(object): self.parsers = parsers self.stderr = [] - def __call__(self,*args, **kwargs): - '''execute the samtools command + def __call__(self, *args, **kwargs): + '''execute a samtools command ''' retval, stderr, stdout = csamtools._samtools_dispatch( self.dispatch, args ) if retval: raise SamtoolsError( "\n".join( stderr ) ) @@ -54,8 +56,11 @@ class SamtoolsDispatcher(object): # for example: [sam_header_read2] 2 sequences loaded. # Ignore messages like these stderr = [ x for x in stderr \ - if not x.startswith( "[sam_header_read2]" ) or \ - x.startswith("[bam_index_load]") ] + if not (x.startswith( "[sam_header_read2]" ) or \ + x.startswith("[bam_index_load]") or \ + x.startswith("[bam_sort_core]") or \ + x.startswith("[samopen] SAM header is present") ) + ] if stderr: raise SamtoolsError( "\n".join( stderr ) ) # call parser for stdout: @@ -81,19 +86,31 @@ class SamtoolsDispatcher(object): # # import is a python reserved word. SAMTOOLS_DISPATCH = { + # samtools 'documented' commands "view" : ( "view", None ), "sort" : ( "sort", None), - "samimport": ( "import", None), - "pileup" : ( "pileup", ( (("-c",), Pileup.iterate ), ), ), + "mpileup" : ( "mpileup", None), + "depth" : ("depth", None), "faidx" : ("faidx", None), "tview" : ("tview", None), "index" : ("index", None), + "idxstats" : ("idxstats", None), "fixmate" : ("fixmate", None), - "glfview" : ("glfview", None), "flagstat" : ("flagstat", None), "calmd" : ("calmd", None), "merge" : ("merge", None), - "rmdup" : ("rmdup", None) } + "rmdup" : ("rmdup", None), + "reheader" : ("reheader", None), + "cat" : ("cat", None), + "targetcut" : ("targetcut", None), + "phase" : ("phase", None), + # others + "samimport": ( "import", None), + "bam2fq" : ("bam2fq", None), + # obsolete + # "pileup" : ( "pileup", ( (("-c",), Pileup.iterate ), ), ), + + } # instantiate samtools commands as python functions for key, options in SAMTOOLS_DISPATCH.iteritems(): @@ -101,9 +118,11 @@ for key, options in SAMTOOLS_DISPATCH.iteritems(): globals()[key] = SamtoolsDispatcher(cmd, parser) # hack to export all the symbols from csamtools -__all__ = csamtools.__all__ + \ +__all__ = \ + csamtools.__all__ + \ ctabix.__all__ + \ + cvcf.__all__ +\ [ "SamtoolsError", "SamtoolsDispatcher" ] + list(SAMTOOLS_DISPATCH) +\ - ["Pileup",] + ["Pileup" ] from version import __version__, __samtools_version__