[BioPython] do_alignment

biter bilen biterbilen@yahoo.com
Tue, 27 Aug 2002 01:33:52 -0700 (PDT)


--0-1010516694-1030437232=:94753
Content-Type: text/plain; charset=us-ascii


sorry for this mail to clog your mailboxes.  
 biter bilen wrote: 
hi to everyone.

my aim for learning python is its bio libraries. i use windows. i want to run clustalw (a multiple alignment program) within it. it requires the clustalx program to be downloaded (it is said so in the python help documents). i downloaded it. the program is as in the attacments.

 



---------------------------------
Do You Yahoo!?
Yahoo! Health - Feel better, live better# !/usr/bin/env python
"""clustal_run.py

Example code to show how to create a clustalw command line, run clustalw
and parse the results into an object that can be dealt with easily."""
# standard library
import os

# biopython
from Bio.Alphabet import IUPAC
from Bio import Clustalw
from Bio.Clustalw import MultipleAlignCL
from Bio.Align import AlignInfo
from Bio.SubsMat import FreqTable

# create the command line to run clustalw
# this assumes you've got clustalw somewhere on your path, otherwise
# you need to pass a second argument to MultipleAlignCL with the complete
# path to clustalw
cline = MultipleAlignCL(os.path.join(os.curdir, 'opuntia.fasta'))
cline.set_output('test.aln')

# actually perform the alignment and get back an alignment object
alignment = Clustalw.do_alignment(cline)

# get the records in the alignment
all_records = alignment.get_all_seqs()

print 'description:', all_records[0].description
print 'sequence:', all_records[0].seq

# get the length of the alignment
print 'length', alignment.get_alignment_length()

print alignment

# print out interesting information about the alignment
summary_align = AlignInfo.SummaryInfo(alignment)

consensus = summary_align.dumb_consensus()
print 'consensus', consensus

my_pssm = summary_align.pos_specific_score_matrix(consensus,
chars_to_ignore = ['N'])

print my_pssm

expect_freq = {
'A' : .3,
'G' : .2,
'T' : .3,
'C' : .2}

freq_table_info = FreqTable.FreqTable(expect_freq, FreqTable.FREQ,
IUPAC.unambiguous_dna)

info_content = summary_align.information_content(5, 30,
chars_to_ignore = ['N'],
e_freq_table = \
freq_table_info)

print "relative info content:", info_content




---------------------------------
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
--0-1010516694-1030437232=:94753
Content-Type: text/html; charset=us-ascii

<P>sorry for this mail to clog your mailboxes.&nbsp; 
<P>&nbsp;<B><I>biter bilen <BITERBILEN@YAHOO.COM></I></B>wrote: 
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">
<P>hi to everyone.</P>
<P>my aim for learning python is its bio libraries.&nbsp;i use windows. i want to run clustalw (a multiple alignment program) within it. it requires the clustalx program to be downloaded (it is said so in the python help documents).&nbsp;i downloaded it. the program is as in the attacments.</P>
<P>&nbsp;</P>
<P><BR>
<HR SIZE=1>
<B>Do You Yahoo!?</B><BR><A href="http://health.yahoo.com/">Yahoo! Health</A> - Feel better, live better# !/usr/bin/env python<BR>"""clustal_run.py<BR><BR>Example code to show how to create a clustalw command line, run clustalw<BR>and parse the results into an object that can be dealt with easily."""<BR># standard library<BR>import os<BR><BR># biopython<BR>from Bio.Alphabet import IUPAC<BR>from Bio import Clustalw<BR>from Bio.Clustalw import MultipleAlignCL<BR>from Bio.Align import AlignInfo<BR>from Bio.SubsMat import FreqTable<BR><BR># create the command line to run clustalw<BR># this assumes you've got clustalw somewhere on your path, otherwise<BR># you need to pass a second argument to MultipleAlignCL with the complete<BR># path to clustalw<BR>cline = MultipleAlignCL(os.path.join(os.curdir, 'opuntia.fasta'))<BR>cline.set_output('test.aln')<BR><BR># actually perform the alignment and get back an alignment object<BR>alignment = Clustalw.do_alignment(cline)<BR><BR># get the records in the alignment<BR>all_records = alignment.get_all_seqs()<BR><BR>print 'description:', all_records[0].description<BR>print 'sequence:', all_records[0].seq<BR><BR># get the length of the alignment<BR>print 'length', alignment.get_alignment_length()<BR><BR>print alignment<BR><BR># print out interesting information about the alignment<BR>summary_align = AlignInfo.SummaryInfo(alignment)<BR><BR>consensus = summary_align.dumb_consensus()<BR>print 'consensus', consensus<BR><BR>my_pssm = summary_align.pos_specific_score_matrix(consensus,<BR>chars_to_ignore = ['N'])<BR><BR>print my_pssm<BR><BR>expect_freq = {<BR>'A' : .3,<BR>'G' : .2,<BR>'T' : .3,<BR>'C' : .2}<BR><BR>freq_table_info = FreqTable.FreqTable(expect_freq, FreqTable.FREQ,<BR>IUPAC.unambiguous_dna)<BR><BR>info_content = summary_align.information_content(5, 30,<BR>chars_to_ignore = ['N'],<BR>e_freq_table = \<BR>freq_table_info)<BR><BR>print "relative info content:", info_content<BR><BR></BLOCKQUOTE><p><br><hr size=1><b>Do You Yahoo!?</b><br>
<a href="http://rd.yahoo.com/finance/mailsig/new/*http://finance.yahoo.com">Yahoo! Finance</a> - Get real-time stock quotes
--0-1010516694-1030437232=:94753--