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

Skip checks when running on an empty vcf file

parent e2c9fe3a
......@@ -57,31 +57,34 @@ object VepNormalizer extends ToolCommand {
}
val header = reader.getFileHeader
logger.debug("Checking for CSQ tag")
csqCheck(header)
logger.debug("CSQ tag OK")
logger.debug("Checkion VCF version")
versionCheck(header)
logger.debug("VCF version OK")
logger.debug("Parsing header")
val newInfos = parseCsq(header)
header.setWriteCommandLine(true)
val writer = new AsyncVariantContextWriter(new VariantContextWriterBuilder().
setOutputFile(output).setReferenceDictionary(header.getSequenceDictionary)
build ())
for (info <- newInfos) {
val tmpheaderline = new VCFInfoHeaderLine(info, VCFHeaderLineCount.UNBOUNDED, VCFHeaderLineType.String, "A VEP annotation")
header.addMetaDataLine(tmpheaderline)
}
logger.debug("Header parsing done")
build())
if (reader.iterator().hasNext) {
logger.debug("Checking for CSQ tag")
csqCheck(header)
logger.debug("CSQ tag OK")
logger.debug("Checkion VCF version")
versionCheck(header)
logger.debug("VCF version OK")
logger.debug("Parsing header")
val newInfos = parseCsq(header)
header.setWriteCommandLine(true)
for (info <- newInfos) {
val tmpheaderline = new VCFInfoHeaderLine(info, VCFHeaderLineCount.UNBOUNDED, VCFHeaderLineType.String, "A VEP annotation")
header.addMetaDataLine(tmpheaderline)
}
logger.debug("Header parsing done")
logger.debug("Writing header to file")
logger.debug("Writing header to file")
writer.writeHeader(header)
logger.debug("Wrote header to file")
writer.writeHeader(header)
logger.debug("Wrote header to file")
normalize(reader, writer, newInfos, commandArgs.mode, commandArgs.removeCSQ)
normalize(reader, writer, newInfos, commandArgs.mode, commandArgs.removeCSQ)
} else writer.writeHeader(header)
writer.close()
logger.debug("Closed writer")
reader.close()
......@@ -91,7 +94,8 @@ object VepNormalizer extends ToolCommand {
/**
* Normalizer
* @param reader input VCF VCFFileReader
*
* @param reader input VCF VCFFileReader
* @param writer output VCF AsyncVariantContextWriter
* @param newInfos array of string containing names of new info fields
* @param mode normalizer mode (explode or standard)
......@@ -118,7 +122,8 @@ object VepNormalizer extends ToolCommand {
/**
* Checks whether header has a CSQ tag
* @param header VCF header
*
* @param header VCF header
*/
def csqCheck(header: VCFHeader) = {
if (!header.hasInfoLine("CSQ")) {
......@@ -131,7 +136,8 @@ object VepNormalizer extends ToolCommand {
* Checks whether version of input VCF is at least 4.0
* VEP is known to cause issues below 4.0
* Throws exception if not
* @param header VCFHeader of input VCF
*
* @param header VCFHeader of input VCF
*/
def versionCheck(header: VCFHeader) = {
var format = ""
......@@ -149,7 +155,8 @@ object VepNormalizer extends ToolCommand {
/**
* Parses the CSQ tag in the header
* @param header the VCF header
*
* @param header the VCF header
* @return list of strings with new info fields
*/
def parseCsq(header: VCFHeader): Array[String] = {
......@@ -160,7 +167,8 @@ object VepNormalizer extends ToolCommand {
/**
* Explode a single VEP-annotated record to multiple normal records
* Based on the number of annotated transcripts in the CSQ tag
* @param record the record as a VariantContext object
*
* @param record the record as a VariantContext object
* @param csqInfos An array with names of new info tags
* @return An array with the new records
*/
......
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