forked from mdshw5/pyfaidx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mdshw5#184 from palao/develop
pathlib.Path can be passed to Fasta and Faidx
- Loading branch information
Showing
4 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,6 @@ __pycache__ | |
.coverage | ||
.coverage.* | ||
tests/data/chr22* | ||
.eggs/ | ||
tests/data/genes.fasta.gz | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
import pytest | ||
from pathlib import Path | ||
from pyfaidx import Faidx, Fasta | ||
|
||
path = os.path.dirname(__file__) | ||
os.chdir(path) | ||
|
||
@pytest.fixture | ||
def remove_index(): | ||
yield | ||
try: | ||
os.remove('data/genes.fasta.fai') | ||
except EnvironmentError: | ||
pass # some tests may delete this file | ||
|
||
def test_Faidx(remove_index): | ||
""" Ensures that Faidx can be created with a pathlib.Path as filename """ | ||
filename = 'data/genes.fasta' | ||
faidx = Faidx(filename) | ||
faidx_w_path = Faidx(Path(filename)) | ||
assert faidx.filename == faidx_w_path.filename | ||
|
||
def test_Fasta(remove_index): | ||
""" Ensures that Fasta can be created with a pathlib.Path as filename """ | ||
filename = 'data/genes.fasta' | ||
fasta = Fasta(filename) | ||
fasta_w_path = Fasta(Path(filename)) | ||
assert fasta.filename == fasta_w_path.filename |