X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=a4f5e4d917635f73fff1555873fb1a0a2049ac1d;hb=be545261cf6e7225da6f3ac1306b1b2609fd0e70;hp=c193ab3565c396d6b6f6f508a6633f9803b11f9a;hpb=58f1100520f493623282142819b09e363f583eb9;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index c193ab3..a4f5e4d 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -174,18 +174,13 @@ public class AlignFrame public void setGUINucleotide(boolean nucleotide) { showTranslation.setVisible( nucleotide ); - sequenceFeatures.setVisible(!nucleotide ); - featureSettings.setVisible( !nucleotide ); + //sequenceFeatures.setVisible(!nucleotide ); + //featureSettings.setVisible( !nucleotide ); conservationMenuItem.setVisible( !nucleotide ); modifyConservation.setVisible( !nucleotide ); - //Deal with separators //Remember AlignFrame always starts as protein - if(nucleotide) - { - viewMenu.remove(viewMenu.getItemCount()-2); - } - else + if(!nucleotide) { calculateMenu.remove(calculateMenu.getItemCount()-2); } @@ -205,8 +200,6 @@ public class AlignFrame { new SequenceFetcher(this); } - - /** * DOCUMENT ME! * @@ -457,42 +450,8 @@ public class AlignFrame // used by undo and redo void restoreHistoryItem(HistoryItem hi) { - if (hi.getType() == HistoryItem.SORT) - { - for (int i = 0; i < hi.getSequences().size(); i++) - { - viewport.alignment.getSequences().setElementAt(hi.getSequences() - .elementAt(i), - i); - } - } - else - { - for (int i = 0; i < hi.getSequences().size(); i++) - { - SequenceI restore = (SequenceI) hi.getSequences().elementAt(i); - if (restore.getLength() == 0) - { - restore.setSequence(hi.getHidden().elementAt(i).toString()); - viewport.alignment.getSequences().insertElementAt(restore, - hi.getAlignIndex(i)); - } - else - { - restore.setSequence(hi.getHidden().elementAt(i).toString()); - } - } - - if (hi.getType() == HistoryItem.PASTE) - { - for (int i = viewport.alignment.getHeight() - 1; - i > (hi.getSequences().size() - 1); i--) - { - viewport.alignment.deleteSequence(i); - } - } - } + hi.restore(); updateEditMenuBar(); @@ -698,7 +657,7 @@ public class AlignFrame if(str.length()<1) return; - String format = IdentifyFile.Identify(str, "Paste"); + String format = new IdentifyFile().Identify(str, "Paste"); SequenceI[] sequences; if(Desktop.jalviewClipboard!=null) @@ -810,24 +769,50 @@ public class AlignFrame return; } - addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment, - HistoryItem.HIDE)); SequenceGroup sg = viewport.getSelectionGroup(); - boolean allSequences = false; - if (sg.sequences.size() == viewport.alignment.getHeight()) + + + + //Jalview no longer allows deletion of residues. + //Check here whether any residues are in selection area + if( sg.getEndRes()-sg.getStartRes() < viewport.alignment.getWidth()-1) { - allSequences = true; + for (int i = 0; i < sg.sequences.size(); i++) + { + SequenceI seq = sg.getSequenceAt(i); + int j = sg.getStartRes(); + do + { + if (!jalview.util.Comparison.isGap(seq.getCharAt(j))) + { + JOptionPane.showInternalMessageDialog( + Desktop.desktop, "Cannot delete residues from alignment!\n" + + "Try hiding columns instead.", + "Deletion of residues not permitted", + JOptionPane.WARNING_MESSAGE); + + return; + } + j++; + }while(j<=sg.getEndRes()); + } } + + addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment, + HistoryItem.HIDE)); + + for (int i = 0; i < sg.sequences.size(); i++) { SequenceI seq = sg.getSequenceAt(i); int index = viewport.getAlignment().findIndex(seq); + seq.deleteChars(sg.getStartRes(), sg.getEndRes() + 1); // If the cut affects all sequences, remove highlighted columns - if (allSequences) + if (sg.sequences.size() == viewport.alignment.getHeight()) { viewport.getColumnSelection().removeElements(sg.getStartRes(), sg.getEndRes() + 1); @@ -906,7 +891,7 @@ public class AlignFrame viewport.getColumnSelection().clear(); viewport.setSelectionGroup(null); alignPanel.seqPanel.seqCanvas.highlightSearchResults(null); - alignPanel.annotationPanel.activeRes = null; + alignPanel.idPanel.idCanvas.searchResults = null; PaintRefresher.Refresh(null, viewport.alignment); } @@ -1200,8 +1185,8 @@ public class AlignFrame JInternalFrame frame = new JInternalFrame(); Finder finder = new Finder(viewport, alignPanel, frame); frame.setContentPane(finder); - Desktop.addInternalFrame(frame, "Find", 340, 110); frame.setLayer(JLayeredPane.PALETTE_LAYER); + Desktop.addInternalFrame(frame, "Find", 340, 110); } /** @@ -1328,25 +1313,37 @@ public class AlignFrame alignPanel.repaint(); } + public void fetchSeqFeatures_actionPerformed(ActionEvent e) + { + if (!viewport.alignment.isNucleotide()) + { + new SequenceFeatureFetcher(viewport. + alignment, + alignPanel); + viewport.setShowSequenceFeatures(true); + showSeqFeatures.setSelected(true); + } + } + + + public void featureSettings_actionPerformed(ActionEvent e) + { + new FeatureSettings(viewport, alignPanel); + } + /** * DOCUMENT ME! * * @param evt DOCUMENT ME! */ - public void sequenceFeatures_actionPerformed(ActionEvent evt) + public void showSeqFeatures_actionPerformed(ActionEvent evt) { - viewport.showSequenceFeatures(sequenceFeatures.isSelected()); - - if (viewport.showSequenceFeatures) + viewport.setShowSequenceFeatures(showSeqFeatures.isSelected()); + alignPanel.repaint(); + if (alignPanel.getOverviewPanel() != null) { - new SequenceFeatureFetcher(viewport. - alignment, - alignPanel); + alignPanel.getOverviewPanel().updateOverviewImage(); } - - featureSettings.setEnabled(true); - - alignPanel.repaint(); } /** @@ -2424,10 +2421,7 @@ public class AlignFrame } }*/ - public void featureSettings_actionPerformed(ActionEvent e) - { - new FeatureSettings(viewport, alignPanel); - } + @@ -2444,6 +2438,8 @@ public void showTranslation_actionPerformed(ActionEvent e) protein = new StringBuffer(); seq = AlignSeq.extractGaps("-. ", viewport.alignment.getSequenceAt(s).getSequence()); resSize = seq.length(); + resSize -= resSize%3; + for(res = 0; res < resSize; res+=3) { String codon = seq.substring(res, res+3); @@ -2545,16 +2541,18 @@ public void showTranslation_actionPerformed(ActionEvent e) */ public boolean parseGroupsFile(String file) { + String line = null; try { BufferedReader in = new BufferedReader(new FileReader(file)); SequenceI seq = null; - String line, type, desc, token; + String type, desc, token; int index, start, end; StringTokenizer st; SequenceFeature sf; int lineNo = 0; + String featureGroup = null; while ( (line = in.readLine()) != null) { lineNo++; @@ -2562,8 +2560,23 @@ public boolean parseGroupsFile(String file) if (st.countTokens() == 2) { type = st.nextToken(); - UserColourScheme ucs = new UserColourScheme(st.nextToken()); - alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setColour(type, ucs.findColour("A")); + if (type.equalsIgnoreCase("startgroup")) + { + featureGroup = st.nextToken(); + } + else if (type.equalsIgnoreCase("endgroup")) + { + //We should check whether this is the current group, + //but at present theres no way of showing more than 1 group + st.nextToken(); + featureGroup = null; + } + else + { + UserColourScheme ucs = new UserColourScheme(st.nextToken()); + alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setColour(type, + ucs.findColour("A")); + } continue; } @@ -2585,8 +2598,6 @@ public boolean parseGroupsFile(String file) end = Integer.parseInt(st.nextToken()); seq = viewport.alignment.getSequenceAt(index); - start = seq.findIndex(start) - 1; - end = seq.findIndex(end) - 1; type = st.nextToken(); @@ -2598,6 +2609,7 @@ public boolean parseGroupsFile(String file) } sf = new SequenceFeature(type, desc, "", start, end); + sf.setFeatureGroup(featureGroup); seq.getDatasetSequence().addSequenceFeature(sf); } @@ -2605,11 +2617,14 @@ public boolean parseGroupsFile(String file) } catch (Exception ex) { - System.out.println("Error parsing groups file: " + ex); + System.out.println(line); + ex.printStackTrace(); + System.out.println("Error parsing groups file: " + ex +"\n"+line); return false; } viewport.showSequenceFeatures = true; + showSeqFeatures.setSelected(true); alignPanel.repaint(); return true; } @@ -2687,7 +2702,7 @@ public void drop(DropTargetDropEvent evt) if (!isGroupsFile) { String protocol = "File"; - String format = jalview.io.IdentifyFile.Identify(file, protocol); + String format = new IdentifyFile().Identify(file, protocol); SequenceI[] sequences = new FormatAdapter().readFile(file, protocol, format); FastaFile ff = new FastaFile();