Fixed issue reported by chartl where cloned functions lost tags on @Inputs.
Updated ExampleUnifiedGenotyper.scala with new syntax.
This commit is contained in:
parent
3cd9f3fe81
commit
33967a4e0c
|
|
@ -56,15 +56,15 @@ class ExampleUnifiedGenotyper extends QScript {
|
||||||
genotyper.input_file :+= qscript.bamFile
|
genotyper.input_file :+= qscript.bamFile
|
||||||
genotyper.out = swapExt(qscript.bamFile, "bam", "unfiltered.vcf")
|
genotyper.out = swapExt(qscript.bamFile, "bam", "unfiltered.vcf")
|
||||||
|
|
||||||
evalUnfiltered.rodBind :+= RodBind("eval", "VCF", genotyper.out)
|
evalUnfiltered.eval :+= genotyper.out
|
||||||
evalUnfiltered.out = swapExt(genotyper.out, "vcf", "eval")
|
evalUnfiltered.out = swapExt(genotyper.out, "vcf", "eval")
|
||||||
|
|
||||||
variantFilter.rodBind :+= RodBind("variant", "VCF", genotyper.out)
|
variantFilter.variant = genotyper.out
|
||||||
variantFilter.out = swapExt(qscript.bamFile, "bam", "filtered.vcf")
|
variantFilter.out = swapExt(qscript.bamFile, "bam", "filtered.vcf")
|
||||||
variantFilter.filterName = filterNames
|
variantFilter.filterName = filterNames
|
||||||
variantFilter.filterExpression = filterExpressions.map("\"" + _ + "\"")
|
variantFilter.filterExpression = filterExpressions.map("\"" + _ + "\"")
|
||||||
|
|
||||||
evalFiltered.rodBind :+= RodBind("eval", "VCF", variantFilter.out)
|
evalFiltered.eval :+= variantFilter.out
|
||||||
evalFiltered.out = swapExt(variantFilter.out, "vcf", "eval")
|
evalFiltered.out = swapExt(variantFilter.out, "vcf", "eval")
|
||||||
|
|
||||||
add(genotyper, evalUnfiltered)
|
add(genotyper, evalUnfiltered)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package org.broadinstitute.sting.queue.extensions.gatk
|
package org.broadinstitute.sting.queue.extensions.gatk
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import org.broadinstitute.sting.queue.function.FileExtension
|
import org.broadinstitute.sting.queue.util.FileExtension
|
||||||
import java.lang.String
|
import java.lang.String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package org.broadinstitute.sting.queue.extensions.gatk
|
package org.broadinstitute.sting.queue.extensions.gatk
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import org.broadinstitute.sting.queue.function.FileExtension
|
import org.broadinstitute.sting.queue.util.FileExtension
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to provide tagged -I input_file arguments to the GATK.
|
* Used to provide tagged -I input_file arguments to the GATK.
|
||||||
|
|
|
||||||
|
|
@ -387,25 +387,11 @@ trait QFunction extends Logging with QJobReport {
|
||||||
*/
|
*/
|
||||||
protected def canon(value: Any) = {
|
protected def canon(value: Any) = {
|
||||||
value match {
|
value match {
|
||||||
case fileExtension: FileExtension =>
|
case file: File => IOUtils.absolute(commandDirectory, file)
|
||||||
val newFile = absolute(fileExtension);
|
|
||||||
val newFileExtension = fileExtension.withPath(newFile.getPath)
|
|
||||||
newFileExtension
|
|
||||||
case file: File =>
|
|
||||||
if (file.getClass != classOf[File])
|
|
||||||
throw new QException("Extensions of file must also extend with FileExtension so that the path can be modified.");
|
|
||||||
absolute(file)
|
|
||||||
case x => x
|
case x => x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the absolute path to the file relative to the run directory and the job command directory.
|
|
||||||
* @param file File to root relative to the command directory if it is not already absolute.
|
|
||||||
* @return The absolute path to file.
|
|
||||||
*/
|
|
||||||
private def absolute(file: File) = IOUtils.absolute(commandDirectory, file)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scala sugar type for checking annotation required and exclusiveOf.
|
* Scala sugar type for checking annotation required and exclusiveOf.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package org.broadinstitute.sting.queue.function
|
package org.broadinstitute.sting.queue.util
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
|
@ -3,6 +3,7 @@ package org.broadinstitute.sting.queue.util
|
||||||
import org.apache.commons.io.FileUtils
|
import org.apache.commons.io.FileUtils
|
||||||
import java.io.{FileReader, File}
|
import java.io.{FileReader, File}
|
||||||
import org.broadinstitute.sting.utils.exceptions.UserException
|
import org.broadinstitute.sting.utils.exceptions.UserException
|
||||||
|
import org.broadinstitute.sting.queue.QException
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of utilities for modifying java.io.
|
* A collection of utilities for modifying java.io.
|
||||||
|
|
@ -12,7 +13,7 @@ object IOUtils extends Logging {
|
||||||
* Checks if the temp directory has been setup and throws an exception if they user hasn't set it correctly.
|
* Checks if the temp directory has been setup and throws an exception if they user hasn't set it correctly.
|
||||||
* @param tempDir Temporary directory.
|
* @param tempDir Temporary directory.
|
||||||
*/
|
*/
|
||||||
def checkTempDir(tempDir: File) = {
|
def checkTempDir(tempDir: File) {
|
||||||
val tempDirPath = tempDir.getAbsolutePath
|
val tempDirPath = tempDir.getAbsolutePath
|
||||||
// Keeps the user from leaving the temp directory as the default, and on Macs from having pluses
|
// Keeps the user from leaving the temp directory as the default, and on Macs from having pluses
|
||||||
// in the path which can cause problems with the Google Reflections library.
|
// in the path which can cause problems with the Google Reflections library.
|
||||||
|
|
@ -20,7 +21,7 @@ object IOUtils extends Logging {
|
||||||
if (tempDirPath.startsWith("/var/folders/") || (tempDirPath == "/tmp") || (tempDirPath == "/tmp/"))
|
if (tempDirPath.startsWith("/var/folders/") || (tempDirPath == "/tmp") || (tempDirPath == "/tmp/"))
|
||||||
throw new UserException.BadTmpDir("java.io.tmpdir must be explicitly set")
|
throw new UserException.BadTmpDir("java.io.tmpdir must be explicitly set")
|
||||||
if (!tempDir.exists && !tempDir.mkdirs)
|
if (!tempDir.exists && !tempDir.mkdirs)
|
||||||
throw new UserException.BadTmpDir("Could not create directory: " + tempDir.getAbsolutePath())
|
throw new UserException.BadTmpDir("Could not create directory: " + tempDir.getAbsolutePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -35,9 +36,9 @@ object IOUtils extends Logging {
|
||||||
throw new UserException.BadTmpDir("Could not create temp directory: " + tempDirParent)
|
throw new UserException.BadTmpDir("Could not create temp directory: " + tempDirParent)
|
||||||
val temp = File.createTempFile(prefix + "-", suffix, tempDirParent)
|
val temp = File.createTempFile(prefix + "-", suffix, tempDirParent)
|
||||||
if (!temp.delete)
|
if (!temp.delete)
|
||||||
throw new UserException.BadTmpDir("Could not delete sub file: " + temp.getAbsolutePath())
|
throw new UserException.BadTmpDir("Could not delete sub file: " + temp.getAbsolutePath)
|
||||||
if (!temp.mkdir)
|
if (!temp.mkdir)
|
||||||
throw new UserException.BadTmpDir("Could not create sub directory: " + temp.getAbsolutePath())
|
throw new UserException.BadTmpDir("Could not create sub directory: " + temp.getAbsolutePath)
|
||||||
absolute(temp)
|
absolute(temp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,7 +47,7 @@ object IOUtils extends Logging {
|
||||||
* @param file File to write to.
|
* @param file File to write to.
|
||||||
* @param content Content to write.
|
* @param content Content to write.
|
||||||
*/
|
*/
|
||||||
def writeContents(file: File, content: String) = FileUtils.writeStringToFile(file, content)
|
def writeContents(file: File, content: String) { FileUtils.writeStringToFile(file, content) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads content of a file into a string.
|
* Reads content of a file into a string.
|
||||||
|
|
@ -146,10 +147,12 @@ object IOUtils extends Logging {
|
||||||
* @return The absolute path to the file in the parent dir if the path was not absolute, otherwise the original path.
|
* @return The absolute path to the file in the parent dir if the path was not absolute, otherwise the original path.
|
||||||
*/
|
*/
|
||||||
def absolute(parent: File, file: File): File = {
|
def absolute(parent: File, file: File): File = {
|
||||||
if (file.isAbsolute)
|
val newPath =
|
||||||
absolute(file)
|
if (file.isAbsolute)
|
||||||
else
|
absolutePath(file)
|
||||||
absolute(new File(parent, file.getPath))
|
else
|
||||||
|
absolutePath(new File(parent, file.getPath))
|
||||||
|
replacePath(file, newPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -159,6 +162,10 @@ object IOUtils extends Logging {
|
||||||
* @return the absolute path to the file.
|
* @return the absolute path to the file.
|
||||||
*/
|
*/
|
||||||
def absolute(file: File) = {
|
def absolute(file: File) = {
|
||||||
|
replacePath(file, absolutePath(file))
|
||||||
|
}
|
||||||
|
|
||||||
|
private def absolutePath(file: File) = {
|
||||||
var fileAbs = file.getAbsoluteFile
|
var fileAbs = file.getAbsoluteFile
|
||||||
var names = List.empty[String]
|
var names = List.empty[String]
|
||||||
while (fileAbs != null) {
|
while (fileAbs != null) {
|
||||||
|
|
@ -190,7 +197,18 @@ object IOUtils extends Logging {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new File(names.mkString("/", "/", ""))
|
names.mkString("/", "/", "")
|
||||||
|
}
|
||||||
|
|
||||||
|
private def replacePath(file: File, path: String) = {
|
||||||
|
file match {
|
||||||
|
case fileExtension: FileExtension =>
|
||||||
|
fileExtension.withPath(path)
|
||||||
|
case file: File =>
|
||||||
|
if (file.getClass != classOf[File])
|
||||||
|
throw new QException("Sub classes of java.io.File must also implement FileExtension so that the path can be modified.")
|
||||||
|
new File(path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue