1

这里对 Perl 完全陌生。无论如何,我被分配了一项任务,我在网上找到了一个 perl 模块,它完全符合我的要求。

矩阵

文档

这是 perl 模块的文档——在 Ext 下有一个叫做 pwmsearch 的文档,它完全符合我的需要。

所以我试着写一个脚本,开始是这样的:

#!/usr/bin/env perl -w

use strict; 
use TFBS::Ext::pwmsearch; #this was how the documentation said in synopsis part for pwmsearch so I figured this was how to do it

问题是我无法弄清楚我应该如何将对象传递给 pwmsearch。上面文档中显示的 pwmsearch 的源代码说它需要 $matrixobj 和 $seqobj,我已经将它们存储为文件矩阵和序列。

因此,在搜索了我可以尝试的内容之后,我尝试了以下操作:

pwmsearch('matrix','sequence'); 

或者

open FILE, 'matrix.txt' or die "Couldn't open file";
$matrix.=<FILE>
close FILE;

open FILE, 'sequence' or die "Couldn't open file";
$seq.=<FILE>
close FILE;
pwmsearch($matrix,$seq)

但是所有这些都使 perl 以各种错误对我咆哮。我做错了什么,我能做些什么来解决它们?

4

1 回答 1

1

以下是如何生成 pwm 矩阵对象的文档:http ://tfbs.genereg.net/DOC/TFBS​​/Matrix/PWM.html

use TFBS::Matrix::PWM;
my $matrixstring = <<ENDMATRIX
 0.61 -3.16  1.83 -3.16  1.21 -0.06
-0.15 -2.57 -3.16 -3.16 -2.57 -1.83
-1.57  1.85 -2.57 -1.34 -1.57  1.14
 0.31 -3.16 -2.57  1.76  0.24 -0.83
ENDMATRIX;
my $pwm_matrix_in = TFBS::Matrix::PWM->new(-matrixstring => $matrixstring,
                 -name         => "MyProfile",
                 -ID           => "M0001"
                );

PWMSearch 文档:http ://tfbs.genereg.net/DOC/Ext/pwmsearch.html

它需要五个输入变量:$matrixobj、$seqobj、$threshold、$start、$end,如果我没看错,最后 3 个是可选的。

seqobj 很可能是 Bio::Seq 兼容对象。从文件创建一个新对象:文档: http://metacpan.org/pod/Bio:: SeqIO

use Bio::SeqIO;
my $seqobj_in  = Bio::SeqIO->new(-file => "inputfilename" ,
                           -format => 'Fasta');


use strict; 
use TFBS::Ext::pwmsearch;
TFBS::Ext::pwmsearch::pwmsearch($pwm_matrix_in,$seqobj_in);

我希望这可以帮助你。

于 2012-10-04T08:34:25.827 回答