From a4015623cfd1057095d5d54043de462d9163af4b Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 24 Feb 2017 15:20:20 +0000 Subject: [PATCH] JAL-838 first version of PID parameters model --- .../analysis/scoremodels/SimilarityParams.java | 73 ++++++++++++++++++++ src/jalview/api/analysis/SimilarityParamsI.java | 41 +++++++++++ 2 files changed, 114 insertions(+) create mode 100644 src/jalview/analysis/scoremodels/SimilarityParams.java create mode 100644 src/jalview/api/analysis/SimilarityParamsI.java diff --git a/src/jalview/analysis/scoremodels/SimilarityParams.java b/src/jalview/analysis/scoremodels/SimilarityParams.java new file mode 100644 index 0000000..8b6b7d0 --- /dev/null +++ b/src/jalview/analysis/scoremodels/SimilarityParams.java @@ -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 index 0000000..9ec2151 --- /dev/null +++ b/src/jalview/api/analysis/SimilarityParamsI.java @@ -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(); +} -- 1.7.10.2