Skip to content

Commit

Permalink
IH 19DEC2022 version to v1.0.3-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ijhoskins committed Dec 19, 2022
1 parent d888782 commit a0ecc54
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ Release Summary:

1.0.2-dev, December 9, 2022
Fixed variant calling bug that caused di-nt MNPs to be called as two SNPs when the di-nt MNP was downstream of a single SNP or another di-nt MNP

1.0.3-dev, December 19, 2022
Added back run_design_conversion.py to scripts directory

Added __init__.py to prototype directory. Now in package.

Fixed URL links in setup.cfg and in satmut_utils_manual.md to point to ijhoskins repo

4 changes: 2 additions & 2 deletions docs/satmut_utils_manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Currently, only Linux and MacOSX operating systems are supported. To get started

2. Clone the satmut\_utils repository:
```
git clone https://github.com/CenikLab/satmut_utils.git
git clone https://github.com/ijhoskins/satmut_utils.git
SATMUT_ROOT="$PWD/satmut_utils"
```

Expand All @@ -62,7 +62,7 @@ SATMUT_ROOT="$PWD/satmut_utils"
REF_DIR="$HOME/satmut_utils_refs"
$SATMUT_ROOT/install_satmut_utils.sh -h
$SATMUT_ROOT/install_satmut_utils.sh -t -g -r "$REF_DIR" "$SATMUT_ROOT"
conda activate satmut_utils
conda activate satmut_utils_dev
```

You are now ready to call the command-line executable ```satmut_utils```
Expand Down
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[metadata]
name = satmut_utils
version = 1.0.2-dev
version = 1.0.3-dev
author = Ian Hoskins
author_email = [email protected]
description = Tools for variant simulation and variant calling in paired end, targeted sequencing saturation mutagenesis experiments
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/CenikLab/satmut_utils
url = https://github.com/ijhoskins/satmut_utils
project_urls =
Bug Tracker = https://github.com/CenikLab/satmut_utils/issues
Bug Tracker = https://github.com/ijhoskins/satmut_utils/issues
classifiers =
Development Status :: 4 - Beta
License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Expand Down
Empty file added src/prototype/__init__.py
Empty file.
109 changes: 109 additions & 0 deletions src/prototype/run_design_conversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/usr/bin/env python3
"""Preprocesses amplicon/tile alignments to meet dms_tools2 and Enrich2 input requirements."""

import argparse
import logging
import os
import sys

from core_utils.file_utils import replace_extension
from satmut_utils.definitions import LOG_FORMATTER
from prototype.design_conversion import DesignConverter

__author__ = "Ian_Hoskins"
__credits__ = ["Ian Hoskins"]
__license__ = "GPLv3"
__maintainer__ = "Ian Hoskins"
__email__ = "[email protected]"
__status__ = "Development"

LOGFILE = replace_extension(os.path.basename(__file__), "log")
logger = logging.getLogger(__name__)
console_handler = logging.StreamHandler()
console_handler.setFormatter(LOG_FORMATTER)
logger.addHandler(console_handler)


def parse_commandline_params(args):
"""Parses command line parameters.
:param list args: command line arguments, no script name
:return argparse.Namespace: namespace object with dict-like access
"""

parser = argparse.ArgumentParser(description="%s arguments" % __name__)

# Add new arguments for command line passing of files, options, etc; see argparse docs
parser.add_argument("-b", "--in_bam", type=str, required=True,
help='BAM file of reads in a single tile to convert. Intersect any alignments with a single '
'target tile using bedtools -f (if alignments consist of multiple PCR tiles).')

parser.add_argument("-r", "--reference", type=str, required=True, help='Corresponding reference FASTA.')

parser.add_argument("-p", "--pos_range", type=str, required=True,
help='Comma-delimited 1-based start and end positions of the amplicon/tile. '
'Reads will be made flush with these coordinates.')

parser.add_argument("-o", "--output_dir", type=str, default=DesignConverter.DEFAULT_OUTDIR,
help='Optional output directory for FASTQs and globally re-aligned BAM. '
'Default current working directory.')

parser.add_argument("-l", "--umi_length", type=int, default=DesignConverter.DEFAULT_UMI_LEN,
help='UMI/barcode length, for addition to 5\' end of each read in dms_tools2 conversion.')

parser.add_argument("-n", "--no_umis", action="store_true",
help='Do not append UMIs to the 5\' end of reads. Use for conversion to Enrich2 format.')

parser.add_argument("-j", "--nthreads", type=int, default=DesignConverter.DEFAULT_NTHREADS,
help='Number of threads to use for BAM sorting operations. Default %i, autodetect.'
% DesignConverter.DEFAULT_NTHREADS)

parsed_args = vars(parser.parse_args(args))
return parsed_args


def workflow(in_bam, ref, pos_range, umi_len=DesignConverter.DEFAULT_UMI_LEN, no_umis=DesignConverter.DEFAULT_NO_UMI,
outdir=DesignConverter.DEFAULT_OUTDIR, nthreads=DesignConverter.DEFAULT_NTHREADS):
"""Runs the dms_tools2/Enrich2 conversion workflow.
:param str in_bam: input alignments for a single tile
:param str ref: reference FASTA
:param str pos_range: 1-based positions flush with codons spanning the target
:param int umi_len: length of randomer UMI. Default 8.
:param bool no_umis: do not add UMIs, only make reads flush with the pos_range. Default False
:param str outdir: output directory. Default current directory.
:param int nthreads: Number of threads to use for BAM operations. Default 0 (autodetect).
"""

zipped_r1_fastq, zipped_r2_fastq = DesignConverter(
in_bam=in_bam, ref=ref, pos_range=pos_range, umi_len=umi_len, no_umis=no_umis,
outdir=outdir, nthreads=nthreads).workflow()

return zipped_r1_fastq, zipped_r2_fastq


def main():
"""Runs the workflow when called from command line."""

parsed_args = parse_commandline_params(sys.argv[1:])

outdir = parsed_args["output_dir"]
if not os.path.exists(outdir):
os.mkdir(outdir)

log_handler = logging.FileHandler(os.path.join(outdir, LOGFILE))
log_handler.setFormatter(LOG_FORMATTER)
logger.addHandler(log_handler)

logger.info("Started %s" % sys.argv[0])

workflow(in_bam=parsed_args["in_bam"], ref=parsed_args["reference"], pos_range=parsed_args["pos_range"],
umi_len=parsed_args["umi_length"], no_umis=parsed_args["no_umis"],
outdir=parsed_args["output_dir"], nthreads=parsed_args["nthreads"])

logger.info("Completed %s" % sys.argv[0])


if __name__ == "__main__":
main()

2 changes: 1 addition & 1 deletion src/satmut_utils/satmut_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
__author__ = "Ian Hoskins"
__credits__ = ["Ian Hoskins"]
__license__ = "GPLv3"
__version__ = "1.0.2-dev"
__version__ = "1.0.3-dev"
__maintainer__ = "Ian Hoskins"
__email__ = "[email protected]"
__status__ = "Development"
Expand Down

0 comments on commit a0ecc54

Please sign in to comment.