Exemplo n.º 1
0
def main():
	os.chdir(wdir)
	file_list = glob.glob(os.path.join(wdir,'cluster_NSR','*.fasta'))
	save=open('all.fasta','w')
	for file1 in file_list:
		fasta = trile.read_fasta(file1)
		for head in fasta.keys():
			save.write('>'+head+'\n')
			save.write(fasta.get(head)+'\n')
	save.close()

	file1 = 'all.fasta'
	name = 'all'
        cmd = uclust+' --sort '+file1
        cmd+= ' --output '+file1+'.tmp'
        os.system(cmd)

        cmd = uclust+' --input '+file1+'.tmp'
        cmd+= ' --uc '+name+'.uc'
        os.system(cmd)

        cmd = uclust+' --input '+name+'.fasta --uc2fasta '
        cmd+= name+'.uc --output '
        cmd+= name+'.fasta.tmp2'
        os.system(cmd)
        os.system('mv '+name+'.fasta.tmp2 '+name+'.fasta')
        os.system('rm '+name+'.uc '+name+'.fasta.tmp')
Exemplo n.º 2
0
def main():
	try:
		os.mkdir(os.path.join(wdir,'cluster_NSR'))
	except:
		pass
	os.chdir(os.path.join(wdir,'cluster_NSR'))
	file_list = glob.glob(os.path.join(wdir,'format_NSR','*.fasta'))
	for file1 in file_list:
		name = os.path.basename(file1).split('.fasta')[0]
		cmd = uclust+' --sort '+file1
		cmd+= ' --output '+os.path.basename(file1)
		os.system(cmd)

		cmd = uclust+' --input '+os.path.basename(file1)
		cmd+= ' --uc '+name+'.uc'
		os.system(cmd)

		cmd = uclust+' --input '+name+'.fasta --uc2fasta '
		cmd+= name+'.uc --types S --output '
		cmd+= name+'.fasta.tmp'
		os.system(cmd)
		os.system('mv '+name+'.fasta.tmp '+name+'.fasta')
		os.system('rm '+name+'.uc')
		
                fasta = trile.read_fasta(name+'.fasta')
                save = open(name+'.fasta','w')
                count = 0
                for head in fasta.keys():
                        count+=1
                        save.write('>'+name+'.'+str(count)+'\n')
                        save.write(fasta.get(head)+'\n')
                save.close()
Exemplo n.º 3
0
def main():
	try:
		os.mkdir(os.path.join(wdir,'format_NSR'))
	except:
		pass
	file_list = glob.glob(os.path.join(wdir,'NSR','*.fasta'))
	for file1 in file_list:
		name = os.path.basename(file1).split('.fasta')[0]
		fasta = trile.read_fasta(file1)
		save = open(os.path.join(wdir,'format_NSR',name+'.fasta'),'w')
		count = 0
		for head in fasta.keys():
			count+=1
			save.write('>'+name+'.'+str(count)+'\n')
			save.write(fasta.get(head)+'\n')
		save.close()
Exemplo n.º 4
0
def main():
	os.chdir(wdir)
	save = open('epidemic.fasta','w')
	read = open('heatmap.tsv')
	head = next(read).split()
	seq_dict = trile.read_fasta('all.fasta')
	bool_dict = dict()
	for line in read:
		col = line.split()
		name = col[0]
		col = col[1:]
		for i in range(len(col)):
			if float(col[i])>20.0:
				if head[i] not in bool_dict.keys():
					bool_dict[head[i]]=name
				else:
					bool_dict[head[i]]+='.'+name
	count = 1
	for key in bool_dict.keys():
		val = bool_dict.get(key)
		if val.count('O')==7 and 'N' not in val:
			save.write('>E'+str(count)+'\n')
			save.write(seq_dict.get(key)+'\n')
			count+=1