Beispiel #1
0
##########################
# Main
##########################

if __name__=='__main__':

	# assign options to variables
	input_folder=opts.inp
	output_folder=opts.out
	bord_thr=opts.bord_thr
	hit_thr=opts.hit_thr
	id_perc_thr=opts.id_perc_thr
	############################
	input_folder,output_folder=check_path(input_folder),check_path(output_folder)
	# clean input/output folders
	inp_proc.clean_folder(input_folder,'') # keep only file ending with TAG from input_folder
	inp_proc.clean_folder(output_folder,'') # keep only file ending with TAG from output_folder
	inp_proc.tag_all(input_folder, '.inp') # add .inp tag to all files in input_folder
	inp_proc.inp_rename_len(input_folder,'.inp') # rename all .inp files in input
	# make all_fasta file from .inp files
	all_fasta,fastas=make_all(input_folder,input_folder+'all_fasta','.inp') 
	print 'creating allfasta db file...', all_fasta
	#time.sleep(5)
	bcl.format_db(all_fasta) # fai il db di allfasta per il BLAST 
	networks={}
	for fasta in fastas: # per ogni file di input...
		#Instazia oggetto Draft + BLASTall
		out=fasta[:-6]+'_blast_out'
		draft=Draft(fasta)
		draft.build()
		bcl.launch_BLAST(fasta,all_fasta,out)
	sys.exit()


def check_path(path):
	if path[-1]=='/': return path
	return path+'/'

##########################################


#process folders and instanciate networks
input_folder=opts.inp
output_folder=opts.out
input_folder,output_folder=check_path(input_folder),check_path(output_folder)
to_parse='blastall_out'
inp_proc.clean_folder(input_folder)
inp_proc.clean_folder(output_folder,'')
inp_proc.inp_rename(input_folder)
print "\ninput processing finshed... now instanciating network objects"
nets={}
for name,draft in inp_proc.instanciate_drafts(input_folder).iteritems():
	nets[name]=Homology.Net(draft)

#Homology part
print "\nnow starting Homology part"
for net in nets:
	blast_all=bcl.BLAST_make(input_folder)
	db=blast_all.all_fasta()
	print 'blasting %s on db %s.... producing %s as output' %(nets[net].fasta,db,nets[net].blast_out)
	blast_all.make(db,nets[net].fasta,nets[net].blast_out)