我正在尝试在Biopython中从Clustalw多序列比对中生成一个位置加权矩阵(PWM)。每次使用间隔对齐时,我都会收到“错误的字母表”错误。通过阅读文档,我认为我需要利用deal来处理deal对齐中的'-‘字符。但是当我这样做的时候,它仍然不能解决错误。有没有人看到这段代码的问题,或者有更好的方法从有间隙的Clustal对齐生成PWM?
from Bio.Alphabet import Gapped
alignment = AlignIO.read("filename.clustalw", "clustal", alphabet=Gapped)
m = Motif.Motif()
for a in alignment:
m.add_instance(a.seq)
m.pwm()发布于 2012-10-09 13:28:54
所以你想用clustal来做这些有缝隙的排列?我用的是Perl,我看你用的是Python,但逻辑基本上是一样的。我使用对clustal可执行文件的系统调用,而不是使用BioPerl/Biopython。我相信clustalw2可执行文件无需调用字母表即可处理间隔对齐。不是百分之百确定,但这是我使用的脚本,它对我有效。创建一个包含所有对齐文件的目录(我使用的是.fasta,但您可以更改系统调用中的标志以接受其他文件)。这是我的Perl脚本,您必须修改最后一行中的可执行路径以匹配clustal在您计算机上的位置。希望这能对你有所帮助。作为附注,这对于快速进行许多对齐非常有用,这就是我使用它的目的,但如果您只想对齐几个文件,则可能希望跳过创建目录的整个过程,并修改代码以接受文件路径而不是目录路径。
#!/usr/bin/perl
use warnings;
print "Please type the list file name of protein fasta files to align (end the directory path with a / or this will fail!): ";
$directory = <STDIN>;
chomp $directory;
opendir (DIR,$directory) or die $!;
my @file = readdir DIR;
closedir DIR;
my $add="_align.fasta";
foreach $file (@file) {
my $infile = "$directory$file";
(my $fileprefix = $infile) =~ s/\.[^.]+$//;
my $outfile="$fileprefix$add";
system "/Users/Wes/Desktop/eggNOG_files/clustalw-2.1-macosx/clustalw2 -INFILE=$infile -OUTFILE=$outfile -OUTPUT=FASTA -tree";
}干杯,韦斯
https://stackoverflow.com/questions/6998727
复制相似问题