【问题标题】:open3-error when trying to run a script using PBS::Client尝试使用 PBS::Client 运行脚本时出现 open3-error
【发布时间】:2014-01-31 09:34:52
【问题描述】:

我正在尝试使以下 perl 脚本正常工作。首先,读取一个 fastq 文件,然后使用该文件被许多程序分析。

代码:

use warnings;
use PBS::Client;

$directory = $ARGV[0];

opendir(DIR, $directory);

@files=();
while ($file = readdir(DIR)) {

        push(@files, $file);
}

closedir(DIR);

@fastq_files = grep(/fastq/, @files);


$client = PBS::Client->new();

foreach $fastq (@fastq_files){

    @commands = ();
    $wd       = "/store/www/labresults_QC/snRNA_sequence_analyser/".$ARGV[0];
    $name     = $fastq."_process_map";
    $queue    = "system";
    $wallt    = "72:00:00";

    chomp($fastq);
    $fastq =~ /.+[^\.fastq]/;

    push (@commands, "/opt/fastx_toolkit-0.0.13.2/bin/fastq_quality_filter -q 30 -p 80 -i " . $fastq . " -o ";
    push (@commands, "/opt/fastx_toolkit-0.0.13.2/bin/fastx_clipper -i " . $& . "_qc.fastq -o " . $& . "_qc_clipped.fastq -v -l 15 -a TGGAATTCTCGGGTGCCAAGG -Q33\n");
    push (@commands, "/opt/fastx_toolkit-0.0.13.2/bin/fastx_collapser -i " . $& . "_qc_clipped.fastq -o " . $& . "_qc_clipped_collapse.fa -v -Q33\n");
    push (@commands, "/opt/bowtie-1.0.0/bowtie -f /opt/genomes/9606/GRCh37/bowtie/GRCh37 "  . $& . "_qc_clipped_collapse.fa " . $& . "_mapped.sam -k 100 -n 0 -l 25 --best");

    $job = PBS::Client::Job -> new(
        wd    => $wd,
        queue => $queue,
        name  => $name,
        wallt => $wallt,
        cmd   => [[@commands]]);

    $client -> qsub($job);

}

但是,当尝试通过 Linux 命令行执行时,它会给出以下错误消息:

open3: exec of /store/www/labresults_QC/snRNA_sequence_analyser/data/data_raw/test_run/n8XyeYIkfv failed at /store/bin/perl_libs/lib/perl5//PBS/Client.pm line 150

错误信息指向PBS Client模块中的这段代码:

#-------------------------------------------------------------------
# Thanks to Sander Hulst
sub call_qsub
{
    my @args = @_;

    # If the qsub command fails, for instance, pbs_server is not running,
    # PBS::Client's qsub should not silently ignore. Disable any reaper
    # functions so the exit code can be captured
    use Symbol qw(gensym);
    use IPC::Open3;
    my $stdout = gensym();
    my $stderr = gensym();
    {
        local $SIG{CHLD} = sub{};
        my $pid = open3(gensym, $stdout, $stderr, @args);   # This is line 150
        waitpid($pid,0);
    }
    confess <$stderr> if ($?);
    return <$stdout>;
}
#-------------------------------------------------------------------

有人知道这是什么意思吗?

编辑
经过一番调查,这条线似乎失败了:$client -&gt; qsub($job); 但我不知道为什么。任何想法我做错了什么?


最终编辑:

所以,我们终于找到了问题的真正原因。事实证明,我们在最新安装的PBS::Client 中出了点问题。所以我们恢复到旧版本,问题就解决了!

【问题讨论】:

  • use strict; 添加到文件顶部并声明(使用my)所有变量是强烈推荐的,因为它可以防止许多简单的错误。您是否查看过 PBS Client 模块的第 150 行及其文档?检查导致第 150 行的代码应该可以提供一些关于发生了什么以及报告错误的原因的线索。
  • 我已经做了use strictmy,但它仍然给出了这个错误。错误指向的那一行也没有让我更聪明......
  • 我附上了PBS Client的相关代码

标签: perl pbs qsub fastq


【解决方案1】:

模块生成一个脚本,然后尝试执行它而不使其可执行。解决方法:

use PBS::Client qw( );
BEGIN {
   my $orig_genScript = \&PBS::Client::genScript;
   my $new_genScript = sub {
      my $script_qfn = $orig_genScript->(@_);
      chmod(0700, $script_qfn) or die $!;
      return $script_qfn;
   };

   no warnings 'redefine';
   *PBS::Client::genScript = $new_genScript;
}

【讨论】:

  • 对于不知道的人来说,这是猴子补丁的一个实例。
  • 感谢 ikegami,它完全符合我的要求。
猜你喜欢
  • 1970-01-01
  • 2019-05-12
  • 1970-01-01
  • 2021-01-22
  • 2022-10-08
  • 1970-01-01
  • 2013-03-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多