X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignFrame.java;h=32a50cfbfa30c359defac13060d2ebab1b8adf1b;hb=e4dca3706ab423352c26ac100f3ca5a3e7c3d2c4;hp=7921ed23bb7d71b097ba36f195326980f606b56e;hpb=e44514b727077d5cd7edb5d8184ab85cbc2eed13;p=jalview.git diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 7921ed2..32a50cf 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -125,11 +125,17 @@ public class AlignFrame }); - if (Desktop.desktop != null) - { - addServiceListeners(); - setGUINucleotide(al.isNucleotide()); - } + if (Desktop.desktop != null) + { + addServiceListeners(); + setGUINucleotide(al.isNucleotide()); + } + + if(jalview.bin.Cache.getDefault("WRAP_ALIGNMENT", false)) + { + wrapMenuItem.setSelected(true); + wrapMenuItem_actionPerformed(null); + } } /* Set up intrinsic listeners for dynamically generated GUI bits. */ @@ -224,19 +230,15 @@ public class AlignFrame public void saveAlignmentMenu_actionPerformed(ActionEvent e) { JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. - getProperty( - "LAST_DIRECTORY"), + getProperty( "LAST_DIRECTORY"), new String[] - { - "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", - "jar" - }, + { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc","jar" }, new String[] - { - "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" - }, currentFileFormat); + { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" }, + currentFileFormat, + false); + - chooser.setAcceptAllFileFilterUsed(false); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle("Save Alignment to file"); chooser.setToolTipText("Save"); @@ -377,6 +379,20 @@ public class AlignFrame thread.start(); } + public void exportFeatures_actionPerformed(ActionEvent e) + { + new AnnotationExporter().exportFeatures(alignPanel); + } + + public void exportAnnotations_actionPerformed(ActionEvent e) + { + new AnnotationExporter().exportAnnotations( + alignPanel, + viewport.alignment.getAlignmentAnnotation() + ); + } + + public void associatedData_actionPerformed(ActionEvent e) { // Pick the tree file @@ -1386,14 +1402,11 @@ public class AlignFrame public void fetchSeqFeatures_actionPerformed(ActionEvent e) { - if (!viewport.alignment.isNucleotide()) - { new DasSequenceFeatureFetcher(viewport. alignment, alignPanel); viewport.setShowSequenceFeatures(true); showSeqFeatures.setSelected(true); - } } @@ -2621,93 +2634,27 @@ public void showTranslation_actionPerformed(ActionEvent e) * * @param String DOCUMENT ME! */ -public boolean parseGroupsFile(String file) +public boolean parseFeaturesFile(String file, String type) { - String line = null; - try - { - BufferedReader in = new BufferedReader(new FileReader(file)); - SequenceI seq = null; - String type, desc, token; - - int index, start, end; - StringTokenizer st; - SequenceFeature sf; - int lineNo = 0; - String featureGroup = null; - while ( (line = in.readLine()) != null) - { - lineNo++; - st = new StringTokenizer(line, "\t"); - if (st.countTokens() == 2) - { - type = st.nextToken(); - 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; - } - - while (st.hasMoreElements()) - { - desc = st.nextToken(); - token = st.nextToken(); - if (!token.equals("ID_NOT_SPECIFIED")) - { - index = viewport.alignment.findIndex(viewport.alignment.findName(token)); - st.nextToken(); - } - else - { - index = Integer.parseInt(st.nextToken()); - } - - start = Integer.parseInt(st.nextToken()); - end = Integer.parseInt(st.nextToken()); - - seq = viewport.alignment.getSequenceAt(index); - - type = st.nextToken(); - - if (alignPanel.seqPanel.seqCanvas.getFeatureRenderer().getColour(type) == null) - { - // Probably the old style groups file - UserColourScheme ucs = new UserColourScheme(type); - alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setColour(type, ucs.findColour("A")); - } - - sf = new SequenceFeature(type, desc, "", start, end, featureGroup); - - seq.getDatasetSequence().addSequenceFeature(sf); - } - } + boolean featuresFile = false; + try{ + featuresFile = new FeaturesFile(file, type).parse(viewport.alignment, + alignPanel.seqPanel.seqCanvas. + getFeatureRenderer().featureColours); } - catch (Exception ex) + catch(Exception 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; + if(featuresFile) + { + viewport.showSequenceFeatures = true; + showSeqFeatures.setSelected(true); + alignPanel.repaint(); + } + + return featuresFile; } public void dragEnter(DropTargetDragEvent evt) @@ -2788,12 +2735,13 @@ public void drop(DropTargetDropEvent evt) public void loadJalviewDataFile(String file) { try{ - boolean isAnnotation = new AnnotationReader().readAnnotationFile(viewport. + boolean isAnnotation = new AnnotationFile().readAnnotationFile(viewport. alignment, file); if (!isAnnotation) { - boolean isGroupsFile = parseGroupsFile(file); + boolean isGroupsFile = parseFeaturesFile(file, + AppletFormatAdapter.FILE); if (!isGroupsFile) { String protocol = "File";