lixin6135 / pysam

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

pysam index does not work in ipython / during automated tests #98

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. open ipython
2. import pysam
3. pysam.index("foo.bam")

Results in error:

AttributeError                            Traceback (most recent call last)
<ipython-input-6-753331f7c892> in <module>()
----> 1 pysam.index("foo.bam")

/usr/local/lib/python2.7/dist-packages/pysam-0.6-py2.7-linux-i686.egg/pysam/__in
it__.pyc in __call__(self, *args, **kwargs)
     48         '''execute a samtools command
     49         '''
---> 50         retval, stderr, stdout = csamtools._samtools_dispatch( 
self.dispatch, args )
     51         if retval: raise SamtoolsError( "\n".join( stderr ) )
     52         self.stderr = stderr

/usr/local/lib/python2.7/dist-packages/pysam-0.6-py2.7-linux-i686.egg/csamtools.
so in csamtools._samtools_dispatch (pysam/csamtools.c:26160)()

AttributeError: 'OutStream' object has no attribute 'fileno'

What is the expected output? What do you see instead?
I would expect the command to succeed, silently like running it from the 
command line

What version of the product are you using? On what operating system?
pysam 0.6
Ubuntu 11.04

Please provide any additional information below.

It appears the issue is with file outputting.  pysam assumes output to stdout 
or something along those lines, when another process hijacks the output it 
breaks.  This bug has broken my unit tests (nose testing in python) and also 
when I try to run in ipython.  

Original issue reported on code.google.com by gabriel....@gmail.com on 17 Aug 2012 at 6:57

GoogleCodeExporter commented 8 years ago
I fixed this issue, my fix is in the clone:
https://code.google.com/r/gabrielpratt-pysamstderr/

I do make some fairly significant changes to the way the dispatch is handled, 
so please code review to make sure you are alright with all the differences.  

It does pass all unit tests included in pysam so everything should be alright.  

Original comment by gabriel....@gmail.com on 6 Sep 2012 at 3:36

GoogleCodeExporter commented 8 years ago
Thanks, I see what you have done (starting a separate process to run samtools).
I am worried that this creates a dependency on a separate samtools installation.
outside of pysam.

However, given the many issues with the dispatch method this might be the way
to go, but I will need to think a little more.

Best wishes,
Andreas

Original comment by andreas....@gmail.com on 8 Oct 2012 at 3:40

GoogleCodeExporter commented 8 years ago
Thanks, it seems to work for me now on python 2.7.3 and the latest pysam, in 
which I have changed how stderr is handled.

Please re-open if it continues to be a problem.

Best wishes,
Andreas

Original comment by andreas....@gmail.com on 21 Nov 2012 at 3:16