Skip to content
Snippets Groups Projects
Commit 92fd93df authored by Wai Yi Leung's avatar Wai Yi Leung
Browse files

Reducing the wrapper to take bam and chrom.sizes file only

parent faeb9100
Branches
Tags
No related merge requests found
...@@ -16,8 +16,8 @@ class IGVToolsCount(val root: Configurable) extends IGVTools { ...@@ -16,8 +16,8 @@ class IGVToolsCount(val root: Configurable) extends IGVTools {
@Input(doc = "Bam File") @Input(doc = "Bam File")
var input: File = _ var input: File = _
@Argument(doc = "Genome name") @Input(doc = "<genome>.chrom.sizes File")
var genomeName: String = config("genomeName") var genomeChromSizes: File = _
@Output @Output
protected var tdf: File = _ protected var tdf: File = _
...@@ -48,30 +48,14 @@ class IGVToolsCount(val root: Configurable) extends IGVTools { ...@@ -48,30 +48,14 @@ class IGVToolsCount(val root: Configurable) extends IGVTools {
this.tdf = new File(input.getAbsolutePath + ".tdf") this.tdf = new File(input.getAbsolutePath + ".tdf")
this.wig = new File(input.getAbsolutePath.stripSuffix(".bam") + ".wig") this.wig = new File(input.getAbsolutePath.stripSuffix(".bam") + ".wig")
// check genome name or File
val genome = new File(genomeName)
if (!genome.exists()) {
// check in the IGVTools genome/directory
val genomeInDir = new File(new File(executable).getParent + File.separator + "genomes" + File.separator + genomeName + ".chrom.sizes")
if (!genomeInDir.exists()) {
throw new FileNotFoundException("genomeName contains a invalid filepath/genomename or not supported by IGVTools")
} else {
genomeName = genomeInDir.getAbsolutePath
}
} else {
// redefine the genomeName.
genomeName = genome.getAbsolutePath
}
} }
def cmdLine = { def cmdLine = {
required(executable) + required(executable) +
required("count") + required("count") +
optional("-z", maxZoom) + optional("--maxZoom", maxZoom) +
optional("-w", windowSize) + optional("--windowSize", windowSize) +
optional("-e", extFactor) + optional("--extFactor", extFactor) +
optional("--preExtFactor", preExtFactor) + optional("--preExtFactor", preExtFactor) +
optional("--postExtFactor", postExtFactor) + optional("--postExtFactor", postExtFactor) +
optional("--windowFunctions", windowFunctions) + optional("--windowFunctions", windowFunctions) +
...@@ -83,9 +67,13 @@ class IGVToolsCount(val root: Configurable) extends IGVTools { ...@@ -83,9 +67,13 @@ class IGVToolsCount(val root: Configurable) extends IGVTools {
conditional(pairs, "--pairs") + conditional(pairs, "--pairs") +
required(input) + required(input) +
required(outputArg) + required(outputArg) +
required(genomeName) required(genomeChromSizes)
} }
/**
* This part should never fail, these values are set within this wrapper
*
*/
private def outputArg: String = { private def outputArg: String = {
(tdf.isInstanceOf[File], wig.isInstanceOf[File]) match { (tdf.isInstanceOf[File], wig.isInstanceOf[File]) match {
case (false, false) => throw new IllegalArgumentException("Either TDF or WIG should be supplied"); case (false, false) => throw new IllegalArgumentException("Either TDF or WIG should be supplied");
...@@ -102,16 +90,14 @@ object IGVToolsCount { ...@@ -102,16 +90,14 @@ object IGVToolsCount {
* and the `genomename` (hg18,hg19,mm10) * and the `genomename` (hg18,hg19,mm10)
* *
* @param input Bamfile to count reads from * @param input Bamfile to count reads from
* @param genomename Name of path to the genome.chrsizes.bed,
* @return a new IGVToolsCount instance * @return a new IGVToolsCount instance
* @throws FileNotFoundException bam File is not found * @throws FileNotFoundException bam File is not found
* @throws IllegalArgumentException tdf or wig not supplied * @throws IllegalArgumentException tdf or wig not supplied
*/ */
def apply(root: Configurable, input: File, def apply(root: Configurable, input: File, genomeChromSizes: File): IGVToolsCount = {
genomename: String): IGVToolsCount = {
val counting = new IGVToolsCount(root) val counting = new IGVToolsCount(root)
counting.input = input counting.input = input
counting.genomeName = genomename counting.genomeChromSizes = genomeChromSizes
return counting return counting
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment