From: Jim Procter Date: Thu, 27 Jun 2024 16:32:24 +0000 (+0100) Subject: JAL-4386 JAL-4411 factored out the test for a particular annotation row being a secon... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4e9d008592b0112a44e57fc7e2fe4a6177c28fce;p=jalview.git JAL-4386 JAL-4411 factored out the test for a particular annotation row being a secondary structure row and from specified provider (if needbe) --- diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index 3ca5bcb..c2a4c45 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -3113,8 +3113,7 @@ public class AlignmentUtils AlignmentAnnotation[] alignAnnotList, String selectedSSSource) { - Map> ssAlignmentAnnotationForSequences - = new HashMap>(); + Map> ssAlignmentAnnotationForSequences = new HashMap>(); if (alignAnnotList == null || alignAnnotList.length == 0) { return ssAlignmentAnnotationForSequences; @@ -3126,39 +3125,44 @@ public class AlignmentUtils { continue; } - - for (String label : Constants.SECONDARY_STRUCTURE_LABELS.keySet()) + + if (isSecondaryStructureFrom(selectedSSSource, aa)) { + ssAlignmentAnnotationForSequences + .computeIfAbsent(aa.sequenceRef.getDatasetSequence(), + k -> new ArrayList<>()) + .add(aa); + } + } - if (label.equals(aa.label)) - { + return ssAlignmentAnnotationForSequences; - if (selectedSSSource.equals(MessageManager.getString("option.ss_providers_all"))) - { - ssAlignmentAnnotationForSequences - .computeIfAbsent(aa.sequenceRef.getDatasetSequence(), - k -> new ArrayList<>()) - .add(aa); - break; - } + } - String ssSource = AlignmentUtils - .extractSSSourceFromAnnotationDescription(aa); - if (ssSource != null && ssSource.equals(selectedSSSource)) - { + public static boolean isSecondaryStructureFrom(String selectedSSSource, + AlignmentAnnotation aa) + { - ssAlignmentAnnotationForSequences - .computeIfAbsent(aa.sequenceRef.getDatasetSequence(), - k -> new ArrayList<>()) - .add(aa); - break; - } + for (String label : Constants.SECONDARY_STRUCTURE_LABELS.keySet()) + { + + if (label.equals(aa.label)) + { + + if (selectedSSSource.equals( + MessageManager.getString("option.ss_providers_all"))) + { + return true; + } + + String ssSource = AlignmentUtils + .extractSSSourceFromAnnotationDescription(aa); + if (ssSource != null && ssSource.equals(selectedSSSource)) + { + return true; } } } - - return ssAlignmentAnnotationForSequences; - + return false; } - }