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