Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

Commit

Permalink
Add non-IUPAC filter to FASTA quickcheck (#16)
Browse files Browse the repository at this point in the history
Boot out FASTA files with spurious characters (such as `-`, `?` and other garbage), finally putting DIPI#38 (COG-UK/dipi-group#38) to rest.
  • Loading branch information
BioWilko authored Jan 5, 2022
1 parent 642fae8 commit 4828e44
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bin/elan_fastacheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def readfq(fp): # this is a generator function
if last: # reach EOF before reading enough quality
yield name, seq, None # yield a fasta record instead
break

iupac_chars = set("ACGTRYKMSWBDHVN")

if len(sys.argv) != 3:
sys.exit(1)
Expand All @@ -50,6 +52,8 @@ def readfq(fp): # this is a generator function
sys.exit(1)
if not seq:
sys.exit(2)
if any(base.upper() not in iupac_chars for base in seq):
sys.exit(65)
if len(seq) < min_len:
sys.exit(3)
fasta_fh.close()

0 comments on commit 4828e44

Please sign in to comment.