From a280f7fc2ab92fdebe51e78d6030bffd94d6e893 Mon Sep 17 00:00:00 2001 From: Tong-Chen Date: Wed, 27 Sep 2023 09:55:46 +0800 Subject: [PATCH 1/2] add ignore zero anchor parameter for skip no matches in batch search --- jcvi/compara/catalog.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/jcvi/compara/catalog.py b/jcvi/compara/catalog.py index 80488cc2..eb8e4749 100644 --- a/jcvi/compara/catalog.py +++ b/jcvi/compara/catalog.py @@ -666,6 +666,12 @@ def ortholog(args): dotplot_group.add_option( "--no_dotplot", default=False, action="store_true", help="Do not make dotplot" ) + p.add_option( + "--ignore_zero_anchor", + default=False, + action="store_true", + help="Ignore this pair of ortholog identification instead of throwing an error when performing many pairs of cataloging." + ) opts, args = p.parse_args(args) @@ -674,6 +680,7 @@ def ortholog(args): a, b = args dbtype = opts.dbtype + ignore_zero_anchor = opts.ignore_zero_anchor suffix = ".cds" if dbtype == "nucl" else ".pep" abed, afasta = a + ".bed", a + suffix bbed, bfasta = b + ".bed", b + suffix @@ -727,7 +734,15 @@ def ortholog(args): dargs += ["--no_strip_names"] if opts.liftover_dist: dargs += ["--liftover_dist={}".format(opts.liftover_dist)] - scan(dargs) + try: + scan(dargs) + except ValueError as e: + if ignore_zero_anchor: + logging.debug(f"{e}") + logging.debug("Ignoring this error and continuing...") + return + else: + raise ValueError(e) if quota: quota_main([lifted_anchors, "--quota={0}".format(quota), "--screen"]) if need_update(anchors, pdf, warn=True) and not opts.no_dotplot: From 1e1fbd21b61d92f4e811440daed3d455817ff27b Mon Sep 17 00:00:00 2001 From: Tong-Chen Date: Sat, 18 Nov 2023 22:18:43 +0800 Subject: [PATCH 2/2] ignore blank line in bed --- jcvi/formats/bed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jcvi/formats/bed.py b/jcvi/formats/bed.py index df791837..c80ee54c 100755 --- a/jcvi/formats/bed.py +++ b/jcvi/formats/bed.py @@ -151,7 +151,7 @@ def __init__(self, filename=None, key=None, sorted=True, juncs=False, include=No return for line in must_open(filename): - if line[0] == "#" or (juncs and line.startswith("track name")): + if line[0] == "#" or (juncs and line.startswith("track name")) or line.strip()=="": continue b = BedLine(line) if include and b.accn not in include: