Skip to content

Commit

Permalink
added --version capability and bumped version
Browse files Browse the repository at this point in the history
  • Loading branch information
ljwharbers committed Oct 16, 2024
1 parent bf09e45 commit d35df72
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/flexi_formatter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Tool to reformat flexiplex tags in a bam file"""

__version__ = "0.0.4"
__version__ = "1.0.0"
39 changes: 26 additions & 13 deletions src/flexi_formatter/reformat_flexiplex_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit d35df72

Please sign in to comment.