Skip to content

Commit

Permalink
Merge pull request #162 from GavinHuttley/develop
Browse files Browse the repository at this point in the history
BUG: fix issue where quotes wind up on alignment name
  • Loading branch information
GavinHuttley authored Sep 6, 2024
2 parents 8ed7517 + 1fd8dab commit f84839f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/ensembl_tui/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,13 @@ def __new__(cls, *args, **kwargs):
return obj


_quotes = re.compile(r"^[\'\"]|[\'\"]$")


def strip_quotes(text: str):
return _quotes.sub("", text)


def get_iterable_tasks(
*,
func: typing.Callable,
Expand Down
10 changes: 5 additions & 5 deletions src/ensembl_tui/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ def alignments(
shutil.rmtree(outdir, ignore_errors=True)

config = elt_config.read_installed_cfg(installed)
align_name = elt_util.strip_quotes(align_name)
align_path = config.path_to_alignment(align_name, elt_align.ALIGN_STORE_SUFFIX)
if align_path is None:
click.secho(
Expand Down Expand Up @@ -480,17 +481,16 @@ def alignments(
total=limit or len(locations),
description="Getting alignment data",
)
for results in maker.as_completed(locations, show_progress=False):
for alignments in maker.as_completed(locations, show_progress=False):
progress.update(task, advance=1)
if not results.obj:
if not alignments:
continue
input_source = results.source.source
alignments = results.obj
input_source = alignments[0].info.source
if len(alignments) == 1:
writer(alignments[0], identifier=input_source)
continue

for i, aln in enumerate(results.obj):
for i, aln in enumerate(alignments):
identifier = f"{input_source}-{i}"
writer(aln, identifier=identifier)

Expand Down
5 changes: 5 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,8 @@ def test_sanitise_stableid(biotype):
stableid = f"{biotype}:{identifier}"
got = elt_util.sanitise_stableid(stableid)
assert got == identifier


@pytest.mark.parametrize("text", ["'primate'", '"primate"'])
def test_stripquotes(text):
assert elt_util.strip_quotes(text) == "primate"

0 comments on commit f84839f

Please sign in to comment.