2017-09-13 34 views
1

我想用命令system()在R中运行shell脚本(BLAST + in NCBI),但它似乎只使用一个线程,即使我在shell脚本中设置了多个线程。在这种情况下,我应该怎么做才能使用多线程?使用多线程在R中运行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个内核此运行?谢谢!

回答

0

随着并行:

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) 
+0

什么是1:4? –

+0

为系统调用功能分配的内核数量 –