【问题标题】:Run a shell script in R with multithreading [duplicate]使用多线程在 R 中运行 shell 脚本 [重复]
【发布时间】:2017-09-13 17:10:48
【问题描述】:

我想使用命令 system() 在 R 中运行一个 shell 脚本(NCBI 中的 BLAST+),但即使我在 shell 脚本中设置了多个线程,它似乎也只使用一个线程。在这种情况下我应该怎么做才能使用多个线程?

代码是 system("blastp -query query.fasta -db db.fasta -num_threads 16 -outfmt \"6 qseqid sseqid pident ppos evalue bitscore qcovs\" -out out.tsv")

如何在 R 中运行 16 个内核?谢谢!

【问题讨论】:

    标签: r multithreading parallel-processing bioinformatics blast


    【解决方案1】:

    并行:

    library(parallel)
    ncore = 4
    
    syscall = system("blastp -query query.fasta -db db.fasta -num_threads 16 -outfmt \"6 qseqid sseqid pident ppos evalue bitscore qcovs\" -out out.tsv")
    mclapply(1:ncore,syscall,mc.cores=ncore)
    

    【讨论】:

    • 什么是 1:4?
    • 为系统调用函数分配的核心数
    猜你喜欢
    • 2019-03-04
    • 1970-01-01
    • 2020-06-23
    • 1970-01-01
    • 2013-06-30
    • 1970-01-01
    • 2020-02-02
    • 1970-01-01
    • 2021-10-22
    相关资源
    最近更新 更多