#!/usr/bin/env python2
#
# Copyright John Reid 2010, 2012, 2013
#

"""
Code that reads in sequences from a FASTA file and outputs the non-empty ones.
"""


import sys
import corebio.seq_io.fasta_io as F
import corebio.seq
import bioinfutils


#
# Check args
#
if 2 != len(sys.argv):
    print >> sys.stderr, 'USAGE: %s <fasta file>' % sys.argv[0]
    sys.exit(-1)
input = bioinfutils.open_input(sys.argv[1])

#
# Read the sequences
#
alphabet = corebio.seq.reduced_nucleic_alphabet
for i, seq in enumerate(F.iterseq(input, alphabet)):
    if len(seq):
        F.writeseq(sys.stdout, seq)
