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 468549358128afb21e5bf829ef9975c2bdf55f55..9ed3b00d01d42e21eec88ac3e3ccb5a03af4203d 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 bdb19ffa05f2fdcbe12b970fbd70ef83f97fce33..e49ff7e5ed4d7ba91fd0bd1ef8b877bf58c3c296 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 } }