From 8a347b5268314778b49c80737058679cb3ec4827 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 3 Sep 2024 15:08:47 +0100 Subject: [PATCH] JAL-4386 remove magic string in registerScoreModel... --- src/jalview/analysis/scoremodels/ScoreModels.java | 29 ++++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/jalview/analysis/scoremodels/ScoreModels.java b/src/jalview/analysis/scoremodels/ScoreModels.java index 490ec00..84db2e3 100644 --- a/src/jalview/analysis/scoremodels/ScoreModels.java +++ b/src/jalview/analysis/scoremodels/ScoreModels.java @@ -80,25 +80,26 @@ public class ScoreModels * using LinkedHashMap keeps models ordered as added */ models = new LinkedHashMap<>(); - BLOSUM62 = loadScoreMatrix("scoreModel/blosum62.scm"); - PAM250 = loadScoreMatrix("scoreModel/pam250.scm"); - DNA = loadScoreMatrix("scoreModel/dna.scm"); + BLOSUM62 = loadScoreMatrix("scoreModel/blosum62.scm",true); + PAM250 = loadScoreMatrix("scoreModel/pam250.scm",true); + DNA = loadScoreMatrix("scoreModel/dna.scm",true); registerScoreModel(new PIDModel()); registerScoreModel(new FeatureDistanceModel()); SECONDARYSTRUCTURE = loadScoreMatrix( - "scoreModel/secondarystructure.scm"); + "scoreModel/secondarystructure.scm",false); registerScoreModel(new SecondaryStructureDistanceModel()); } /** * Tries to load a score matrix from the given resource file, and if - * successful, registers it. + * successful, optionally registers it. * - * @param string - * @return + * @param resourcePath + * @param register (if true) + * @return loaded matrix */ - ScoreMatrix loadScoreMatrix(String resourcePath) + ScoreMatrix loadScoreMatrix(String resourcePath, boolean register) { try { @@ -108,7 +109,9 @@ public class ScoreModels FileParse fp = new FileParse(resourcePath, DataSourceType.CLASSLOADER); ScoreMatrix sm = new ScoreMatrixFile(fp).parseMatrix(); - registerScoreModel(sm); + if (register) { + registerScoreModel(sm); + } return sm; } catch (IOException e) { @@ -147,10 +150,6 @@ public class ScoreModels public void registerScoreModel(ScoreModelI sm) { - if (sm.getName().equals("SECONDARYSTRUCTURE")) - { - return; - } ScoreModelI sm2 = models.get(sm.getName()); if (sm2 != null) { @@ -190,6 +189,10 @@ public class ScoreModels return PAM250; } + /** + * get currently configured matrix for comparing secondary structure + * @return + */ public ScoreMatrix getSecondaryStructureMatrix() { return SECONDARYSTRUCTURE; -- 1.7.10.2