Example #1
0
def align_fasta(fasta_string):
	'''
	Aligns all records from a string containing fasta entries.
	'''
	assert type(fasta_string) is str, 'Error, input must be a string.'
	#add more asserts

	muscle_cline = MuscleCommandline() #instantiate
	stdout, stderr = muscle_cline(stdin=fasta_string) #perform alignment
	aln = fasta.parseString(stdout) #parse output

	#add some assert to make sure the alignment went well

	#prepare for export
	output = []
	for entry in aln:
		output.append((entry[0], entry[1]))
	return output
Example #2
0
def align_fasta(fasta_string):
    '''
	Aligns all records from a string containing fasta entries.
	'''
    assert type(fasta_string) is str, 'Error, input must be a string.'
    #add more asserts

    muscle_cline = MuscleCommandline()  #instantiate
    stdout, stderr = muscle_cline(stdin=fasta_string)  #perform alignment
    aln = fasta.parseString(stdout)  #parse output

    #add some assert to make sure the alignment went well

    #prepare for export
    output = []
    for entry in aln:
        output.append((entry[0], entry[1]))
    return output
Example #3
0
def alignString(string):


	records_handle = StringIO(string) #turn string into a handle
	tempdata = records_handle.getvalue()
	
	#for separate fasta entries
	muscle_cline = MuscleCommandline()
	stdout, stderr = muscle_cline(stdin=tempdata)
	stdout = fasta.parseString(stdout)

#	#for aligned fasta entries
#	muscle_cline = MuscleCommandline(clw=True)
#	stdout, stderr = muscle_cline(stdin=tempdata)
#	print(stdout)
	
#	#the clustalw-type output can be further formated
#	align = AlignIO.read(StringIO(stdout), "clustal")
#	print(align)

	return stdout