JAL-842; Give Varna frames name for window organizer; always display
[jalview.git] / src / jalview / gui / AlignFrame.java
index f74d05e..7b6c6af 100755 (executable)
@@ -65,6 +65,7 @@ import jalview.schemes.HelixColourScheme;
 import jalview.schemes.HydrophobicColourScheme;
 import jalview.schemes.NucleotideColourScheme;
 import jalview.schemes.PIDColourScheme;
+import jalview.schemes.PurinePyrimidineColourScheme;
 import jalview.schemes.ResidueProperties;
 import jalview.schemes.StrandColourScheme;
 import jalview.schemes.TaylorColourScheme;
@@ -754,7 +755,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       progressBars.put(lId, progressPanel);
     }
     // update GUI
-    setMenusForViewport();
+    // setMenusForViewport();
     validate();
   }
 
@@ -2964,10 +2965,25 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     changeColour(new NucleotideColourScheme());
   }
 
+  public void purinePyrimidineColour_actionPerformed(ActionEvent e)
+  {
+    changeColour(new PurinePyrimidineColourScheme());
+  }
+  /*
+  public void covariationColour_actionPerformed(ActionEvent e)
+  {
+    changeColour(new CovariationColourScheme(viewport.alignment.getAlignmentAnnotation()[0]));
+  }
+  */
   public void annotationColour_actionPerformed(ActionEvent e)
   {
     new AnnotationColourChooser(viewport, alignPanel);
   }
+  
+  public void rnahelicesColour_actionPerformed(ActionEvent e)
+  {
+    new RNAHelicesColourChooser(viewport, alignPanel);
+  }
 
   /**
    * DOCUMENT ME!
@@ -3724,6 +3740,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     }
   }
 
+  public boolean sortBy(AlignmentOrder alorder, String undoname)
+  {
+    SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
+    AlignmentSorter.sortBy(viewport.getAlignment(), alorder);
+    if (undoname != null)
+    {
+      addHistoryItem(new OrderCommand(undoname, oldOrder,
+              viewport.alignment));
+    }
+    alignPanel.paintAlignment(true);
+    return true;
+  }
+
   /**
    * Work out whether the whole set of sequences or just the selected set will
    * be submitted for multiple alignment.
@@ -4377,7 +4406,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       featuresFile = new FeaturesFile(file, type)
               .parse(viewport.alignment.getDataset(),
                       alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureColours,
-                      false);
+                      false, jalview.bin.Cache.getDefault(
+                              "RELAXEDSEQIDMATCHING", false));
     } catch (Exception ex)
     {
       ex.printStackTrace();
@@ -4499,19 +4529,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           if (pdbfn.length() > 0)
           {
             // attempt to find a match in the alignment
-            SequenceI mtch = idm.findIdMatch(pdbfn);
+            SequenceI[] mtch = idm.findAllIdMatches(pdbfn);
             int l = 0, c = pdbfn.indexOf(".");
             while (mtch == null && c != -1)
             {
-              while ((c = pdbfn.indexOf(".", l)) > l)
+              do 
               {
                 l = c;
-              }
+              } while ((c = pdbfn.indexOf(".", l)) > l);
               if (l > -1)
               {
                 pdbfn = pdbfn.substring(0, l);
               }
-              mtch = idm.findIdMatch(pdbfn);
+              mtch = idm.findAllIdMatches(pdbfn);
             }
             if (mtch != null)
             {
@@ -4556,17 +4586,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
               // try and associate
               // TODO: may want to set a standard ID naming formalism for
               // associating PDB files which have no IDs.
+              for (SequenceI toassoc: (SequenceI[])fm[2]) {
               PDBEntry pe = new AssociatePdbFileWithSeq()
                       .associatePdbWithSeq((String) fm[0], (String) fm[1],
-                              (SequenceI) fm[2], false);
+                              toassoc, false);
               if (pe != null)
               {
                 System.err
                         .println("Associated file : " + ((String) fm[0])
                                 + " with "
-                                + ((SequenceI) fm[2]).getDisplayId(true));
+                                + toassoc.getDisplayId(true));
                 assocfiles++;
               }
+              }
               alignPanel.paintAlignment(true);
             }
           }
@@ -4685,6 +4717,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
         viewport.updateSequenceIdColours();
         buildSortByAnnotationScoresMenu();
         alignPanel.paintAlignment(true);
+        System.out.println("Hallo");
       }
     } catch (Exception ex)
     {
@@ -5030,6 +5063,26 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       alignPanel.paintAlignment(true);
     }
   }
+
+  /**
+   * make the given alignmentPanel the currently selected tab
+   * 
+   * @param alignmentPanel
+   */
+  public void setDisplayedView(AlignmentPanel alignmentPanel)
+  {
+    if (!viewport.getSequenceSetId().equals(
+            alignmentPanel.av.getSequenceSetId()))
+    {
+      throw new Error(
+              "Implementation error: cannot show a view from another alignment in an AlignFrame.");
+    }
+    if (tabbedPane != null
+            & alignPanels.indexOf(alignmentPanel) != tabbedPane.getSelectedIndex())
+    {
+      tabbedPane.setSelectedIndex(alignPanels.indexOf(alignmentPanel));
+    }
+  }
 }
 
 class PrintThread extends Thread