From 66ce14ba5b90e06df1aad2a28d5b9ebf5dc75f01 Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Sun, 23 Aug 2015 09:38:29 +0200
Subject: [PATCH] Full bed record output

---
 .../sasc/biopet/utils/intervals/BedRecord.scala     | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecord.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecord.scala
index d396464ff..a7e346fb6 100644
--- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecord.scala
+++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecord.scala
@@ -50,9 +50,18 @@ case class BedRecord(chr: String,
     }))
   } else None
 
-  //TODO: Complete bed line output
   override def toString = {
-    s"$chr\t$start\t$end"
+    def arrayToOption[T](array: Array[T]): Option[Array[T]] = {
+      if (array.isEmpty) None
+      else Some(array)
+    }
+    List(Some(chr), Some(start), Some(end),
+      name, score, strand.map(if (_) "+" else "-"),
+      thickStart, thickEnd, rgbColor.map(x => s"${x._1},${x._2},${x._3}"),
+      blockCount, arrayToOption(blockSizes).map(_.mkString(",")), arrayToOption(blockStarts).map(_.mkString(",")))
+      .takeWhile(_.isDefined)
+      .flatten
+      .mkString("\t")
   }
 }
 
-- 
GitLab