MaciekAber / pysam

Automatically exported from code.google.com/p/pysam
0 stars 0 forks source link

Pysam.index does not check filename #17

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. pysam.index("I_do_not_exist")

What is the expected output? What do you see instead?
ValueError("File does not exist 'I_do_not_exist") or OSError(...)
Actual output: []

What version of the product are you using? On what operating system?
Revision 68:d7f5059cbe52
on Ubuntu Linux.

Original issue reported on code.google.com by finkerna...@mathematik.uni-marburg.de on 21 Oct 2009 at 3:25

GoogleCodeExporter commented 8 years ago
Thanks for bringing this to our attention. Unfortunately there is no elegant
way to fix it. Pysam forwards the call of pysam.index to samtools bam_index(). 
The
latter returns an error if the options are invalid, but not if
there is an error in the actual processing. This affects more than just 
bam_index().

I have added a patch to the repository that raises an SamtoolsError if
samtools outputs on stderr. NB: This might cause other problems as samtools
writes to stderr for simple information messages.

Original comment by andreas....@gmail.com on 24 Oct 2009 at 1:11

GoogleCodeExporter commented 8 years ago
Indeed, it fails for sort
if stderr: raise SamtoolsError( "\n".join( stderr ) )
pysam.pysam.SamtoolsError: '[bam_sort_core] merging from 4 files...\n'

Guess we should stick to returncode != 0 and forward the bug upstream to 
samtools?

Original comment by finkerna...@mathematik.uni-marburg.de on 26 Oct 2009 at 6:53

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago

Original comment by andreas....@gmail.com on 4 May 2010 at 4:55

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
This bug has not been fixed in PySam v0.3.1!

There is still and error in PySAM v0.3.1 regarding bam_sort_core! The error 
message is:
'pysam.SamtoolsError: '[bam_sort_core] merging from 2 files...\n'

The lines in file '__init__.py':
============================================================
....
        stderr = [ x for x in stderr \
                       if not x.startswith( "[sam_header_read2]" ) or \
                       x.startswith("[bam_index_load]") or \
                       x.startswith("[bam_sort_core]") or \
                       x.startswith("[samopen] SAM header is present")
                   ]
...
============================================================
should be changed to:
============================================================
...
        stderr = [ x for x in stderr \
                       if not (x.startswith( "[sam_header_read2]" ) or \
                       x.startswith("[bam_index_load]") or \
                       x.startswith("[bam_sort_core]") or \
                       x.startswith("[samopen] SAM header is present"))
                   ]
...
============================================================

Original comment by enxx...@gmail.com on 19 Nov 2010 at 11:55

GoogleCodeExporter commented 8 years ago
Thanks,

hopefully finally finally fixed in version 0.4
Added unit test

Bw,
Andreas

Original comment by andreas....@gmail.com on 10 Feb 2011 at 11:01