#!/usr/bin/env python
from Bio import SeqIO
import sys
from sys import argv
#getContigs.py <assemblyfile> <textfile_delimited_by_\n, newline>
scafHandle=open('%s'%argv[2],'r')
outHandle=open("%s.fasta"%argv[2],'w')
genome_handle=open("%s"%argv[1],"r")
scafDict={}
for line in scafHandle:
	scafDict[line.rstrip('\n')]=1
#print scafDict
for seq_record in SeqIO.parse(genome_handle,"fasta"):
	seqlength=len(seq_record.seq)
	ident="%s"%seq_record.id
	if scafDict.has_key(ident):
		outHandle.write(">%s\n%s\n"%(ident,seq_record.seq))
		print "found it!"

		
genome_handle.close()
outHandle.close()
