diff --git a/bean/annotate/utils.py b/bean/annotate/utils.py index e6cca3e..f7d5944 100755 --- a/bean/annotate/utils.py +++ b/bean/annotate/utils.py @@ -297,13 +297,13 @@ def parse_args(parser=None): parser.add_argument( "--reporter-length", type=int, - default=32, + default=None, help="Length of reporter sequence in the construct.", ) parser.add_argument( "--reporter-right-flank-length", type=int, - default=6, + default=None, help="Length of the right-flanking nucleotides of protospacer in the reporter.", ) parser.add_argument( diff --git a/bean/cli/filter.py b/bean/cli/filter.py index 66d63de..46e5852 100755 --- a/bean/cli/filter.py +++ b/bean/cli/filter.py @@ -43,6 +43,18 @@ def main(args): args = check_args(args) if not args.load_tmp: bdata = be.read_h5ad(args.bdata_path) + if args.reporter_length is None: + if "reporter_length" in bdata.uns: + args.reporter_length = bdata.uns["reporter_length"] + else: + args.reporter_length = 32 + if args.reporter_right_flank_length is None: + if "reporter_right_flank_length" in bdata.uns: + args.reporter_right_flank_length = bdata.uns[ + "reporter_right_flank_length" + ] + else: + args.reporter_right_flank_length = 6 allele_df_keys = ["allele_counts"] info( f"Starting from .uns['allele_counts'] with {len(bdata.uns['allele_counts'])} alleles." diff --git a/bean/mapping/GuideEditCounter.py b/bean/mapping/GuideEditCounter.py index 43e67c9..5b74c0d 100755 --- a/bean/mapping/GuideEditCounter.py +++ b/bean/mapping/GuideEditCounter.py @@ -112,6 +112,8 @@ def __init__(self, **kwargs): tiling=kwargs["tiling"], ) self.screen.guides["guide_len"] = self.screen.guides.sequence.map(len) + self.screen.uns["reporter_length"] = kwargs["reporter_length"] + self.screen.uns["reporter_right_flank_length"] = kwargs["reporter_length"] - kwargs["gstart_reporter"] - self.screen.guides["guide_len"].max() self.count_guide_edits = kwargs["count_guide_edits"] if self.count_guide_edits: self.screen.uns["guide_edit_counts"] = {} diff --git a/bean/qc/parser.py b/bean/qc/parser.py index 69c4c8e..6946c22 100755 --- a/bean/qc/parser.py +++ b/bean/qc/parser.py @@ -154,13 +154,13 @@ def parse_args(parser=None): parser.add_argument( "--reporter-length", type=int, - default=32, + default=None, help="Length of reporter sequence in the construct.", ) parser.add_argument( "--reporter-right-flank-length", type=int, - default=6, + default=None, help="Length of the right-flanking nucleotides of protospacer in the reporter.", ) return parser diff --git a/bean/qc/utils.py b/bean/qc/utils.py index 7ca4b90..63c2585 100755 --- a/bean/qc/utils.py +++ b/bean/qc/utils.py @@ -61,6 +61,16 @@ def check_args(args): args.base_edit_data = False else: args.base_edit_data = True + if args.reporter_length is None: + if "reporter_length" in bdata.uns: + args.reporter_length = bdata.uns["reporter_length"] + else: + args.reporter_length = 32 + if args.reporter_right_flank_length is None: + if "reporter_right_flank_length" in bdata.uns: + args.reporter_right_flank_length = bdata.uns["reporter_right_flank_length"] + else: + args.reporter_right_flank_length = 6 return args