From 7bea0e9577bdda29291eebe1782bc0966692f638 Mon Sep 17 00:00:00 2001 From: Sander Bollen <a.h.b.bollen@lumc.nl> Date: Tue, 5 Jan 2016 10:55:57 +0100 Subject: [PATCH] manwe wrapper fixes --- .../ManweActivateAfterAnnotImport.scala | 38 ++++++++++++++++--- .../toucan/ManweDownloadAfterAnnotate.scala | 36 +++++++++++++++--- 2 files changed, 64 insertions(+), 10 deletions(-) diff --git a/public/toucan/src/main/scala/nl/lumc/sasc/biopet/pipelines/toucan/ManweActivateAfterAnnotImport.scala b/public/toucan/src/main/scala/nl/lumc/sasc/biopet/pipelines/toucan/ManweActivateAfterAnnotImport.scala index 468549358..9ed3b00d0 100644 --- a/public/toucan/src/main/scala/nl/lumc/sasc/biopet/pipelines/toucan/ManweActivateAfterAnnotImport.scala +++ b/public/toucan/src/main/scala/nl/lumc/sasc/biopet/pipelines/toucan/ManweActivateAfterAnnotImport.scala @@ -1,5 +1,7 @@ package nl.lumc.sasc.biopet.pipelines.toucan +import java.io.File + import nl.lumc.sasc.biopet.extensions.manwe.{ ManweAnnotateVcf, ManweSamplesActivate, ManweSamplesImport } import nl.lumc.sasc.biopet.utils.config.Configurable @@ -24,13 +26,39 @@ class ManweActivateAfterAnnotImport(root: Configurable, override def beforeCmd: Unit = { super.beforeCmd - if (imported.output.exists()) { - val reader = Source.fromFile(imported.output) - this.uri = reader.getLines().toList.head.split(' ').last - reader.close() + this.uri = getUri + } + + def getUriFromFile(f: File): String = { + val r = if (f.exists()) { + val reader = Source.fromFile(f) + val it = reader.getLines() + if (it.isEmpty) { + throw new IllegalArgumentException("Empty manwe stderr file") + } + it.filter(_.contains("Added sample")).toList.head.split(" ").last } else { - this.uri = "" + "" } + r + } + + def getUri: String = { + val err: Option[File] = Some(imported.jobOutputFile) + uri = err match { + case None => "" + case Some(s) => s match { + case null => "" + case other => getUriFromFile(other) + } + case _ => "" + } + + uri + } + + override def subCommand = { + required("samples") + required("activate") + getUri } } diff --git a/public/toucan/src/main/scala/nl/lumc/sasc/biopet/pipelines/toucan/ManweDownloadAfterAnnotate.scala b/public/toucan/src/main/scala/nl/lumc/sasc/biopet/pipelines/toucan/ManweDownloadAfterAnnotate.scala index bdb19ffa0..e49ff7e5e 100644 --- a/public/toucan/src/main/scala/nl/lumc/sasc/biopet/pipelines/toucan/ManweDownloadAfterAnnotate.scala +++ b/public/toucan/src/main/scala/nl/lumc/sasc/biopet/pipelines/toucan/ManweDownloadAfterAnnotate.scala @@ -22,13 +22,39 @@ class ManweDownloadAfterAnnotate(root: Configurable, override def beforeCmd: Unit = { super.beforeCmd - if (annotate.output.exists()) { - val reader = Source.fromFile(annotate.output) - this.uri = reader.getLines().toList.head.split(' ').last - reader.close() + this.uri = getUri + } + + def getUriFromFile(f: File): String = { + val r = if (f.exists()) { + val reader = Source.fromFile(f) + val it = reader.getLines() + if (it.isEmpty) { + throw new IllegalArgumentException("Empty manwe stderr file") + } + it.filter(_.contains("Annotated VCF file")).toList.head.split(" ").last } else { - this.uri = "" + "" + } + r + } + + def getUri: String = { + val err: Option[File] = Some(annotate.jobOutputFile) + uri = err match { + case None => "" + case Some(s) => s match { + case null => "" + case other => getUriFromFile(other) + } + case _ => "" } + + uri + } + + override def subCommand = { + required("data-sources") + required("download") + getUri } } -- GitLab