au.csiro.variantspark.output.CSVFeatureSink.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.output
import au.csiro.variantspark.input.FeatureSource
import java.io.FileWriter
import au.csiro.pbdava.ssparkle.common.utils.CSVUtils
import java.io.File
/**
* This only works for smallish datasets (used local files)
*/
case class CSVFeatureSink(fileName: String) extends FeatureSink {
def save(fs: FeatureSource) {
CSVUtils.withFile(new File(fileName)) { csvWriter =>
csvWriter.writeRow("" :: fs.sampleNames)
csvWriter.writeAll(fs.features.collect().toSeq.map(f => f.label :: f.valueAsStrings))
}
}
}