我有以下代码:
s"""java ${MemString} -jar ${toolsFolder}/GenomeAnalysisTK.jar -T IndelRealigner -R ${refFolder}/${RefFileName} -I ${tmpFolder}/region${chrRegion}.bam
-targetIntervals ${tmpFolder}/region${chrRegion}.intervals -o ${tmpFolder}/region${chrRegion}-2.bam -L ${tmpFolder}/bed${chrRegion}.bed""" !
s"rm -rf ${tmpFolder}/region${chrRegion}.bam, ${tmpFolder}/region${chrRegion}.bai, ${tmpFolder}/region${chrRegion}.intervals" !
由于第一行有一个很大的输入字符串,我试图为进程使用多行字符串输入。但我收到以下错误:
sbt package
[info] Set current project to DNASeqAnalyzer (in build file:/home/sarthaksharma/Lab3/dnaseq_analyzer/)
[info] Compiling 1 Scala source to /home/sarthaksharma/Lab3/dnaseq_analyzer/target/scala-2.11/classes...
[error] /home/sarthaksharma/Lab3/dnaseq_analyzer/src/main/scala/DNASeqAnalyzer.scala:148 : type mismatch;
[error] found : String
[error] required: scala.sys.process.ProcessLogger
[error] s"rm -rf ${tmpFolder}/region${chrRegion}.bam, ${tmpFolder}/region${chrRegion}.bai, ${tmpFolder}/region${chrRegion}.intervals" !
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
如果我评论代码的第一行,它运行正常。为什么它显示不同行的错误?我该怎么办呢?
答案 0 :(得分:2)
问题出现是因为您点击了替代方法.!(logger)
,而不是没有参数的方法。所以尽量明确地写点:
s"""long
command""".!
s"another command".!
另外,我建议你将任何命令构造为字符串序列,这解决了你的长命令问题,并且对于如何解释(和转义)参数不那么模糊:
Seq(
"command",
s"option=${value}",
"argument"
).!