From d35df727477f4469242548ac5dafaf945c77a008 Mon Sep 17 00:00:00 2001 From: ljwharbers Date: Wed, 16 Oct 2024 15:02:17 +0200 Subject: [PATCH] added --version capability and bumped version --- src/flexi_formatter/__init__.py | 2 +- .../reformat_flexiplex_tags.py | 39 ++++++++++++------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/flexi_formatter/__init__.py b/src/flexi_formatter/__init__.py index e82265b..06f3834 100644 --- a/src/flexi_formatter/__init__.py +++ b/src/flexi_formatter/__init__.py @@ -1,3 +1,3 @@ """Tool to reformat flexiplex tags in a bam file""" -__version__ = "0.0.4" \ No newline at end of file +__version__ = "1.0.0" \ No newline at end of file diff --git a/src/flexi_formatter/reformat_flexiplex_tags.py b/src/flexi_formatter/reformat_flexiplex_tags.py index 7339476..f376a4f 100755 --- a/src/flexi_formatter/reformat_flexiplex_tags.py +++ b/src/flexi_formatter/reformat_flexiplex_tags.py @@ -2,25 +2,38 @@ import sys import typer import simplesam +from flexi_formatter import __version__ app = typer.Typer() @app.command() def main(infile: str): - with simplesam.Reader(open(infile)) as in_bam: - with simplesam.Writer(sys.stdout, in_bam.header) as out_sam: - for read in in_bam: - # Get header name and split by "_#" - bc_umi = read.qname.split("#")[0] - bc = bc_umi.split("_")[0] - read.tags['CB'] = bc + with simplesam.Reader(open(infile)) as in_bam: + with simplesam.Writer(sys.stdout, in_bam.header) as out_sam: + for read in in_bam: + # Get header name and split by "_#" + bc_umi = read.qname.split("#")[0] + bc = bc_umi.split("_")[0] + read.tags['CB'] = bc - if len(bc_umi.split("_")) > 1: - umi = bc_umi.split("_")[1] - read.tags['UR'] = umi + if len(bc_umi.split("_")) > 1: + umi = bc_umi.split("_")[1] + read.tags['UR'] = umi - # Write new reads - out_sam.write(read) + # Write new reads + out_sam.write(read) + +@app.callback() +def callback(): + """ + A simple tool for processing BAM/SAM files. + """ + pass + +@app.command() +def version(): + """Prints the version of the tool.""" + typer.echo(f"flexi_formatter version: {__version__}") if __name__ == "__main__": - app() + app() \ No newline at end of file