Search in sources :

Example 1 with UserException

use of org.broadinstitute.gatk.utils.exceptions.UserException in project jvarkit by lindenb.

the class WindowVariants method initialize.

@Override
public void initialize() {
    if (this.window_size <= 0) {
        throw new UserException("Bad window size.");
    }
    if (this.window_shift <= 0) {
        throw new UserException("Bad window shift.");
    }
    if (this.winName == null || this.winName.isEmpty()) {
        throw new UserException("Bad INFO ID windowName");
    }
    final Map<String, String> exprMap = new HashMap<>();
    for (final String expStr : this.selectExpressions) {
        exprMap.put("expr" + (1 + exprMap.size()), expStr);
    }
    this.jexls = VariantContextUtils.initializeMatchExps(exprMap);
    final VCFHeader header = new VCFHeader(super.getVcfHeader());
    if (header.getInfoHeaderLine(this.winName) != null) {
        throw new UserException("VCF header already contains the INFO header ID=" + this.winName);
    }
    header.addMetaDataLine(new VCFInfoHeaderLine(this.winName, VCFHeaderLineCount.UNBOUNDED, VCFHeaderLineType.String, "Window : start|end|number-of-matching-variants|number-of-non-matching-variants"));
    super.writer.writeHeader(header);
    super.initialize();
}
Also used : HashMap(java.util.HashMap) UserException(org.broadinstitute.gatk.utils.exceptions.UserException) VCFHeader(htsjdk.variant.vcf.VCFHeader) VCFInfoHeaderLine(htsjdk.variant.vcf.VCFInfoHeaderLine)

Aggregations

VCFHeader (htsjdk.variant.vcf.VCFHeader)1 VCFInfoHeaderLine (htsjdk.variant.vcf.VCFInfoHeaderLine)1 HashMap (java.util.HashMap)1 UserException (org.broadinstitute.gatk.utils.exceptions.UserException)1