2011年7月16日星期六

Re: [PerlChina] Perl为何用given ... when ... 而不用switch ... case ... ?

switch ... case {} 这个语法用 if/else 很容易模拟, 所以可能 perl 不想加它们进来?另外 switch ... case 从自然语言角度来说很别扭, 而 given ... when 就和 if ... else 一样, 非常自然, larry wall 是语言学家, 你懂的.(个人猜测) 
perl 5.8 开始, 有 Switch 模块可以实现 switch ... case, 但从 perl 5.10 开始, 就可以用更高级的 given ... when 了.
given ... when 虽然和 C 里面的 switch ... case 很像, 但是它们并不是完全一样的
given ... when 有如下的不同:

1. 匹配的时候使用 smart matching, 会根据数据类型自动调整匹配行为, 比如说你想看给定的值是不是存在于某个数组里面,那么只要这样就行了:
    given($item) {
        when(@array) { say "found it!"; }
        ...
    }

   不需要你针对不同数据类型做不同操作.

2. given ... when 的每个 when 语句块默认是 break 的, 而且其 fall through 策略是不同的, 比如你在 when 语句最后指定了 continue, 它后面的其他 when 的判断语句还是会运行的, 而 switch ... case 不管下面的 case 判断条件是什么, 之而后的语句一律都执行了(除非主动跳出)

3. given ... when 不一定需要成对出现,  when 也可以用于 for 循环中(只在循环变量为默认的 $_ 时有效), 此时每个 when 语句块的结尾默认会 next, 你可以用 continue 让when 后的语句继续执行或者 last 跳出循环

4. given ... when 语句是合法的表达式, 表达式是可以求值的, 因此 given ... when 是有返回值的, 可参看: http://perldoc.perl.org/perlsyn.html#Return-value



2011/7/16 HY@CN <think.hy@gmail.com>
同求答案

在 2011年7月16日 下午9:43,Beckheng Lam <bi.ken.lam@gmail.com>写道:

以上是其一,另一个是为何Perl在这么多年以后,才决定加入这个风格的语句呢?

--
我的博客 -- http://blog.yixinit.com/
诸法从缘起,如来说是因。
彼法因缘尽,是大沙门说。

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。




--
HY_CN


--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: [PerlChina] Perl为何用given ... when ... 而不用switch ... case ... ?

同求答案

在 2011年7月16日 下午9:43,Beckheng Lam <bi.ken.lam@gmail.com>写道:
以上是其一,另一个是为何Perl在这么多年以后,才决定加入这个风格的语句呢?

--
我的博客 -- http://blog.yixinit.com/
诸法从缘起,如来说是因。
彼法因缘尽,是大沙门说。

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。




--
HY_CN

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

[PerlChina] Perl为何用given ... when ... 而不用switch ... case ... ?

以上是其一,另一个是为何Perl在这么多年以后,才决定加入这个风格的语句呢?

--
我的博客 -- http://blog.yixinit.com/
诸法从缘起,如来说是因。
彼法因缘尽,是大沙门说。

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

2011年7月15日星期五

[PerlChina] Re: 模块PDL::Graphics::PGPLOT 报告 undefined subroutine pgqinf

又到cpan看了一下,原来是没有安装pgplot造成的,安装后问题解决了。。

On Jul 13, 6:44 pm, Lolo Liu <imlyc.m...@gmail.com> wrote:
> 我通过
> perl -MCPAN -e shell
> install PDL
> 安装的这个模块,期间报了很多函数未定义的警告。
> 我按照官网上demo写的程序,报告了这个错误:
> undefined subroutine &PDL::Graphics::PGPLOT::pgqinf at ...
> 后来在/usr/lib/perl5的文件夹下找了一下,没有发现这个函数。CPAN和官网上都没有说有什么dependence,这是什么情况。。

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: [PerlChina] Re: DNA,DG值。

谢谢各位哈,总算找到办法了,虽然最终发现是个NPC问题。

另外,请问各位有谁做RNA结构预测相关的事情?

2011/7/15 朱岩 <riyeyan@gmail.com>
不好意思,index搞错了,下面是修改版,用的Jie Liu的矩阵,
得到结果(index从0开始):
0 1 3
0 1 4
0 2 4
2 4 7
4 7 9
好像vertex number不能取10以上(包括10)...看看能不能根据作者的算法重写吧


use strict;
use Graph::Clique;



my @edges;
my %h;
my $nnz;  # num of non-zeros


# build up undirected graph
open F, 'matrix_small.txt' or die;
while(<F>){
my $i = $.-1; 
my @a = split(/ /,$_);
for my $j (0..$#a){
if ($a[$j] == 1){
$nnz++;
my $e = $i <= $j ? $i.",".$j : $j.",".$i;
$h{$e}++;
}
}
}
close F;


foreach my $key (sort keys %h){
my @a = split(/\,/, $key);
push @edges, [@a];
}



# find maximal clique

my @cliques;

