    001    package calhoun.analysis.crf.scoring;
    002
    003    import calhoun.analysis.crf.LocalPathSimilarityScore;
    004    import calhoun.analysis.crf.io.TrainingSequence;
    005
    006    public class SimScoreMinExonBoundaryMiscallsSV13 implements LocalPathSimilarityScore {
    007
    008            public double evaluate(int yprev, int y, TrainingSequence<?> seq, int pos) {
    009                    if (pos == 0) { return 0.0; }
    010                    int realy = seq.getY(pos);
    011                    int realyprev = seq.getY(pos-1);
    012
    013                    if (isPStart(yprev,y) ^ isPStart(realyprev,realy)) { return -1.0; }
    014                    if (isPDon(yprev,y)   ^ isPDon(realyprev,realy)) { return -1.0; }
    015                    if (isPAcc(yprev,y)   ^ isPAcc(realyprev,realy)) { return -1.0; }
    016                    if (isPStop(yprev,y)  ^ isPStop(realyprev,realy)) { return -1.0; }
    017
    018                    if (isMStart(yprev,y) ^ isMStart(realyprev,realy)) { return -1.0; }
    019                    if (isMDon(yprev,y)   ^ isMDon(realyprev,realy)) { return -1.0; }
    020                    if (isMAcc(yprev,y)   ^ isMAcc(realyprev,realy)) { return -1.0; }
    021                    if (isMStop(yprev,y)  ^ isMStop(realyprev,realy)) { return -1.0; }
    022
    023                    return 0.0;
    024            }
    025
    026            private boolean isPStart(int yprev, int y) {
    027                    if ( (yprev==0) && (y==1)) { return true; }
    028                    return false;
    029            }
    030
    031            private boolean isPDon(int yprev, int y) {
    032                    if ( (yprev==1) && (y==4)) { return true; }
    033                    if ( (yprev==2) && (y==5)) { return true; }
    034                    if ( (yprev==3) && (y==6)) { return true; }
    035                    return false;
    036            }
    037
    038            private boolean isPAcc(int yprev, int y) {
    039                    if ( (yprev==4) && (y==2)) { return true; }
    040                    if ( (yprev==5) && (y==3)) { return true; }
    041                    if ( (yprev==6) && (y==1)) { return true; }
    042                    return false;
    043            }
    044
    045            private boolean isPStop(int yprev, int y) {
    046                    if ( (yprev==3) && (y==0)) { return true; }
    047                    return false;
    048            }
    049
    050            private boolean isMStart(int yprev, int y) {
    051                    if ( (yprev==7) && (y==0)) { return true; }
    052                    return false;
    053            }
    054
    055            private boolean isMDon(int yprev, int y) {
    056                    if ( (yprev==11) && (y==8)) { return true; }
    057                    if ( (yprev==10) && (y==7)) { return true; }
    058                    if ( (yprev==12) && (y==9)) { return true; }
    059                    return false;
    060            }
    061
    062            private boolean isMAcc(int yprev, int y) {
    063                    if ( (yprev==9) && (y==11)) { return true; }
    064                    if ( (yprev==8) && (y==10)) { return true; }
    065                    if ( (yprev==7) && (y==12)) { return true; }
    066                    return false;
    067            }
    068
    069            private boolean isMStop(int yprev, int y) {
    070                    if ( (yprev==0) && (y==9)) { return true; }
    071                    return false;
    072            }
    073    }