How to use the bamnostic.bam.BamWriter function in bamnostic

To help you get started, we’ve selected a few bamnostic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github betteridiot / bamnostic / bamnostic / bam.py View on Github external
def write(self, data):
        if len(data) + len(self._buffer) > 65536 and len(self._buffer) != 0:
            self.flush()
        super(BamWriter, self).write(data)
github betteridiot / bamnostic / bamnostic / core.py View on Github external
assert 'b' in mode.lower(), 'BAM files must be used in binary mode'
        
        write_modes = ['w', 'a', 'x', 'r+']

        # Check if user wants to write a BAM file
        if any([wm in mode.lower() for wm in write_modes]):
            write_args = ('filepath_or_object', 'mode', 'compresslevel', 
                        'ignore_overwrite', 'copy_header', 'header',
                        'reference_names', 'reference_lengths')
            wargs = {}
            for key in write_args:
                try:
                    wargs.update({key: kwargs.pop(key)})
                except KeyError:
                    pass
            bam.BamWriter.__init__(self, **wargs)

        else:
            read_args = ('filepath_or_object', 'mode', 'max_cache', 'index_filename',
                'filename', 'check_header', 'check_sq', 'reference_filename',
                'filepath_index', 'require_index', 'duplicate_filehandle',
                'ignore_truncation')
            rargs = {}
            for key in read_args:
                try:
                    rargs.update({key: kwargs.pop(key)})
                except KeyError:
                    pass
            bam.BamReader.__init__(self, **rargs)