Move swapExt() methods to QScriptUtils, have versions in QScript class call into the util versions

This commit is contained in:
David Roazen 2015-07-23 10:12:46 -04:00
parent 66cf22b28f
commit 5fd3d2be76
2 changed files with 24 additions and 4 deletions

View File

@ -82,8 +82,7 @@ trait QScript extends Logging with PrimitiveOptionConversions with StringFileCon
* @param newExtension New extension to append.
* @return new File with the new extension in the current directory.
*/
protected def swapExt(file: File, oldExtension: String, newExtension: String) =
new File(file.getName.stripSuffix(oldExtension) + newExtension)
protected def swapExt(file: File, oldExtension: String, newExtension: String) = QScriptUtils.swapExt(file, oldExtension, newExtension)
/**
* Exchanges the extension on a file.
@ -93,8 +92,7 @@ trait QScript extends Logging with PrimitiveOptionConversions with StringFileCon
* @param newExtension New extension to append.
* @return new File with the new extension in dir.
*/
protected def swapExt(dir: File, file: File, oldExtension: String, newExtension: String) =
new File(dir, file.getName.stripSuffix(oldExtension) + newExtension)
protected def swapExt(dir: File, file: File, oldExtension: String, newExtension: String) = QScriptUtils.swapExt(dir, file, oldExtension, newExtension)
/**
* Adds one or more command line functions to be run.
@ -181,4 +179,5 @@ object QScript {
def resetAddOrder() {
addOrder = 0
}
}

View File

@ -41,6 +41,27 @@ import collection.JavaConversions._
object QScriptUtils {
/**
* Exchanges the extension on a file.
* @param file File to look for the extension.
* @param oldExtension Old extension to strip off, if present.
* @param newExtension New extension to append.
* @return new File with the new extension in the current directory.
*/
def swapExt(file: File, oldExtension: String, newExtension: String) =
new File(file.getName.stripSuffix(oldExtension) + newExtension)
/**
* Exchanges the extension on a file.
* @param dir New directory for the file.
* @param file File to look for the extension.
* @param oldExtension Old extension to strip off, if present.
* @param newExtension New extension to append.
* @return new File with the new extension in dir.
*/
def swapExt(dir: File, file: File, oldExtension: String, newExtension: String) =
new File(dir, file.getName.stripSuffix(oldExtension) + newExtension)
/**
* Takes a bam list file and produces a scala sequence with each file allowing the bam list
* to have empty lines and comment lines (lines starting with #).