From: jprocter Date: Wed, 31 Oct 2007 17:41:19 +0000 (+0000) Subject: rejiggered loadDataFile and parseFeatureFile so JNet annotation parsing is attempted... X-Git-Tag: Release_2_4~206 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=10b27a2672c66e9c927194065d187cc744105867;hp=a3a998f2eb05edbf4bdb22cf2f5449d742001ee7;p=jalview.git rejiggered loadDataFile and parseFeatureFile so JNet annotation parsing is attempted before feature file parsing (avoids additional exception reports on stderr) --- diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 99227e1..a714ce6 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -3761,9 +3761,10 @@ public void showTranslation_actionPerformed(ActionEvent e) } /** - * DOCUMENT ME! - * - * @param String DOCUMENT ME! + * Try to load a features file onto the alignment. + * @param file contents or path to retrieve file + * @param type access mode of file (see jalview.io.AlignFile) + * @return true if features file was parsed corectly. */ public boolean parseFeaturesFile(String file, String type) { @@ -3864,12 +3865,15 @@ public void drop(DropTargetDropEvent evt) } } - // This method will attempt to load a "dropped" file first by testing - // whether its and Annotation file, then features file. If both are - // false then the user may have dropped an alignment file onto this - // AlignFrame + /** + * Attempt to load a "dropped" file: First by testing + * whether it's and Annotation file, then a JNet file, and finally a features file. If all are + * false then the user may have dropped an alignment file onto this + * AlignFrame. + * @param file either a filename or a URL string. + */ public void loadJalviewDataFile(String file) - { + { try { String protocol = "File"; @@ -3884,34 +3888,37 @@ public void drop(DropTargetDropEvent evt) if (!isAnnotation) { - boolean isGroupsFile = parseFeaturesFile(file,protocol); - if (!isGroupsFile) + // try to see if its a JNet 'concise' style annotation file *before* we try to parse it as a features file + String format = new IdentifyFile().Identify(file, protocol); + if(format.equalsIgnoreCase("JnetFile")) { - String format = new IdentifyFile().Identify(file, protocol); - - if(format.equalsIgnoreCase("JnetFile")) - { - jalview.io.JPredFile predictions = new jalview.io.JPredFile( - file, protocol); - new JnetAnnotationMaker().add_annotation(predictions, + jalview.io.JPredFile predictions = new jalview.io.JPredFile( + file, protocol); + new JnetAnnotationMaker().add_annotation(predictions, viewport.getAlignment(), 0, false); - alignPanel.adjustAnnotationHeight(); - alignPanel.paintAlignment(true); - } - else + isAnnotation=true; + } + else + { + // try to parse it as a features file + boolean isGroupsFile = parseFeaturesFile(file,protocol); + // if it wasn't a features file then we just treat it as a general alignment file to load into the current view. + if (!isGroupsFile) { new FileLoader().LoadFile(viewport, file, protocol, format); + } else { + alignPanel.paintAlignment(true); + } } } - } - else + if (isAnnotation) { - // (isAnnotation) + alignPanel.adjustAnnotationHeight(); buildSortByAnnotationScoresMenu(); + alignPanel.paintAlignment(true); } - } catch (Exception ex) {