def sam2bam(sam_fhand, bam_fhand, header=None): 'It converts between bam and sam.' sam_fhand.seek(0) if header is not None: pass cmd = ['samtools', 'view', '-bSh', '-o', bam_fhand.name, sam_fhand.name] call(cmd, raise_on_error=True) bam_fhand.flush()
def bam2sam(bam_fhand, sam_fhand, header=False): '''It converts between bam and sam.''' bam_fhand.seek(0) cmd = ['samtools', 'view', bam_fhand.name, '-o', sam_fhand.name] if header: cmd.insert(2, '-h') call(cmd, raise_on_error=True) sam_fhand.flush()
def get_bam_header(bam_fhand, header_fhand): 'It gets the header of the bam' cmd = ['samtools', 'view', '-H', bam_fhand.name, '-o', header_fhand.name] call(cmd, raise_on_error=True)