From 59fb76fbaff9944f9d3cc9e12bd749b3a059929a Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Tue, 5 Jul 2016 15:44:01 +0200
Subject: [PATCH] posible to get list from dict now

---
 .../sasc/biopet/utils/intervals/BedRecordList.scala   | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecordList.scala b/biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecordList.scala
index 2cfb86e50..08788a294 100644
--- a/biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecordList.scala
+++ b/biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedRecordList.scala
@@ -14,12 +14,12 @@
  */
 package nl.lumc.sasc.biopet.utils.intervals
 
-import java.io.{ PrintWriter, File }
+import java.io.{ File, PrintWriter }
 
+import htsjdk.samtools.SAMSequenceDictionary
 import htsjdk.samtools.reference.FastaSequenceFile
 
 import scala.collection.JavaConversions._
-
 import scala.collection.mutable
 import scala.collection.mutable.ListBuffer
 import scala.io.Source
@@ -154,8 +154,13 @@ object BedRecordList {
 
   def fromReference(file: File) = {
     val referenceFile = new FastaSequenceFile(file, true)
+    val dict = referenceFile.getSequenceDictionary
+    referenceFile.close()
+    fromDict(dict)
+  }
 
-    fromList(for (contig <- referenceFile.getSequenceDictionary.getSequences) yield {
+  def fromDict(dict: SAMSequenceDictionary) = {
+    fromList(for (contig <- dict.getSequences) yield {
       BedRecord(contig.getSequenceName, 0, contig.getSequenceLength)
     })
   }
-- 
GitLab