X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=7efd90031064528903a0405b536c9cd915ad93fe;hb=0180bdb7d844cd1119a885dc42329ccc6deeacd5;hp=61c66724f1f10baad6dac2ceac7fe10674d9553b;hpb=e9217775986fbca85770d7fe5b3763b6920b0c3f;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 61c6672..7efd900 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -59,9 +59,13 @@ public class AlignFrame Vector alignPanels = new Vector(); - /** DOCUMENT ME!! */ + /** + * Last format used to load or save alignments in this window + */ String currentFileFormat = null; - + /** + * Current filename for this alignment + */ String fileName = null; @@ -142,7 +146,7 @@ public class AlignFrame } setMenusFromViewport(viewport); - + buildSortByAnnotationScoresMenu(); if (viewport.wrapAlignment) { wrapMenuItem_actionPerformed(null); @@ -498,14 +502,17 @@ public class AlignFrame showTranslation.setVisible( nucleotide ); conservationMenuItem.setEnabled( !nucleotide ); modifyConservation.setEnabled( !nucleotide ); - + //Remember AlignFrame always starts as protein if(!nucleotide) { calculateMenu.remove(calculateMenu.getItemCount()-2); } + setShowProductsEnabled(); } + + /** * Need to call this method when tabs are selected for multiple views, * or when loading from Jalview2XML.java @@ -689,10 +696,8 @@ public class AlignFrame { JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. getProperty( "LAST_DIRECTORY"), - new String[] - { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc","jar" }, - new String[] - { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" }, + jalview.io.AppletFormatAdapter.WRITABLE_EXTENSIONS, + jalview.io.AppletFormatAdapter.WRITABLE_FNAMES, currentFileFormat, false); @@ -722,7 +727,10 @@ public class AlignFrame currentFileFormat); jalview.bin.Cache.setProperty("LAST_DIRECTORY", fileName); - + if (currentFileFormat.indexOf(" ")>-1) + { + currentFileFormat = currentFileFormat.substring(0, currentFileFormat.indexOf(" ")); + } saveAlignment(fileName, currentFileFormat); } } @@ -766,11 +774,12 @@ public class AlignFrame omitHidden = viewport.getViewAsString(false); } } + FormatAdapter f = new FormatAdapter(); - String output = new FormatAdapter().formatSequences( + String output = f.formatSequences( format, - viewport.alignment.getSequencesArray(), - omitHidden); + (Alignment) viewport.alignment, // class cast exceptions will occur in the distant future + omitHidden, f.getCacheSuffixDefault(format), viewport.colSel); if (output == null) { @@ -841,8 +850,8 @@ public class AlignFrame cap.setText(new FormatAdapter().formatSequences( e.getActionCommand(), - viewport.alignment.getSequencesArray(), - omitHidden)); + viewport.alignment, + omitHidden, viewport.colSel)); } /** @@ -1049,8 +1058,28 @@ public class AlignFrame } } - - + /** + * + * @return alignment objects for all views + */ + AlignmentI[] getViewAlignments() + { + if (alignPanels!=null) + { + Enumeration e = alignPanels.elements(); + AlignmentI[] als = new AlignmentI[alignPanels.size()]; + for (int i=0; e.hasMoreElements(); i++) + { + als[i] = ((AlignmentPanel) e.nextElement()).av.getAlignment(); + } + return als; + } + if (viewport!=null) + { + return new AlignmentI[] { viewport.alignment }; + } + return null; + } /** * DOCUMENT ME! * @@ -1058,9 +1087,11 @@ public class AlignFrame */ protected void undoMenuItem_actionPerformed(ActionEvent e) { + if (viewport.historyList.empty()) + return; CommandI command = (CommandI)viewport.historyList.pop(); viewport.redoList.push(command); - command.undoCommand(); + command.undoCommand(getViewAlignments()); AlignViewport originalSource = getOriginatingSource(command); updateEditMenuBar(); @@ -1088,7 +1119,7 @@ public class AlignFrame CommandI command = (CommandI) viewport.redoList.pop(); viewport.historyList.push(command); - command.doCommand(); + command.doCommand(getViewAlignments()); AlignViewport originalSource = getOriginatingSource(command); updateEditMenuBar(); @@ -1582,18 +1613,44 @@ public class AlignFrame alignment.addAnnotation(sequences[i].getAnnotation()[a]); // annotation was duplicated earlier alignment.setAnnotationIndex(sequences[i].getAnnotation()[a], a); } - - } } if (!newAlignment) { + // propagate alignment changed. viewport.setEndSeq(alignment.getHeight()); if (annotationAdded) { - alignPanel.annotationPanel.adjustPanelHeight(); + // Duplicate sequence annotation in all views. + AlignmentI[] alview = this.getViewAlignments(); + for (int i = 0; i < sequences.length; i++) + { + AlignmentAnnotation sann[] = sequences[i].getAnnotation(); + if (sann == null) + continue; + for (int avnum=0;avnum0); scoreSorts.clear(); + + _annotationScoreVectorHash = + viewport.alignment.getAlignmentAnnotation().hashCode(); } } @@ -3255,21 +3325,28 @@ public class AlignFrame { String choice = chooser.getSelectedFile().getPath(); jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice); - + jalview.io.NewickFile fin = null; try { - jalview.io.NewickFile fin = new jalview.io.NewickFile(choice, + fin = new jalview.io.NewickFile(choice, "File"); viewport.setCurrentTree(ShowNewickTree(fin, choice).getTree()); } catch (Exception ex) { JOptionPane.showMessageDialog(Desktop.desktop, - "Problem reading tree file", ex.getMessage(), + "Problem reading tree file", JOptionPane.WARNING_MESSAGE); ex.printStackTrace(); } + if (fin!=null && fin.hasWarningMessage()) + { + JOptionPane.showMessageDialog(Desktop.desktop, + fin.getWarningMessage(), + "Possible problem with tree file", + JOptionPane.WARNING_MESSAGE); + } } } @@ -3334,7 +3411,7 @@ public class AlignFrame { ex.printStackTrace(); } - + return tp; } @@ -3466,7 +3543,7 @@ public class AlignFrame public void actionPerformed(ActionEvent e) { - new jalview.io.DBRefFetcher( + new jalview.ws.DBRefFetcher( alignPanel.av.getSequenceSelection(), alignPanel.alignFrame).fetchDBRefs(false); } @@ -3492,8 +3569,164 @@ public class AlignFrame vs.storeJalview( chooser.getSelectedFile().getAbsolutePath(), this); } }*/ + /** + * prototype of an automatically enabled/disabled analysis function + * + */ + protected void setShowProductsEnabled() + { + SequenceI [] selection = viewport.getSequenceSelection(); + if (canShowProducts(selection, viewport.getSelectionGroup()!=null, viewport.getAlignment().getDataset())) + { + showProducts.setEnabled(true); + + } else { + showProducts.setEnabled(false); + } + } + /** + * search selection for sequence xRef products and build the + * show products menu. + * @param selection + * @param dataset + * @return true if showProducts menu should be enabled. + */ + public boolean canShowProducts(SequenceI[] selection, boolean isRegionSelection, Alignment dataset) + { + boolean showp=false; + try { + showProducts.removeAll(); + final boolean dna = viewport.getAlignment().isNucleotide(); + final Alignment ds = dataset; + String[] ptypes = CrossRef.findSequenceXrefTypes(dna, selection, dataset); + //Object[] prods = CrossRef.buildXProductsList(viewport.getAlignment().isNucleotide(), selection, dataset, true); + final SequenceI[] sel = selection; + for (int t=0; ptypes!=null && t