JAL-1632 'includeGaps' applied to FeatureDistanceModel (needs review)
[jalview.git] / src / jalview / analysis / scoremodels / SimilarityParams.java
1 package jalview.analysis.scoremodels;
2
3 import jalview.api.analysis.SimilarityParamsI;
4
5 public class SimilarityParams implements SimilarityParamsI
6 {
7   /**
8    * Based on Jalview's Comparison.PID method, which includes gaps and counts
9    * them as matching; it counts over the length of the shorter sequence
10    */
11   public static final SimilarityParamsI Jalview = new SimilarityParams(
12           true, true, true, true);
13
14   /**
15    * 'SeqSpace' mode PCA calculation includes gaps but does not count them as
16    * matching; it uses the longest sequence length
17    */
18   public static final SimilarityParamsI SeqSpace = new SimilarityParams(
19           true, false, true, true);
20
21   /**
22    * as described in the Raghava-Barton paper
23    * <ul>
24    * <li>ignores gap-gap</li>
25    * <li>does not score gap-residue</li>
26    * <li>includes gap-residue in lengths</li>
27    * <li>matches on longer of two sequences</li>
28    * </ul>
29    */
30   public static final SimilarityParamsI PID1 = new SimilarityParams(false,
31           false, true, false);
32
33   /**
34    * as described in the Raghava-Barton paper
35    * <ul>
36    * <li>ignores gap-gap</li>
37    * <li>ignores gap-residue</li>
38    * <li>matches on longer of two sequences</li>
39    * </ul>
40    */
41   public static final SimilarityParamsI PID2 = new SimilarityParams(false,
42           false, false, false);
43
44   /**
45    * as described in the Raghava-Barton paper
46    * <ul>
47    * <li>ignores gap-gap</li>
48    * <li>ignores gap-residue</li>
49    * <li>matches on shorter of sequences only</li>
50    * </ul>
51    */
52   public static final SimilarityParamsI PID3 = new SimilarityParams(false,
53           false, false, true);
54
55   /**
56    * as described in the Raghava-Barton paper
57    * <ul>
58    * <li>ignores gap-gap</li>
59    * <li>does not score gap-residue</li>
60    * <li>includes gap-residue in lengths</li>
61    * <li>matches on shorter of sequences only</li>
62    * </ul>
63    */
64   public static final SimilarityParamsI PID4 = new SimilarityParams(false,
65           false, true, true);
66
67   private boolean includeGappedColumns;
68
69   private boolean matchGaps;
70
71   private boolean includeGaps;
72
73   private boolean denominateByShortestLength;
74
75   /**
76    * Constructor
77    * 
78    * @param includeGapGap
79    * @param matchGapResidue
80    * @param includeGapResidue
81    *          if true, gapped positions are counted for normalisation by length
82    * @param shortestLength
83    *          if true, the denominator is the shorter sequence length (possibly
84    *          including gaps)
85    */
86   public SimilarityParams(boolean includeGapGap, boolean matchGapResidue,
87           boolean includeGapResidue, boolean shortestLength)
88   {
89     includeGappedColumns = includeGapGap;
90     matchGaps = matchGapResidue;
91     includeGaps = includeGapResidue;
92     denominateByShortestLength = shortestLength;
93   }
94
95   @Override
96   public boolean includeGaps()
97   {
98     return includeGaps;
99   }
100
101   @Override
102   public boolean denominateByShortestLength()
103   {
104     return denominateByShortestLength;
105   }
106
107   @Override
108   public boolean includeGappedColumns()
109   {
110     return includeGappedColumns;
111   }
112
113   @Override
114   public boolean matchGaps()
115   {
116     return matchGaps;
117   }
118 }