Skip to content

Commit

Permalink
+ document how to run bcftools commands from pysam
Browse files Browse the repository at this point in the history
  - this wasn't explicitly stated in the documentation.  I was
    using the notes described in [github issue 958][0] as a guide.
  - in the changes also put updated links to the bcftools and htslib.org pages

[0]: pysam-developers#958
  • Loading branch information
indraniel committed Mar 31, 2024
1 parent cdc0ed1 commit be9ab9f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,25 @@ Note that this means that output from commands which produce output on
stdout will not be available. The only solution is to run samtools
commands through subprocess.

=====================================
Using bcftools commands within python
=====================================

Commands available in `bcftools <https://samtools.github.io/bcftools/>`_ are also available as simple
function calls, but they are invoked slightly differently from `samtools <https://www.htslib.org>`_.
Command line options are also provided as arguments. For
example::

import pysam.bcftools as bcftools
bcftools.reheader("-s", "samples.txt", "-o", "out.vcf.gz", "in.vcf.gz", catch_stdout=False)

corresponds to the command line::

bcftools reheader -s samples.txt -o out.vcf.gz in.vcf.gz

If the ``catch_stdout=False`` option is not specified, then the output of the
`bcftools <https://samtools.github.io/bcftools/>`_ command will be returned as a variable

================================
Working with tabix-indexed files
================================
Expand Down

0 comments on commit be9ab9f

Please sign in to comment.