
/*
 * The Exomiser - A tool to annotate and prioritize genomic variants
 *
 * Copyright (c) 2016-2018 Queen Mary University of London.
 * Copyright (c) 2012-2016 Charité Universitätsmedizin Berlin and Genome Research Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.monarchinitiative.exomiser.core.model.pathogenicity;

import de.charite.compbio.jannovar.annotation.PutativeImpact;
import de.charite.compbio.jannovar.annotation.VariantEffect;

/**
 * Set of constants for use as default pathogenicity scores for a given {@link VariantEffect}.
 *
 * @author Jules Jacobsen <jules.jacobsen@sanger.ac.uk>
 * @author Manuel Holtgrewe <manuel.holtgrewe@charite.de>
 */
public abstract class VariantEffectPathogenicityScore {

    /**
     * This is the pathogenicity value we will give to missense (nonsynonymous)
     * variants for which we cannot find values for mutationTaster, polyphen2,
     * or SIFT.
     */
    public static final float DEFAULT_MISSENSE_SCORE = 0.6f;
    /**
     * Pathogenicity score for a mutation class such as INTERGENIC where we are
     * entirely sure it is nonpathogenic (for the purposes of this software).
     */
    public static final float NON_PATHOGENIC_SCORE = 0.00f;
    /**
     * Assumed pathogenicity score for a frameshift mutation.
     */
    public static final float FRAMESHIFT_SCORE = 1.00f;
    /**
     * Assumed pathogenicity score for a nonframeshift indel mutation.
     */
    public static final float NONFRAMESHIFT_INDEL_SCORE = 0.85f;
    /**
     * Assumed pathogenicity score for a nonsense mutation.
     */
    public static final float NONSENSE_SCORE = 1.00f;
    /**
     * Assumed pathogenicity score for a splice site mutation.
     */
    public static final float SPLICING_SCORE = 1.00f;
    /**
     * Assumed pathogenicity score for a synonymous mutation.
     */
    public static final float SYNONYMOUS_SCORE = 0.10f;
    /**
     * Assumed pathogenicity score for a stoploss mutation.
     */
    public static final float STOPLOSS_SCORE = 1.00f;
    /**
     * Assumed pathogenicity score for a variant that causes the start codon to
     * be lost.
     */
    public static final float STARTLOSS_SCORE = 1.00f;

    private VariantEffectPathogenicityScore() {
        //Uninstantiable.  This class should be an enum, but then it doesn't code nicely :(
    }

    public static float getPathogenicityScoreOf(VariantEffect variantEffect) {
        if (variantEffect == VariantEffect.SEQUENCE_VARIANT) {
            // no effect annotated
            return NON_PATHOGENIC_SCORE; 
        }
        // highest priority effect
        // guard against the case that the highest-impact effect is neither high nor moderate
        if (variantEffect.getImpact().ordinal() > PutativeImpact.MODERATE.ordinal()) {
             // neither HIGH nor MODERATE
            return NON_PATHOGENIC_SCORE;
        }
        switch (variantEffect) {
            case MISSENSE_VARIANT:
                return DEFAULT_MISSENSE_SCORE;
            case SYNONYMOUS_VARIANT:
                return SYNONYMOUS_SCORE;
            case FRAMESHIFT_ELONGATION:
            case FRAMESHIFT_TRUNCATION:
            case FRAMESHIFT_VARIANT:
                return FRAMESHIFT_SCORE;
            case MNV:
            case FEATURE_TRUNCATION:
            case DISRUPTIVE_INFRAME_DELETION:
            case DISRUPTIVE_INFRAME_INSERTION:
            case INFRAME_DELETION:
            case INFRAME_INSERTION:
            case INTERNAL_FEATURE_ELONGATION:
            case COMPLEX_SUBSTITUTION:
                return NONFRAMESHIFT_INDEL_SCORE;
            case SPLICE_ACCEPTOR_VARIANT:
            case SPLICE_DONOR_VARIANT:
            case SPLICE_REGION_VARIANT:
                return SPLICING_SCORE;
            case START_LOST:
                return STARTLOSS_SCORE;
            case STOP_LOST:
                return STOPLOSS_SCORE;
            case STOP_GAINED:
                return NONSENSE_SCORE;
            // NO REGULATORY_REGION, FIVE_PRIME_UTR_EXON_VARIANT, FIVE_PRIME_UTR_TRUNCATION
            // FIVE_PRIME_UTR_PREMATURE_START_CODON_GAIN_VARIANT.... ?
            // There, are many other missing cases which really need default scores!
            default:
                return NON_PATHOGENIC_SCORE;
        }
    }

}

@@ -2370,27 +2370,40 @@
  float SPLIC
-ING
+E_DONOR_ACCEPTOR
 _SCORE = 1.0
@@ -2406,32 +2406,205 @@
  1.00f;%0A    /**%0A
+     * Default pathogenicity score for variants in the a splice region, but not a donor or acceptor.%0A     */%0A    public static final float SPLICE_REGION_SCORE = 0.8f;   /**%0A
      * Assumed p
@@ -4478,32 +4478,84 @@
 _DONOR_VARIANT:%0A
+                return SPLICE_DONOR_ACCEPTOR_SCORE;%0A
             case
@@ -4610,11 +4610,16 @@
 PLIC
-ING
+E_REGION
 _SCO

Split SPLICING_SCORE into SPLICE_DONOR_ACCEPTOR_SCORE and SPLICE_REGION_SCORE to VariantEffectPathogenicityScore