#!/usr/local/bin/python

'''
Created on 16 aout 2012

@author: merciece

>>>> Example : [convertEcoPCRDB --fasta-output /Documents/my_ecoPCR_database > output.fasta]
'''

from obitools.options import getOptionManager
from obitools.format.options import addOutputFormatOption, sequenceWriterGenerator
from obitools.ecopcr.sequence import EcoPCRDBSequenceIterator
from obitools.fasta import formatFasta

import sys

if __name__ == '__main__':
    try:
        import psyco
        psyco.full()
    except ImportError:
        pass
    
    optionParser = getOptionManager([addOutputFormatOption], progdoc=__doc__)   
    
    (options,entries) = optionParser()
    
    db_read = 0

    options.outputFormater=formatFasta()
    options.outputFormat="fasta"
    
    for arg in sys.argv :
        if arg[0] != "-" & db_read == 0 : 
            i = EcoPCRDBSequenceIterator(arg)
            db_read = 1
            
    writer = sequenceWriterGenerator(options)
    
    for seq in i :
        writer(seq)