Merge branch 'jims/JAL-4386_from_renia' into spike/JAL-4386_generate_multiple_leaves_... spike/JAL-4386_generate_multiple_leaves_for_ss_sources
authorJim Procter <jprocter@dundee.ac.uk>
Fri, 26 Jul 2024 10:17:24 +0000 (11:17 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Fri, 26 Jul 2024 10:17:24 +0000 (11:17 +0100)
 Conflicts:
src/jalview/analysis/AlignmentUtils.java
src/jalview/gui/CalculationChooser.java
src/jalview/structure/StructureSelectionManager.java

1  2 
src/jalview/analysis/AlignmentUtils.java
src/jalview/gui/CalculationChooser.java
src/jalview/gui/TreeCanvas.java
src/jalview/renderer/AnnotationRenderer.java
src/jalview/structure/StructureSelectionManager.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;
          }
        }
      }
@@@ -678,9 -678,8 +678,7 @@@ public class CalculationChooser extend
    {
      AlignmentAnnotation[] annotations = af.getViewport().getAlignment().getAlignmentAnnotation();
      
-     //List<String> ssSources = AlignmentUtils.getSecondaryStructureSources(annotations);
      List<String> ssSources = AlignmentUtils.extractSSSourceInAlignmentAnnotation(annotations);
-     
 -                 
      return ssSources;
    }
  
Simple merge
@@@ -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<PDBEntry> 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<PDBEntry> 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);
+                 }
                }
              }
            }