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

Add nested option to originals

parent fb9e71f4
No related branches found
No related tags found
No related merge requests found
......@@ -40,8 +40,7 @@ object RegionAfCount extends ToolCommand {
case class Args(bedFile: File = null,
outputFile: File = null,
scatterpPlot: Option[File] = None,
vcfFiles: List[File] = Nil,
exonsOnly: Boolean = false) extends AbstractArgs
vcfFiles: List[File] = Nil) extends AbstractArgs
class OptParser extends AbstractOptParser {
opt[File]('b', "bedFile") required () maxOccurs 1 valueName "<file>" action { (x, c) =>
......@@ -56,9 +55,6 @@ object RegionAfCount extends ToolCommand {
opt[File]('V', "vcfFile") unbounded () minOccurs 1 action { (x, c) =>
c.copy(vcfFiles = c.vcfFiles ::: x :: Nil)
}
opt[Unit]("exonsOnly") unbounded () action { (x, c) =>
c.copy(exonsOnly = true)
}
}
def main(args: Array[String]): Unit = {
......@@ -89,8 +85,8 @@ object RegionAfCount extends ToolCommand {
case a: util.ArrayList[_] => a.map(_.toString.toDouble).toArray
case s => Array(s.toString.toDouble)
}).sum
region.originals
.map(_.name.getOrElse("error"))
region.originals()
.map(x => x.name.getOrElse(s"${x.chr}:${x.start}-${x.end}"))
.distinct
.foreach(name => afCounts += name -> (afCounts.getOrElse(name, 0.0) + sum))
}
......
......@@ -18,7 +18,11 @@ case class BedRecord(chr: String,
protected[intervals] var _originals: List[BedRecord] = Nil
def originals = _originals
def originals(nested: Boolean = false): List[BedRecord] = {
if (_originals.isEmpty) List(this)
else if (nested) _originals.flatMap(_.originals(true))
else _originals
}
lazy val exons = if (blockCount.isDefined && blockSizes.length > 0 && blockStarts.length > 0) {
Some(BedRecordList.fromList(for (i <- 0 to blockCount.get) yield {
......@@ -62,14 +66,14 @@ object BedRecord {
values(2).toInt,
values.lift(3),
values.lift(4).map(_.toInt),
values.lift(5).map(_ match {
values.lift(5).map {
case "-" => false
case "+" => true
case _ => throw new IllegalStateException("Strand (column 6) must be '+' or '-'")
}),
case _ => throw new IllegalStateException("Strand (column 6) must be '+' or '-'")
},
values.lift(6).map(_.toInt),
values.lift(7) map (_.toInt),
values.lift(8).map(_.split(",", 3).map(_.toInt)).map(x => (x.lift(0).getOrElse(0), x.lift(1).getOrElse(0), x.lift(2).getOrElse(0))),
values.lift(8).map(_.split(",", 3).map(_.toInt)).map(x => (x.headOption.getOrElse(0), x.lift(1).getOrElse(0), x.lift(2).getOrElse(0))),
values.lift(9).map(_.toInt),
values.lift(10).map(_.split(",").map(_.toInt)).getOrElse(Array()),
values.lift(11).map(_.split(",").map(_.toInt)).getOrElse(Array())
......
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