text: user57: (How) can you index a BAM file using pysam?
  When I tried the intuitive pysam.index I got:
  import pysam
  my_bam = pysam.AlignmentFile("regular_bwamem_mapping.bam", "rb")
  pysam.index(my_bam)
  
  ---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  <ipython-input-5-a0b3a04ecb2c> in <module>
  ----> 1 pysam.index(L_bam)
  
  ~/miniconda3/lib/python3.7/site-packages/pysam/utils.py in __call__(self, *args, **kwargs)
       59             args,
       60             catch_stdout=kwargs.get("catch_stdout", True),
  ---> 61             save_stdout=kwargs.get("save_stdout", None))
       62
       63         if kwargs.get("split_lines", False):
  
  pysam/libcutils.pyx in pysam.libcutils._pysam_dispatch()
  
  TypeError: object of type 'pysam.libcalignmentfile.AlignmentFile' has no len()
  
  
  user57: Oh you silly sausage, pysam.index takes a bam file name, not a python object.
  import pysam
  pysam.index("regular_bwamem_mapping.bam")
  
  will index your .bam file.
  
original_text: 57: <p>(How) can you index a BAM file using <code>pysam</code>?</p>
  
  <p>When I tried the intuitive <code>pysam.index</code> I got:</p>
  
  <pre><code>import pysam
  my_bam = pysam.AlignmentFile("regular_bwamem_mapping.bam", "rb")
  pysam.index(my_bam)
  
  ---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-5-a0b3a04ecb2c&gt; in &lt;module&gt;
  ----&gt; 1 pysam.index(L_bam)
  
  ~/miniconda3/lib/python3.7/site-packages/pysam/utils.py in __call__(self, *args, **kwargs)
       59             args,
       60             catch_stdout=kwargs.get("catch_stdout", True),
  ---&gt; 61             save_stdout=kwargs.get("save_stdout", None))
       62
       63         if kwargs.get("split_lines", False):
  
  pysam/libcutils.pyx in pysam.libcutils._pysam_dispatch()
  
  TypeError: object of type 'pysam.libcalignmentfile.AlignmentFile' has no len()
  </code></pre>
   57: <p>Oh you silly sausage, <code>pysam.index</code> takes a bam file name, not a python object.</p>
  <pre><code>import pysam
  pysam.index(&quot;regular_bwamem_mapping.bam&quot;)
  </code></pre>
  <p>will index your <code>.bam</code> file.</p>
  