From 0886c76f3c8a5177fcee354133226f20b8f3fc68 Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Tue, 11 Nov 2014 15:00:59 +0100
Subject: [PATCH] Added general vcf utils

---
 .../nl/lumc/sasc/biopet/util/VcfUtils.scala   | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 biopet-framework/src/main/scala/nl/lumc/sasc/biopet/util/VcfUtils.scala

diff --git a/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/util/VcfUtils.scala b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/util/VcfUtils.scala
new file mode 100644
index 000000000..c91f5b2a0
--- /dev/null
+++ b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/util/VcfUtils.scala
@@ -0,0 +1,19 @@
+package nl.lumc.sasc.biopet.util
+
+import htsjdk.variant.variantcontext.VariantContext
+import scala.collection.JavaConversions._
+
+/** Utility object for general vcf file/records functions. */
+object VcfUtils {
+  /**
+   * Return longest allele of VariantContext.
+   *
+   * @param vcfRecord record to check
+   * @return allele with most nucleotides 
+   */
+  def getLongestAllele(vcfRecord: VariantContext) = {
+    val alleles = vcfRecord.getAlleles
+    val longestAlleleId = alleles.map(_.getBases.length).zipWithIndex.maxBy(_._1)._2
+    alleles(longestAlleleId)
+  }
+}
-- 
GitLab