#!/usr/bin/env python
#coding:utf-8
# Author:  LPP --<lpp1985@hotmail.com>
# Purpose: 
# Created: 2011/5/22
from lpp import *
from optparse import OptionParser
import subprocess
import multiprocessing
usage = '''usage: python2.7 %prog -a [ACE_file] -o [OUTPUT] -t [ Threshold  ]'''
parser = OptionParser(usage =usage ) 


parser.add_option("-o", "--output", action="store", 
	dest="have", 
	default = 'have',
	help="The PREFIX you want for Ok  FILE !!!!")

parser.add_option("-l", "--left", action="store", 
	dest="left", 
	default = 'left',
	help="The PREFIX you want for Left  FILE !!!!")

parser.add_option("-t", "--top1", action="store", 
	dest="top", 

	help="The Top1 File generated by Blast_parse !!!!")



parser.add_option("-f", "--fasta", action="store", 
	
	dest="fasta", 
    
	
	help="the fasta file for assembly!!!")


(options, args) = parser.parse_args() 
have = options.have
left = options.left
top = options.top

fasta = options.fasta


LEFT = open( left,'w')

HAVE = open( have,'w' )
all_top = File_dict(  open( top   ) ).read(3,1)

ALL_FASTA = fasta_check( open( fasta  )    )
for t,s in ALL_FASTA:
	if t[1:-1] in all_top:
		HAVE.write( t+s )
	else:
		LEFT.write( t+s )
		

