Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add BLAT output caching/reusing #6

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/dcd_mapping/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@
default=False,
help="Enable debug logging",
)
def cli(urn: str, debug: bool) -> None:
@click.option(
"--cache_align",
"-c",
is_flag=True,
show_default=True,
default=False,
help="Enable caching for alignment results. Mostly useful for development/debugging.",
)
def cli(urn: str, debug: bool, cache_align: bool) -> None:
"""Get VRS mapping on preferred transcript for URN.

For example:
Expand All @@ -29,6 +37,7 @@ def cli(urn: str, debug: bool) -> None:
\f
:param urn: scoreset URN
:param debug: if True, enable debug logging
:param cache_align: if True, save alignment output and reuse when available
""" # noqa: D301
logging.basicConfig(
filename="dcd-mapping.log",
Expand All @@ -41,7 +50,7 @@ def cli(urn: str, debug: bool) -> None:
else:
_logger.setLevel(logging.INFO)
_logger.debug("debug logging enabled")
asyncio.run(map_scoreset_urn(urn, silent=False))
asyncio.run(map_scoreset_urn(urn, silent=False, cache_align=cache_align))


if __name__ == "__main__":
Expand Down
23 changes: 14 additions & 9 deletions src/dcd_mapping/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,20 @@ def _save_results(


async def map_scoreset(
metadata: ScoresetMetadata, records: List[ScoreRow], silent: bool = True
metadata: ScoresetMetadata,
records: List[ScoreRow],
silent: bool = True,
cache_align: bool = False,
) -> None:
"""Given information about a MAVE experiment, map to VRS.
"""Given information about a MAVE experiment, map to VRS and save output as JSON.

:param metadata: salient data gathered from scoreset on MaveDB
:param records: experiment scoring results
:param silent:
:return: something (TODO)
:param silent: if True, suppress console output
:param cache_align: if True, save alignment output and reuse when available
"""
try:
alignment_result = align(metadata, silent, True)
alignment_result = align(metadata, silent, cache_align)
except AlignmentError:
_logger.error(f"Alignment failed for scoreset {metadata.urn}")
return None
Expand All @@ -71,11 +74,14 @@ async def map_scoreset(
_save_results(metadata, vrs_results)


async def map_scoreset_urn(urn: str, silent: bool = True) -> None:
async def map_scoreset_urn(
urn: str, silent: bool = True, cache_align: bool = False
) -> None:
"""Perform end-to-end mapping for a scoreset.

:param urn: identifier for a scoreset.
:return: something (TODO)
:param silent: if True, suppress console output
:param cache_align: if True, save alignment output and reuse when available
"""
try:
metadata = get_scoreset_metadata(urn)
Expand All @@ -85,5 +91,4 @@ async def map_scoreset_urn(urn: str, silent: bool = True) -> None:
_logger.critical(msg)
click.echo(f"Error: {msg}")
return None
mapped = await map_scoreset(metadata, records, silent)
return mapped # TODO not sure what this will be
await map_scoreset(metadata, records, silent, cache_align)