Merge branch 'develop' into feature/JAL-4159_pasimap_JAL-4423_alt_msa_source
authorJim Procter <jprocter@dundee.ac.uk>
Mon, 19 Aug 2024 16:39:09 +0000 (17:39 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Mon, 19 Aug 2024 16:39:09 +0000 (17:39 +0100)
 Conflicts:
src/jalview/analysis/AlignSeq.java
src/jalview/analysis/PaSiMap.java
src/jalview/gui/CalculationChooser.java
src/jalview/gui/PaSiMapPanel.java
src/jalview/viewmodel/PaSiMapModel.java

1  2 
src/jalview/analysis/AlignSeq.java
src/jalview/analysis/PaSiMap.java
src/jalview/gui/CalculationChooser.java
src/jalview/gui/PaSiMapPanel.java
src/jalview/viewmodel/PaSiMapModel.java

Simple merge
   */
  package jalview.analysis;
  
 +import jalview.analysis.scoremodels.ScoreModels;
 +import jalview.analysis.scoremodels.SimilarityParams;
  import jalview.api.analysis.ScoreModelI;
  import jalview.api.analysis.SimilarityParamsI;
+ import jalview.analysis.scoremodels.ScoreMatrix;
 -import jalview.analysis.scoremodels.ScoreModels;
  import jalview.bin.Console;
 +import jalview.datamodel.Alignment;
 +import jalview.datamodel.AlignmentI;
 +import jalview.datamodel.AlignmentView;
  import jalview.datamodel.Point;
  import jalview.datamodel.SequenceI;
  import jalview.datamodel.SequenceGroup;
@@@ -210,37 -229,10 +225,37 @@@ public class PaSiMap implements Runnabl
      try
      {
        // alignment = new PairwiseAlignPanel(seqs, true, 100, 5);
 -      alignment.calculate(scoreMatrix);
 -      float[][] scores = alignment.getAlignmentScores(); // bigger index first
 -                                                         // -- eg scores[14][13]
 -      SequenceI[] iseqs = alignment.getInputSequences();
 +      float[][] scores;
 +      SequenceI[] iseqs;
-       if (!dontRealign)
++      if (!dontRealign && scoreModel instanceof ScoreMatrix)
 +      {
-         alignment.calculate();
++        alignment.calculate((ScoreMatrix)scoreModel);
 +        iseqs = alignment.getInputSequences();
 +        scores = alignment.getAlignmentScores(); // bigger index first -- eg
 +                                                 // scores[14][13]
 +      }
 +      else
 +      {
 +        AlignmentView alignview = seqs.getAlignmentView(true);
 +        iseqs = alignview.getEditedSequences(seqs.getGapCharacter(), false);
 +        ScoreModelI sm = scoreModel;
 +        if (sm== null)
 +        {
 +          sm = ScoreModels.getInstance().getDefaultModel(!seqs.isNucleotide());
 +        }
 +        MatrixI similarities = sm.findSimilarities(alignview,
 +                SimilarityParams.Jalview);
 +        scores = new float[similarities.height()][similarities.width()];
 +        for (int i = 0; i < scores.length; i++)
 +        {
 +          double[] row = similarities.getRow(i);
 +          for (int j = 0; j < scores[i].length; j++)
 +          {
 +            scores[i][j] = (float) row[j];
 +          }
 +        }
 +      }
 +
        Connectivity.getConnectivity(iseqs, scores, dim);
  
        pairwiseScores = new Matrix(scores);
@@@ -308,17 -353,8 +355,17 @@@ public class CalculationChooser extend
      paramsPanel.add(matchGaps);
      paramsPanel.add(includeGappedColumns);
      paramsPanel.add(shorterSequence);
-     
      /*
 +     * pasimap parameters
 +     */
 +    reuseAlignment = new JCheckBox("Use aligned similarity");
 +    reuseAlignment.setSelected(false);
 +    reuseAlignment.setVisible(false);
 +    scoreModelPanel.add(reuseAlignment);
 +              
 +    
 +    /*
       * OK / Cancel buttons
       */
      calculate = new JButton(MessageManager.getString("action.calculate"));
              MIN_TREE_SELECTION);
      boolean checkAverageDistance = checkEnabled(averageDistance, size,
              MIN_TREE_SELECTION);
+     boolean checkPairwise = checkEnabled(pairwise, size,
+             MIN_PAIRWISE_SELECTION);
  
 +    reuseAlignment.setVisible(checkPasimap);
-     if (checkPca || checkPasimap || checkNeighbourJoining || checkAverageDistance)
+     if (checkPca || checkPasimap || checkPca || checkNeighbourJoining
+             || checkAverageDistance || checkPairwise)
      {
        calculate.setToolTipText(null);
        calculate.setEnabled(true);
@@@ -201,23 -198,27 +201,28 @@@ public class PaSiMapPanel extends GPaSi
        {
          selGroup = new SequenceGroup(av.getAlignment().getSequences());
          selGroup.setStartRes(0);
-         selGroup.setEndRes(av.getAlignment().getWidth()-1);
+         selGroup.setEndRes(av.getAlignment().getWidth() - 1);
        }
-       
-       if (selGroup.getSize()>MAX_PASIMAP_SEQ)
+       if (selGroup.getSize() > MAX_PASIMAP_SEQ)
        {
-         int start = selGroup.getStartRes(),end=selGroup.getEndRes();
-           selGroup = new SequenceGroup(selGroup.getSequences().subList(0, MAX_PASIMAP_SEQ));
-           selGroup.setStartRes(start);
-           selGroup.setEndRes(end);
-           Console.warn("Truncated input sequences for PASIMAP analysis to "+MAX_PASIMAP_SEQ);
+         int start = selGroup.getStartRes(), end = selGroup.getEndRes();
+         selGroup = new SequenceGroup(
+                 selGroup.getSequences().subList(0, MAX_PASIMAP_SEQ));
+         selGroup.setStartRes(start);
+         selGroup.setEndRes(end);
+         Console.warn("Truncated input sequences for PASIMAP analysis to "
+                 + MAX_PASIMAP_SEQ);
        }
-       
        PairwiseAlignPanel pap = new PairwiseAlignPanel(av, selGroup, true,
-               GAP_OPEN_COST, GAP_EXTEND_COST, false);
+               GAP_OPEN_COST, GAP_EXTEND_COST, false, null);
+       pap.setDiscardAlignments(true);
+       pap.setQuiet(true);
        System.out.println(pap != null);
        setPairwiseAlignPanel(pap);
 +      getPasimapModel().setUseObservedAlignment(useObservedAlignment);
        getPasimapModel().calculate(pap);
  
        xCombobox.setSelectedIndex(0);