mdshw5 / pyfaidx

Efficient pythonic random access to fasta subsequences
https://pypi.python.org/pypi/pyfaidx
Other
459 stars 75 forks source link

Editing FASTA files sporadically does not have effect. #110

Closed sfbrunner closed 7 years ago

sfbrunner commented 7 years ago

Hi there, First of, thanks for writing pyfaidx, it's really useful to my work. I am currently experiencing an issue where I try to replace a sequence fragment of a FASTA file and the replacement only takes place sporadically. Ie. I do the following:

fasta_connxn = pyfaidx.Fasta(fasta_path, mutable=True)
fasta_connxn[chrom][start:end] = 'NNNNNNNNNN'

Now if I check the file on disk, it does not contain the 'N's. If I then execute the same command again, it now does. Just appears as if the changes do not always take effect. Have you ever seen a similar error? Do you know a fix for this? I am using bioconda pyfaidx version 0.4.8.1 py27_0.

Thanks!

mdshw5 commented 7 years ago

This is expected behavior for the current version, since writes are not immediately flushed to disk and instead may be buffered. There shouldn't be much of a performance penalty to change this and make MutableFastaRecord flush writes. I'll make the change and release 0.4.8.4 shortly.

mdshw5 commented 7 years ago

Thanks for reporting this, by the way!

mdshw5 commented 7 years ago

The new version is available and hopefully meets your needs: https://pypi.python.org/pypi/pyfaidx

sfbrunner commented 7 years ago

Thanks for the rapid response, I'll give the new version a try!

sfbrunner commented 7 years ago

Btw: are you going to attend the Abcam Mutational Signatures conference in Boston this week?

mdshw5 commented 7 years ago

No, but that looks like a worthwhile conference. I'll have to check it out for next year!