From 4e9d008592b0112a44e57fc7e2fe4a6177c28fce Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 27 Jun 2024 17:32:24 +0100 Subject: [PATCH] JAL-4386 JAL-4411 factored out the test for a particular annotation row being a secondary structure row and from specified provider (if needbe) --- src/jalview/analysis/AlignmentUtils.java | 60 ++++++++++++++++-------------- 1 file changed, 32 insertions(+), 28 deletions(-) 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; } - } -- 1.7.10.2