From be9ab9ff472adf041cebe55186816fb9dac1689a Mon Sep 17 00:00:00 2001 From: indraniel Date: Sun, 31 Mar 2024 15:13:48 -0500 Subject: [PATCH] + document how to run bcftools commands from pysam - 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]: https://github.com/pysam-developers/pysam/issues/958 --- doc/usage.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/usage.rst b/doc/usage.rst index 3c8ab04e..c456de2a 100644 --- a/doc/usage.rst +++ b/doc/usage.rst @@ -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 `_ are also available as simple +function calls, but they are invoked slightly differently from `samtools `_. +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 `_ command will be returned as a variable + ================================ Working with tabix-indexed files ================================