au.csiro.variantspark.cmd.EchoUtils.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of variant-spark_2.11 Show documentation
Show all versions of variant-spark_2.11 Show documentation
Genomic variants interpretation toolkit
The newest version!
package au.csiro.variantspark.cmd
object EchoUtils {
val defaultPreviewSize: Int = 7
val longPreviewSize: Int = 20
val defaultElipses: String = "..."
def dumpList(l: List[_], maxSize: Int = defaultPreviewSize): String = {
val strList =
if (l.size <= maxSize) { l.map(_.toString) }
else {
l.take(maxSize / 2).map(_.toString) ::: (defaultElipses :: l
.takeRight(maxSize - maxSize / 2 - 1)
.map(_.toString))
}
strList.mkString("[", ",", "]") + s" total: ${l.size}"
}
def dumpListHead(l: List[_], totalSize: Long, maxSize: Int = defaultPreviewSize): String = {
val strList =
if (totalSize <= maxSize) l.map(_.toString)
else l.take(maxSize - 1).map(_.toString) ::: List(defaultElipses)
strList.mkString("[", ",", "]") + s" total: ${totalSize}"
}
}