From: Renia Correya Date: Wed, 25 Sep 2024 14:48:53 +0000 (+0100) Subject: Merge develop into feature/JAL-4386_calculate_tree_using_secondary_structure_annotation X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2940d9c01539dd10962eb201ec7f0cb0eb905be9;p=jalview.git Merge develop into feature/JAL-4386_calculate_tree_using_secondary_structure_annotation Resolved merge conflicts in Messages.properties, GAlignFrame.java, AlignmentViewport.java, and SecondaryStructureConsensusThread.java --- 2940d9c01539dd10962eb201ec7f0cb0eb905be9 diff --cc src/jalview/analysis/AAFrequency.java index 7ff77af,dd5cb91..8d287df --- a/src/jalview/analysis/AAFrequency.java +++ b/src/jalview/analysis/AAFrequency.java @@@ -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++) { diff --cc src/jalview/jbgui/GAlignFrame.java index e802646,8c71384..109a6d1 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@@ -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); @@@ -2084,19 -2085,14 +2084,20 @@@ // 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 diff --cc src/jalview/viewmodel/AlignmentViewport.java index 8308992,529475b..e30545d --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@@ -2133,6 -2056,7 +2132,23 @@@ public abstract class AlignmentViewpor { initConservation(); initQuality(); - initSSConsensus(); ++ ++ setSecondaryStructureSources(alignment.getAlignmentAnnotation()); ++ List secondaryStructureSources = getSecondaryStructureSources(); ++ ++ if(secondaryStructureSources!=null) { ++ ++ secondaryStructureConsensus = new ArrayList(); ++ 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 { @@@ -2141,24 -2065,9 +2157,8 @@@ consensus = new AlignmentAnnotation("Consensus", MessageManager.getString("label.consensus_descr"), new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); - setSecondaryStructureSources(alignment.getAlignmentAnnotation()); - List secondaryStructureSources = getSecondaryStructureSources(); - - if(secondaryStructureSources!=null) { - - secondaryStructureConsensus = new ArrayList(); - 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(); } @@@ -2214,21 -2123,22 +2214,19 @@@ alignment.addAnnotation(aa); } } - - private void initSSConsensus() + + private void initSSConsensus(List 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); } } diff --cc src/jalview/workers/SecondaryStructureConsensusThread.java index 259d96b,5b046b6..aa4823b --- a/src/jalview/workers/SecondaryStructureConsensusThread.java +++ b/src/jalview/workers/SecondaryStructureConsensusThread.java @@@ -57,9 -49,8 +57,8 @@@ public class SecondaryStructureConsensu // long started = System.currentTimeMillis(); try { - AlignmentAnnotation ssConsensus = getSSConsensusAnnotation(); + List ssConsensus = getSSConsensusAnnotation(); - AlignmentAnnotation gap = getGapAnnotation(); - if ((ssConsensus == null && gap == null) || calcMan.isPending(this)) + if ((ssConsensus == null) || calcMan.isPending(this)) { calcMan.workerComplete(this); return; @@@ -124,18 -114,11 +123,13 @@@ */ protected void eraseSSConsensus(int aWidth) { - AlignmentAnnotation ssConsensus = getSSConsensusAnnotation(); - if (ssConsensus != null) - { - ssConsensus.annotations = new Annotation[aWidth]; + List 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]; - } } /** @@@ -189,41 -166,8 +183,31 @@@ return alignViewport .getAlignmentSecondaryStructureConsensusAnnotation(); } + + /** + * Get the Consensus annotation for the alignment + * + * @return + */ + protected void setSecondaryStructureSources() + { + List 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 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. */ @@@ -235,31 -179,14 +219,27 @@@ public void updateResultAnnotation(boolean immediate) { - AlignmentAnnotation ssConsensus = getSSConsensusAnnotation(); - ProfilesI hSSConsensus = (ProfilesI) getViewportSSConsensus(); + List ssConsensuses = getSSConsensusAnnotation(); + Map 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; + } } }