From cf68f68becfa018590217b41d67815fa12ed2be3 Mon Sep 17 00:00:00 2001 From: Haibao Tang Date: Fri, 4 Oct 2024 15:56:53 -0700 Subject: [PATCH] Add must_open() --- jcvi/formats/fasta.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jcvi/formats/fasta.py b/jcvi/formats/fasta.py index 3846609c..5ca4a516 100644 --- a/jcvi/formats/fasta.py +++ b/jcvi/formats/fasta.py @@ -1223,7 +1223,7 @@ def summary(args): p.add_argument( "--suffix", default="Mb", help="make the base pair counts human readable" ) - p.add_argument("--ids", help="write the ids that have >= 50% N's") + p.add_argument("--ids", help="write the ids that have >= 50%% N's") p.set_outfile() opts, args = p.parse_args(args) @@ -1239,7 +1239,7 @@ def summary(args): data = [] for fastafile in args: - for rec in SeqIO.parse(fastafile, "fasta"): + for rec in SeqIO.parse(must_open(fastafile), "fasta"): seqlen = len(rec) nns = rec.seq.count("n") + rec.seq.count("N") reals = seqlen - nns @@ -2183,7 +2183,7 @@ def _uniq_rec(fastafile, seq=False): Returns unique records """ seen = set() - for rec in SeqIO.parse(fastafile, "fasta"): + for rec in SeqIO.parse(must_open(fastafile), "fasta"): name = str(rec.seq) if seq else rec.id if name in seen: logger.debug("ignore {0}".format(rec.id))