def __call__(self, *args, **kwargs): """execute a samtools command. Keyword arguments: catch_stdout -- redirect stdout from the samtools command and return as variable (default True) raw -- ignore any parsers associated with this samtools command. """ retval, stderr, stdout = _pysam_dispatch( self.collection, self.dispatch, args, catch_stdout=kwargs.get("catch_stdout", True) ) if retval: raise SamtoolsError( "%s returned with error %i: " "stdout=%s, stderr=%s" % (self.collection, retval, "\n".join(stdout), "\n".join(stderr)) ) self.stderr = stderr # call parser for stdout: if not kwargs.get("raw") and stdout and self.parsers: for options, parser in self.parsers: for option in options: if option not in args: break else: return parser(stdout) return stdout
def __call__(self, *args, **kwargs): '''execute a samtools command. Keyword arguments: catch_stdout -- redirect stdout from the samtools command and return as variable (default True) raw -- ignore any parsers associated with this samtools command. ''' retval, stderr, stdout = _pysam_dispatch(self.collection, self.dispatch, args, catch_stdout=kwargs.get( "catch_stdout", True)) if retval: raise SamtoolsError("%s returned with error %i: " "stdout=%s, stderr=%s" % (self.collection, retval, "\n".join(stdout), "\n".join(stderr))) self.stderr = stderr # call parser for stdout: if not kwargs.get("raw") and stdout and self.parsers: for options, parser in self.parsers: for option in options: if option not in args: break else: return parser(stdout) return stdout
def __call__(self, *args, **kwargs): '''execute a samtools command. Keyword arguments: catch_stdout -- redirect stdout from the samtools command and return as variable (default True) save_stdout -- redirect stdout to a filename. raw -- ignore any parsers associated with this samtools command. split_lines -- return stdout (if catch_stdout is True and stderr as a list of strings. ''' retval, stderr, stdout = _pysam_dispatch( self.collection, self.dispatch, args, catch_stdout=kwargs.get("catch_stdout", True), save_stdout=kwargs.get("save_stdout", None)) if kwargs.get("split_lines", False): stdout = stdout.splitlines() if stderr: stderr = stderr.splitlines() if retval: raise SamtoolsError( "%s returned with error %i: " "stdout=%s, stderr=%s" % (self.collection, retval, stdout, stderr)) self.stderr = stderr # call parser for stdout: if not kwargs.get("raw") and stdout and self.parsers: for options, parser in self.parsers: for option in options: if option not in args: break else: return parser(stdout) return stdout