JAL-838 first version of PID parameters model
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 24 Feb 2017 15:20:20 +0000 (15:20 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 24 Feb 2017 15:20:20 +0000 (15:20 +0000)
src/jalview/analysis/scoremodels/SimilarityParams.java [new file with mode: 0644]
src/jalview/api/analysis/SimilarityParamsI.java [new file with mode: 0644]

diff --git a/src/jalview/analysis/scoremodels/SimilarityParams.java b/src/jalview/analysis/scoremodels/SimilarityParams.java
new file mode 100644 (file)
index 0000000..8b6b7d0
--- /dev/null
@@ -0,0 +1,73 @@
+package jalview.analysis.scoremodels;
+
+import jalview.api.analysis.SimilarityParamsI;
+
+public class SimilarityParams implements SimilarityParamsI
+{
+  public static final SimilarityParamsI Jalview = new SimilarityParams(
+          true, true, true, true);
+
+  public static final SimilarityParamsI PID1 = new SimilarityParams(false,
+          false, true, false);
+
+  public static final SimilarityParamsI PID2 = new SimilarityParams(false,
+          false, false, false);
+
+  public static final SimilarityParamsI PID3 = new SimilarityParams(false,
+          false, false, true);
+
+  public static final SimilarityParamsI PID4 = new SimilarityParams(false,
+          false, true, true);
+
+  private boolean includeGappedColumns;
+
+  private boolean matchGaps;
+
+  private boolean denominatorIncludesGaps;
+
+  private boolean denominateByShortestLength;
+
+  /**
+   * Constructor
+   * 
+   * @param includeGapGap
+   * @param matchGap
+   * @param includeGaps
+   *          if true, gapped positions are counted in the PID denominator
+   * @param shortestLength
+   *          if true, the denominator is the shorter sequence length (possibly
+   *          including gaps)
+   */
+  SimilarityParams(boolean includeGapGap, boolean matchGap,
+          boolean includeGaps, boolean shortestLength)
+  {
+    includeGappedColumns = includeGapGap;
+    matchGaps = matchGap;
+    denominatorIncludesGaps = includeGaps;
+    denominateByShortestLength = shortestLength;
+  }
+
+  @Override
+  public boolean denominatorIncludesGaps()
+  {
+    return denominatorIncludesGaps;
+  }
+
+  @Override
+  public boolean denominateByShortestLength()
+  {
+    return denominateByShortestLength;
+  }
+
+  @Override
+  public boolean includeGappedColumns()
+  {
+    return includeGappedColumns;
+  }
+
+  @Override
+  public boolean matchGaps()
+  {
+    return matchGaps;
+  }
+}
diff --git a/src/jalview/api/analysis/SimilarityParamsI.java b/src/jalview/api/analysis/SimilarityParamsI.java
new file mode 100644 (file)
index 0000000..9ec2151
--- /dev/null
@@ -0,0 +1,41 @@
+package jalview.api.analysis;
+
+/**
+ * A description of options when computing percentage identity of two aligned
+ * sequences
+ */
+public interface SimilarityParamsI
+{
+  /**
+   * Answers true if gap-gap aligned positions should be included in the
+   * calculation
+   * 
+   * @return
+   */
+  boolean includeGappedColumns();
+
+  /**
+   * Answers true if gap-residue alignment is considered a match
+   * 
+   * @return
+   */
+  boolean matchGaps();
+
+  /**
+   * Answers true if the demoninator (normalisation factor) of the score count
+   * includes gap-residue positions, false if it only includes residue-residue
+   * aligned positions. Gap-gap positions are included if this and
+   * includeGappedColumns both answer true.
+   * 
+   * @return
+   */
+  boolean denominatorIncludesGaps();
+
+  /**
+   * Answers true if only the shortest sequence length is used to divide the
+   * total score, false if the longest sequence length
+   * 
+   * @return
+   */
+  boolean denominateByShortestLength();
+}