source: trunk/autoquest-plugin-alignment/src/main/java/de/ugoe/cs/autoquest/plugin/alignment/substitution/NearbySubstitutionMatrix.java @ 1323

Last change on this file since 1323 was 1323, checked in by rkrimmel, 10 years ago

Added Substitution Package, Fixed Array access error in SimpleSequenceGenerator?

File size: 844 bytes
Line 
1/**
2 *
3 */
4package de.ugoe.cs.autoquest.plugin.alignment.substitution;
5
6/**
7 * @author Ralph Krimmel
8 *
9 */
10public class NearbySubstitutionMatrix implements SubstitutionMatrix {
11
12        private int[] input1;
13        private int[] input2;
14        private int range;
15       
16        public NearbySubstitutionMatrix(int[] input1,int[] input2, int range) {
17                this.input1 = input1;
18                this.input2 = input2;
19                this.range = range;
20        }
21       
22        /* (non-Javadoc)
23         * @see de.ugoe.cs.autoquest.plugin.alignment.SubstitutionMatrix#getDistance(int, int)
24         */
25        public double getDistance(int pos1, int pos2) {
26                int difference = Math.abs(input1[pos1]-input2[pos2]);
27                if(difference < range) {
28                        return range-difference;
29                }
30                else {
31                        return -range;
32                }
33        }
34
35
36        @Override
37        public double getGapPenalty() {
38                return -range-1;
39        }
40
41        @Override
42        public String info() {
43                return "Range: " + range;
44        }
45
46}
Note: See TracBrowser for help on using the repository browser.