Thanks both for the comments! If I may ask, am I onto something here?
from Bio import SeqIO
import re,fileinput,os
INPUTDIR = "Users/test"
def main():
for files in os.walk(INPUTDIR):
records = SeqIO.parse(files, 'fasta')
filtered = (rec for rec in records if any(ch != '-' for ch in rec.seq))
with open (files+"stripped.fas", "w") as out:
SeqIO.write(filtered, out, 'fasta')
if __name__=="__main__":
main()
I get this error message:
Traceback (most recent call last):
File "loop_test-remove_empty_fasta.py", line 14, in <module>
main()
File "loop_test-remove_empty_fasta.py", line 10, in main
with open (files+"stripped.fas", "w") as out:
TypeError: can only concatenate tuple (not "str") to tuple