BDI-pathogens / phyloscanner

Phylogenetics between and within hosts at once, all along the genome.
GNU General Public License v3.0
47 stars 14 forks source link

Make error message less opaque if the .bai file is missing #27

Closed mdhall272 closed 5 years ago

mdhall272 commented 6 years ago

I was using symbolic links as input .bam and _ref.fasta files, without realising that the .bai files were also expected in the same directory, and got the error message:

Problem running samtools index. Quitting.
Traceback (most recent call last):
  File "/users/fraser/mdhall/phyloscanner/phyloscanner_make_trees.py", line 981, in <module>
    pf.MakeBamIndices(BamFiles, args.x_samtools)
  File "/gpfs0/users/fraser/mdhall/phyloscanner/tools/phyloscanner_funcs.py", line 999, in MakeBamIndices
    ExitStatus = subprocess.call([SamtoolsCommand, 'index', BamFileName])
  File "/apps/well/python/2.7.10/lib/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/apps/well/python/2.7.10/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/apps/well/python/2.7.10/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

This was a bit baffling until I looked at the code. (Also, what is the function MakeBamIndices supposed to do? It it's intended to do something when the .bai file is missing then that did not work for me.)

ChrisHIV commented 6 years ago

Indeed MakeBamIndices runs (from the command line) 'samtools index BamFile' for any BamFile for which BamFile+".bai" doesn't exist. It's encountering an error running that command; "Problem running samtools index. Quitting." was my error message, and the rest is what python is producing on it's own. I've increased the verbosity of my message; have another go. I can't reproduce the error you're getting: when I specify a symlink in place of an actual bam file, it seems to follow the link first and check for the existing of the bai file afterwards - it's not troubled by the lack of a symlink+".bai" file. ?