diff --git a/.travis.yml b/.travis.yml index 8cbbeac..6e05961 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ python: - '2.6' - pypy install: +- pip install biopython - pip install -e . script: nosetests deploy: diff --git a/README.rst b/README.rst index 190648c..4f5a313 100644 --- a/README.rst +++ b/README.rst @@ -215,6 +215,16 @@ CLI Usage Changes ------- +*New in version 0.2.5*: + +- Fasta and Faidx can take `default_seq` in addition to `as_raw`, `key_function`, + and `strict_bounds` parameters. +- Fixed issue [#20](https://github.com/mdshw5/pyfaidx/issues/20) +- Faidx has attribute `raw_index` which is a list representing the fai file. +- Faidx has `rebuild_index` and `write_fai` functions for building and writing + `raw_index` to file. +- Extra test cases, and test cases against Biopython SeqIO + *New in version 0.2.4*: - Faidx index order is stable and non-random diff --git a/setup.py b/setup.py index b7688d1..ffb6171 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name='pyfaidx', provides='pyfaidx', - version='0.2.4', + version='0.2.5', author='Matthew Shirley', author_email='mdshw5@gmail.com', url='http://mattshirley.com', diff --git a/tests/test_bio_seqio.py b/tests/test_bio_seqio.py new file mode 100644 index 0000000..96b833d --- /dev/null +++ b/tests/test_bio_seqio.py @@ -0,0 +1,23 @@ +import os +from pyfaidx import Fasta, FetchError +from Bio import SeqIO + +path = os.path.dirname(__file__) +os.chdir(path) + +class TestBioSeqIO: + def __init__(self): + self.genes = os.path.join(path, 'data/genes.fasta') + self.fasta = Fasta(self.genes) + with open(self.genes, "rU") as fh: + self.seqio = SeqIO.to_dict(SeqIO.parse(fh, "fasta")) + + def test_fetch_whole_entry(self): + assert str(self.fasta['KF435150.1']) == str(self.seqio['KF435150.1'].seq) + assert self.fasta['KF435150.1'].name == str(self.seqio['KF435150.1'].name) + + def test_slice_whole_entry(self): + assert str(self.fasta['KF435150.1'][::3]) == str(self.seqio['KF435150.1'].seq[::3]) + + def test_revcomp_whole_entry(self): + assert str(self.fasta['KF435150.1'][:].reverse.complement) == str(self.seqio['KF435150.1'].reverse_complement().seq)