#!/usr/bin/env python

#use: fasta_size_filter.py <fasta> <fasta_out>

import sys
from Bio import SeqIO

myFASTA = open(sys.argv[1], 'rU')
output = open(sys.argv[2], 'w')
for record in SeqIO.parse(myFASTA, "fasta") :
    i=0
    errors=0
    while i < len(record.seq) :
        if str(record.seq[i]) == "X":
            errors=1
        if str(record.seq[i]) == "Z":
            errors=1
        if str(record.seq[i]) == "*":
            errors=1
        i+=1
    if errors==0 :
        SeqIO.write(record,output,"fasta")

myFASTA.close()
