Skip to content

Commit

Permalink
Require pysam>=0.21.0; fix mpileup call (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinghunt authored May 26, 2023
1 parent a065b38 commit 71909ed
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
7 changes: 3 additions & 4 deletions ariba/samtools_variants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
import pysam
import pysam.bcftools
import pyfastaq
import vcfcall_ariba

Expand Down Expand Up @@ -36,13 +37,11 @@ def _make_vcf_and_read_depths_files(self):

tmp_vcf = self.vcf_file + '.tmp'
with open(tmp_vcf, 'w') as f:
print(pysam.mpileup(
'-t', 'INFO/AD,INFO/ADF,INFO/ADR',
print(pysam.bcftools.mpileup(
'-a', 'INFO/AD,INFO/ADF,INFO/ADR',
'-L', '99999999',
'-A',
'-f', self.ref_fa,
'-u',
'-v',
self.bam,
), end='', file=f)

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ref1 121 . C A,T,<*> 0 . DP=142;ADF=72,16,18,0;ADR=22,8,1,0;AD=94,24,19,0;I16=72,22,34,9,3752,149792,1660,65086,3948,165816,1300,42424,1488,30666,682,13620;QS=0.748454,0.135248,0.116298,0;VDB=0.419877;SGB=-0.693146;RPB=0.693393;MQB=2.09583e-09;MQSB=0.677623;BQB=0.54095;MQ0F=0 PL 78,0,255,65,197,255,255,255,255,255
ref1 149 . AC ACC 0 . INDEL;IDV=162;IMF=0.910112;DP=178;ADF=0,96;ADR=0,79;AD=0,175;I16=0,0,96,79,0,0,6916,273882,0,0,5838,208760,0,0,2791,56033;QS=0,1;VDB=0.470182;SGB=-0.693147;MQSB=0.999996;MQ0F=0 PL 255,255,0
ref1 201 . C G,<*> 0 . DP=190;ADF=0,80,0;ADR=0,94,0;AD=0,174,0;I16=0,0,80,94,0,0,6796,267896,0,0,6554,257056,0,0,2900,58094;QS=0,1,0;VDB=0.437278;SGB=-0.693147;MQSB=0.849709;MQ0F=0 PL 255,255,0,255,255,255
ref2 170 . A T,<*> 0 . DP=117;ADF=0,52,0;ADR=0,59,0;AD=0,111,0;I16=0,0,52,59,0,0,4390,174306,0,0,4662,195804,0,0,1824,36678;QS=0,1,0;VDB=0.30232;SGB=-0.693147;MQSB=1;MQ0F=0 PL 255,255,0,255,255,255
ref1 121 . C A,T,<*> 0 . DP=142;ADF=72,16,20,0;ADR=22,8,2,0;AD=94,24,22,0;I16=72,22,36,10,3752,149792,1684,65278,3948,165816,1408,46528,1488,30666,685,13623;QS=0.744888,0.134604,0.120508,0;VDB=0.740082;SGB=-0.693147;RPBZ=-0.623486;MQBZ=-8.79322;MQSBZ=-1.56952;BQBZ=-3.61356;SCBZ=0;MQ0F=0 PL 77,0,255,51,195,255,255,255,255,255
ref1 149 . AC ACC 0 . INDEL;IDV=162;IMF=0.910112;DP=178;ADF=6,91;ADR=2,71;AD=8,162;I16=6,2,91,71,320,12800,6480,259200,296,11478,5382,191916,12,22,2780,56012;QS=0.0254111,0.974589;VDB=0.0591298;SGB=-0.693147;RPBZ=1.64808;MQBZ=0.803052;MQSBZ=-1.56952;BQBZ=-3.61356;SCBZ=0;MQ0F=0 PL 255,255,0
ref1 201 . C G,<*> 0 . DP=190;ADF=0,84,0;ADR=0,99,0;AD=0,183,0;I16=0,0,84,99,0,0,6868,268472,0,0,6842,266992,0,0,2911,58109;QS=0,1,0;VDB=0.708247;SGB=-0.693147;MQSBZ=0.614759;MQ0F=0 PL 255,255,0,255,255,255
ref2 170 . A T,<*> 0 . DP=117;ADF=0,55,0;ADR=0,62,0;AD=0,117,0;I16=0,0,55,62,0,0,4680,187200,0,0,4914,206388,0,0,1827,36681;QS=0,1,0;VDB=0.655552;SGB=-0.693147;MQSBZ=0;MQ0F=0 PL 255,255,0,255,255,255
4 changes: 3 additions & 1 deletion ariba/tests/samtools_variants_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def get_vcf_call_lines(fname):
got = got_lines[i].split('\t')
self.assertEqual(len(expected), len(got))
self.assertEqual(expected[:7], got[:7])
self.assertEqual(expected[-2:], got[-2:])
# last two cols are PL and then values. These are not used, and
# can change slightly between samtools/bcftools versions. Ignore.
#self.assertEqual(expected[-2:], got[-2:])
exp_set = set(expected[7].split(';'))
got_set = set(got[7].split(';'))
self.assertEqual(exp_set, got_set)
Expand Down
3 changes: 2 additions & 1 deletion install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ apt-get install --no-install-recommends -y \
python3-dev \
python3-setuptools \
python3-pip \
python3-pysam \
python3-tk \
python3-matplotlib \
unzip \
Expand All @@ -38,6 +37,8 @@ if [ ! -d $install_root ]; then
fi
cd $install_root

# pysam from pip because apt-get version is too old
python3 -m pip install pysam>=0.21.0

# --------------- bowtie2 ------------------
cd $install_root
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ BeautifulSoup4 >= 4.1.0
biopython < 1.78
dendropy >= 4.2.0
pyfastaq >= 3.12.0
pysam >= 0.9.1
pysam >= 0.21.0
pymummer <= 0.10.3
matplotlib >= 3.1.0

0 comments on commit 71909ed

Please sign in to comment.