text: user9: Ideally, I'd like to do something like the following:
  f = pysam.AlignmentFile(filename, index_filename=index_filename)
  read = list(f.fetch('Chromosome', 1, 10000))[0]
  read.get_variations()
  
  And have that output something like:
  [
    (1, 'A', 'C'), # An A -> C mismatch at position 1
    (15, 'I', 'CGGG'), # An insertion of the string 'CGGG' starting at position 15 of the read
    (32, 'D', 4), # A deletion of 4 base pairs starting at position 32
  ]
  
  I know that it's possible to figure out all of those values by parsing the CIGAR string and MD tags but I'm wondering if there's a more intuitive interface.
  
  user77: You're looking for pileup, which is the htslib (and thus samtools/bcftools) method for finding variants. See this section of the pysam documentation. You may want to peruse about the output as well. The gist is:
  import pysam
  samfile = pysam.AlignmentFile("ex1.bam", "rb" )
  for pileupcolumn in samfile.pileup("chr1", 100, 120):
      for pileupread in pileupcolumn.pileups:
          if not pileupread.is_del and not pileupread.is_refskip:
              # query position is None if is_del or is_refskip is set.
              ...handle mismatches...
  
  
original_text: 9: <p>Ideally, I'd like to do something like the following:</p>
  <pre><code>f = pysam.AlignmentFile(filename, index_filename=index_filename)
  read = list(f.fetch('Chromosome', 1, 10000))[0]
  read.get_variations()
  </code></pre>
  <p>And have that output something like:</p>
  <pre><code>[
    (1, 'A', 'C'), # An A -&gt; C mismatch at position 1
    (15, 'I', 'CGGG'), # An insertion of the string 'CGGG' starting at position 15 of the read
    (32, 'D', 4), # A deletion of 4 base pairs starting at position 32
  ]
  </code></pre>
  <p>I know that it's possible to figure out all of those values by parsing the CIGAR string and MD tags but I'm wondering if there's a more intuitive interface.</p>
   77: <p>You're looking for <code>pileup</code>, which is the htslib (and thus samtools/bcftools) method for finding variants. See <a href="https://pysam.readthedocs.io/en/latest/api.html#introduction" rel="nofollow noreferrer">this section</a> of the pysam documentation. You may want to peruse about <a href="https://pysam.readthedocs.io/en/latest/api.html#pysam.PileupColumn" rel="nofollow noreferrer">the output</a> as well. The gist is:</p>
  <pre><code>import pysam
  samfile = pysam.AlignmentFile(&quot;ex1.bam&quot;, &quot;rb&quot; )
  for pileupcolumn in samfile.pileup(&quot;chr1&quot;, 100, 120):
      for pileupread in pileupcolumn.pileups:
          if not pileupread.is_del and not pileupread.is_refskip:
              # query position is None if is_del or is_refskip is set.
              ...handle mismatches...
  </code></pre>
  