mdshw5 / pyfaidx

Efficient pythonic random access to fasta subsequences

Home Page:https://pypi.python.org/pypi/pyfaidx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fasta(as_raw=True) behavior

jayhesselberth opened this issue · comments

I am finding that to get as_raw=True to work correctly, I have to call it twice:

ipdb> fasta = Fasta(fasta_filename, as_raw = True)
ipdb> chrom = fasta.keys()[0]
ipdb> fasta[chrom][1:2]
>chrII:236683-237683(+):2-2
T
ipdb> fasta = Fasta(fasta_filename, as_raw = True)
ipdb> fasta[chrom][1:2]
u'T'

Note that the index for fasta_filename doesn't exist before the first call.

Is this expected behaviour? Does as_raw only work on an existing index? i.e. the index is created at the first call, and then as_raw is used?

This is definitely not expected behavior, since the index does not have any bearing on the as_raw parameter. What version of pyfaidx are you using?

Using v0.2.4

$ pip show pyfaidx

Name: pyfaidx
Version: 0.2.4
Location: /vol1/software/modules-python/python/2.7.6/lib/python2.7/site-packages
Requires: six

I think I identified a fix. Thanks for the bug report! This was a case that I hadn't caught, when the index has to be built and then I re-initialize the Faidx class but forgot to pass any parameters from the initial init.

fixed. thanks.