Commit 5f91fed6 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Relax the reference check

parent 766d624d
......@@ -24,6 +24,7 @@ import htsjdk.variant.variantcontext.writer.{ AsyncVariantContextWriter, Variant
import htsjdk.variant.vcf._
import nl.lumc.sasc.biopet.utils.ToolCommand
import nl.lumc.sasc.biopet.utils.VcfUtils.scalaListToJavaObjectArrayList
import nl.lumc.sasc.biopet.utils.BamUtils.SamDictCheck
import scala.collection.JavaConversions._
......@@ -89,14 +90,14 @@ object VcfWithVcf extends ToolCommand {
val header = reader.getFileHeader
val vcfDict = header.getSequenceDictionary match {
case r if r != null =>
r.assertSameDictionary(referenceDict)
r.assertSameDictionary(referenceDict, true)
r
case _ => referenceDict
}
val secondHeader = secondaryReader.getFileHeader
secondHeader.getSequenceDictionary match {
case r if r != null => r.assertSameDictionary(referenceDict)
case r if r != null => r.assertSameDictionary(referenceDict, true)
case _ =>
}
......
......@@ -17,8 +17,8 @@ package nl.lumc.sasc.biopet.utils
import java.io.File
import htsjdk.samtools.{ SamReader, SamReaderFactory }
import nl.lumc.sasc.biopet.utils.intervals.{ BedRecord, BedRecordList }
import htsjdk.samtools.{SAMSequenceDictionary, SamReader, SamReaderFactory}
import nl.lumc.sasc.biopet.utils.intervals.{BedRecord, BedRecordList}
import scala.collection.JavaConversions._
import scala.collection.mutable
......@@ -146,4 +146,13 @@ object BamUtils {
bamFile -> sampleBamInsertSize(bamFile, samplingSize, binSize)
}.toMap
implicit class SamDictCheck(samDics: SAMSequenceDictionary) extends SAMSequenceDictionary {
def assertSameDictionary(that: SAMSequenceDictionary, ignoreOrder: Boolean): Unit = {
if (ignoreOrder) {
assert(this.getReferenceLength == that.getReferenceLength)
val thisContigNames = this.getSequences.map(x => (x.getSequenceName, x.getSequenceLength)).sorted.toSet
assert(thisContigNames == that.getSequences.map(x => (x.getSequenceName, x.getSequenceLength)).sorted.toSet)
} else assertSameDictionary(this)
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment