Skip to content
Snippets Groups Projects
Commit 50d678ff authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Added regex option

parent 2727f142
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ import nl.lumc.sasc.biopet.utils.ToolCommand
import scala.collection.mutable.ListBuffer
import scala.io.Source
import scala.util.matching.Regex
/**
* This tool will find all pairs above a cutoff in a data table
......@@ -17,7 +18,9 @@ object FindOverlapMatch extends ToolCommand {
case class Args(inputMetrics: File = null,
outputFile: Option[File] = None,
cutoff: Double = 0.0,
filterSameNames: Boolean = true) extends AbstractArgs
filterSameNames: Boolean = true,
rowSampleRegex: Option[Regex] = None,
columnSampleRegex: Option[Regex] = None) extends AbstractArgs
class OptParser extends AbstractOptParser {
opt[File]('i', "input") required () unbounded () valueName "<file>" action { (x, c) =>
......@@ -32,7 +35,12 @@ object FindOverlapMatch extends ToolCommand {
opt[Unit]("use_same_names") unbounded () valueName "<value>" action { (x, c) =>
c.copy(filterSameNames = false)
} text "Do not compare samples with the same name"
opt[String]("rowSampleRegex") unbounded () valueName "<regex>" action { (x, c) =>
c.copy(rowSampleRegex = Some(x.r))
}
opt[String]("columnSampleRegex") unbounded () valueName "<regex>" action { (x, c) =>
c.copy(columnSampleRegex = Some(x.r))
}
}
/**
......@@ -58,9 +66,9 @@ object FindOverlapMatch extends ToolCommand {
case _ => sys.process.stdout
}
for (i1 <- samplesColumnHeader) {
for (i1 <- samplesColumnHeader if cmdArgs.columnSampleRegex.map(_.findFirstIn(i1._1).isDefined).getOrElse(true)) {
val buffer = ListBuffer[(String, Double)]()
for (i2 <- samplesRowHeader) {
for (i2 <- samplesRowHeader if cmdArgs.rowSampleRegex.map(_.findFirstIn(i2._1).isDefined).getOrElse(true)) {
val value = data(i1._2)(i2._2).toDouble
if (value >= cmdArgs.cutoff && (!cmdArgs.filterSameNames || i1._2 != i2._2)) {
buffer.+=((i2._1, value))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment