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

Add must_open() #708

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Changes from all 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: 3 additions & 3 deletions jcvi/formats/fasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand Down
Loading