Skip to content

Commit

Permalink
Merge pull request #40 from COMBINE-lab/develop
Browse files Browse the repository at this point in the history
fix: fix bug in format detection for id-to-name
  • Loading branch information
rob-p authored Jun 23, 2023
2 parents dc60cad + 8d4bb65 commit 7e69996
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
echo $CONDA/bin >> $GITHUB_PATH
- name: Install dependencies
run: |
conda install -n base python=3.9 conda-forge::biopython bioconda::pyranges packaging bioconda::scanpy pytest -y
conda install -n base python=3.9 conda-forge::biopython numpy==1.23 bioconda::pyranges==0.0.120 packaging bioconda::scanpy pytest -y
- name: pytest
run: |
pip install .
pytest
pytest
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pyroe
version = 0.9.2
version = 0.9.3
author = Dongze He, Rob Patro
author_email = [email protected], [email protected]
description = utilities of alevin-fry
Expand Down
2 changes: 1 addition & 1 deletion src/pyroe/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.9.2"
__version__ = "0.9.3"

from pyroe.load_fry import load_fry
from pyroe.make_txome import make_splici_txome, make_spliceu_txome
Expand Down
28 changes: 16 additions & 12 deletions src/pyroe/id_to_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,35 @@

def id_to_name(params):
format_map = {
".gtf": pyranges.read_gtf,
".gff": pyranges.read_gff3,
".gff3": pyranges.read_gff3,
"gtf": pyranges.read_gtf,
"gff": pyranges.read_gff3,
"gff3": pyranges.read_gff3,
}
annot_reader = None
if params.format is None:
p = pathlib.Path(params.gtf_file)
suffs = [z.lower() for z in p.suffixes]
suffs = [z.lower().strip('.') for z in p.suffixes]

z = None
if len(suffs) == 1:
z = suffs[0]
elif len(suffs) == 2 and suffs[-1] == ".gz":
z = suffs[-2]
if len(suffs) >= 1:
# look at the final suffix
z = suffs[-1]
# if the final suffix is gz and there are
# suffixes preceding it, check the penultimate
# one and use that
if z == "gz" and len(suffs) > 1:
z = suffs[-2]

if z in format_map.keys():
annot_reader = format_map[z]
else:
if z is None or z not in format_map.keys():
logging.error(
"Could not determine format of annotation file. Please provide it explicitly."
)
sys.exit(1)
else:
annot_reader = format_map[z]
else:
fmt = params.format.lower()
if fmt not in ["gtf", "gff3"]:
if fmt not in format_map.keys():
logging.error(
f'Format must be either "gtf" or "gff3", but {fmt} was provided.'
)
Expand Down

0 comments on commit 7e69996

Please sign in to comment.