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 0000000000000000000000000000000000000000..c91f5b2a0f836fdac0bb12a754f51e0a88e11cc4 --- /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) + } +}