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

filter-bam into filter-file #138

Merged
merged 6 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 5 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ The format is based on
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.10.4] - 2025-1-2

### Changed
- Changed filter-bam function into filter-file; Now accepts BED and CRAM in addition to BAM
- filter-file command can now accept a blacklist file

## [0.10.3] - 2024-12-21

### Fixed
Expand Down
50 changes: 28 additions & 22 deletions src/finaletoolkit/cli/main_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,72 +848,78 @@ def main_cli_parser():
help='Number of header rows to ignore. Default is 0')
cli_interval_mds.set_defaults(module='finaletoolkit.frag._end_motifs', func='_cli_interval_mds')

# filter-bam
cli_filter_bam = subparsers.add_parser(
'filter-bam',
prog='finaletoolkit-filter-bam',
description='Filters a BAM file so that all reads are in mapped pairs,'
' exceed a certain MAPQ, are not flagged for quality, are read1, are '
'not secondary or supplementary alignments, and are on the same '
'reference sequence as the mate.')
cli_filter_bam.add_argument(
# filter-file
cli_filter_file = subparsers.add_parser(
'filter-file',
prog='finaletoolkit-filter-file',
description='Filters a BED/BAM/CRAM file so that all reads/intervals, when applicable,'
'are in mapped pairs, exceed a certain MAPQ, are not flagged for quality, are read1, are '
'not secondary or supplementary alignments, are within/excluding specified intervals, '
'and are on the same reference sequence as the mate.')
cli_filter_file.add_argument(
'input_file',
help='Path to BAM file.')
cli_filter_bam.add_argument(
'-r',
'--region-file',
cli_filter_file.add_argument(
'-W',
'--whitelist-file',
default=None,
help='Only output alignments overlapping the intervals in this BED '
'file will be included.')
cli_filter_bam.add_argument(
cli_filter_file.add_argument(
'-B',
'--blacklist-file',
default=None,
help='Only output alignments outside of the intervals in this BED '
'file will be included.')
cli_filter_file.add_argument(
'-o',
'--output-file',
default='-',
help='Output BAM file path.')
cli_filter_bam.add_argument(
help='Output BED/BAM/CRAM file path.')
cli_filter_file.add_argument(
'-q',
'--quality-threshold',
type=int,
default=30,
help='Minimum mapping quality threshold.')
cli_filter_bam.add_argument(
cli_filter_file.add_argument(
'-min',
'--min-length',
default=None,
type=int,
help='Minimum length for a fragment to be included.'
)
cli_filter_bam.add_argument(
cli_filter_file.add_argument(
'-max',
'--max-length',
default=None,
type=int,
help='Maximum length for a fragment to be included.'
)
cli_filter_bam.add_argument(
cli_filter_file.add_argument(
'-lo',
'--fraction-low',
type=int,
dest='min_length',
help='Deprecated alias for --min-length')
cli_filter_bam.add_argument(
cli_filter_file.add_argument(
'-hi',
'--fraction-high',
type=int,
dest='max_length',
help='Deprecated alias for --max-length')
cli_filter_bam.add_argument(
cli_filter_file.add_argument(
'-w',
'--workers',
type=int,
default=1,
help='Number of worker processes.')
cli_filter_bam.add_argument(
cli_filter_file.add_argument(
'-v',
'--verbose',
action='count',
help='Enable verbose mode to display detailed processing information.')
cli_filter_bam.set_defaults(module='finaletoolkit.utils', func='filter_bam')
cli_filter_file.set_defaults(module='finaletoolkit.utils', func='filter_file')

# agg-bw
cli_agg_bw = subparsers.add_parser(
Expand Down
2 changes: 1 addition & 1 deletion src/finaletoolkit/frag/_frag_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def frag_length_intervals(
output_file : str, optional
quality_threshold : int, optional
workers : int, optional
verbose : boo or int, optional
verbose : bool or int, optional

Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion src/finaletoolkit/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from finaletoolkit.utils.utils import *
from finaletoolkit.utils._filter_bam import filter_bam
from finaletoolkit.utils._filter_file import filter_file
from finaletoolkit.utils._agg_bw import agg_bw
127 changes: 0 additions & 127 deletions src/finaletoolkit/utils/_filter_bam.py

This file was deleted.

Loading
Loading