for (my $k=int(sqrt($nnz)); $k>0; $k--){
@cliques = getcliques($k,\@edges);
if ($#cliques >=0){ last; }
}

print join("\n", @cliques),"\n";



在 2011年7月14日 下午11:16,nixin <nicene714@gmail.com>写道:

google到的matlab的maximal cliques程序:
http://www.mathworks.com/matlabcentral/fileexchange/19889-maximal-cliques


On Jul 14, 9:27 pm, jie liu <liujie....@gmail.com> wrote:
> 附件忘加了,在这个邮件里
>
> 2011/7/14 jie liu <liujie....@gmail.com>
>
>
>
>
>
>
>
>
>
>
>
> > 朱岩,出了一些状况. 我造了一个  无向图 的矩阵数据。
> > ------------data----------------
> > 0 0 0 0 0 0 0 0 0 0
> > 1 0 0 0 0 0 0 0 0 0
> > 1 0 0 0 0 0 0 0 0 0
> > 1 1 0 0 0 0 0 0 0 0
> > 1 1 1 0 0 0 0 0 0 0
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 1 0 1 0 0 0 0 0
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 0 0 1 0 0 1 0 0
> > --------------------
> > 我用matlab可视化了这个graph,请见附件。
>
> > 之后我用你的程序(我把K值改成了K>1)处理这个矩阵,显示的结果是:2,6,9这个节点。这与附件的图矛盾啊,2,6,9实际不是完全连通图啊。怎么回事? 我先把结果反馈给大家,同时我也想想
>
> > ------------ perl script--------------------
>
> > use strict;
> > use Graph::Clique;
>
> > my @edges;
> > my %h;
> > my $nnz;       # num of non-zeros
>
> > # build up undirected graph
> > open FASTA, "<@ARGV";
> > while (<FASTA>) {
> > my $i = $. + 1;
> >  my @a = split( / /, $_ );
> > for my $j ( 0 .. $#a ) {
> > if ( $a[$j] ) {
> >  $nnz++;
> > my $e = $i <= $j ? $i . "," . $j : $j . "," . $i;
> >  $h{$e}++;
> > }
> > }
> > }
>
> > foreach my $key ( sort keys %h ) {
> > my @a = split( /\,/, $key );
> > push @edges, [@a];
> > }
>
> > # find maximal clique
>
> > my @cliques;
>
> > for ( my $k = int( sqrt($nnz) ) ; $k > 1 ; $k-- ) {
> >  @cliques = getcliques( $k, \@edges );
> > if ( $#cliques >= 0 ) {
> > last;
> >  }
> > }
>
> > print join( "\n", @cliques ), "\n";
>
> > ------------end--------------------------------
> > 2011/7/14 朱岩 <riye...@gmail.com>
>
> >> 读文件把while(<DATA>)换成while(<F>)就可以了
>
> >> 在 2011年7月14日 下午4:02,jie liu <liujie....@gmail.com>写道:
>
> >>> 我刚刚也看到了,还去了作者给的一个地址(http://home.hiwaay.net/~gbacon/perl/clique.html
> >>> )看来一下,很激动!就是我要找的,谢谢大家了哈。
>
> >>> 但是,我都perl不熟,现在我把矩阵存在txt里了(1代表有边,0代表无边),我怎么把矩阵读进去,然后形成graph,然后用clique呢...朱岩的 程序我使了下,没成功。朱岩的程序里我没有看到读入的操作啊(实在是对perl不熟悉...)
>
> >>> 2011/7/14 nixin <nicene...@gmail.com>
>
> >>>> 果然有现成的库。clique这个关键词没有掌握,搜了好一会全连通图,啥也没搜到。呵呵。
>
> >>>> On 7月14日, 下午1时28分, 朱岩 <riye...@gmail.com> wrote:
> >>>> > 图论解法:
>
> >>>> > 找最大完全连通子图,可以用Graph::Clique,当然应该还有更好的算法;
> >>>> > 这里只举了个10x10的小例子
> >>>> > 用非零数的平方根作为最大子图顶点数的上限
>
> >>>> > use strict;
> >>>> > use Graph::Clique;
>
> >>>> > my @edges;
> >>>> > my %h;
> >>>> > my $nnz;  # num of non-zeros
>
> >>>> > # build up undirected graph
>
> >>>> > while(<DATA>){
> >>>> > my $i = $.+1;
> >>>> >  my @a = split(/ /,$_);
> >>>> >  for my $j (0..$#a){
> >>>> >   if ($a[$j]){
> >>>> >    $nnz++;
> >>>> > my $e = $i <= $j ? $i.",".$j : $j.",".$i;
> >>>> > $h{$e}++;
> >>>> >   }
> >>>> >  }
>
> >>>> > }
>
> >>>> > foreach my $key (sort keys %h){
> >>>> > my @a = split(/\,/, $key);
> >>>> > push @edges, [@a];
>
> >>>> > }
>
> >>>> > # find maximal clique
>
> >>>> > my @cliques;
>
> >>>> > for (my $k=int(sqrt($nnz)); $k>3; $k--){
> >>>> >  @cliques = getcliques($k,\@edges);
> >>>> >  if ($#cliques >=0){
> >>>> >   last;
> >>>> >  }
>
> >>>> > }
>
> >>>> > print join("\n", @cliques),"\n";
>
> >>>> > __DATA__
> >>>> > 0 0 1 0 1 0 0 0 0 0
> >>>> > 0 1 1 0 0 0 0 0 0 0
> >>>> > 1 1 1 0 1 0 0 1 0 0
> >>>> > 1 1 1 0 0 0 0 0 0 0
> >>>> > 1 1 1 0 1 0 0 1 0 1
> >>>> > 0 0 0 0 0 0 0 0 0 0
> >>>> > 0 0 0 0 0 0 0 0 0 0
> >>>> > 0 0 1 0 1 0 0 1 0 1
> >>>> > 0 0 0 0 0 0 0 0 0 0
> >>>> > 0 0 0 0 1 0 0 1 0 0
>
> >>>> --
> >>>> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> >>>> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
> >>>> 要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
> >>>> 若有更多问题,请通过http://groups.google.com/group/perlchina?hl=zh-CN访问此网上论坛。
>
> >>> --
> >>> Best regards,
> >>> Liu Jie
>
> >>> 020-32015312
> >>> Guangzhou Institutes of Biomedicine and Health, Chinese Academy of
> >>> Sciences
> >>>http://www.gibh.cas.cn/
>
> >>>  --
> >>> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> >>> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
> >>> 要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
> >>> 若有更多问题,请通过http://groups.google.com/group/perlchina?hl=zh-CN访问此网上论坛。
>
> >> --
> >> Yours, Yan Zhu
>
> >> Institute of Microbiology, Chinese Academy of Sciences
>
> >> Datun Rd.
> >> Chaoyang District
> >> Beijing 100101
> >> P. R. China
>
> >> --
> >> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> >> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
> >> 要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
> >> 若有更多问题,请通过http://groups.google.com/group/perlchina?hl=zh-CN访问此网上论坛。
>
> > --
> > Best regards,
> > Liu Jie
>
> > 020-32015312
> > Guangzhou Institutes of Biomedicine and Health, Chinese Academy of
> > Sciences
> >http://www.gibh.cas.cn/
>
> --
> Best regards,
> Liu Jie
>
> 020-32015312
> Guangzhou Institutes of Biomedicine and Health, Chinese Academy of Scienceshttp://www.gibh.cas.cn/
>
>  Graph.jpg
> 30KViewDownload

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。




--
Yours, Yan Zhu

Institute of Microbiology, Chinese Academy of Sciences

Datun Rd.
Chaoyang District
Beijing 100101
P. R. China

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。



--
Best regards,
Liu Jie
 
020-32015312
Guangzhou Institutes of Biomedicine and Health, Chinese Academy of Sciences 

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

回复: [PerlChina] Re: 请问哪位用perl写过解方程组的脚本?

理工科应该都学线性代数吧,增广矩阵大家还是知道的
 
 
------------------ 原始邮件 ------------------
发送时间: 2011年7月15日(星期五) 上午10:27
收件人: "perlchina"<perlchina@googlegroups.com>;
主题: Re: [PerlChina] Re: 请问哪位用perl写过解方程组的脚本?
 
你这纯数学问题,太专业了
知道什么是增广矩阵的都没几个,你指望大家能怎么帮你

在 2011年7月13日 下午5:32,Hydraphenix <hydraphenixpz@gmail.com> 写道:
> 没有人回答我的问题,只好自己参照网上python的程序写了个gauss-jordan消元的程序,将增广矩阵作消元后,得到简化行梯矩阵,参数是增
> 广矩阵的reference。
> 好像这个组里能真正帮上忙的不多...
>
> sub gauss_jordan
> {
>     print "gauss_jordan elimination!\n";
>     my $m = &matrix_row($_[0]);      print "there are $m rows in the
> matrix!\n";
>     my $n = &matrix_column($_[0]);    print "there are $n columns in
> the matrix!\n";
>     my $k = $m;
>     $k=$n, if($k>$n);
>
>     for(my $i=0;$i<$k;$i++)  #转换成上三角矩阵
>     {
>         my $maxrow = $i;
>            for(my $j=($i + 1) ;$j<$m;$j++)
>            {
>                 if(abs($_[0]->[$j][$i]) > abs($_[0]->[$maxrow][$i]))
>                 {
>                 $maxrow = $j;
>                 }
>            }
>         my @temp;
>            @temp = @{$_[0]->[$i]};
>            @{$_[0]->[$i]} = @{$_[0]->[$maxrow]};
>            @{$_[0]->[$maxrow]} = @temp;
>         #换行成功!接下来将该列的余下的元素全部消为0
>         if(abs($_[0]->[$i][$i]) > 0 )
>         {
>            for(my $j=($i + 1) ;$j<$m;$j++)
>            {
>                 my $c = $_[0]->[$j][$i]/$_[0]->[$i][$i];
>                 for(my $x =$i;$x<$n;$x++)
>                 {
>                    $_[0]->[$j][$x] -=  $_[0]->[$i][$x]*$c;
>                 }
>            }
>         }
>         else
>         {
>           print "find a o column!\n";
>         }
>     } ##成功转换成上三角矩阵
>     &output_matrix($_[0]);
>     print "\n";
>     ##下面将上三角矩阵尽量简化,反向将非对角线元素消为0
>     for(my $i=$k-1;$i>=0;$i--)
>     {
>          if(abs($_[0]->[$i][$i])>0)
>          {
>                   my $c = $_[0]->[$i][$i];
>                   for(my $j=0; $j<$i;$j++)
>                   {
>                        for(my $x=$n-1;$x>=$i;$x--)
>                        {
>                          $_[0]->[$j][$x] -= $_[0]->[$i][$x]*$_[0]-
>>[$j][$i]/$c;
>                        }
>                   }
>                   ##以上已经将上三角非对角线元素消为0
>                   ##以下将对角线元素消为1
>                   for(my $x=$i;$x<$n;$x++)
>                   {
>                        $_[0]->[$i][$x] /=$c;
>                   }
>          }
>          else
>          {
>                  print "the diagonal element is 0!\n";
>           }
>     }
>     &output_matrix($_[0]);
>      return($_[0]);
> }
>
>  # &matrix_row($m)
> sub matrix_row
> {    my $array = $_[0];
>     my $k=0;
>    foreach (@{$array})
>    {
>     $k++;
>     # print "$_!\n";
>    }
>    return($k);
> }
>
>  # &matrix_column($m)
> sub matrix_column
> {
>    my $array = $_[0];
>    my $k=0;
>    foreach (@{$array->[0]})
>    {
>     $k++;
>     # print "$_!\n";
>    }
>    return($k);
> }
>
> sub output_matrix
> {
>     my $m = &matrix_row($_[0]);    #  print "there are $m rows in the
> matrix!\n";
>     my $n = &matrix_column($_[0]);  #  print "there are $n columns in
> the matrix!\n";
>     for(my $i=0;$i<$m;$i++)  #转换成上三角矩阵
>     {
>        my $line = join("\t",@{$_[0]->[$i]});
>        print "$line\n";
>     }
> }
>
>
>
>
>
>
>
> On 7月5日, 下午4时20分, Hydraphenix <hydrapheni...@gmail.com> wrote:
>> 要做一些数据的计算,使用math-assistant中的Solve_Det函数,要求系数矩阵必须是正方形矩阵。我的数据中不能保证是正方形矩阵。
>> 但计算前可以判断矩阵的秩与未知数的个数相等。在网上搜索了半天,都没有好的思路,希望有朋友能指点下。
>
> --
> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
> 要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>
>

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

2011年7月14日星期四

Re: [PerlChina] 新手请教:perl脚本在win32环境下运行遇到的问题!

可以用双引号把通配符包住当做参数送入脚本,脚本内用glob函数展开。

--
Jianqiang Liu

On 2011-07-14 22:40, hhs66317@gmail.com wrote:
> 你说的我明白,我这里举例echo只是说明echo在unix上和win32上对于通配符支持的异同。
> perl脚本在win32上执行对于通配符同样不支持,我这里也正是想知道有没有什么办法来实现?请赐教
>
> -----原信息-----
> 发件人: 夏凯
> 发送: 2011/07/14, 22:32
> 收件人: perlchina@googlegroups.com
> 主题: Re: [PerlChina] 新手请教:perl脚本在win32环境下运行遇到的问题!
>
>
> 并不是windows的shell不支持*,是echo不支持*:
> C:\test>echo a*
> a*
> C:\test>dir
> 2011-07-14 22:28 0 a1
> 2011-07-14 22:28 0 a2
> 2011-07-14 22:28 0 a3
> 2011-07-14 22:28 0 b
> 2011-07-14 22:28 0 c
> C:\test>del a*
> C:\test>dir
> 2011-07-14 22:28 0 b
> 2011-07-14 22:28 0 c
> 为了节省空间,无关的行删除了。
> 2011/7/14 Matthew<hhs66317@gmail.com>:
>> WIN32的shell貌似不给力 ,不支持这种做法。
>> 举个例子:我最近一直在看《Perl入门》,里边有这样的例子:
>> ++++++++++++++++++++
>> $ echo *.pm
>> barney.pm dino.pm Fred.pm wilma.pm
>> $
>> ++++++++++++++++++++
>> 但是我在Win32环境下是这样的
>> ++++++++++++++++++++
>> D:\Desktop>echo *.pl
>> *.pl
>>
>> D:\Desktop>
>> ++++++++++++++++++++
>> 不知道有没有什么其他方法来达到类似的目的?

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: [PerlChina] Re: 请问哪位用perl写过解方程组的脚本?

你这纯数学问题,太专业了
知道什么是增广矩阵的都没几个,你指望大家能怎么帮你

在 2011年7月13日 下午5:32,Hydraphenix <hydraphenixpz@gmail.com> 写道:
> 没有人回答我的问题,只好自己参照网上python的程序写了个gauss-jordan消元的程序,将增广矩阵作消元后,得到简化行梯矩阵,参数是增
> 广矩阵的reference。
> 好像这个组里能真正帮上忙的不多...
>
> sub gauss_jordan
> {
> print "gauss_jordan elimination!\n";
> my $m = &matrix_row($_[0]); print "there are $m rows in the
> matrix!\n";
> my $n = &matrix_column($_[0]); print "there are $n columns in
> the matrix!\n";
> my $k = $m;
> $k=$n, if($k>$n);
>
> for(my $i=0;$i<$k;$i++) #转换成上三角矩阵
> {
> my $maxrow = $i;
> for(my $j=($i + 1) ;$j<$m;$j++)
> {
> if(abs($_[0]->[$j][$i]) > abs($_[0]->[$maxrow][$i]))
> {
> $maxrow = $j;
> }
> }
> my @temp;
> @temp = @{$_[0]->[$i]};
> @{$_[0]->[$i]} = @{$_[0]->[$maxrow]};
> @{$_[0]->[$maxrow]} = @temp;
> #换行成功!接下来将该列的余下的元素全部消为0
> if(abs($_[0]->[$i][$i]) > 0 )
> {
> for(my $j=($i + 1) ;$j<$m;$j++)
> {
> my $c = $_[0]->[$j][$i]/$_[0]->[$i][$i];
> for(my $x =$i;$x<$n;$x++)
> {
> $_[0]->[$j][$x] -= $_[0]->[$i][$x]*$c;
> }
> }
> }
> else
> {
> print "find a o column!\n";
> }
> } ##成功转换成上三角矩阵
> &output_matrix($_[0]);
> print "\n";
> ##下面将上三角矩阵尽量简化,反向将非对角线元素消为0
> for(my $i=$k-1;$i>=0;$i--)
> {
> if(abs($_[0]->[$i][$i])>0)
> {
> my $c = $_[0]->[$i][$i];
> for(my $j=0; $j<$i;$j++)
> {
> for(my $x=$n-1;$x>=$i;$x--)
> {
> $_[0]->[$j][$x] -= $_[0]->[$i][$x]*$_[0]-
>>[$j][$i]/$c;
> }
> }
> ##以上已经将上三角非对角线元素消为0
> ##以下将对角线元素消为1
> for(my $x=$i;$x<$n;$x++)
> {
> $_[0]->[$i][$x] /=$c;
> }
> }
> else
> {
> print "the diagonal element is 0!\n";
> }
> }
> &output_matrix($_[0]);
> return($_[0]);
> }
>
> # &matrix_row($m)
> sub matrix_row
> { my $array = $_[0];
> my $k=0;
> foreach (@{$array})
> {
> $k++;
> # print "$_!\n";
> }
> return($k);
> }
>
> # &matrix_column($m)
> sub matrix_column
> {
> my $array = $_[0];
> my $k=0;
> foreach (@{$array->[0]})
> {
> $k++;
> # print "$_!\n";
> }
> return($k);
> }
>
> sub output_matrix
> {
> my $m = &matrix_row($_[0]); # print "there are $m rows in the
> matrix!\n";
> my $n = &matrix_column($_[0]); # print "there are $n columns in
> the matrix!\n";
> for(my $i=0;$i<$m;$i++) #转换成上三角矩阵
> {
> my $line = join("\t",@{$_[0]->[$i]});
> print "$line\n";
> }
> }
>
>
>
>
>
>
>
> On 7月5日, 下午4时20分, Hydraphenix <hydrapheni...@gmail.com> wrote:
>> 要做一些数据的计算,使用math-assistant中的Solve_Det函数,要求系数矩阵必须是正方形矩阵。我的数据中不能保证是正方形矩阵。
>> 但计算前可以判断矩阵的秩与未知数的个数相等。在网上搜索了半天,都没有好的思路,希望有朋友能指点下。
>
> --
> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
> 要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>
>

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: [PerlChina] Re: DNA,DG值。

不好意思,index搞错了,下面是修改版,用的Jie Liu的矩阵,
得到结果(index从0开始):
0 1 3
0 1 4
0 2 4
2 4 7
4 7 9
好像vertex number不能取10以上(包括10)...看看能不能根据作者的算法重写吧


use strict;
use Graph::Clique;



my @edges;
my %h;
my $nnz;  # num of non-zeros


# build up undirected graph
open F, 'matrix_small.txt' or die;
while(<F>){
my $i = $.-1; 
my @a = split(/ /,$_);
for my $j (0..$#a){
if ($a[$j] == 1){
$nnz++;
my $e = $i <= $j ? $i.",".$j : $j.",".$i;
$h{$e}++;
}
}
}
close F;


foreach my $key (sort keys %h){
my @a = split(/\,/, $key);
push @edges, [@a];
}



# find maximal clique

my @cliques;

for (my $k=int(sqrt($nnz)); $k>0; $k--){
@cliques = getcliques($k,\@edges);
if ($#cliques >=0){ last; }
}

print join("\n", @cliques),"\n";



在 2011年7月14日 下午11:16,nixin <nicene714@gmail.com>写道:
google到的matlab的maximal cliques程序:
http://www.mathworks.com/matlabcentral/fileexchange/19889-maximal-cliques


On Jul 14, 9:27 pm, jie liu <liujie....@gmail.com> wrote:
> 附件忘加了,在这个邮件里
>
> 2011/7/14 jie liu <liujie....@gmail.com>
>
>
>
>
>
>
>
>
>
>
>
> > 朱岩,出了一些状况. 我造了一个  无向图 的矩阵数据。
> > ------------data----------------
> > 0 0 0 0 0 0 0 0 0 0
> > 1 0 0 0 0 0 0 0 0 0
> > 1 0 0 0 0 0 0 0 0 0
> > 1 1 0 0 0 0 0 0 0 0
> > 1 1 1 0 0 0 0 0 0 0
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 1 0 1 0 0 0 0 0
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 0 0 1 0 0 1 0 0
> > --------------------
> > 我用matlab可视化了这个graph,请见附件。
>
> > 之后我用你的程序(我把K值改成了K>1)处理这个矩阵,显示的结果是:2,6,9这个节点。这与附件的图矛盾啊,2,6,9实际不是完全连通图啊。怎么回事? 我先把结果反馈给大家,同时我也想想
>
> > ------------ perl script--------------------
>
> > use strict;
> > use Graph::Clique;
>
> > my @edges;
> > my %h;
> > my $nnz;       # num of non-zeros
>
> > # build up undirected graph
> > open FASTA, "<@ARGV";
> > while (<FASTA>) {
> > my $i = $. + 1;
> >  my @a = split( / /, $_ );
> > for my $j ( 0 .. $#a ) {
> > if ( $a[$j] ) {
> >  $nnz++;
> > my $e = $i <= $j ? $i . "," . $j : $j . "," . $i;
> >  $h{$e}++;
> > }
> > }
> > }
>
> > foreach my $key ( sort keys %h ) {
> > my @a = split( /\,/, $key );
> > push @edges, [@a];
> > }
>
> > # find maximal clique
>
> > my @cliques;
>
> > for ( my $k = int( sqrt($nnz) ) ; $k > 1 ; $k-- ) {
> >  @cliques = getcliques( $k, \@edges );
> > if ( $#cliques >= 0 ) {
> > last;
> >  }
> > }
>
> > print join( "\n", @cliques ), "\n";
>
> > ------------end--------------------------------
> > 2011/7/14 朱岩 <riye...@gmail.com>
>
> >> 读文件把while(<DATA>)换成while(<F>)就可以了
>
> >> 在 2011年7月14日 下午4:02,jie liu <liujie....@gmail.com>写道:
>
> >>> 我刚刚也看到了,还去了作者给的一个地址(http://home.hiwaay.net/~gbacon/perl/clique.html
> >>> )看来一下,很激动!就是我要找的,谢谢大家了哈。
>
> >>> 但是,我都perl不熟,现在我把矩阵存在txt里了(1代表有边,0代表无边),我怎么把矩阵读进去,然后形成graph,然后用clique呢...朱岩的 程序我使了下,没成功。朱岩的程序里我没有看到读入的操作啊(实在是对perl不熟悉...)
>
> >>> 2011/7/14 nixin <nicene...@gmail.com>
>
> >>>> 果然有现成的库。clique这个关键词没有掌握,搜了好一会全连通图,啥也没搜到。呵呵。
>
> >>>> On 7月14日, 下午1时28分, 朱岩 <riye...@gmail.com> wrote:
> >>>> > 图论解法:
>
> >>>> > 找最大完全连通子图,可以用Graph::Clique,当然应该还有更好的算法;
> >>>> > 这里只举了个10x10的小例子
> >>>> > 用非零数的平方根作为最大子图顶点数的上限
>
> >>>> > use strict;
> >>>> > use Graph::Clique;
>
> >>>> > my @edges;
> >>>> > my %h;
> >>>> > my $nnz;  # num of non-zeros
>
> >>>> > # build up undirected graph
>
> >>>> > while(<DATA>){
> >>>> > my $i = $.+1;
> >>>> >  my @a = split(/ /,$_);
> >>>> >  for my $j (0..$#a){
> >>>> >   if ($a[$j]){
> >>>> >    $nnz++;
> >>>> > my $e = $i <= $j ? $i.",".$j : $j.",".$i;
> >>>> > $h{$e}++;
> >>>> >   }
> >>>> >  }
>
> >>>> > }
>
> >>>> > foreach my $key (sort keys %h){
> >>>> > my @a = split(/\,/, $key);
> >>>> > push @edges, [@a];
>
> >>>> > }
>
> >>>> > # find maximal clique
>
> >>>> > my @cliques;
>
> >>>> > for (my $k=int(sqrt($nnz)); $k>3; $k--){
> >>>> >  @cliques = getcliques($k,\@edges);
> >>>> >  if ($#cliques >=0){
> >>>> >   last;
> >>>> >  }
>
> >>>> > }
>
> >>>> > print join("\n", @cliques),"\n";
>
> >>>> > __DATA__
> >>>> > 0 0 1 0 1 0 0 0 0 0
> >>>> > 0 1 1 0 0 0 0 0 0 0
> >>>> > 1 1 1 0 1 0 0 1 0 0
> >>>> > 1 1 1 0 0 0 0 0 0 0
> >>>> > 1 1 1 0 1 0 0 1 0 1
> >>>> > 0 0 0 0 0 0 0 0 0 0
> >>>> > 0 0 0 0 0 0 0 0 0 0
> >>>> > 0 0 1 0 1 0 0 1 0 1
> >>>> > 0 0 0 0 0 0 0 0 0 0
> >>>> > 0 0 0 0 1 0 0 1 0 0
>
> >>>> --
> >>>> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> >>>> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
> >>>> 要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
> >>>> 若有更多问题,请通过http://groups.google.com/group/perlchina?hl=zh-CN访问此网上论坛。
>
> >>> --
> >>> Best regards,
> >>> Liu Jie
>
> >>> 020-32015312
> >>> Guangzhou Institutes of Biomedicine and Health, Chinese Academy of
> >>> Sciences
> >>>http://www.gibh.cas.cn/
>
> >>>  --
> >>> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> >>> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
> >>> 要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
> >>> 若有更多问题,请通过http://groups.google.com/group/perlchina?hl=zh-CN访问此网上论坛。
>
> >> --
> >> Yours, Yan Zhu
>
> >> Institute of Microbiology, Chinese Academy of Sciences
>
> >> Datun Rd.
> >> Chaoyang District
> >> Beijing 100101
> >> P. R. China
>
> >> --
> >> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> >> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
> >> 要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
> >> 若有更多问题,请通过http://groups.google.com/group/perlchina?hl=zh-CN访问此网上论坛。
>
> > --
> > Best regards,
> > Liu Jie
>
> > 020-32015312
> > Guangzhou Institutes of Biomedicine and Health, Chinese Academy of
> > Sciences
> >http://www.gibh.cas.cn/
>
> --
> Best regards,
> Liu Jie
>
> 020-32015312
> Guangzhou Institutes of Biomedicine and Health, Chinese Academy of Scienceshttp://www.gibh.cas.cn/
>
>  Graph.jpg
> 30KViewDownload

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。




--
Yours, Yan Zhu

Institute of Microbiology, Chinese Academy of Sciences

Datun Rd.
Chaoyang District
Beijing 100101
P. R. China

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: Re: [PerlChina] 新手请教:perl脚本在win32环境下运行遇到的问题!

装个cygwin吧

在 2011年7月14日 下午10:40,hhs66317@gmail.com <hhs66317@gmail.com>写道:
你说的我明白,我这里举例echo只是说明echo在unix上和win32上对于通配符支持的异同。
perl脚本在win32上执行对于通配符同样不支持,我这里也正是想知道有没有什么办法来实现?请赐教

-----原信息-----
发件人: 夏凯
发送:  2011/07/14, 22:32
收件人: perlchina@googlegroups.com
主题: Re: [PerlChina] 新手请教:perl脚本在win32环境下运行遇到的问题!


并不是windows的shell不支持*,是echo不支持*:
C:\test>echo a*
a*
C:\test>dir
2011-07-14  22:28                 0 a1
2011-07-14  22:28                 0 a2
2011-07-14  22:28                 0 a3
2011-07-14  22:28                 0 b
2011-07-14  22:28                 0 c
C:\test>del a*
C:\test>dir
2011-07-14  22:28                 0 b
2011-07-14  22:28                 0 c
为了节省空间,无关的行删除了。
2011/7/14 Matthew <hhs66317@gmail.com>:
> WIN32的shell貌似不给力 ,不支持这种做法。
> 举个例子:我最近一直在看《Perl入门》,里边有这样的例子:
> ++++++++++++++++++++
> $ echo *.pm
> barney.pm dino.pm Fred.pm wilma.pm
> $
> ++++++++++++++++++++
> 但是我在Win32环境下是这样的
> ++++++++++++++++++++
> D:\Desktop>echo *.pl
> *.pl
>
> D:\Desktop>
> ++++++++++++++++++++
> 不知道有没有什么其他方法来达到类似的目的?
--
contact me:
MSN: walkerxk@gmail.com
GTALK: walkerxk@gmail.com

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。


--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。




--
woosley.xu.    http://twitter.com/redicaps



--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

[PerlChina] Re: DNA,DG值。

google到的matlab的maximal cliques程序:
http://www.mathworks.com/matlabcentral/fileexchange/19889-maximal-cliques


On Jul 14, 9:27 pm, jie liu <liujie....@gmail.com> wrote:
> 附件忘加了,在这个邮件里
>
> 2011/7/14 jie liu <liujie....@gmail.com>
>
>
>
>
>
>
>
>
>
>
>
> > 朱岩,出了一些状况. 我造了一个 无向图 的矩阵数据。
> > ------------data----------------
> > 0 0 0 0 0 0 0 0 0 0
> > 1 0 0 0 0 0 0 0 0 0
> > 1 0 0 0 0 0 0 0 0 0
> > 1 1 0 0 0 0 0 0 0 0
> > 1 1 1 0 0 0 0 0 0 0
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 1 0 1 0 0 0 0 0
> > 0 0 0 0 0 0 0 0 0 0
> > 0 0 0 0 1 0 0 1 0 0
> > --------------------
> > 我用matlab可视化了这个graph,请见附件。
>
> > 之后我用你的程序(我把K值改成了K>1)处理这个矩阵,显示的结果是:2,6,9这个节点。这与附件的图矛盾啊,2,6,9实际不是完全连通图啊。怎么回事? 我先把结果反馈给大家,同时我也想想
>
> > ------------ perl script--------------------
>
> > use strict;
> > use Graph::Clique;
>
> > my @edges;
> > my %h;
> > my $nnz; # num of non-zeros
>
> > # build up undirected graph
> > open FASTA, "<@ARGV";
> > while (<FASTA>) {
> > my $i = $. + 1;
> > my @a = split( / /, $_ );
> > for my $j ( 0 .. $#a ) {
> > if ( $a[$j] ) {
> > $nnz++;
> > my $e = $i <= $j ? $i . "," . $j : $j . "," . $i;
> > $h{$e}++;
> > }
> > }
> > }
>
> > foreach my $key ( sort keys %h ) {
> > my @a = split( /\,/, $key );
> > push @edges, [@a];
> > }
>
> > # find maximal clique
>
> > my @cliques;
>
> > for ( my $k = int( sqrt($nnz) ) ; $k > 1 ; $k-- ) {
> > @cliques = getcliques( $k, \@edges );
> > if ( $#cliques >= 0 ) {
> > last;
> > }
> > }
>
> > print join( "\n", @cliques ), "\n";
>
> > ------------end--------------------------------
> > 2011/7/14 朱岩 <riye...@gmail.com>
>
> >> 读文件把while(<DATA>)换成while(<F>)就可以了
>
> >> 在 2011年7月14日 下午4:02,jie liu <liujie....@gmail.com>写道:
>
> >>> 我刚刚也看到了,还去了作者给的一个地址(http://home.hiwaay.net/~gbacon/perl/clique.html
> >>> )看来一下,很激动!就是我要找的,谢谢大家了哈。
>
> >>> 但是,我都perl不熟,现在我把矩阵存在txt里了(1代表有边,0代表无边),我怎么把矩阵读进去,然后形成graph,然后用clique呢...朱岩的 程序我使了下,没成功。朱岩的程序里我没有看到读入的操作啊(实在是对perl不熟悉...)
>
> >>> 2011/7/14 nixin <nicene...@gmail.com>
>
> >>>> 果然有现成的库。clique这个关键词没有掌握,搜了好一会全连通图,啥也没搜到。呵呵。
>
> >>>> On 7月14日, 下午1时28分, 朱岩 <riye...@gmail.com> wrote:
> >>>> > 图论解法:
>
> >>>> > 找最大完全连通子图,可以用Graph::Clique,当然应该还有更好的算法;
> >>>> > 这里只举了个10x10的小例子
> >>>> > 用非零数的平方根作为最大子图顶点数的上限
>
> >>>> > use strict;
> >>>> > use Graph::Clique;
>
> >>>> > my @edges;
> >>>> > my %h;
> >>>> > my $nnz; # num of non-zeros
>
> >>>> > # build up undirected graph
>
> >>>> > while(<DATA>){
> >>>> > my $i = $.+1;
> >>>> > my @a = split(/ /,$_);
> >>>> > for my $j (0..$#a){
> >>>> > if ($a[$j]){
> >>>> > $nnz++;
> >>>> > my $e = $i <= $j ? $i.",".$j : $j.",".$i;
> >>>> > $h{$e}++;
> >>>> > }
> >>>> > }
>
> >>>> > }
>
> >>>> > foreach my $key (sort keys %h){
> >>>> > my @a = split(/\,/, $key);
> >>>> > push @edges, [@a];
>
> >>>> > }
>
> >>>> > # find maximal clique
>
> >>>> > my @cliques;
>
> >>>> > for (my $k=int(sqrt($nnz)); $k>3; $k--){
> >>>> > @cliques = getcliques($k,\@edges);
> >>>> > if ($#cliques >=0){
> >>>> > last;
> >>>> > }
>
> >>>> > }
>
> >>>> > print join("\n", @cliques),"\n";
>
> >>>> > __DATA__
> >>>> > 0 0 1 0 1 0 0 0 0 0
> >>>> > 0 1 1 0 0 0 0 0 0 0
> >>>> > 1 1 1 0 1 0 0 1 0 0
> >>>> > 1 1 1 0 0 0 0 0 0 0
> >>>> > 1 1 1 0 1 0 0 1 0 1
> >>>> > 0 0 0 0 0 0 0 0 0 0
> >>>> > 0 0 0 0 0 0 0 0 0 0
> >>>> > 0 0 1 0 1 0 0 1 0 1
> >>>> > 0 0 0 0 0 0 0 0 0 0
> >>>> > 0 0 0 0 1 0 0 1 0 0
>
> >>>> --
> >>>> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> >>>> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
> >>>> 要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
> >>>> 若有更多问题,请通过http://groups.google.com/group/perlchina?hl=zh-CN访问此网上论坛。
>
> >>> --
> >>> Best regards,
> >>> Liu Jie
>
> >>> 020-32015312
> >>> Guangzhou Institutes of Biomedicine and Health, Chinese Academy of
> >>> Sciences
> >>>http://www.gibh.cas.cn/
>
> >>> --
> >>> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> >>> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
> >>> 要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
> >>> 若有更多问题,请通过http://groups.google.com/group/perlchina?hl=zh-CN访问此网上论坛。
>
> >> --
> >> Yours, Yan Zhu
>
> >> Institute of Microbiology, Chinese Academy of Sciences
>
> >> Datun Rd.
> >> Chaoyang District
> >> Beijing 100101
> >> P. R. China
>
> >> --
> >> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
> >> 要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
> >> 要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
> >> 若有更多问题,请通过http://groups.google.com/group/perlchina?hl=zh-CN访问此网上论坛。
>
> > --
> > Best regards,
> > Liu Jie
>
> > 020-32015312
> > Guangzhou Institutes of Biomedicine and Health, Chinese Academy of
> > Sciences
> >http://www.gibh.cas.cn/
>
> --
> Best regards,
> Liu Jie
>
> 020-32015312
> Guangzhou Institutes of Biomedicine and Health, Chinese Academy of Scienceshttp://www.gibh.cas.cn/
>
> Graph.jpg
> 30KViewDownload

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: Re: [PerlChina] 新手请教:perl脚本在win32环境下运行遇到的问题!

这个我就不知道了。
2011/7/14 hhs66317@gmail.com <hhs66317@gmail.com>:
> 你说的我明白,我这里举例echo只是说明echo在unix上和win32上对于通配符支持的异同。
> perl脚本在win32上执行对于通配符同样不支持,我这里也正是想知道有没有什么办法来实现?请赐教
--
contact me:
MSN: walkerxk@gmail.com
GTALK: walkerxk@gmail.com

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: Re: [PerlChina] 新手请教:perl脚本在win32环境下运行遇到的问题!

你说的我明白,我这里举例echo只是说明echo在unix上和win32上对于通配符支持的异同。
perl脚本在win32上执行对于通配符同样不支持,我这里也正是想知道有没有什么办法来实现?请赐教

-----原信息-----
发件人: 夏凯
发送: 2011/07/14, 22:32
收件人: perlchina@googlegroups.com
主题: Re: [PerlChina] 新手请教:perl脚本在win32环境下运行遇到的问题!


并不是windows的shell不支持*,是echo不支持*:
C:\test>echo a*
a*
C:\test>dir
2011-07-14 22:28 0 a1
2011-07-14 22:28 0 a2
2011-07-14 22:28 0 a3
2011-07-14 22:28 0 b
2011-07-14 22:28 0 c
C:\test>del a*
C:\test>dir
2011-07-14 22:28 0 b
2011-07-14 22:28 0 c
为了节省空间,无关的行删除了。
2011/7/14 Matthew <hhs66317@gmail.com>:
> WIN32的shell貌似不给力 ,不支持这种做法。
> 举个例子:我最近一直在看《Perl入门》,里边有这样的例子:
> ++++++++++++++++++++
> $ echo *.pm
> barney.pm dino.pm Fred.pm wilma.pm
> $
> ++++++++++++++++++++
> 但是我在Win32环境下是这样的
> ++++++++++++++++++++
> D:\Desktop>echo *.pl
> *.pl
>
> D:\Desktop>
> ++++++++++++++++++++
> 不知道有没有什么其他方法来达到类似的目的?
--
contact me:
MSN: walkerxk@gmail.com
GTALK: walkerxk@gmail.com

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。


--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: [PerlChina] 新手请教:perl脚本在win32环境下运行遇到的问题!

并不是windows的shell不支持*,是echo不支持*:
C:\test>echo a*
a*
C:\test>dir
2011-07-14 22:28 0 a1
2011-07-14 22:28 0 a2
2011-07-14 22:28 0 a3
2011-07-14 22:28 0 b
2011-07-14 22:28 0 c
C:\test>del a*
C:\test>dir
2011-07-14 22:28 0 b
2011-07-14 22:28 0 c
为了节省空间,无关的行删除了。
2011/7/14 Matthew <hhs66317@gmail.com>:
> WIN32的shell貌似不给力 ,不支持这种做法。
> 举个例子:我最近一直在看《Perl入门》,里边有这样的例子:
> ++++++++++++++++++++
> $ echo *.pm
> barney.pm dino.pm Fred.pm wilma.pm
> $
> ++++++++++++++++++++
> 但是我在Win32环境下是这样的
> ++++++++++++++++++++
> D:\Desktop>echo *.pl
> *.pl
>
> D:\Desktop>
> ++++++++++++++++++++
> 不知道有没有什么其他方法来达到类似的目的?
--
contact me:
MSN: walkerxk@gmail.com
GTALK: walkerxk@gmail.com

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: [PerlChina] Re: DNA,DG值。

附件忘加了,在这个邮件里

2011/7/14 jie liu <liujie.dhu@gmail.com>

朱岩,出了一些状况. 我造了一个  无向图 的矩阵数据。
——————data————————
0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0 0
1 1 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 1 0 0
——————————
我用matlab可视化了这个graph,请见附件。
之后我用你的程序(我把K值改成了K>1)处理这个矩阵,显示的结果是:2,6,9这个节点。这与附件的图矛盾啊,2,6,9实际不是完全连通图啊。怎么回事?我先把结果反馈给大家,同时我也想想

—————— perl script——————————

use strict;
use Graph::Clique;

my @edges;
my %h;
my $nnz;       # num of non-zeros

# build up undirected graph
open FASTA, "<@ARGV";
while (<FASTA>) {
my $i = $. + 1;
my @a = split( / /, $_ );
for my $j ( 0 .. $#a ) {
if ( $a[$j] ) {
$nnz++;
my $e = $i <= $j ? $i . "," . $j : $j . "," . $i;
$h{$e}++;
}
}
}

foreach my $key ( sort keys %h ) {
my @a = split( /\,/, $key );
push @edges, [@a];
}

# find maximal clique

my @cliques;

for ( my $k = int( sqrt($nnz) ) ; $k > 1 ; $k-- ) {
@cliques = getcliques( $k, \@edges );
if ( $#cliques >= 0 ) {
last;
}
}

print join( "\n", @cliques ), "\n";

——————end————————————————
2011/7/14 朱岩 <riyeyan@gmail.com>
读文件把while(<DATA>)换成while(<F>)就可以了
   

在 2011年7月14日 下午4:02,jie liu <liujie.dhu@gmail.com>写道:
我刚刚也看到了,还去了作者给的一个地址(http://home.hiwaay.net/~gbacon/perl/clique.html)看来一下,很激动!就是我要找的,谢谢大家了哈。
但是,我都perl不熟,现在我把矩阵存在txt里了(1代表有边,0代表无边),我怎么把矩阵读进去,然后形成graph,然后用clique呢...朱岩的程序我使了下,没成功。朱岩的程序里我没有看到读入的操作啊(实在是对perl不熟悉...)


2011/7/14 nixin <nicene714@gmail.com>
果然有现成的库。clique这个关键词没有掌握,搜了好一会全连通图,啥也没搜到。呵呵。

On 7月14日, 下午1时28分, 朱岩 <riye...@gmail.com> wrote:
> 图论解法:
>
> 找最大完全连通子图,可以用Graph::Clique,当然应该还有更好的算法;
> 这里只举了个10x10的小例子
> 用非零数的平方根作为最大子图顶点数的上限
>
> use strict;
> use Graph::Clique;
>
> my @edges;
> my %h;
> my $nnz;  # num of non-zeros
>
> # build up undirected graph
>
> while(<DATA>){
> my $i = $.+1;
>  my @a = split(/ /,$_);
>  for my $j (0..$#a){
>   if ($a[$j]){
>    $nnz++;
> my $e = $i <= $j ? $i.",".$j : $j.",".$i;
> $h{$e}++;
>   }
>  }
>
> }
>
> foreach my $key (sort keys %h){
> my @a = split(/\,/, $key);
> push @edges, [@a];
>
> }
>
> # find maximal clique
>
> my @cliques;
>
> for (my $k=int(sqrt($nnz)); $k>3; $k--){
>  @cliques = getcliques($k,\@edges);
>  if ($#cliques >=0){
>   last;
>  }
>
> }
>
> print join("\n", @cliques),"\n";
>
> __DATA__
> 0 0 1 0 1 0 0 0 0 0
> 0 1 1 0 0 0 0 0 0 0
> 1 1 1 0 1 0 0 1 0 0
> 1 1 1 0 0 0 0 0 0 0
> 1 1 1 0 1 0 0 1 0 1
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0
> 0 0 1 0 1 0 0 1 0 1
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 1 0 0 1 0 0

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。




--
Best regards,
Liu Jie
 
020-32015312
Guangzhou Institutes of Biomedicine and Health, Chinese Academy of Sciences 

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。



--
Yours, Yan Zhu

Institute of Microbiology, Chinese Academy of Sciences

Datun Rd.
Chaoyang District
Beijing 100101
P. R. China

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。



--
Best regards,
Liu Jie
 
020-32015312
Guangzhou Institutes of Biomedicine and Health, Chinese Academy of Sciences 




--
Best regards,
Liu Jie
 
020-32015312
Guangzhou Institutes of Biomedicine and Health, Chinese Academy of Sciences 

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: [PerlChina] Re: DNA,DG值。


朱岩,出了一些状况. 我造了一个  无向图 的矩阵数据。
——————data————————
0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0 0
1 1 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 1 0 0
——————————
我用matlab可视化了这个graph,请见附件。
之后我用你的程序(我把K值改成了K>1)处理这个矩阵,显示的结果是:2,6,9这个节点。这与附件的图矛盾啊,2,6,9实际不是完全连通图啊。怎么回事?我先把结果反馈给大家,同时我也想想

—————— perl script——————————

use strict;
use Graph::Clique;

my @edges;
my %h;
my $nnz;       # num of non-zeros

# build up undirected graph
open FASTA, "<@ARGV";
while (<FASTA>) {
my $i = $. + 1;
my @a = split( / /, $_ );
for my $j ( 0 .. $#a ) {
if ( $a[$j] ) {
$nnz++;
my $e = $i <= $j ? $i . "," . $j : $j . "," . $i;
$h{$e}++;
}
}
}

foreach my $key ( sort keys %h ) {
my @a = split( /\,/, $key );
push @edges, [@a];
}

# find maximal clique

my @cliques;

for ( my $k = int( sqrt($nnz) ) ; $k > 1 ; $k-- ) {
@cliques = getcliques( $k, \@edges );
if ( $#cliques >= 0 ) {
last;
}
}

print join( "\n", @cliques ), "\n";

——————end————————————————
2011/7/14 朱岩 <riyeyan@gmail.com>
读文件把while(<DATA>)换成while(<F>)就可以了
   

在 2011年7月14日 下午4:02,jie liu <liujie.dhu@gmail.com>写道:
我刚刚也看到了,还去了作者给的一个地址(http://home.hiwaay.net/~gbacon/perl/clique.html)看来一下,很激动!就是我要找的,谢谢大家了哈。
但是,我都perl不熟,现在我把矩阵存在txt里了(1代表有边,0代表无边),我怎么把矩阵读进去,然后形成graph,然后用clique呢...朱岩的程序我使了下,没成功。朱岩的程序里我没有看到读入的操作啊(实在是对perl不熟悉...)


2011/7/14 nixin <nicene714@gmail.com>
果然有现成的库。clique这个关键词没有掌握,搜了好一会全连通图,啥也没搜到。呵呵。

On 7月14日, 下午1时28分, 朱岩 <riye...@gmail.com> wrote:
> 图论解法:
>
> 找最大完全连通子图,可以用Graph::Clique,当然应该还有更好的算法;
> 这里只举了个10x10的小例子
> 用非零数的平方根作为最大子图顶点数的上限
>
> use strict;
> use Graph::Clique;
>
> my @edges;
> my %h;
> my $nnz;  # num of non-zeros
>
> # build up undirected graph
>
> while(<DATA>){
> my $i = $.+1;
>  my @a = split(/ /,$_);
>  for my $j (0..$#a){
>   if ($a[$j]){
>    $nnz++;
> my $e = $i <= $j ? $i.",".$j : $j.",".$i;
> $h{$e}++;
>   }
>  }
>
> }
>
> foreach my $key (sort keys %h){
> my @a = split(/\,/, $key);
> push @edges, [@a];
>
> }
>
> # find maximal clique
>
> my @cliques;
>
> for (my $k=int(sqrt($nnz)); $k>3; $k--){
>  @cliques = getcliques($k,\@edges);
>  if ($#cliques >=0){
>   last;
>  }
>
> }
>
> print join("\n", @cliques),"\n";
>
> __DATA__
> 0 0 1 0 1 0 0 0 0 0
> 0 1 1 0 0 0 0 0 0 0
> 1 1 1 0 1 0 0 1 0 0
> 1 1 1 0 0 0 0 0 0 0
> 1 1 1 0 1 0 0 1 0 1
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0
> 0 0 1 0 1 0 0 1 0 1
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 1 0 0 1 0 0

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。




--
Best regards,
Liu Jie
 
020-32015312
Guangzhou Institutes of Biomedicine and Health, Chinese Academy of Sciences 

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。



--
Yours, Yan Zhu

Institute of Microbiology, Chinese Academy of Sciences

Datun Rd.
Chaoyang District
Beijing 100101
P. R. China

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。



--
Best regards,
Liu Jie
 
020-32015312
Guangzhou Institutes of Biomedicine and Health, Chinese Academy of Sciences 

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: [PerlChina] Re: DNA,DG值。

读文件把while(<DATA>)换成while(<F>)就可以了
   

在 2011年7月14日 下午4:02,jie liu <liujie.dhu@gmail.com>写道:
我刚刚也看到了,还去了作者给的一个地址(http://home.hiwaay.net/~gbacon/perl/clique.html)看来一下,很激动!就是我要找的,谢谢大家了哈。
但是,我都perl不熟,现在我把矩阵存在txt里了(1代表有边,0代表无边),我怎么把矩阵读进去,然后形成graph,然后用clique呢...朱岩的程序我使了下,没成功。朱岩的程序里我没有看到读入的操作啊(实在是对perl不熟悉...)


2011/7/14 nixin <nicene714@gmail.com>
果然有现成的库。clique这个关键词没有掌握,搜了好一会全连通图,啥也没搜到。呵呵。

On 7月14日, 下午1时28分, 朱岩 <riye...@gmail.com> wrote:
> 图论解法:
>
> 找最大完全连通子图,可以用Graph::Clique,当然应该还有更好的算法;
> 这里只举了个10x10的小例子
> 用非零数的平方根作为最大子图顶点数的上限
>
> use strict;
> use Graph::Clique;
>
> my @edges;
> my %h;
> my $nnz;  # num of non-zeros
>
> # build up undirected graph
>
> while(<DATA>){
> my $i = $.+1;
>  my @a = split(/ /,$_);
>  for my $j (0..$#a){
>   if ($a[$j]){
>    $nnz++;
> my $e = $i <= $j ? $i.",".$j : $j.",".$i;
> $h{$e}++;
>   }
>  }
>
> }
>
> foreach my $key (sort keys %h){
> my @a = split(/\,/, $key);
> push @edges, [@a];
>
> }
>
> # find maximal clique
>
> my @cliques;
>
> for (my $k=int(sqrt($nnz)); $k>3; $k--){
>  @cliques = getcliques($k,\@edges);
>  if ($#cliques >=0){
>   last;
>  }
>
> }
>
> print join("\n", @cliques),"\n";
>
> __DATA__
> 0 0 1 0 1 0 0 0 0 0
> 0 1 1 0 0 0 0 0 0 0
> 1 1 1 0 1 0 0 1 0 0
> 1 1 1 0 0 0 0 0 0 0
> 1 1 1 0 1 0 0 1 0 1
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0
> 0 0 1 0 1 0 0 1 0 1
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 1 0 0 1 0 0

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。




--
Best regards,
Liu Jie
 
020-32015312
Guangzhou Institutes of Biomedicine and Health, Chinese Academy of Sciences 

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。



--
Yours, Yan Zhu

Institute of Microbiology, Chinese Academy of Sciences

Datun Rd.
Chaoyang District
Beijing 100101
P. R. China

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: [PerlChina] Re: DNA,DG值。

我刚刚也看到了,还去了作者给的一个地址(http://home.hiwaay.net/~gbacon/perl/clique.html)看来一下,很激动!就是我要找的,谢谢大家了哈。
但是,我都perl不熟,现在我把矩阵存在txt里了(1代表有边,0代表无边),我怎么把矩阵读进去,然后形成graph,然后用clique呢...朱岩的程序我使了下,没成功。朱岩的程序里我没有看到读入的操作啊(实在是对perl不熟悉...)

2011/7/14 nixin <nicene714@gmail.com>
果然有现成的库。clique这个关键词没有掌握,搜了好一会全连通图,啥也没搜到。呵呵。

On 7月14日, 下午1时28分, 朱岩 <riye...@gmail.com> wrote:
> 图论解法:
>
> 找最大完全连通子图,可以用Graph::Clique,当然应该还有更好的算法;
> 这里只举了个10x10的小例子
> 用非零数的平方根作为最大子图顶点数的上限
>
> use strict;
> use Graph::Clique;
>
> my @edges;
> my %h;
> my $nnz;  # num of non-zeros
>
> # build up undirected graph
>
> while(<DATA>){
> my $i = $.+1;
>  my @a = split(/ /,$_);
>  for my $j (0..$#a){
>   if ($a[$j]){
>    $nnz++;
> my $e = $i <= $j ? $i.",".$j : $j.",".$i;
> $h{$e}++;
>   }
>  }
>
> }
>
> foreach my $key (sort keys %h){
> my @a = split(/\,/, $key);
> push @edges, [@a];
>
> }
>
> # find maximal clique
>
> my @cliques;
>
> for (my $k=int(sqrt($nnz)); $k>3; $k--){
>  @cliques = getcliques($k,\@edges);
>  if ($#cliques >=0){
>   last;
>  }
>
> }
>
> print join("\n", @cliques),"\n";
>
> __DATA__
> 0 0 1 0 1 0 0 0 0 0
> 0 1 1 0 0 0 0 0 0 0
> 1 1 1 0 1 0 0 1 0 0
> 1 1 1 0 0 0 0 0 0 0
> 1 1 1 0 1 0 0 1 0 1
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0
> 0 0 1 0 1 0 0 1 0 1
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 1 0 0 1 0 0

--
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。




--
Best regards,
Liu Jie
 
020-32015312
Guangzhou Institutes of Biomedicine and Health, Chinese Academy of Sciences 

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

[PerlChina] Re: DNA,DG值。

果然有现成的库。clique这个关键词没有掌握,搜了好一会全连通图,啥也没搜到。呵呵。

On 7月14日, 下午1时28分, 朱岩 <riye...@gmail.com> wrote:
> 图论解法:
>
> 找最大完全连通子图,可以用Graph::Clique,当然应该还有更好的算法;
> 这里只举了个10x10的小例子
> 用非零数的平方根作为最大子图顶点数的上限
>
> use strict;
> use Graph::Clique;
>
> my @edges;
> my %h;
> my $nnz; # num of non-zeros
>
> # build up undirected graph
>
> while(<DATA>){
> my $i = $.+1;
> my @a = split(/ /,$_);
> for my $j (0..$#a){
> if ($a[$j]){
> $nnz++;
> my $e = $i <= $j ? $i.",".$j : $j.",".$i;
> $h{$e}++;
> }
> }
>
> }
>
> foreach my $key (sort keys %h){
> my @a = split(/\,/, $key);
> push @edges, [@a];
>
> }
>
> # find maximal clique
>
> my @cliques;
>
> for (my $k=int(sqrt($nnz)); $k>3; $k--){
> @cliques = getcliques($k,\@edges);
> if ($#cliques >=0){
> last;
> }
>
> }
>
> print join("\n", @cliques),"\n";
>
> __DATA__
> 0 0 1 0 1 0 0 0 0 0
> 0 1 1 0 0 0 0 0 0 0
> 1 1 1 0 1 0 0 1 0 0
> 1 1 1 0 0 0 0 0 0 0
> 1 1 1 0 1 0 0 1 0 1
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0
> 0 0 1 0 1 0 0 1 0 1
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 1 0 0 1 0 0

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

Re: [PerlChina] 新手请教:perl脚本在win32环境下运行遇到的问题!

WIN32的shell貌似不给力 ,不支持这种做法。

举个例子:我最近一直在看《Perl入门》,里边有这样的例子:
++++++++++++++++++++
$ echo *.pm
barney.pm dino.pm Fred.pm wilma.pm
$
++++++++++++++++++++
但是我在Win32环境下是这样的
++++++++++++++++++++
D:\Desktop>echo *.pl
*.pl

D:\Desktop>
++++++++++++++++++++

不知道有没有什么其他方法来达到类似的目的?

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要在网络上查看此讨论,请访问 https://groups.google.com/d/msg/perlchina/-/zHaM4b8EpKcJ
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

2011年7月13日星期三

Re: [PerlChina] Re: DNA,DG值。

图论解法:

找最大完全连通子图,可以用Graph::Clique,当然应该还有更好的算法;
这里只举了个10x10的小例子
用非零数的平方根作为最大子图顶点数的上限



use strict;
use Graph::Clique;



my @edges;
my %h;
my $nnz;  # num of non-zeros


# build up undirected graph

while(<DATA>){
my $i = $.+1;
 my @a = split(/ /,$_);
 for my $j (0..$#a){
  if ($a[$j]){
   $nnz++;
my $e = $i <= $j ? $i.",".$j : $j.",".$i;
$h{$e}++;
  }
 }
}

foreach my $key (sort keys %h){
my @a = split(/\,/, $key);
push @edges, [@a];
}


# find maximal clique

my @cliques;

for (my $k=int(sqrt($nnz)); $k>3; $k--){
 @cliques = getcliques($k,\@edges);
 if ($#cliques >=0){
  last;
 }
}

print join("\n", @cliques),"\n";


__DATA__
0 0 1 0 1 0 0 0 0 0
0 1 1 0 0 0 0 0 0 0
1 1 1 0 1 0 0 1 0 0
1 1 1 0 0 0 0 0 0 0
1 1 1 0 1 0 0 1 0 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 1 0 1 0 0 1 0 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 1 0 0

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

[PerlChina] Re: shebang行在Windows下也有用?

On 7月14日, 下午1时01分, nixin <nicene...@gmail.com> wrote:
> 是我想简单了。我想可以蛮力搜索:
> 在上面说的L中,有一个以上的全连通子图,目标是找出顶点最多的全连通子图。
> Step 0, x 为L顶点列表,subG_list为空。
> Step 1,x中任意找一个顶点。
> Step 2,找出此顶点在L中所在的全连通子图,并把结果记录在subG_list中。
> Step 3,x删除上一步结果中所有的全连通子图中的顶点。如果x空,结束。如果x非空,回到Step 0.
这里写错了,应该是回到Step1.
> 得到的subG_list应该是L的全连通子图集,再根据顶点个数排序就可以了。
>
> 400个点的图不算大,蛮力搜索应该不会用太久。不过一个图的全连通子图查找问题应该是一个比较经典的问题,肯定有经典算法的。我也没专门研究过图的算
> 法,不知道有没有工具能直接拿来用。
>
> On 7月14日, 上午11时33分, Hydraphenix <hydrapheni...@gmail.com> wrote:
>
>
>
>
>
>
>
> > 好像这个思路不行,有些DNA可能属于两个group,这个思路就没办法处理了。
> > 看来这个问题难度超出我的想象啊。
>
> > On 7月14日, 上午9时13分, Hydraphenix <hydrapheni...@gmail.com> wrote:
>
> > > 最近也在用perl写矩阵相关的脚本。觉得你的问题,用矩阵就可以实现了。
> > > 思路如下:
> > > 做一个循环,给每个DNA分组,若这个dna的所有target中只有一个为1(自己),那么这个组就只有自己;若这个dna的target中有多个
> > > 1,则检查target与group中的所有成员的score是否都为1,若是,加入group中,若不是,则不加入。
> > > 这个循环做下来,每个DNA都有了分组,删除那些冗余的分组,剩下都是独立的分组,再统计每组成员的个数,就完成了。
>
> > > On 7月12日, 下午8时19分, jie liu <liujie....@gmail.com> wrote:
>
> > > > 大家好!
>
> > > > 我这有个最优化问题,是关于求最大子集的,想请大家帮我想想。
> > > > 问题的具体情形是这样的:
> > > > 有一种指标dG,它能描述两两单链DNA互补杂交的热力学特征。我现在有400条DNA(编号为0,2,3...399),它们组成一个集合;我现在要从这个集 合中找到一个子集,这个子集里的任意两两DNA的dG值大于等于一个值(m=1)。因为符合这样条件的子集很多,我要找到含有最多DNA个数的那个子集。
> > > > 我的方法是这样的:方便起见,400条DNA两两之间的dG,凡dG>=1的重新赋值为1,dG<1的重新赋值为0。我把这些值写入一个2维矩阵。如图1(见附 件)。含有最多1的那一行所代表的DNA被选出来,并且把所有与这个DNA杂交指标为1的其他DNA序列的相互关系写入一个新的2维矩阵,同时也会得到一个含有 最多1的那一行,把它选出来,重复上个运算。如此反复,最终筛选出来的DNA将组成最大子集。
> > > > 我用perl写出来这个算法,但是当我扩大总DNA数时出现了问题:理论上,最大子集中DNA个数将不小于扩大之前的,但是实际上,情况相反。
> > > > 请大家帮我看看,1)这个算法有问题吗?2)你能把你的办法写成伪代码告诉我吗?如果你能用perl写成源代码最好了。
>
> > > > --
> > > > Best regards,
> > > > Liu Jie
>
> > > > 020-32015312
> > > > Guangzhou Institutes of Biomedicine and Health, Chinese Academy of Scienceshttp://www.gibh.cas.cn/
>
> > > > matrix.txt
> > > > 423K查看下载
>
> > > > 图1.jpg
> > > > 48K查看下载

--
您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。
要向此网上论坛发帖,请发送电子邮件至 perlchina@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 perlchina+unsubscribe@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。