pysam: How do I type an AlignedSegment in Cython?
0
0
Entering edit mode
2.9 years ago

I have the following code, where I want to type a:

for a in samfile:
    flag = a.flag
    is_reverse = flag & 0x10
    ....

It should have the type AlignedSegment from https://github.com/pysam-developers/pysam/blob/master/pysam/libcalignedsegment.pxd because that seems to be the type of a:

In [25]: a
Out[25]: <pysam.libcalignedsegment.AlignedSegment at 0x7f7fc5e53588>

When I use

from pysam.libcalignedsegment cimport AlignedSegment

I get the error

read_bam.cpp:618:28: fatal error: htslib/kstring.h: No such file or directory
compilation terminated.

I understand this means that it cannot find htslib when compiling. However pysam works so I guess it is me just cimporting pysam in the wrong way.

To be clear, I want to type a so I get no overhead:

 cdef AlignedSegment a

What do I import?

cython pysam • 1.1k views
ADD COMMENT
0
Entering edit mode

However pysam works

How did you test it ?

What is the command line and the output of your pysam installation ?

ADD REPLY
0
Entering edit mode

I am able to run

samfile = pysam.AlignmentFile("test.bam", "rb")
for a in samfile: print(a)

and it works :)

ADD REPLY
0
Entering edit mode

Export LIBRARY_PATH before starting Jupyter.

ADD REPLY
0
Entering edit mode

This is a problem when I try to compile a Cython project. echo $LIBRARY_PATH is empty, btw.

ADD REPLY
0
Entering edit mode

I know it's empty, you need to set it appropriately.

ADD REPLY

Login before adding your answer.

Traffic: 1878 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6