X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fanalysis%2Fscoremodels%2FSimilarityParams.java;h=5c477035c3a403e9989e3950d50b62bea8719d85;hb=6ca8a32d88328b8f2162512f41c657c87e131045;hp=b6f2ba22fd18fb76df7bfe799f32db2ebe5dac76;hpb=e2e2b85d7a8e3d7ed6926ef1bf55eb2328e744d1;p=jalview.git
diff --git a/src/jalview/analysis/scoremodels/SimilarityParams.java b/src/jalview/analysis/scoremodels/SimilarityParams.java
index b6f2ba2..5c47703 100644
--- a/src/jalview/analysis/scoremodels/SimilarityParams.java
+++ b/src/jalview/analysis/scoremodels/SimilarityParams.java
@@ -1,15 +1,47 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.analysis.scoremodels;
import jalview.api.analysis.SimilarityParamsI;
+/**
+ * A class to hold parameters that configure the pairwise similarity
+ * calculation. Based on the paper
+ *
+ *
+ * Quantification of the variation in percentage identity for protein sequence alignments
+ * Raghava, GP and Barton, GJ
+ * BMC Bioinformatics. 2006 Sep 19;7:415
+ *
+ *
+ * @see https://www.ncbi.nlm.nih.gov/pubmed/16984632
+ */
public class SimilarityParams implements SimilarityParamsI
{
/**
* Based on Jalview's Comparison.PID method, which includes gaps and counts
* them as matching; it counts over the length of the shorter sequence
*/
- public static final SimilarityParamsI Jalview = new SimilarityParams(
- true, true, true, true);
+ public static final SimilarityParamsI Jalview = new SimilarityParams(true,
+ true, true, true);
/**
* 'SeqSpace' mode PCA calculation includes gaps but does not count them as
@@ -19,29 +51,47 @@ public class SimilarityParams implements SimilarityParamsI
true, false, true, true);
/**
- * as described in the Raghava-Barton paper; considers pairwise similarity
- * only (excludes gap-gap) and does not match gaps
+ * as described in the Raghava-Barton paper
+ *
+ * - ignores gap-gap
+ * - does not score gap-residue
+ * - includes gap-residue in lengths
+ * - matches on longer of two sequences
+ *
*/
public static final SimilarityParamsI PID1 = new SimilarityParams(false,
false, true, false);
/**
- * as described in the Raghava-Barton paper; considers pairwise similarity
- * only (excludes gap-gap) and does not match gaps
+ * as described in the Raghava-Barton paper
+ *
+ * - ignores gap-gap
+ * - ignores gap-residue
+ * - matches on longer of two sequences
+ *
*/
public static final SimilarityParamsI PID2 = new SimilarityParams(false,
false, false, false);
/**
- * as described in the Raghava-Barton paper; considers pairwise similarity
- * only (excludes gap-gap) and does not match gaps
+ * as described in the Raghava-Barton paper
+ *
+ * - ignores gap-gap
+ * - ignores gap-residue
+ * - matches on shorter of sequences only
+ *
*/
public static final SimilarityParamsI PID3 = new SimilarityParams(false,
false, false, true);
/**
- * as described in the Raghava-Barton paper; considers pairwise similarity
- * only (excludes gap-gap) and does not match gaps
+ * as described in the Raghava-Barton paper
+ *
+ * - ignores gap-gap
+ * - does not score gap-residue
+ * - includes gap-residue in lengths
+ * - matches on shorter of sequences only
+ *
*/
public static final SimilarityParamsI PID4 = new SimilarityParams(false,
false, true, true);
@@ -50,7 +100,7 @@ public class SimilarityParams implements SimilarityParamsI
private boolean matchGaps;
- private boolean denominatorIncludesGaps;
+ private boolean includeGaps;
private boolean denominateByShortestLength;
@@ -58,26 +108,26 @@ public class SimilarityParams implements SimilarityParamsI
* Constructor
*
* @param includeGapGap
- * @param matchGap
- * @param includeGaps
- * if true, gapped positions are counted in the PID denominator
+ * @param matchGapResidue
+ * @param includeGapResidue
+ * if true, gapped positions are counted for normalisation by length
* @param shortestLength
* if true, the denominator is the shorter sequence length (possibly
* including gaps)
*/
- public SimilarityParams(boolean includeGapGap, boolean matchGap,
- boolean includeGaps, boolean shortestLength)
+ public SimilarityParams(boolean includeGapGap, boolean matchGapResidue,
+ boolean includeGapResidue, boolean shortestLength)
{
includeGappedColumns = includeGapGap;
- matchGaps = matchGap;
- denominatorIncludesGaps = includeGaps;
+ matchGaps = matchGapResidue;
+ includeGaps = includeGapResidue;
denominateByShortestLength = shortestLength;
}
@Override
- public boolean denominatorIncludesGaps()
+ public boolean includeGaps()
{
- return denominatorIncludesGaps;
+ return includeGaps;
}
@Override
@@ -97,4 +147,57 @@ public class SimilarityParams implements SimilarityParamsI
{
return matchGaps;
}
+
+ /**
+ * IDE-generated hashCode method
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (denominateByShortestLength ? 1231 : 1237);
+ result = prime * result + (includeGappedColumns ? 1231 : 1237);
+ result = prime * result + (includeGaps ? 1231 : 1237);
+ result = prime * result + (matchGaps ? 1231 : 1237);
+ return result;
+ }
+
+ /**
+ * IDE-generated equals method
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ SimilarityParams other = (SimilarityParams) obj;
+ if (denominateByShortestLength != other.denominateByShortestLength)
+ {
+ return false;
+ }
+ if (includeGappedColumns != other.includeGappedColumns)
+ {
+ return false;
+ }
+ if (includeGaps != other.includeGaps)
+ {
+ return false;
+ }
+ if (matchGaps != other.matchGaps)
+ {
+ return false;
+ }
+ return true;
+ }
}