【问题标题】:gnu parallel not recognize user-defined functionsgnu 并行无法识别用户定义的函数
【发布时间】:2015-02-17 16:30:39
【问题描述】:

我无法获得 gnu 并行函数来实现我构建的自定义函数。

我的功能是:

function run_cuffLinks() {
    inputBAM="${HOME}/Analyses/P_miniata/CleanUpPipeline/TH_${1}/${1}.realigned.bam"
    if [[ ! -f $inputBAM ]]; then echo -e "$inputBAM could not be found\nexit 1" ; fi 
    WORKING_DIR="${HOME}/data/CuffLinks/TH_$1"
    if [[ ! -d $WORKING_DIR ]]; then mkdir -p $WORKING_DIR; fi

    REF="${HOME}/ReferenceSequences/GATK_pmin.scaf.fa"
    if [[ ! -f $REF ]]; then echo -e "$inputBAM could not be found\nexit 1" ; exit 1; fi 

    GTF_FILE="${HOME}/ReferenceSequences/genes.sorted.gff3"    
    if [[ ! -f $GTF_FILE ]]; then echo -e "$inputBAM could not be found\nexit 1" ; exit 1; fi 

    cufflinks \
    --output-dir $WORKING_DIR \
    --num-threads 2 \
    --frag-len-mean 100 \
    --GTF-guide $GTF_FILE \
    --frag-bias-correct $REF \
    -L "HH" \
    $inputBAM ;
}

当我进入时:

parallel --no-notice -j+2 run_cuffLinks {} ::: sample1 sample2 sample3

我得到了输出:

/bin/bash: run_cuffLinks: command not found
/bin/bash: run_cuffLinks: command not found
/bin/bash: run_cuffLinks: command not found

如果我在函数名前包含一个“$”符号,我会得到:

/bin/bash: sample1: command not found
/bin/bash: sample2: command not found
/bin/bash: sample3: command not found

我也尝试过使用 -pipe --recend 和 --rrs 选项,但没有得到肯定的结果。 GNU 并行不能处理用户定义的函数吗?

【问题讨论】:

    标签: function user-defined-functions gnu gnu-parallel


    【解决方案1】:

    你不写你是否已经完成了教程(man parallel_tutorial)。因为它表明你必须export -f这个函数,因为你没有写这个,我相信你可能已经忘记了:

    export -f run_cuffLinks
    parallel ...
    

    从 20180522 版本开始你也可以使用env_parallel:

    env_parallel --session
    [define functions and variables here that you want parallel to see]
    # Use env_parallel like you would parallel
    env_parallel run_cuffLinks ...
    

    PS:使用--bibtex 一次,避免以后使用--no-notice。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-03
      • 2011-05-06
      • 2017-06-21
      • 2021-01-21
      • 1970-01-01
      • 1970-01-01
      • 2016-05-06
      相关资源
      最近更新 更多