Merge develop into feature/JAL-4386_calculate_tree_using_secondary_structure_annotation feature/JAL-4386_calculate_tree_using_secondary_structure_annotation
authorRenia Correya <rcorreya001@dundee.ac.uk>
Wed, 25 Sep 2024 14:48:53 +0000 (15:48 +0100)
committerRenia Correya <rcorreya001@dundee.ac.uk>
Wed, 25 Sep 2024 14:48:53 +0000 (15:48 +0100)
Resolved merge conflicts in Messages.properties, GAlignFrame.java, AlignmentViewport.java, and SecondaryStructureConsensusThread.java

13 files changed:
1  2 
resources/lang/Messages.properties
src/jalview/analysis/AAFrequency.java
src/jalview/analysis/AlignmentAnnotationUtils.java
src/jalview/analysis/AlignmentUtils.java
src/jalview/datamodel/AlignmentAnnotation.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/AnnotationLabels.java
src/jalview/gui/Preferences.java
src/jalview/jbgui/GAlignFrame.java
src/jalview/renderer/AnnotationRenderer.java
src/jalview/viewmodel/AlignmentViewport.java
src/jalview/workers/SecondaryStructureConsensusThread.java
test/jalview/renderer/ResidueShaderTest.java

Simple merge
@@@ -231,11 -232,9 +231,11 @@@ public class AAFrequenc
    {
  
      int seqCount = sequences.length;
 +    
 +    int seqWithSSCount = 0;
  
      ProfileI[] result = new ProfileI[width];
+     int maxSSannotcount=0;
      for (int column = start; column < end; column++)
      {
  
Simple merge
Simple merge
Simple merge
@@@ -1997,9 -1997,10 +1997,9 @@@ public class GAlignFrame extends JInter
      autoAnnMenu.addSeparator();
      autoAnnMenu.add(applyAutoAnnotationSettings);
      autoAnnMenu.add(showConsensusHistogram);
 -    autoAnnMenu.add(showSSConsensusHistogram);
      autoAnnMenu.add(showSequenceLogo);
      autoAnnMenu.add(normaliseSequenceLogo);
-     //autoAnnMenu.add(showSSConsensus);
+     // autoAnnMenu.add(showSSConsensus);
      autoAnnMenu.addSeparator();
      autoAnnMenu.add(showGroupConservation);
      autoAnnMenu.add(showGroupConsensus);
      // selectMenu.addSeparator();
      // selectMenu.add(listenToViewSelections);
    }
+   
  
-   protected void showStructureProvider_actionPerformed(ActionEvent e)
+   protected void showSSConsensus_actionPerformed(ActionEvent e)
    {
      // TODO Auto-generated method stub
-     
    }
  
-   protected void showSSConsensus_actionPerformed(ActionEvent e)
++  protected void showStructureProvider_actionPerformed(ActionEvent e)
 +  {
 +    // TODO Auto-generated method stub
 +    
 +  }
 +
    protected void createPNG_actionPerformed(ActionEvent object)
    {
      // TODO Auto-generated method stub
@@@ -2133,6 -2056,7 +2132,23 @@@ public abstract class AlignmentViewpor
        {
          initConservation();
          initQuality();
 -        initSSConsensus();
++        
++        setSecondaryStructureSources(alignment.getAlignmentAnnotation());
++        List<String> secondaryStructureSources = getSecondaryStructureSources();
++
++        if(secondaryStructureSources!=null) {
++
++          secondaryStructureConsensus = new ArrayList<AlignmentAnnotation>();
++          for (String ssSource : secondaryStructureSources) {
++          
++            AlignmentAnnotation ssConsensus = new AlignmentAnnotation(MessageManager.getString("label.ssconsensus_label") + " "+ssSource,
++                    ssSource + " " + MessageManager.getString("label.ssconsensus_descr"),
++                    new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
++            secondaryStructureConsensus.add(ssConsensus);
++          }
++          
++        }
++        initSSConsensus(secondaryStructureConsensus);
        }
        else
        {
        consensus = new AlignmentAnnotation("Consensus",
                MessageManager.getString("label.consensus_descr"),
                new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
-       setSecondaryStructureSources(alignment.getAlignmentAnnotation());
-       List<String> secondaryStructureSources = getSecondaryStructureSources();
-       if(secondaryStructureSources!=null) {
-         secondaryStructureConsensus = new ArrayList<AlignmentAnnotation>();
-         for (String ssSource : secondaryStructureSources) {
-         
-           AlignmentAnnotation ssConsensus = new AlignmentAnnotation(MessageManager.getString("label.ssconsensus_label") + " "+ssSource,
-                   ssSource + " " + MessageManager.getString("label.ssconsensus_descr"),
-                   new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
-           secondaryStructureConsensus.add(ssConsensus);
-         }
-         
-       }
  
 -
        initConsensus(consensus);
-       initSSConsensus(secondaryStructureConsensus);
        initGapCounts();
        initComplementConsensus();
      }
        alignment.addAnnotation(aa);
      }
    }
 -
 -  private void initSSConsensus()
 +  
 +  private void initSSConsensus(List<AlignmentAnnotation> secondaryStructureConsensuses)
    {
 +    if(secondaryStructureConsensuses == null) {
 +      return;
 +    }
-     for(AlignmentAnnotation aa : secondaryStructureConsensuses) {
-       aa.hasText = true;
-       aa.autoCalculated = true;
-   
-       if (showSSConsensus)
-       {
+     if (!alignment.isNucleotide() && showSSConsensus)
+     {
 -      if (secondaryStructureConsensus == null)
 -      {
 -        secondaryStructureConsensus = new AlignmentAnnotation(
 -                MessageManager.getString("label.ssconsensus_label"),
 -                MessageManager.getString("label.ssconsensus_descr"),
 -                new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
 -
 -        secondaryStructureConsensus.hasText = true;
 -        secondaryStructureConsensus.autoCalculated = true;
++      for(AlignmentAnnotation aa : secondaryStructureConsensuses) {
++        aa.hasText = true;
++        aa.autoCalculated = true;
 +        alignment.addAnnotation(aa);
        }
-       
 -      alignment.addAnnotation(secondaryStructureConsensus);
      }
    }
  
@@@ -57,9 -49,8 +57,8 @@@ public class SecondaryStructureConsensu
      // long started = System.currentTimeMillis();
      try
      {
 -      AlignmentAnnotation ssConsensus = getSSConsensusAnnotation();
 +      List<AlignmentAnnotation> ssConsensus = getSSConsensusAnnotation();
-       AlignmentAnnotation gap = getGapAnnotation();
-       if ((ssConsensus == null && gap == null) || calcMan.isPending(this))
+       if ((ssConsensus == null) || calcMan.isPending(this))
        {
          calcMan.workerComplete(this);
          return;
     */
    protected void eraseSSConsensus(int aWidth)
    {
 -    AlignmentAnnotation ssConsensus = getSSConsensusAnnotation();
 -    if (ssConsensus != null)
 -    {
 -      ssConsensus.annotations = new Annotation[aWidth];
 +    List<AlignmentAnnotation> ssConsensuses = getSSConsensusAnnotation();
 +    for(AlignmentAnnotation ssConsensus : ssConsensuses) {
 +      if (ssConsensus != null)
 +      {
 +        ssConsensus.annotations = new Annotation[aWidth];
 +      }
      }
-     AlignmentAnnotation gap = getGapAnnotation();
-     if (gap != null)
-     {
-       gap.annotations = new Annotation[aWidth];
-     }
    }
  
    /**
      return alignViewport
              .getAlignmentSecondaryStructureConsensusAnnotation();
    }
 +  
 +  /**
 +   * Get the Consensus annotation for the alignment
 +   * 
 +   * @return
 +   */
 +  protected void setSecondaryStructureSources()
 +  {
 +    List<String> sources = null;
 +    AlignmentAnnotation[] aa = alignViewport.getAlignment().getAlignmentAnnotation();
 +    if(aa!=null) {
 +      sources = AlignmentUtils.extractSSSourceInAlignmentAnnotation(aa);
 +      if(sources != null) {
 +        sources.add(0, Constants.SS_ALL_PROVIDERS);
 +        alignViewport.setSecondaryStructureSources(sources);
 +      }
 +    }
 +  }
 +  
 +  protected List<String> getSecondaryStructureSources()
 +  {
 +    return alignViewport.getSecondaryStructureSources();
 +  }
  
    /**
-    * Get the Gap annotation for the alignment
-    * 
-    * @return
-    */
-   protected AlignmentAnnotation getGapAnnotation()
-   {
-     return alignViewport.getAlignmentGapAnnotation();
-   }
-   /**
     * update the consensus annotation from the sequence profile data using
     * current visualization settings.
     */
  
    public void updateResultAnnotation(boolean immediate)
    {
 -    AlignmentAnnotation ssConsensus = getSSConsensusAnnotation();
 -    ProfilesI hSSConsensus = (ProfilesI) getViewportSSConsensus();
 +    List<AlignmentAnnotation> ssConsensuses = getSSConsensusAnnotation();
 +    Map<String, ProfilesI> ssConsensusProfileMap = getViewportSSConsensus();
 +    for(AlignmentAnnotation ssConsensus : ssConsensuses) {
 +      ProfilesI ssConsensusProfile = null;
 +      for(String source: ssConsensusProfileMap.keySet()) {
 +        if(ssConsensus.description.startsWith(source)) {
 +          ssConsensusProfile = ssConsensusProfileMap.get(source);
 +          break;
 +        }
 +      }
 +    if(ssConsensusProfile==null) {
 +      continue;
 +    }
      if (immediate || !calcMan.isWorking(this) && ssConsensus != null
 -            && hSSConsensus != null)
 +            && ssConsensusProfile != null)
      {
 -      deriveSSConsensus(ssConsensus, hSSConsensus);
 -      
 -      ssConsensus.hasData=hSSConsensus.getCount()>0;
 +      if(ssConsensusProfile.get(0)!=null)
 +      ssConsensus.setNoOfSequencesIncluded(ssConsensusProfile.get(0).getSeqWithSSCount());
 +      deriveSSConsensus(ssConsensus, ssConsensusProfile);
-       AlignmentAnnotation gap = getGapAnnotation();
-       if (gap != null)
-       {
-         deriveGap(gap, ssConsensusProfile);
-       }
++      ssConsensus.hasData=ssConsensusProfile.getCount()>0;
 +    }
      }
    }