From: Jim Procter Date: Tue, 21 May 2024 17:16:59 +0000 (+0100) Subject: JAL-4159 PASiMap currently doesn't support different score models X-Git-Tag: Release_2_11_4_0~31^2~16 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=b21e94b5a1885b167c9168f1250cc478cfb6a723;p=jalview.git JAL-4159 PASiMap currently doesn't support different score models --- diff --git a/src/jalview/gui/CalculationChooser.java b/src/jalview/gui/CalculationChooser.java index 80102cb..6536358 100644 --- a/src/jalview/gui/CalculationChooser.java +++ b/src/jalview/gui/CalculationChooser.java @@ -538,7 +538,7 @@ public class CalculationChooser extends JPanel boolean ssPresent = AlignmentUtils.isSecondaryStructurePresent(alignmentAnnotations); List models = getApplicableScoreModels(nucleotide, pca.isSelected(), - ssPresent); + ssPresent, pasimap.isSelected()); /* * now we can actually add entries to the combobox, @@ -591,15 +591,16 @@ public class CalculationChooser extends JPanel * @return */ protected static List getApplicableScoreModels( - boolean nucleotide, boolean forPca, boolean ssPresent) + boolean nucleotide, boolean forPca, boolean ssPresent, boolean forPasimap) { List filtered = new ArrayList<>(); ScoreModels scoreModels = ScoreModels.getInstance(); for (ScoreModelI sm : scoreModels.getModels()) { - if (!nucleotide && sm.isProtein() || nucleotide && sm.isDNA() - || ssPresent && sm.isSecondaryStructure()) + if (!forPasimap && (!nucleotide && sm.isProtein() || nucleotide && sm.isDNA() + || sm.isSecondaryStructure() && ssPresent)) + { filtered.add(sm); } @@ -609,7 +610,7 @@ public class CalculationChooser extends JPanel * special case: add BLOSUM62 as last option for nucleotide PCA, * for backwards compatibility with Jalview < 2.8 (JAL-2962) */ - if (nucleotide && forPca + if (!forPasimap && nucleotide && forPca && Cache.getDefault("BLOSUM62_PCA_FOR_NUCLEOTIDE", false)) { filtered.add(scoreModels.getBlosum62()); @@ -637,7 +638,7 @@ public class CalculationChooser extends JPanel { boolean doPCA = pca.isSelected(); boolean doPaSiMap = pasimap.isSelected(); - String modelName = modelNames.getSelectedItem().toString(); + String modelName = modelNames.getSelectedItem() == null ? "" : modelNames.getSelectedItem().toString(); String ssSource = ""; Object selectedItem = ssSourceDropdown.getSelectedItem(); if (selectedItem != null) { diff --git a/test/jalview/gui/CalculationChooserTest.java b/test/jalview/gui/CalculationChooserTest.java index 23538c2..1fbad1d 100644 --- a/test/jalview/gui/CalculationChooserTest.java +++ b/test/jalview/gui/CalculationChooserTest.java @@ -55,7 +55,7 @@ public class CalculationChooserTest * peptide models for PCA */ List filtered = CalculationChooser - .getApplicableScoreModels(false, true, true); + .getApplicableScoreModels(false, true, true,false); assertEquals(filtered.size(), 5); assertSame(filtered.get(0), blosum62); assertSame(filtered.get(1), pam250); @@ -66,7 +66,7 @@ public class CalculationChooserTest /* * peptide models for Tree are the same */ - filtered = CalculationChooser.getApplicableScoreModels(false, false, true); + filtered = CalculationChooser.getApplicableScoreModels(false, false, true,false); assertEquals(filtered.size(), 5); assertSame(filtered.get(0), blosum62); assertSame(filtered.get(1), pam250); @@ -77,7 +77,7 @@ public class CalculationChooserTest /* * nucleotide models for PCA */ - filtered = CalculationChooser.getApplicableScoreModels(true, true, false); + filtered = CalculationChooser.getApplicableScoreModels(true, true, false,false); assertEquals(filtered.size(), 3); assertSame(filtered.get(0), dna); assertEquals(filtered.get(1).getName(), "PID"); @@ -86,7 +86,7 @@ public class CalculationChooserTest /* * nucleotide models for Tree are the same */ - filtered = CalculationChooser.getApplicableScoreModels(true, false, false); + filtered = CalculationChooser.getApplicableScoreModels(true, false, false,false); assertEquals(filtered.size(), 3); assertSame(filtered.get(0), dna); assertEquals(filtered.get(1).getName(), "PID"); @@ -101,7 +101,7 @@ public class CalculationChooserTest /* * nucleotide models for Tree are unchanged */ - filtered = CalculationChooser.getApplicableScoreModels(true, false, true); + filtered = CalculationChooser.getApplicableScoreModels(true, false, true,false); assertEquals(filtered.size(), 4); assertSame(filtered.get(0), dna); assertEquals(filtered.get(1).getName(), "PID"); @@ -111,11 +111,20 @@ public class CalculationChooserTest /* * nucleotide models for PCA add BLOSUM62 as last option */ - filtered = CalculationChooser.getApplicableScoreModels(true, true, false); + filtered = CalculationChooser.getApplicableScoreModels(true, true, false,false); assertEquals(filtered.size(), 4); assertSame(filtered.get(0), dna); assertEquals(filtered.get(1).getName(), "PID"); assertEquals(filtered.get(2).getName(), "Sequence Feature Similarity"); assertSame(filtered.get(3), blosum62); + + filtered = CalculationChooser.getApplicableScoreModels(true, true, false,true); + assertEquals(filtered.size(), 0); + for (int i=0; i<=8;i++) + { + boolean isDna = (i & 1) != 0,isPca = (i & 2) != 0,isSS = (i & 4) != 0; + + assertEquals(CalculationChooser.getApplicableScoreModels(isDna,isPca,isSS,true).size(), 0); + } } }