Skip to content

Commit

Permalink
Merge pull request #27 from genomewalker/reassign-disable-sort
Browse files Browse the repository at this point in the history
Reassign disable sort
  • Loading branch information
genomewalker authored Apr 30, 2024
2 parents 7798d45 + b78d14d commit 4172412
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 148 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ Full list of options:

```bash
$ filterBAM reassign --help
usage: filterBAM reassign [-h] --bam BAM [-p STR] [-r FILE] [-t INT] [-i INT] [-s FLOAT]
[-A FLOAT] [-l INT] [-n INT] [--match-reward INT]
usage: filterBAM reassign [-h] --bam BAM [-p STR] [-r FILE] [-t INT] [-i INT]
[-s FLOAT] [-A FLOAT] [-l INT] [-n INT] [--match-reward INT]
[--mismatch-penalty INT] [--gap-open-penalty INT]
[--gap-extension-penalty INT] [--lambda FLOAT] [-k FLOAT] [-o [FILE]]
[-m STR] [-N] [--tmp-dir DIR]
[--gap-extension-penalty INT] [--lambda FLOAT] [-k FLOAT]
[-o [FILE]] [-m STR] [-N] [--tmp-dir DIR] [--disable-sort]

optional arguments:
-h, --help show this help message and exit
Expand Down Expand Up @@ -132,10 +132,13 @@ Re-assign optional arguments:
-o [FILE], --out-bam [FILE]
Save a BAM file without multimapping reads (default: None)
-m STR, --sort-memory STR
Set maximum memory per thread for sorting; suffix K/M/G recognized
(default: 1G)
Set maximum memory per thread for sorting; suffix K/M/G
recognized (default: 1G)
-N, --sort-by-name Sort by read names (default: False)
--tmp-dir DIR Temporary directory (default: None)

miscellaneous arguments:
--disable-sort Disable sorting of the filtered BAM file (default: False)
```
Expand Down
9 changes: 9 additions & 0 deletions bam_filter/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def filter_references(args):
mode="filter",
)

sorted_bam = args.bam.replace(".bam", ".bf-sorted.bam")
bam = check_bam_file(
bam=args.bam,
threads=4,
Expand Down Expand Up @@ -256,4 +257,12 @@ def filter_references(args):

if args.low_memory:
os.remove(out_files["bam_tmp_sorted"])
# check if sorted BAM file exists, if yes remove it
if os.path.exists(sorted_bam):
os.remove(sorted_bam)
# check if sorted BAM index file exists, if yes remove it
if os.path.exists(sorted_bam + ".bai"):
os.remove(sorted_bam + ".bai")
elif os.path.exists(sorted_bam + ".csi"):
os.remove(sorted_bam + ".csi")
logging.info("ALL DONE.")
Loading

0 comments on commit 4172412

Please sign in to comment.