From: Jim Procter Date: Fri, 26 Jul 2024 10:17:24 +0000 (+0100) Subject: Merge branch 'jims/JAL-4386_from_renia' into spike/JAL-4386_generate_multiple_leaves_... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fspike%2FJAL-4386_generate_multiple_leaves_for_ss_sources;p=jalview.git Merge branch 'jims/JAL-4386_from_renia' into spike/JAL-4386_generate_multiple_leaves_for_ss_sources Conflicts: src/jalview/analysis/AlignmentUtils.java src/jalview/gui/CalculationChooser.java src/jalview/structure/StructureSelectionManager.java --- a92d9ee8c25e41770bf745b793262f9a7937893e diff --cc src/jalview/analysis/AlignmentUtils.java index 2cefaa7,d78bcdc..f5927ab --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@@ -3125,39 -3153,33 +3152,45 @@@ public class AlignmentUtil { 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 (Constants.SS_ALL_PROVIDERS.equals(selectedSSSource)) - { - ssAlignmentAnnotationForSequences - .computeIfAbsent(aa.sequenceRef.getDatasetSequence(), - k -> new ArrayList<>()) - .add(aa); - break; - } + } - String ssSource = AlignmentUtils - .extractSSSourceFromAnnotationDescription(aa); - if (ssSource != null && ssSource.equals(selectedSSSource)) - { ++ /** ++ * ++ * @param selectedSSSource ++ * @param aa ++ * @return true if aa is from a provider or all providers as specified by 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(Constants.SS_ALL_PROVIDERS)) + { + return true; + } + String ssSource = AlignmentUtils + .extractSSSourceFromAnnotationDescription(aa); + if (ssSource != null && ssSource.equals(selectedSSSource)) + { + return true; } } } diff --cc src/jalview/gui/CalculationChooser.java index 4b89711,b831f43..2e4e99d --- a/src/jalview/gui/CalculationChooser.java +++ b/src/jalview/gui/CalculationChooser.java @@@ -678,9 -678,8 +678,7 @@@ public class CalculationChooser extend { AlignmentAnnotation[] annotations = af.getViewport().getAlignment().getAlignmentAnnotation(); - //List ssSources = AlignmentUtils.getSecondaryStructureSources(annotations); List ssSources = AlignmentUtils.extractSSSourceInAlignmentAnnotation(annotations); - - return ssSources; } diff --cc src/jalview/structure/StructureSelectionManager.java index 731d82f,7248e47..73c4c0f --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@@ -708,40 -708,30 +708,44 @@@ public class StructureSelectionManage ssAnnotDescriptionInPDB = ssAnnotationsInPDB[0].description; } - //Match the PDB entry using file path in the pdb data model and get the provider - if(seq.getDatasetSequence() != null) { - Vector pdbEntries = seq.getDatasetSequence().getAllPDBEntries(); - if(pdbEntries != null) { - for(PDBEntry pdbEntry : pdbEntries) { - if(pdbEntry.getFile()!=null) { - if(ssStructFilePathNameInPDB.startsWith(pdbEntry.getFile())) { - provider = pdbEntry.getProvider(); - break; - } + // Match the PDB entry using file path in the pdb data model and get the + // provider - if (seq.getDatasetSequence() != null) ++ if (ssStructFilePathNameInPDB != null ++ && seq.getDatasetSequence() != null) + { + Vector pdbEntries = seq.getDatasetSequence() + .getAllPDBEntries(); - for (PDBEntry pdbEntry : pdbEntries) ++ if (pdbEntries != null) + { - if (ssStructFilePathNameInPDB != null - && pdbEntry.getFile() != null && ssStructFilePathNameInPDB - .startsWith(pdbEntry.getFile())) ++ for (PDBEntry pdbEntry : pdbEntries) + { - provider = pdbEntry.getProvider(); - break; ++ if (pdbEntry.getFile() != null && ssStructFilePathNameInPDB ++ .startsWith(pdbEntry.getFile())) ++ { ++ provider = pdbEntry.getProvider(); ++ break; + } } - } - // Add provider value as property to the ss annotation - if (provider != null) - { - AlignmentAnnotation[] ssAnnotList = ds - .getAnnotation(Constants.SS_ANNOTATION_LABEL); - if (ssAnnotList != null) - - - //Add provider value as property to the ss annotation - if(provider != null) { - AlignmentAnnotation[] ssAnnotList = ds.getAnnotation(Constants.SS_ANNOTATION_LABEL); - if(ssAnnotList != null) { - for(AlignmentAnnotation ssAnnot : ssAnnotList) { - //Match the annotation description with the annotation in pdb data object - if(ssAnnot.getProperty(Constants.SS_PROVIDER_PROPERTY) == null - && ssAnnot.description.equals(ssAnnotDescriptionInPDB)) { - ssAnnot.setProperty(Constants.SS_PROVIDER_PROPERTY, provider); ++ // Add provider value as property to the ss annotation ++ if (provider != null) + { - for (AlignmentAnnotation ssAnnot : ssAnnotList) ++ // TODO - JAL-2880 JAL-4441 this should be applied to all structure derived annotations, not just secondary structure! ++ AlignmentAnnotation[] ssAnnotList = ds ++ .getAnnotation(Constants.SS_ANNOTATION_LABEL); ++ if (ssAnnotList != null) + { - // Match the annotation description with the annotation in pdb - // data object - if (ssAnnot - .getProperty(Constants.SS_PROVIDER_PROPERTY) == null - && ssAnnot.description - .equals(ssAnnotDescriptionInPDB)) ++ for (AlignmentAnnotation ssAnnot : ssAnnotList) + { - ssAnnot.setProperty(Constants.SS_PROVIDER_PROPERTY, - provider); ++ // Match the annotation description with the annotation in pdb ++ // data object ++ if (ssAnnot ++ .getProperty(Constants.SS_PROVIDER_PROPERTY) == null ++ && ssAnnot.description ++ .equals(ssAnnotDescriptionInPDB)) ++ { ++ ssAnnot.setProperty(Constants.SS_PROVIDER_PROPERTY, ++ provider); + } } } }