From: Jim Procter Date: Mon, 1 Dec 2014 15:40:00 +0000 (+0000) Subject: Merge branch 'bug/JAL-1610refAnnotationsInViews' into develop X-Git-Tag: Jalview_2_9~135 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=08617b1bc5ef84c8134ad7d69c68a8eb4a9433de;hp=263d87f485673ab9e1b6e1b50229a282c2c85671 Merge branch 'bug/JAL-1610refAnnotationsInViews' into develop --- diff --git a/.classpath b/.classpath index f87dd26..4c39421 100644 --- a/.classpath +++ b/.classpath @@ -45,15 +45,15 @@ + - - + diff --git a/.gitignore b/.gitignore index c47ff62..0c12fb0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ /.DS_Store .DS_Store /.com.apple.timemachine.supported +.gitattributes + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 884491a..f72955b 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,15 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/examples/example_biojs.html b/examples/example_biojs.html new file mode 100644 index 0000000..b6f7bec --- /dev/null +++ b/examples/example_biojs.html @@ -0,0 +1,9031 @@ + +
BioJS viewer
+ + + + + + + + Jalview Logo + +
+
+ + + + +
+
+ +
press "Run with JS"
+ + + + + + + + diff --git a/help/html/features/clarguments.html b/help/html/features/clarguments.html index 1cb1849..dc28e03 100644 --- a/help/html/features/clarguments.html +++ b/help/html/features/clarguments.html @@ -126,6 +126,13 @@ arguments have been processed + + +
-jabaws URL
+ +
Specify the URL of the preferred JABAWS server
+ +
-vdoc VAMSAS DOCUMENT FILE/URL
@@ -196,7 +203,7 @@
-svg FILE
-
Create Support Vector Graphics file FILE from alignment.
+
Create Scalable Vector Graphics file FILE from alignment.
diff --git a/help/html/io/export.html b/help/html/io/export.html index 6d121b8..35b2481 100755 --- a/help/html/io/export.html +++ b/help/html/io/export.html @@ -35,7 +35,7 @@ diagrams and powerpoint presentations
  • EPS - an Encapsulated Postscript Document
    For high quality diagrams and publications. -
  • SVG - a Support Vector Graphics document
    For high quality +
  • SVG - a Scalable Vector Graphics document
    For high quality diagrams in publications and on the web.
  • diff --git a/help/html/menus/alwfile.html b/help/html/menus/alwfile.html index 7cd096c..63f4aec 100755 --- a/help/html/menus/alwfile.html +++ b/help/html/menus/alwfile.html @@ -89,7 +89,7 @@ Create a Portable Network Graphics file from your alignment.
  • SVG
    -
    Create a Support Vector Graphics file from your alignment for embedding in web pages.
  • + Create a Scalable Vector Graphics file from your alignment for embedding in web pages.
  • Export Features
    diff --git a/help/html/na/index.html b/help/html/na/index.html index f3c4a56..844b6b7 100644 --- a/help/html/na/index.html +++ b/help/html/na/index.html @@ -67,7 +67,7 @@ td { as LocaRNA output consensus RNA secondary structure lines in the line normally reserved for the Clustal consensus line in a clustal file.
  • - +
  • RNAML Jalview can import RNAML files containing sequences and extended secondary structure annotation derived from RNA 3D structure
  • RNA Secondary Structure Visualization and Analysis
    @@ -85,6 +85,10 @@ td { Visualization in VARNA - allows linked viewing of the consensus or an individual sequence's structure +

    Pseudo-knots
    + Jalview 2.8.2 introduced limited support for working with structures including pseudoknots. Where possible, extended WUSS symbols (e.g. different types of parentheses, or upper and lower case letters) are preserved when parsing RNA structure annotation and will be shaded differently when displayed in the structure.
    + Extended WUSS annotation is also employed to distinguish different base pair interactions obtained from RNAML files.

    +

    Limitations when working with RNA in Jalview
    Currently, Jalview is not able to export RNA secondary structure annotation in any format other than Jalview annotation
    diff --git a/help/html/releases.html b/help/html/releases.html index 8913a32..1f5ca08 100755 --- a/help/html/releases.html +++ b/help/html/releases.html @@ -25,43 +25,191 @@

    Release History

    - - - - - + + + + + - +
  • Output in Stockholm format
  • +
  • Internationalisation: improved Spanish (es) translation
  • +
  • Structure viewer preferences tab
  • +
  • Disorder and Secondary Structure annotation tracks shared + between alignments
  • +
  • UCSF launch and linked highlighting from Jalview
  • +
  • Show/hide all sequence associated annotation rows for all + or current selection
  • +
  • disorder and secondary structure predictions available as + dataset annotation
  • +
  • Per-sequence rna helices colouring
  • + + +
  • Sequence database accessions imported when fetching + alignments from Rfam
  • +
  • update VARNA version to 3.91
  • + +
  • New groovy scripts for exporting aligned positions, + conservation values, and calculating sum of pairs scores.
  • +
  • Command line argument to set default JABAWS server
  • +
  • include installation type in build properties and console + log output
  • +
  • Updated Jalview project format to preserve dataset annotation
  • + + Deployment and Documentation +
      +
    • 2G and 1G options in launchApp have no effect on memory + allocation
    • +
    • launchApp service doesn't automatically open + www.jalview.org/examples/exampleFile.jar if no file is given
    • +
    + Application Known issues +
      +
    • + + corrupted or unreadable alignment display when scrolling alignment + to right +
    • +
    • + + 'Superpose with' submenu not shown when new view created +
    • +
    • + + retrieval fails but progress bar continues for DAS retrieval with + large number of ID +
    • +
    • + + flatfile output of visible region has incorrect sequence start/end +
    • +
    • + + rna structure consensus doesn't update when secondary + structure tracks are rearranged +
    • +
    • + + InstallAnywhere reports cannot find valid JVM when Java 1.7_055 is + available +
    • +
    • + + invalid rna structure positional highlighting isn't useful +
    • +
    +
      +
    • + + out of memory errors are not raised when saving jalview project + from alignment window file menu +
    • +
    • + + Switching to RNA Helices colouring doesn't propagate to + structures +
    • +
    • + + colour by RNA Helices not enabled when user created annotation + added to alignment +
    • TOFIX +
    • + + Jalview icon not shown on dock in Mountain Lion/Webstart +
    • +
    + Applet Known Issues +
      +
    • + + JalviewLite needs JmolApplet and JmolData jar dependencies +
    • +
    • + + Jalview and Jmol example not compatible with IE9 +
    • + +
    • Sort by annotation score doesn't reverse order when + selected
    • +
    +
    -
    Release
    -
    -
    New Features
    -
    -
    Issues Resolved
    -
    +
    + Release +
    +
    +
    + New Features +
    +
    +
    + Issues Resolved +
    +
    2.8.2
    18/11/2014
    - - General + General
      +
    • Features and annotation preserved when performing pairwise + alignment
    • +
    • RNA pseudoknot annotation can be + imported/exported/displayed
    • +
    • 'colour by annotation' can colour by RNA and + protein secondary structure
    Application
      -
    • Update Jalview project format: +
    • Extract and display secondary structure for sequences with + 3D structures
    • +
    • Support for parsing RNAML
    • +
    • Annotations menu for layout
        +
      • sort sequence annotation rows by alignment
      • +
      • place sequence annotation above/below alignment + annotation
      -
    • -
    -
    Application
      +
    • Distinguish alignment and sequence associated RNA + structure in structure->view->VARNA
    • +
    • Raise dialog box if user deletes all sequences in an + alignment
    • +
    • Pressing F1 results in documentation opening twice
    • +
    • Sequence feature tooltip is wrapped
    • +
    • Double click on sequence associated annotation selects + only first column
    • +
    • Redundancy removal doesn't result in unlinked leaves + shown in tree
    • +
    • Undos after several redundancy removals don't undo + properly
    • +
    • Hide sequence doesn't hide associated annotation
    • +
    • User defined colours dialog box too big to fit on screen + and buttons not visible
    • +
    • author list isn't updated if already written to jalview + properties
    • +
    • Popup menu won't open after retrieving sequence from + database
    • +
    • File open window for associate PDB doesn't open
    • +
    • Left-then-right click on a sequence id opens a browser + search window
    • +
    • Cannot open sequence feature shading/sort popup menu in + feature settings dialog
    • +
    • better tooltip placement for some areas of Jalview desktop
    • +
    • Unable to add JABAWS Server which doesn't pass + validation
    • +
    • Web services parameters dialog box is too large to fit on + screen
    • +
    • Muscle nucleotide alignment preset obscured by tooltip
    • +
    • JABAWS preset submenus don't contain newly defined + user preset
    • +
    • MSA web services warns user if they were launched with + invalid input
    • +
    • Jalview cannot contact dasregisty (Java 8)
    Applet
      -
    Other + General
      -
    -
    diff --git a/help/html/whatsNew.html b/help/html/whatsNew.html index ae45aae..4ca6e93 100755 --- a/help/html/whatsNew.html +++ b/help/html/whatsNew.html @@ -29,12 +29,12 @@

    Jalview 2.8.2 is the first release produced by our new core development team.
    It incorporates many minor improvements and - bug-fixes, and also includes new features for working with 3D - structure data, shading alignments by secondary structure and - generation of alignment figures as Scalable Vector Graphics.
    As - ever, the highlights are detailed below, and the full list is given in - the Jalview 2.8.2 Release - Notes. + bug-fixes, and new features for working with 3D structure data, + shading alignments by secondary structure and generation of alignment + figures as Scalable Vector Graphics. +
    As ever, the highlights are detailed below, and the full list is + given in the + Jalview 2.8.2 Release Notes.

    diff --git a/lib/jsoup-1.8.1.jar b/lib/jsoup-1.8.1.jar new file mode 100644 index 0000000..ae717d4 Binary files /dev/null and b/lib/jsoup-1.8.1.jar differ diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 795dfa0..151b4a7 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1095,6 +1095,7 @@ warn.job_cannot_be_cancelled_close_window = This job cannot be cancelled.\nJust warn.service_not_supported = Service not supported! warn.input_is_too_big = Input is too big! warn.invalid_job_param_set = Invalid job parameter set! +warn.oneseq_msainput_selection = The current selection only contains a single sequence. Do you want to submit all sequences for alignment instead ? info.job_couldnt_be_run_server_doesnt_support_program = Job could not be run because the server doesn't support this program.\n{0} info.job_couldnt_be_run_exceeded_hard_limit = Job could not be run because it exceeded a hard limit on the server.\n{0} info.job_couldnt_be_run_incorrect_param_setting = Job could not be run because some of the parameter settings are not supported by the server.\n{0}\nPlease check to make sure you have used the correct parameter set for this service\!\n @@ -1104,6 +1105,8 @@ info.invalid_jnet_job_result_data ={0}\n{1}\nInvalid JNet job result data\!\n{2} info.failed_to_submit_sequences_for_alignment = Failed to submit sequences for alignment.\nIt is most likely that there is a problem with the server.\nJust close the window\n info.alignment_object_method_notes = \nAlignment Object Method Notes\n info.server_exception = \n{0} Server exception\!\n{1} +info.invalid_msa_input_mininfo = Need at least two sequences with at least 3 residues each, with no hidden regions between them. +info.invalid_msa_notenough = Not enough sequence data to align status.processing_commandline_args = Processing commandline arguments... status.das_features_being_retrived = DAS features being retrieved... status.searching_for_sequences_from = Searching for sequences from {0} diff --git a/resources/templates/BioJSTemplate.txt b/resources/templates/BioJSTemplate.txt new file mode 100644 index 0000000..bf780bb --- /dev/null +++ b/resources/templates/BioJSTemplate.txt @@ -0,0 +1,9032 @@ + +
    BioJS viewer
    + + + + + + + + Jalview Logo + +
    +
    + + + + +
    +
    + +
    press "Run with JS"
    + + + + + + + + \ No newline at end of file diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 3b0a23e..3dea84e 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -379,15 +379,21 @@ public class Cache String jnlpVersion = System.getProperty("jalview.version"); String codeVersion = getProperty("VERSION"); - + String codeInstallation = getProperty("INSTALLATION"); if (codeVersion == null) { // THIS SHOULD ONLY BE THE CASE WHEN TESTING!! codeVersion = "Test"; jnlpVersion = "Test"; + codeInstallation = ""; + } + else + { + codeInstallation = " (" + codeInstallation + ")"; } - System.out.println("Jalview Version: " + codeVersion); + System.out + .println("Jalview Version: " + codeVersion + codeInstallation); // jnlpVersion will be null if we're using InstallAnywhere // Dont do this check if running in headless mode @@ -477,6 +483,8 @@ public class Cache applicationProperties.remove("AUTHORS"); applicationProperties.remove("AUTHORFNAMES"); applicationProperties.remove("YEAR"); + applicationProperties.remove("BUILD_DATE"); + applicationProperties.remove("INSTALLATION"); } /** diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index f80f341..bca5051 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -658,7 +658,7 @@ public class Jalview public void run() { Cache.log - .info("Initialising googletracker for usage stats."); + .debug("Initialising googletracker for usage stats."); Cache.initGoogleTracker(); Cache.log.debug("Tracking enabled."); } @@ -666,7 +666,7 @@ public class Jalview { public void run() { - Cache.log.info("Not enabling Google Tracking."); + Cache.log.debug("Not enabling Google Tracking."); } }, null, true); desktop.addDialogThread(prompter); diff --git a/src/jalview/exceptions/JalviewException.java b/src/jalview/exceptions/JalviewException.java new file mode 100644 index 0000000..80e0b08 --- /dev/null +++ b/src/jalview/exceptions/JalviewException.java @@ -0,0 +1,25 @@ +package jalview.exceptions; + +@SuppressWarnings("serial") +public class JalviewException extends Exception +{ + public JalviewException(String exceptionMessage) + { + super(exceptionMessage); + } + + public JalviewException() + { + super(); + } + + public JalviewException(String exceptionMessage, Throwable cause) + { + super(exceptionMessage, cause); + } + + public JalviewException(Throwable cause) + { + super(cause); + } +} diff --git a/src/jalview/exceptions/NoFileSelectedException.java b/src/jalview/exceptions/NoFileSelectedException.java new file mode 100644 index 0000000..5c56f47 --- /dev/null +++ b/src/jalview/exceptions/NoFileSelectedException.java @@ -0,0 +1,10 @@ +package jalview.exceptions; + +@SuppressWarnings("serial") +public class NoFileSelectedException extends JalviewException +{ + public NoFileSelectedException(String msg) + { + super(msg); + } +} diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 31652c1..9f5b8f0 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -55,6 +55,7 @@ import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.io.AlignmentProperties; import jalview.io.AnnotationFile; +import jalview.io.BioJsHTMLOutput; import jalview.io.FeaturesFile; import jalview.io.FileLoader; import jalview.io.FormatAdapter; @@ -1234,6 +1235,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, alignPanel.seqPanel.seqCanvas.getFeatureRenderer()); } + @Override + public void bioJSMenuItem_actionPerformed(ActionEvent e) + { + new BioJsHTMLOutput(alignPanel, + alignPanel.seqPanel.seqCanvas.getFeatureRenderer()); + } public void createImageMap(File file, String image) { alignPanel.makePNGImageMap(file, image); @@ -4189,28 +4196,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, else if (viewport.getSelectionGroup() != null && viewport.getSelectionGroup().getSize() == 1) { - int option = JOptionPane - .showConfirmDialog( -this, - "More than one sequece group selection is required for this Job, click \n'Cancel' to edit your selection or 'Ok' to submit the entire sequence.", - "Invalid selection", - JOptionPane.OK_CANCEL_OPTION); + int option = JOptionPane.showConfirmDialog(this, + MessageManager.getString("warn.oneseq_msainput_selection"), + MessageManager.getString("label.invalid_selection"), + JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION) { msa = viewport.getAlignmentView(false); } - } else { - /* - * Vector seqs = viewport.getAlignment().getSequences(); - * - * if (seqs.size() > 1) { msa = new SequenceI[seqs.size()]; - * - * for (int i = 0; i < seqs.size(); i++) { msa[i] = (SequenceI) - * seqs.elementAt(i); } } - */ msa = viewport.getAlignmentView(false); } return msa; diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index d24f6c4..632d2b2 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -129,7 +129,7 @@ public class AlignViewport extends AlignmentViewport implements * Keys are the feature types which are currently visible. Note: Values are * not used! */ - Hashtable featuresDisplayed = null; + private Hashtable featuresDisplayed = null; boolean antiAlias = false; @@ -1274,6 +1274,16 @@ public class AlignViewport extends AlignmentViewport implements } } + + public Hashtable getFeaturesDisplayed() + { + return featuresDisplayed; + } + + public void setFeaturesDisplayed(Hashtable featuresDisplayed) + { + this.featuresDisplayed = featuresDisplayed; + } protected SequenceAnnotationOrder getSortAnnotationsBy() { return sortAnnotationsBy; diff --git a/src/jalview/gui/AnnotationExporter.java b/src/jalview/gui/AnnotationExporter.java index 315c3e2..ecf4b8e 100644 --- a/src/jalview/gui/AnnotationExporter.java +++ b/src/jalview/gui/AnnotationExporter.java @@ -210,11 +210,11 @@ public class AnnotationExporter extends JPanel private Hashtable getDisplayedFeatureCols() { Hashtable fcols = new Hashtable(); - if (ap.av.featuresDisplayed == null) + if (ap.av.getFeaturesDisplayed() == null) { return fcols; } - Enumeration en = ap.av.featuresDisplayed.keys(); + Enumeration en = ap.av.getFeaturesDisplayed().keys(); FeatureRenderer fr = ap.seqPanel.seqCanvas.getFeatureRenderer(); // consider // higher // level diff --git a/src/jalview/gui/BlogReader.java b/src/jalview/gui/BlogReader.java index 7a1065d..7d4399d 100644 --- a/src/jalview/gui/BlogReader.java +++ b/src/jalview/gui/BlogReader.java @@ -25,10 +25,10 @@ import jalview.util.MessageManager; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dialog.ModalExclusionType; import java.awt.Dimension; import java.awt.Font; import java.awt.Rectangle; -import java.awt.Dialog.ModalExclusionType; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; @@ -198,7 +198,7 @@ public class BlogReader extends JPanel { if (parent != null) { - Cache.log.info("News window closed."); + Cache.log.debug("News window closed."); jd = null; parent.showNews(false); } @@ -246,7 +246,7 @@ public class BlogReader extends JPanel public BlogReader(Desktop desktop) { - Cache.log.info("Constructing news reader."); + Cache.log.debug("Constructing news reader."); parent = desktop; _channelModel = new ChannelListModel(); @@ -275,10 +275,10 @@ public class BlogReader extends JPanel if (setvisible) { - Cache.log.info("Will show jalview news automatically"); + Cache.log.debug("Will show jalview news automatically"); showNews(); } - Cache.log.info("Completed construction of reader."); + Cache.log.debug("Completed construction of reader."); } @@ -334,7 +334,7 @@ public class BlogReader extends JPanel jd.initDialogFrame(me, false, false, MessageManager.getString("label.news_from_jalview"), bounds.width, bounds.height); jd.frame.setModalExclusionType(ModalExclusionType.NO_EXCLUDE); - Cache.log.info("Displaying news."); + Cache.log.debug("Displaying news."); jd.waitForInput(); } } @@ -421,7 +421,7 @@ public class BlogReader extends JPanel { jalview.bin.Cache.setDateProperty("JALVIEW_NEWS_RSS_LASTMODIFIED", lastDate); - jalview.bin.Cache.log.info("Saved last read date as " + jalview.bin.Cache.log.debug("Saved last read date as " + jalview.bin.Cache.date_format.format(lastDate)); } @@ -758,16 +758,16 @@ public class BlogReader extends JPanel + jalview.bin.Cache.date_format.format(lastread.getTime())); if (me.isNewsNew()) { - Cache.log.info("There is news to read."); + Cache.log.debug("There is news to read."); } else { - Cache.log.info("There is no new news."); + Cache.log.debug("There is no new news."); me.xf.setTitle("Testing : Last read is " + me.lastDate); me.showNews(); me.xf.toFront(); } - Cache.log.info("Waiting for closure."); + Cache.log.debug("Waiting for closure."); do { try @@ -781,11 +781,11 @@ public class BlogReader extends JPanel if (me.isNewsNew()) { - Cache.log.info("Still new news after reader displayed."); + Cache.log.debug("Still new news after reader displayed."); } if (lastread.getTime().before(me.lastDate)) { - Cache.log.info("The news was read."); + Cache.log.debug("The news was read."); lastread.setTime(me.lastDate); } else diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 007fefd..b8f629a 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -631,38 +631,85 @@ public class Desktop extends jalview.jbgui.GDesktop implements * Adds and opens the given frame to the desktop * * @param frame - * DOCUMENT ME! + * Frame to show * @param title - * DOCUMENT ME! + * Visible Title * @param w - * DOCUMENT ME! + * width * @param h - * DOCUMENT ME! + * height */ public static synchronized void addInternalFrame( final JInternalFrame frame, String title, int w, int h) { - addInternalFrame(frame, title, w, h, true); + addInternalFrame(frame, title, true, w, h, true); } + /** - * DOCUMENT ME! + * Add an internal frame to the Jalview desktop * * @param frame - * DOCUMENT ME! + * Frame to show * @param title - * DOCUMENT ME! + * Visible Title + * @param makeVisible + * When true, display frame immediately, otherwise, caller must call + * setVisible themselves. * @param w - * DOCUMENT ME! + * width * @param h - * DOCUMENT ME! + * height + */ + public static synchronized void addInternalFrame( + final JInternalFrame frame, String title, boolean makeVisible, + int w, int h) + { + addInternalFrame(frame, title, makeVisible, w, h, true); + } + + /** + * Add an internal frame to the Jalview desktop and make it visible + * + * @param frame + * Frame to show + * @param title + * Visible Title + * @param w + * width + * @param h + * height * @param resizable - * DOCUMENT ME! + * Allow resize */ public static synchronized void addInternalFrame( final JInternalFrame frame, String title, int w, int h, boolean resizable) { + addInternalFrame(frame, title, true, w, h, resizable); + } + + /** + * Add an internal frame to the Jalview desktop + * + * @param frame + * Frame to show + * @param title + * Visible Title + * @param makeVisible + * When true, display frame immediately, otherwise, caller must call + * setVisible themselves. + * @param w + * width + * @param h + * height + * @param resizable + * Allow resize + */ + public static synchronized void addInternalFrame( + final JInternalFrame frame, String title, boolean makeVisible, + int w, int h, boolean resizable) + { // TODO: allow callers to determine X and Y position of frame (eg. via // bounds object). @@ -687,7 +734,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements openFrameCount++; - frame.setVisible(true); + frame.setVisible(makeVisible); frame.setClosable(true); frame.setResizable(resizable); frame.setMaximizable(resizable); @@ -1064,7 +1111,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements { CutAndPasteTransfer cap = new CutAndPasteTransfer(); cap.setForInput(viewport); - Desktop.addInternalFrame(cap, MessageManager.getString("label.cut_paste_alignmen_file"), 600, 500); + Desktop.addInternalFrame(cap, + MessageManager.getString("label.cut_paste_alignmen_file"), + true, 600, 500); } /* diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index d2d9c9c..fe083b0 100644 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -192,20 +192,20 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer // copy over the displayed feature settings if (fr.av != null) { - if (fr.av.featuresDisplayed != null) + if (fr.av.getFeaturesDisplayed() != null) { // update display settings - if (av.featuresDisplayed == null) + if (av.getFeaturesDisplayed() == null) { - av.featuresDisplayed = new Hashtable(fr.av.featuresDisplayed); + av.setFeaturesDisplayed(new Hashtable(fr.av.getFeaturesDisplayed())); } else { - av.featuresDisplayed.clear(); - Enumeration en = fr.av.featuresDisplayed.keys(); + av.getFeaturesDisplayed().clear(); + Enumeration en = fr.av.getFeaturesDisplayed().keys(); while (en.hasMoreElements()) { - av.featuresDisplayed.put(en.nextElement(), Boolean.TRUE); + av.getFeaturesDisplayed().put(en.nextElement(), Boolean.TRUE); } } @@ -349,11 +349,11 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer fm = g.getFontMetrics(); } - if (av.featuresDisplayed == null || renderOrder == null + if (av.getFeaturesDisplayed() == null || renderOrder == null || newFeatureAdded) { findAllFeatures(); - if (av.featuresDisplayed.size() < 1) + if (av.getFeaturesDisplayed().size() < 1) { return; } @@ -388,7 +388,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer { type = renderOrder[renderIndex]; - if (type == null || !av.featuresDisplayed.containsKey(type)) + if (type == null || !av.getFeaturesDisplayed().containsKey(type)) { continue; } @@ -682,9 +682,9 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer findingFeatures = true; - if (av.featuresDisplayed == null) + if (av.getFeaturesDisplayed() == null) { - av.featuresDisplayed = new Hashtable(); + av.setFeaturesDisplayed(new Hashtable()); } allfeatures = new Vector(); @@ -717,7 +717,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer int index = 0; while (index < features.length) { - if (!av.featuresDisplayed.containsKey(features[index].getType())) + if (!av.getFeaturesDisplayed().containsKey(features[index].getType())) { if (featureGroups.containsKey(features[index].getType())) @@ -742,7 +742,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer { // this is a new feature type on the alignment. Mark it for // display. - av.featuresDisplayed.put(features[index].getType(), + av.getFeaturesDisplayed().put(features[index].getType(), new Integer(getColour(features[index].getType()) .getRGB())); setOrder(features[index].getType(), 0); @@ -1253,7 +1253,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer sf.description = lastDescriptionAdded; setColour(sf.type, fcol); - av.featuresDisplayed.put(sf.type, getColour(sf.type)); + av.getFeaturesDisplayed().put(sf.type, getColour(sf.type)); try { @@ -1281,9 +1281,9 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer ffile.parseDescriptionHTML(features[i], false); } - if (av.featuresDisplayed == null) + if (av.getFeaturesDisplayed() == null) { - av.featuresDisplayed = new Hashtable(); + av.setFeaturesDisplayed(new Hashtable()); } if (lastFeatureGroupAdded != null) @@ -1293,7 +1293,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer featureGroups.put(lastFeatureGroupAdded, new Boolean(true)); } setColour(lastFeatureAdded, fcol); - av.featuresDisplayed.put(lastFeatureAdded, + av.getFeaturesDisplayed().put(lastFeatureAdded, getColour(lastFeatureAdded)); findAllFeatures(false); @@ -1386,13 +1386,13 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer { if (visibleNew) { - if (av.featuresDisplayed != null) + if (av.getFeaturesDisplayed() != null) { - av.featuresDisplayed.clear(); + av.getFeaturesDisplayed().clear(); } else { - av.featuresDisplayed = new Hashtable(); + av.setFeaturesDisplayed(new Hashtable()); } } if (data == null) @@ -1414,7 +1414,7 @@ public class FeatureRenderer implements jalview.api.FeatureRenderer // interface object if (((Boolean) data[i][2]).booleanValue()) { - av.featuresDisplayed.put(type, new Integer(getColour(type) + av.getFeaturesDisplayed().put(type, new Integer(getColour(type) .getRGB())); } diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index 2210148..8f841d1 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -222,7 +222,7 @@ public class FeatureSettings extends JPanel dassourceBrowser = new DasSourceBrowser(this); dasSettingsPane.add(dassourceBrowser, BorderLayout.CENTER); - if (af.getViewport().featuresDisplayed == null + if (af.getViewport().getFeaturesDisplayed() == null || fr.renderOrder == null) { fr.findAllFeatures(true); // display everything! @@ -645,7 +645,7 @@ public class FeatureSettings extends JPanel data[dataIndex][0] = type; data[dataIndex][1] = fr.getFeatureStyle(type); data[dataIndex][2] = new Boolean( - af.getViewport().featuresDisplayed.containsKey(type)); + af.getViewport().getFeaturesDisplayed().containsKey(type)); dataIndex++; visibleChecks.removeElement(type); } @@ -1277,7 +1277,7 @@ public class FeatureSettings extends JPanel System.arraycopy(fr.renderOrder, 0, typ, 0, typ.length); for (int i = 0; i < typ.length; i++) { - if (af.viewport.featuresDisplayed.get(typ[i]) == null) + if (af.viewport.getFeaturesDisplayed().get(typ[i]) == null) { typ[i] = null; } diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index d003cb0..08fd306 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -1145,7 +1145,7 @@ public class Jalview2XML view.setFollowHighlight(av.followHighlight); view.setFollowSelection(av.followSelection); view.setIgnoreGapsinConsensus(av.getIgnoreGapsConsensus()); - if (av.featuresDisplayed != null) + if (av.getFeaturesDisplayed() != null) { jalview.schemabinding.version2.FeatureSettings fs = new jalview.schemabinding.version2.FeatureSettings(); @@ -1180,7 +1180,7 @@ public class Jalview2XML .getColour(renderOrder[ro]).getRGB()); } - setting.setDisplay(av.featuresDisplayed + setting.setDisplay(av.getFeaturesDisplayed() .containsKey(renderOrder[ro])); float rorder = ap.seqPanel.seqCanvas.getFeatureRenderer() .getOrder(renderOrder[ro]); @@ -3606,7 +3606,7 @@ public class Jalview2XML // recover featre settings if (jms.getFeatureSettings() != null) { - af.viewport.featuresDisplayed = new Hashtable(); + af.viewport.setFeaturesDisplayed(new Hashtable()); String[] renderOrder = new String[jms.getFeatureSettings() .getSettingCount()]; for (int fs = 0; fs < jms.getFeatureSettings().getSettingCount(); fs++) @@ -3658,7 +3658,7 @@ public class Jalview2XML } if (setting.getDisplay()) { - af.viewport.featuresDisplayed.put(setting.getType(), new Integer( + af.viewport.getFeaturesDisplayed().put(setting.getType(), new Integer( setting.getColour())); } } diff --git a/src/jalview/gui/Jalview2XML_V1.java b/src/jalview/gui/Jalview2XML_V1.java index 9263cd9..3773a64 100755 --- a/src/jalview/gui/Jalview2XML_V1.java +++ b/src/jalview/gui/Jalview2XML_V1.java @@ -415,7 +415,7 @@ public class Jalview2XML_V1 if (jms.getFeatureSettings() != null) { - af.viewport.featuresDisplayed = new Hashtable(); + af.viewport.setFeaturesDisplayed(new Hashtable()); String[] renderOrder = new String[jms.getFeatureSettings() .getSettingCount()]; for (int fs = 0; fs < jms.getFeatureSettings().getSettingCount(); fs++) @@ -429,7 +429,7 @@ public class Jalview2XML_V1 if (setting.getDisplay()) { - af.viewport.featuresDisplayed.put(setting.getType(), new Integer( + af.viewport.getFeaturesDisplayed().put(setting.getType(), new Integer( setting.getColour())); } } diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index c10a4a9..5d3df1a 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -251,8 +251,9 @@ public class SeqPanel extends JPanel implements MouseListener, { for (int i = 0; i < features.length; i++) { - if (av.featuresDisplayed == null - || !av.featuresDisplayed.containsKey(features[i].getType())) + if (av.getFeaturesDisplayed() == null + || !av.getFeaturesDisplayed().containsKey( + features[i].getType())) { continue; } diff --git a/src/jalview/gui/WebserviceInfo.java b/src/jalview/gui/WebserviceInfo.java index 8dcf72a..cd93277 100644 --- a/src/jalview/gui/WebserviceInfo.java +++ b/src/jalview/gui/WebserviceInfo.java @@ -20,21 +20,40 @@ */ package jalview.gui; -import java.util.*; +import jalview.jbgui.GWebserviceInfo; +import jalview.util.MessageManager; +import jalview.ws.WSClientI; -import java.awt.*; -import java.awt.event.*; -import java.awt.image.*; -import javax.swing.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GridLayout; +import java.awt.Image; +import java.awt.MediaTracker; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; +import java.util.Hashtable; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JEditorPane; +import javax.swing.JInternalFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextArea; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.StyleSheet; -import jalview.jbgui.*; -import jalview.util.MessageManager; -import jalview.ws.WSClientI; - /** * Base class for web service client thread and gui TODO: create StAX parser to * extract html body content reliably when preparing html formatted job statuses @@ -78,6 +97,13 @@ public class WebserviceInfo extends GWebserviceInfo implements JInternalFrame frame; + @Override + public void setVisible(boolean aFlag) + { + super.setVisible(aFlag); + frame.setVisible(aFlag); + }; + JTabbedPane subjobs = null; java.util.Vector jobPanes = null; @@ -210,10 +236,13 @@ public class WebserviceInfo extends GWebserviceInfo implements * short name and job type * @param info * reference or other human readable description + * @param makeVisible + * true to display the webservices window immediatly (otherwise need + * to call setVisible(true)) */ - public WebserviceInfo(String title, String info) + public WebserviceInfo(String title, String info, boolean makeVisible) { - init(title, info, 520, 500); + init(title, info, 520, 500, makeVisible); } /** @@ -228,9 +257,10 @@ public class WebserviceInfo extends GWebserviceInfo implements * @param height * DOCUMENT ME! */ - public WebserviceInfo(String title, String info, int width, int height) + public WebserviceInfo(String title, String info, int width, int height, + boolean makeVisible) { - init(title, info, width, height); + init(title, info, width, height, makeVisible); } /** @@ -288,11 +318,12 @@ public class WebserviceInfo extends GWebserviceInfo implements * @param height * DOCUMENT ME! */ - void init(String title, String info, int width, int height) + void init(String title, String info, int width, int height, + boolean makeVisible) { frame = new JInternalFrame(); frame.setContentPane(this); - Desktop.addInternalFrame(frame, title, width, height); + Desktop.addInternalFrame(frame, title, makeVisible, width, height); frame.setClosable(false); this.title = title; diff --git a/src/jalview/gui/WsParamSetManager.java b/src/jalview/gui/WsParamSetManager.java index 3322d6a..2db19a2 100644 --- a/src/jalview/gui/WsParamSetManager.java +++ b/src/jalview/gui/WsParamSetManager.java @@ -20,6 +20,13 @@ */ package jalview.gui; +import jalview.bin.Cache; +import jalview.io.JalviewFileChooser; +import jalview.util.MessageManager; +import jalview.ws.params.ParamDatastoreI; +import jalview.ws.params.ParamManager; +import jalview.ws.params.WsParamSetI; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -33,13 +40,6 @@ import java.util.StringTokenizer; import javax.swing.JOptionPane; -import jalview.bin.Cache; -import jalview.io.JalviewFileChooser; -import jalview.util.MessageManager; -import jalview.ws.params.ParamDatastoreI; -import jalview.ws.params.ParamManager; -import jalview.ws.params.WsParamSetI; - /** * store and retrieve web service parameter sets. * @@ -159,7 +159,7 @@ public class WsParamSetManager implements ParamManager { if (filename != null && !((outfile = new File(filename)).canWrite())) { - Cache.log.info("Can't write to " + filename + Cache.log.warn("Can't write to " + filename + " - Prompting for new file to write to."); filename = null; } diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index d3b19fa..505f609 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -47,7 +47,9 @@ public class AppletFormatAdapter */ public static final String[] READABLE_FORMATS = new String[] { "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "STH", - "PDB", "JnetFile", "RNAML", PhylipFile.FILE_DESC }; // , "SimpleBLAST" }; + "PDB", "JnetFile", "RNAML", PhylipFile.FILE_DESC, "HTML" }; // , + // "SimpleBLAST" + // }; /** * List of valid format strings for use by callers of the formatSequences @@ -79,7 +81,8 @@ public class AppletFormatAdapter */ public static final String[] READABLE_EXTENSIONS = new String[] { "fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa", - "jar,jvp", "sto,stk", "xml,rnaml", PhylipFile.FILE_EXT }; // ".blast" + "jar,jvp", "sto,stk", "xml,rnaml", PhylipFile.FILE_EXT, + "html" }; // ".blast" /** * List of readable formats by application in order corresponding to @@ -87,7 +90,7 @@ public class AppletFormatAdapter */ public static final String[] READABLE_FNAMES = new String[] { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "Jalview", - "Stockholm", "RNAML", PhylipFile.FILE_DESC };// , + "Stockholm", "RNAML", PhylipFile.FILE_DESC, "HTML" };// , // "SimpleBLAST" // }; @@ -109,7 +112,7 @@ public class AppletFormatAdapter for (int i = 0, iSize = els.length - 1; i < iSize; i++) { list.append(els[i]); - list.append(","); + list.append(", "); } list.append(" and " + els[els.length - 1] + "."); return list.toString(); @@ -268,6 +271,10 @@ public class AppletFormatAdapter { afile = new PhylipFile(inFile, type); } + // else if (format.equals(HtmlFile.FILE_DESC)) + // { + // afile = new HtmlFile(inFile, type); + // } else if (format.equals("RNAML")) { afile = new RnamlFile(inFile, type); @@ -392,6 +399,10 @@ public class AppletFormatAdapter { afile = new PhylipFile(source); } + // else if (format.equals(HtmlFile.FILE_DESC)) + // { + // afile = new HtmlFile(source); + // } Alignment al = new Alignment(afile.getSeqsAsArray()); afile.addAnnotations(al); @@ -527,6 +538,10 @@ public class AppletFormatAdapter { afile = new PhylipFile(); } + // else if (format.equalsIgnoreCase(HtmlFile.FILE_DESC)) + // { + // afile = new HtmlFile(); + // } else if (format.equalsIgnoreCase("RNAML")) { afile = new RnamlFile(); diff --git a/src/jalview/io/BioJsHTMLOutput.java b/src/jalview/io/BioJsHTMLOutput.java new file mode 100644 index 0000000..772337a --- /dev/null +++ b/src/jalview/io/BioJsHTMLOutput.java @@ -0,0 +1,221 @@ +package jalview.io; + +import jalview.datamodel.AlignmentI; +import jalview.datamodel.SequenceFeature; +import jalview.datamodel.SequenceI; +import jalview.exceptions.NoFileSelectedException; +import jalview.gui.AlignViewport; +import jalview.gui.AlignmentPanel; +import jalview.gui.FeatureRenderer; +import jalview.json.binding.v1.BioJsAlignmentPojo; +import jalview.json.binding.v1.BioJsFeaturePojo; +import jalview.json.binding.v1.BioJsSeqPojo; +import jalview.schemes.ColourSchemeProperty; +import jalview.util.MessageManager; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.util.ArrayList; +import java.util.Hashtable; + +import com.json.JSONException; + +public class BioJsHTMLOutput +{ + private AlignViewport av; + + private FeatureRenderer fr; + + private String globalColorScheme; + + private Hashtable displayedFeatures; + + private String jalviewVersion; + + private String webStartLaunchServletUrl = "http://www.jalview.org/services/launchApp"; + + public BioJsHTMLOutput(AlignmentPanel ap, + FeatureRenderer fr1) + { + + jalviewVersion = jalview.bin.Cache.getProperty("VERSION"); + webStartLaunchServletUrl = jalview.bin.Cache.getDefault( + "www.jalview.org", "http://www.jalview.org") + + "/services/launchApp"; + if (ap != null) + { + this.av = ap.av; + this.globalColorScheme = ColourSchemeProperty.getColourName(av + .getGlobalColourScheme()); + this.fr = new FeatureRenderer(ap); + fr.transferSettings(fr1); + displayedFeatures = av.getFeaturesDisplayed(); + + exportJalviewAlignmentAsBioJsHtmlFile(); + } + } + + private void exportJalviewAlignmentAsBioJsHtmlFile() + { + try + { + String outputFile = getOutputFile(); + String jalviewAlignmentJson = getJalviewAlignmentAsJsonString(av + .getAlignment()); + String bioJSTemplateString = getBioJsTemplateAsString(this); + String generatedBioJsWithJalviewAlignmentAsJson = bioJSTemplateString + .replaceAll( +"#sequenceData#", jalviewAlignmentJson) + .toString(); + + PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter( + outputFile)); + out.print(generatedBioJsWithJalviewAlignmentAsJson); + out.flush(); + out.close(); + jalview.util.BrowserLauncher.openURL("file:///" + outputFile); + } catch (NoFileSelectedException ex) + { + // do noting if no file was selected + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public String getOutputFile() throws NoFileSelectedException + { + String selectedFile = null; + JalviewFileChooser jvFileChooser = new JalviewFileChooser( + jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] + { "html" }, new String[] + { "HTML files" }, "HTML files"); + jvFileChooser.setFileView(new JalviewFileView()); + + // TODO uncomment when supported by MassageManager + jvFileChooser.setDialogTitle(MessageManager + .getString("label.save_as_biojs_html")); + jvFileChooser.setDialogTitle("save as BioJs HTML"); + jvFileChooser.setToolTipText(MessageManager.getString("action.save")); + + int fileChooserOpt = jvFileChooser.showSaveDialog(null); + if (fileChooserOpt == JalviewFileChooser.APPROVE_OPTION) + { + jalview.bin.Cache.setProperty("LAST_DIRECTORY", jvFileChooser + .getSelectedFile().getParent()); + selectedFile = jvFileChooser.getSelectedFile().getPath(); + } + else + { + throw new NoFileSelectedException("No file was selected."); + } + + return selectedFile; + } + + public String getJalviewAlignmentAsJsonString(AlignmentI alignment) + throws IOException, JSONException + { + BioJsAlignmentPojo bjsAlignment = new BioJsAlignmentPojo(); + + bjsAlignment.setGlobalColorScheme(getGlobalColorScheme()); + bjsAlignment.setJalviewVersion(jalviewVersion); + bjsAlignment.setWebStartUrl(webStartLaunchServletUrl); + + int count = 0; + for (SequenceI seq : alignment.getSequences()) + { + StringBuilder name = new StringBuilder(); + name.append(seq.getName()).append("/").append(seq.getStart()) + .append("-").append(seq.getEnd()); + + BioJsSeqPojo seqPojo = new BioJsSeqPojo(); + seqPojo.setId(String.valueOf(++count)); + seqPojo.setEnd(seq.getEnd()); + seqPojo.setStart(seq.getStart()); + seqPojo.setName(name.toString()); + seqPojo.setSeq(seq.getSequenceAsString()); + + SequenceFeature[] seqFeatures = seq.getDatasetSequence() + .getSequenceFeatures(); + if (seqFeatures != null) + { + ArrayList bjsSeqFeatures = new ArrayList(); + for (SequenceFeature sf : seqFeatures) + { + if (displayedFeatures != null + && displayedFeatures.get(sf.getType()) != null) + { + String featureColour = jalview.util.Format.getHexString(fr + .getColour(sf)); + BioJsFeaturePojo bjsFeature = new BioJsFeaturePojo(); + bjsFeature.setFillColor(featureColour); + bjsFeature.setXstart(seq.findIndex(sf.getBegin()) - 1); + bjsFeature.setXend(seq.findIndex(sf.getEnd())); + bjsFeature.setText(sf.getType()); + bjsSeqFeatures.add(bjsFeature); + } + } + seqPojo.setFeatures(bjsSeqFeatures); + } + bjsAlignment.getSeqs().add(seqPojo); + } + + return new com.json.JSONObject(bjsAlignment).toString() + .replaceAll("xstart", "xStart").replaceAll("xend", "xEnd"); + } + + public static String getBioJsTemplateAsString(Object currentObj) + throws IOException + { + InputStreamReader isReader = null; + BufferedReader buffReader = null; + StringBuilder sb = new StringBuilder(); + URL url = currentObj.getClass().getResource( + "/templates/BioJSTemplate.txt"); + if (url != null) + { + try + { + isReader = new InputStreamReader(url.openStream()); + buffReader = new BufferedReader(isReader); + String line; + String lineSeparator = System.getProperty("line.separator"); + while ((line = buffReader.readLine()) != null) + { + sb.append(line).append(lineSeparator); + } + + } catch (Exception ex) + { + ex.printStackTrace(); + } finally + { + if (isReader != null) + { + isReader.close(); + } + + if (buffReader != null) + { + buffReader.close(); + } + } + } + return sb.toString(); + } + + public String getGlobalColorScheme() + { + return globalColorScheme; + } + + public void setGlobalColorScheme(String globalColorScheme) + { + this.globalColorScheme = globalColorScheme; + } + +} diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index 82b94c3..833f590 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -152,6 +152,7 @@ public class FileLoader implements Runnable public AlignFrame LoadFileWaitTillLoaded(FileParse source, String format) { this.source = source; + file = source.getInFile(); protocol = source.type; this.format = format; @@ -352,6 +353,11 @@ public class FileLoader implements Runnable { alignFrame.setFileName(file, format); } + if (source instanceof HtmlFile) + { + ((HtmlFile) source).LoadAlignmentFeatures(alignFrame); + + } if (raiseGUI) { // add the window to the GUI diff --git a/src/jalview/io/FormatAdapter.java b/src/jalview/io/FormatAdapter.java index 8ca0c35..df5353c 100755 --- a/src/jalview/io/FormatAdapter.java +++ b/src/jalview/io/FormatAdapter.java @@ -255,6 +255,41 @@ public class FormatAdapter extends AppletFormatAdapter return this.formatSequences(format, alignment, suffix); } + public Alignment readFile(String inFile, String type, String format) + throws java.io.IOException + { + Alignment al; + if (format.equals("HTML")) + { + afile = new HtmlFile(inFile, type); + al = new Alignment(afile.getSeqsAsArray()); + afile.addAnnotations(al); + } + else + { + al = super.readFile(inFile, type, format); + } + + return al; + } + + public AlignmentI readFromFile(FileParse source, String format) + throws java.io.IOException + { + Alignment al; + if (format.equals("HTML")) + { + afile = new HtmlFile(source); + al = new Alignment(afile.getSeqsAsArray()); + afile.addAnnotations(al); + } + else + { + al = (Alignment) super.readFromFile(source, format); + } + return al; + } + /** * validate format is valid for IO in Application. This is basically the * AppletFormatAdapter.isValidFormat call with additional checks for diff --git a/src/jalview/io/HtmlFile.java b/src/jalview/io/HtmlFile.java new file mode 100644 index 0000000..3cb7c3f --- /dev/null +++ b/src/jalview/io/HtmlFile.java @@ -0,0 +1,152 @@ +package jalview.io; + +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceFeature; +import jalview.gui.AlignFrame; +import jalview.json.binding.v1.BioJsAlignmentPojo.JalviewBioJsColorSchemeMapper; +import jalview.schemes.ColourSchemeI; + +import java.io.IOException; +import java.util.Iterator; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; + +public class HtmlFile extends AlignFile +{ + // public static final String FILE_EXT = "html"; + // + // public static final String FILE_DESC = "HTML"; + + private ColourSchemeI cs; + + public HtmlFile() + { + super(); + } + + public HtmlFile(FileParse source) throws IOException + { + super(source); + } + + public HtmlFile(String inFile, String type) throws IOException + { + super(inFile, type); + } + + @SuppressWarnings("unchecked") + @Override + public void parse() throws IOException + { + try + { + StringBuilder htmlData = new StringBuilder(); + String currentLine; + while ((currentLine = nextLine()) != null) + { + htmlData.append(currentLine); + } + + Document doc = Jsoup.parse(htmlData.toString()); + Element content = doc.getElementById("seqData"); + + String alignmentJsonString = content.val(); + JSONParser jsonParser = new JSONParser(); + JSONObject alignmentJsonObj = (JSONObject) jsonParser + .parse(alignmentJsonString); + JSONArray seqJsonArray = (JSONArray) alignmentJsonObj.get("seqs"); + String bioJsColourScheme = (String) alignmentJsonObj + .get("globalColorScheme"); + cs = getJalviewColorScheme(bioJsColourScheme); + + for (Iterator sequenceIter = seqJsonArray.iterator(); sequenceIter + .hasNext();) + { + JSONObject sequence = sequenceIter.next(); + String sequcenceString = sequence.get("seq").toString(); + Sequence seq = new Sequence(sequence.get("name").toString(), + sequcenceString, Integer.valueOf(sequence.get("start") + .toString()), Integer.valueOf(sequence.get("end") + .toString())); + + JSONArray jsonSeqArray = (JSONArray) sequence.get("features"); + SequenceFeature[] retrievedSeqFeatures = getJalviewSequenceFeatures( + jsonSeqArray, seq); + if (retrievedSeqFeatures != null) + { + seq.setSequenceFeatures(retrievedSeqFeatures); + } + seqs.add(seq); + + } + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public SequenceFeature[] getJalviewSequenceFeatures( + JSONArray jsonSeqFeatures, Sequence seq) + { + SequenceFeature[] seqFeatures = null; + int count = 0; + if (jsonSeqFeatures != null) + { + seqFeatures = new SequenceFeature[jsonSeqFeatures.size()]; + for (@SuppressWarnings("unchecked") + Iterator seqFeatureItr = jsonSeqFeatures.iterator(); seqFeatureItr + .hasNext();) + { + + SequenceFeature sequenceFeature = new SequenceFeature(); + JSONObject jsonFeature = seqFeatureItr.next(); + Long begin = (Long) jsonFeature.get("xStart"); + Long end = (Long) jsonFeature.get("xEnd"); + String type = (String) jsonFeature.get("text"); + // String color = (String) jsonFeature.get("fillColor"); + + sequenceFeature.setBegin(seq.findPosition(begin.intValue())); + sequenceFeature.setEnd(seq.findPosition(end.intValue()) - 1); + sequenceFeature.setType(type); + seqFeatures[count++] = sequenceFeature; + } + } + return seqFeatures; + } + + public void LoadAlignmentFeatures(AlignFrame af) + { + + af.setShowSeqFeatures(true); + af.changeColour(cs); + af.setMenusForViewport(); + } + + private ColourSchemeI getJalviewColorScheme(String bioJsColourSchemeName) + { + ColourSchemeI jalviewColor = null; + for (JalviewBioJsColorSchemeMapper cs : JalviewBioJsColorSchemeMapper + .values()) + { + if (cs.getBioJsName().equals(bioJsColourSchemeName)) + { + jalviewColor = cs.getJvColourScheme(); + break; + } + } + return jalviewColor; + } + + @Override + public String print() + { + throw new UnsupportedOperationException( + "Print method of HtmlFile not yet supported!"); + } + +} diff --git a/src/jalview/io/IdentifyFile.java b/src/jalview/io/IdentifyFile.java index 9c7478b..4fb2516 100755 --- a/src/jalview/io/IdentifyFile.java +++ b/src/jalview/io/IdentifyFile.java @@ -136,8 +136,14 @@ public class IdentifyFile break; } + // if (data.matches("<(\"[^\"]*\"|'[^']*'|[^'\">])*>")) + if (data.matches("<(?i)html(\"[^\"]*\"|'[^']*'|[^'\">])*>")) + { + reply = "HTML"; + break; + } - if ((data.indexOf("<") > -1)) + if (data.matches("<(?i)rnaml (\"[^\"]*\"|'[^']*'|[^'\">])*>")) { reply = "RNAML"; @@ -275,6 +281,7 @@ public class IdentifyFile break; } + /* * // TODO comment out SimpleBLAST identification for Jalview 2.4.1 else * if (!lineswereskipped && data.indexOf("BLAST")<4) { reply = @@ -320,6 +327,7 @@ public class IdentifyFile public static void main(String[] args) { + for (int i = 0; args != null && i < args.length; i++) { IdentifyFile ider = new IdentifyFile(); diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 387bb7f..4bf8176 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -214,6 +214,8 @@ public class GAlignFrame extends JInternalFrame JMenuItem createPNG = new JMenuItem(); + JMenuItem createBioJS = new JMenuItem(); + JMenuItem createSVG = new JMenuItem(); protected JMenuItem font = new JMenuItem(); @@ -1197,6 +1199,19 @@ public class GAlignFrame extends JInternalFrame htmlMenuItem_actionPerformed(e); } }); + + // TODO uncomment when supported by MassageManager + // createBioJS.setText(MessageManager.getString("label.biojs_html_export")); + createBioJS.setText("BioJS"); + createBioJS.addActionListener(new java.awt.event.ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + bioJSMenuItem_actionPerformed(e); + } + }); + overviewMenuItem.setText(MessageManager .getString("label.overview_window")); overviewMenuItem.addActionListener(new java.awt.event.ActionListener() @@ -1603,7 +1618,6 @@ public class GAlignFrame extends JInternalFrame font_actionPerformed(e); } }); - seqLimits.setText(MessageManager .getString("label.show_sequence_limits")); seqLimits.setState(jalview.bin.Cache.getDefault("SHOW_JVSUFFIX", true)); @@ -2353,6 +2367,7 @@ public class GAlignFrame extends JInternalFrame jMenu2.add(htmlMenuItem); jMenu2.add(epsFile); jMenu2.add(createPNG); + jMenu2.add(createBioJS); jMenu2.add(createSVG); addSequenceMenu.add(addFromFile); addSequenceMenu.add(addFromText); @@ -2611,6 +2626,11 @@ public class GAlignFrame extends JInternalFrame { } + protected void bioJSMenuItem_actionPerformed(ActionEvent e) + { + + } + protected void closeMenuItem_actionPerformed(boolean b) { } diff --git a/src/jalview/json/binding/v1/BioJsAlignmentPojo.java b/src/jalview/json/binding/v1/BioJsAlignmentPojo.java new file mode 100644 index 0000000..8e8747f --- /dev/null +++ b/src/jalview/json/binding/v1/BioJsAlignmentPojo.java @@ -0,0 +1,151 @@ +package jalview.json.binding.v1; + +import jalview.schemes.Blosum62ColourScheme; +import jalview.schemes.BuriedColourScheme; +import jalview.schemes.ColourSchemeI; +import jalview.schemes.HelixColourScheme; +import jalview.schemes.HydrophobicColourScheme; +import jalview.schemes.NucleotideColourScheme; +import jalview.schemes.PIDColourScheme; +import jalview.schemes.PurinePyrimidineColourScheme; +import jalview.schemes.RNAInteractionColourScheme; +import jalview.schemes.StrandColourScheme; +import jalview.schemes.TaylorColourScheme; +import jalview.schemes.TurnColourScheme; +import jalview.schemes.ZappoColourScheme; + +import java.util.ArrayList; + +public class BioJsAlignmentPojo +{ + private String globalColorScheme = "none"; + + private String jalviewVersion; + + private String webStartUrl; + private ArrayList seqs = new ArrayList(); + + public BioJsAlignmentPojo() + { + + } + public ArrayList getSeqs() + { + return seqs; + } + + public void setSeqs(ArrayList seqs) + { + this.seqs = seqs; + } + public String getGlobalColorScheme() + { + return globalColorScheme; + } + public void setGlobalColorScheme(String globalColorScheme) + { + for (JalviewBioJsColorSchemeMapper cs : JalviewBioJsColorSchemeMapper + .values()) + { + if (cs.getJalviewName().equals(globalColorScheme)) + { + this.globalColorScheme = cs.getBioJsName(); + break; + } + } + + // JALVIEW colors not in biojs + // Blosum62 + // T-Coffee Scores (almost same with Blosom62 + // RNA Interaction type - no color applied + // RNA Helices - missing + + // BIOJS Colour not in jalview + // schemes.push name: "Lesk", id: "lesk" + // schemes.push name: "Cinema", id: "cinema" + // schemes.push name: "MAE", id: "mae" + // schemes.push name: "Clustal2", id: "clustal2" + + } + + + public String getJalviewVersion() + { + return jalviewVersion; + } + + public void setJalviewVersion(String jalviewVersion) + { + this.jalviewVersion = jalviewVersion; + } + + public String getWebStartUrl() + { + return webStartUrl; + } + + public void setWebStartUrl(String webStartUrl) + { + this.webStartUrl = webStartUrl; + } + + public enum JalviewBioJsColorSchemeMapper + { + USER_DEFINED("User Defined", "user defined", null), NONE("None", "foo", + null), CLUSTAL("Clustal", "clustal", null), ZAPPO("Zappo", + "zappo", new ZappoColourScheme()), TAYLOR( + "Taylor", "taylor", new TaylorColourScheme()), NUCLEOTIDE( + "Nucleotide", "nucleotide", new NucleotideColourScheme()), PURINE_PYRIMIDINE( + "Purine/Pyrimidine", "purine", + new PurinePyrimidineColourScheme()), HELIX_PROPENCITY( + "Helix Propensity", "helix", new HelixColourScheme()), TURN_PROPENSITY( + "Turn Propensity", "turn", new TurnColourScheme()), STRAND_PROPENSITY( + "Strand Propensity", "strand", new StrandColourScheme()), BURIED_INDEX( + "Buried Index", "buried", new BuriedColourScheme()), HYDROPHOBIC( + "Hydrophobic", "hydro", new HydrophobicColourScheme()), + + // The color types below are not yet supported by BioJs MSA viewer + T_COFFE_SCORES("T-Coffee Scores", "T-Coffee Scores", + null), RNA_INT_TYPE( + "RNA Interaction type", "RNA Interaction type", + new RNAInteractionColourScheme()), BLOSUM62("Blosum62", + "Blosum62", new Blosum62ColourScheme()), RNA_HELICES( + "RNA Helices", "RNA Helices", null), PERCENTAGE_IDENTITY( + "% Identity", "pid", + new PIDColourScheme()); + + private String jalviewName; + private String bioJsName; + + private ColourSchemeI jvColourScheme; + + private JalviewBioJsColorSchemeMapper(String jalviewName, + String bioJsName, ColourSchemeI jvColourScheme) + { + this.jalviewName = jalviewName; + this.bioJsName = bioJsName; + this.setJvColourScheme(jvColourScheme); + } + + public String getJalviewName() + { + return jalviewName; + } + + public String getBioJsName() + { + return bioJsName; + } + + public ColourSchemeI getJvColourScheme() + { + return jvColourScheme; + } + + public void setJvColourScheme(ColourSchemeI jvColourScheme) + { + this.jvColourScheme = jvColourScheme; + } + + } +} diff --git a/src/jalview/json/binding/v1/BioJsFeaturePojo.java b/src/jalview/json/binding/v1/BioJsFeaturePojo.java new file mode 100644 index 0000000..3c2fdda --- /dev/null +++ b/src/jalview/json/binding/v1/BioJsFeaturePojo.java @@ -0,0 +1,60 @@ +package jalview.json.binding.v1; + +public class BioJsFeaturePojo +{ + + private int xstart; + + private int xend; + + private String text; + + private String fillColor; + + public BioJsFeaturePojo() + { + } + + + public String getText() + { + return text; + } + + public void setText(String text) + { + this.text = text; + } + + public String getFillColor() + { + return "#" + fillColor; + } + + public void setFillColor(String fillColor) + { + this.fillColor = fillColor; + } + + public int getXstart() + { + return xstart; + } + + public void setXstart(int xstart) + { + this.xstart = xstart; + } + + public int getXend() + { + return xend; + } + + public void setXend(int xend) + { + this.xend = xend; + } + + +} diff --git a/src/jalview/json/binding/v1/BioJsSeqPojo.java b/src/jalview/json/binding/v1/BioJsSeqPojo.java new file mode 100644 index 0000000..bac8601 --- /dev/null +++ b/src/jalview/json/binding/v1/BioJsSeqPojo.java @@ -0,0 +1,90 @@ +package jalview.json.binding.v1; + +import java.util.ArrayList; + + +public class BioJsSeqPojo +{ + private String seq; + + private String name; + + private String id; + + private int start; + + private int end; + + private ArrayList features = new ArrayList(); + + public BioJsSeqPojo() + { + } + + public BioJsSeqPojo(int start, int end, String id, String name, String seq) + { + this.id = id; + this.name = name; + this.seq = seq; + } + public String getSeq() + { + return seq; + } + + public void setSeq(String seq) + { + this.seq = seq; + } + + public String getName() + { + + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public int getStart() + { + return start; + } + + public void setStart(int start) + { + this.start = start; + } + + public int getEnd() + { + return end; + } + + public void setEnd(int end) + { + this.end = end; + } + + public ArrayList getFeatures() + { + return features; + } + + public void setFeatures(ArrayList features) + { + this.features = features; + } +} diff --git a/src/jalview/ws/DasSequenceFeatureFetcher.java b/src/jalview/ws/DasSequenceFeatureFetcher.java index 8a7bcbc..a778ab1 100644 --- a/src/jalview/ws/DasSequenceFeatureFetcher.java +++ b/src/jalview/ws/DasSequenceFeatureFetcher.java @@ -496,13 +496,13 @@ public class DasSequenceFeatureFetcher } catch (Exception ex) { Cache.log - .info("Error in 'experimental' mapping of features. Please try to reproduce and then report info to jalview-discuss@jalview.org."); - Cache.log.info("Mapping feature from " + f.getBegin() + .warn("Error in 'experimental' mapping of features. Please try to reproduce and then report info to jalview-discuss@jalview.org."); + Cache.log.warn("Mapping feature from " + f.getBegin() + " to " + f.getEnd() + " in dbref " + dbref.getAccessionId() + " in " + dbref.getSource()); - Cache.log.info("using das Source " + source); - Cache.log.info("Exception", ex); + Cache.log.warn("using das Source " + source); + Cache.log.warn("Exception", ex); } if (vf != null) @@ -626,7 +626,9 @@ public class DasSequenceFeatureFetcher Object[] nextSequence(jalviewSourceI dasSource, SequenceI seq) { if (cancelled) + { return null; + } DBRefEntry[] uprefs = jalview.util.DBRefUtils.selectRefs( seq.getDBRef(), new String[] { @@ -668,7 +670,9 @@ public class DasSequenceFeatureFetcher qstring.add(uprefs[j].getAccessionId()); } else + { System.out.println("IGNORE " + csys.getAuthority()); + } } } } @@ -839,7 +843,7 @@ public class DasSequenceFeatureFetcher { for (String note : feat.getNOTE()) { - desc += (String) note; + desc += note; } } diff --git a/src/jalview/ws/jws1/JPredClient.java b/src/jalview/ws/jws1/JPredClient.java index 1a96464..df0e091 100644 --- a/src/jalview/ws/jws1/JPredClient.java +++ b/src/jalview/ws/jws1/JPredClient.java @@ -20,18 +20,28 @@ */ package jalview.ws.jws1; +import jalview.analysis.AlignSeq; +import jalview.bin.Cache; +import jalview.datamodel.AlignmentView; +import jalview.datamodel.SeqCigar; +import jalview.datamodel.SequenceI; +import jalview.gui.AlignFrame; +import jalview.gui.Desktop; +import jalview.gui.WebserviceInfo; +import jalview.util.MessageManager; + import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.*; +import java.util.Hashtable; -import javax.swing.*; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; -import ext.vamsas.*; -import jalview.analysis.*; -import jalview.bin.*; -import jalview.datamodel.*; -import jalview.gui.*; -import jalview.util.MessageManager; +import ext.vamsas.Jpred; +import ext.vamsas.JpredServiceLocator; +import ext.vamsas.JpredSoapBindingStub; +import ext.vamsas.ServiceHandle; public class JPredClient extends WS1Client { @@ -291,7 +301,7 @@ public class JPredClient extends WS1Client WsURL = "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred"; WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle, - WebServiceReference); + WebServiceReference, true); return wsInfo; } diff --git a/src/jalview/ws/jws1/WS1Client.java b/src/jalview/ws/jws1/WS1Client.java index 210e520..9001c61 100644 --- a/src/jalview/ws/jws1/WS1Client.java +++ b/src/jalview/ws/jws1/WS1Client.java @@ -92,7 +92,8 @@ public abstract class WS1Client extends WSClient implements WebserviceInfo wsInfo = null; if (!headless) { - wsInfo = new WebserviceInfo(WebServiceJobTitle, WebServiceReference); + wsInfo = new WebserviceInfo(WebServiceJobTitle, WebServiceReference, + true); } return wsInfo; } diff --git a/src/jalview/ws/jws2/JabaWsServerQuery.java b/src/jalview/ws/jws2/JabaWsServerQuery.java index 74dce4d..832a2cb 100644 --- a/src/jalview/ws/jws2/JabaWsServerQuery.java +++ b/src/jalview/ws/jws2/JabaWsServerQuery.java @@ -212,7 +212,7 @@ public class JabaWsServerQuery implements Runnable else { jws2Discoverer.addInvalidServiceUrl(jwsserver); - Cache.log.info("Ignoring invalid Jws2 service url " + jwsserver); + Cache.log.warn("Ignoring invalid Jws2 service url " + jwsserver); } } catch (Exception e) { diff --git a/src/jalview/ws/jws2/Jws2Client.java b/src/jalview/ws/jws2/Jws2Client.java index afefe65..751d330 100644 --- a/src/jalview/ws/jws2/Jws2Client.java +++ b/src/jalview/ws/jws2/Jws2Client.java @@ -20,17 +20,6 @@ */ package jalview.ws.jws2; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.List; - -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.event.MenuEvent; -import javax.swing.event.MenuListener; - -import compbio.metadata.Argument; import jalview.api.AlignCalcWorkerI; import jalview.bin.Cache; import jalview.gui.AlignFrame; @@ -45,6 +34,18 @@ import jalview.ws.jws2.jabaws2.Jws2Instance; import jalview.ws.params.WsParamSetI; import jalview.ws.uimodel.AlignAnalysisUIText; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; + +import compbio.metadata.Argument; + /** * provides metadata for a jabaws2 service instance - resolves names, etc. * @@ -148,7 +149,7 @@ public abstract class Jws2Client extends jalview.ws.WSClient { return new WebserviceInfo(WebServiceJobTitle, WebServiceJobTitle + " using service hosted at " + serv.hosturl + "\n" - + (serv.description != null ? serv.description : "")); + + (serv.description != null ? serv.description : ""), false); } return null; } diff --git a/src/jalview/ws/jws2/Jws2Discoverer.java b/src/jalview/ws/jws2/Jws2Discoverer.java index a111d68..7a8eee9 100644 --- a/src/jalview/ws/jws2/Jws2Discoverer.java +++ b/src/jalview/ws/jws2/Jws2Discoverer.java @@ -705,7 +705,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI } else { - Cache.log.info("Ignoring duplicate url " + url + " in " + Cache.log.warn("Ignoring duplicate url " + url + " in " + JWS2HOSTURLS + " list"); } } catch (MalformedURLException ex) diff --git a/src/jalview/ws/jws2/MsaWSClient.java b/src/jalview/ws/jws2/MsaWSClient.java index 39be454..e7301a6 100644 --- a/src/jalview/ws/jws2/MsaWSClient.java +++ b/src/jalview/ws/jws2/MsaWSClient.java @@ -22,7 +22,6 @@ package jalview.ws.jws2; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentView; -import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; import jalview.gui.Desktop; import jalview.gui.JvSwingUtils; @@ -175,47 +174,20 @@ public class MsaWSClient extends Jws2Client MsaWSThread msathread = new MsaWSThread(server, preset, paramset, WsURL, wsInfo, alignFrame, WebServiceName, jobtitle, msa, submitGaps, preserveOrder, seqdataset); - wsInfo.setthisService(msathread); - - msathread.start(); - - } - - private boolean isValidAlignment(AlignmentView av) - { - int validSeqCount = 0; - List seqs = av.getVisibleAlignment('c').getSequences(); // .getSequences(); - if (seqs.size() < 2) + if (msathread.hasValidInput()) { - JOptionPane - .showMessageDialog( - alignFrame, - "A minimum of two sequences is required to perform this operation", - "Invalid selection", JOptionPane.INFORMATION_MESSAGE); - - return false; + wsInfo.setthisService(msathread); + wsInfo.setVisible(true); + msathread.start(); } - - for (SequenceI seq : seqs) + else { - - if (seq.getSequenceAsString().matches("(-*[a-zA-Z]-*){3}[a-zA-Z-]*")) - { - ++validSeqCount; - } - if (validSeqCount > 1) - { - return true; - } + JOptionPane.showMessageDialog(alignFrame, + MessageManager.getString("info.invalid_msa_input_mininfo"), + MessageManager.getString("info.invalid_msa_notenough"), + JOptionPane.INFORMATION_MESSAGE); + wsInfo.setVisible(false); } - - JOptionPane - .showMessageDialog( - alignFrame, - "All selected sequence for this job must have a minimum of \nthree non-gap character to perform this operation", - "Invalid selection", JOptionPane.INFORMATION_MESSAGE); - - return false; } public static void main(String[] args) @@ -300,7 +272,7 @@ public class MsaWSClient extends Jws2Client { AlignmentView msa = alignFrame.gatherSequencesForAlignment(); - if (msa != null && isValidAlignment(msa)) + if (msa != null) { new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps, true, alignFrame.getViewport().getAlignment() @@ -324,10 +296,9 @@ public class MsaWSClient extends Jws2Client public void actionPerformed(ActionEvent e) { AlignmentView msa = alignFrame.gatherSequencesForAlignment(); - - if (msa != null && isValidAlignment(msa)) + if (msa != null) { - new MsaWSClient(service, null, null, true, alignFrame + new MsaWSClient(service, null, null, true, alignFrame .getTitle(), msa, withGaps, true, alignFrame .getViewport().getAlignment().getDataset(), alignFrame); } @@ -382,9 +353,10 @@ public class MsaWSClient extends Jws2Client AlignmentView msa = alignFrame .gatherSequencesForAlignment(); - if (msa != null && isValidAlignment(msa)) + if (msa != null) { - new MsaWSClient(service, preset, alignFrame.getTitle(), + MsaWSClient msac = new MsaWSClient(service, preset, + alignFrame.getTitle(), msa, false, true, alignFrame.getViewport() .getAlignment().getDataset(), alignFrame); } diff --git a/src/jalview/ws/jws2/MsaWSThread.java b/src/jalview/ws/jws2/MsaWSThread.java index 5e8cb98..2bae428 100644 --- a/src/jalview/ws/jws2/MsaWSThread.java +++ b/src/jalview/ws/jws2/MsaWSThread.java @@ -20,7 +20,29 @@ */ package jalview.ws.jws2; -import java.util.*; +import jalview.analysis.AlignSeq; +import jalview.bin.Cache; +import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentOrder; +import jalview.datamodel.AlignmentView; +import jalview.datamodel.ColumnSelection; +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceI; +import jalview.gui.AlignFrame; +import jalview.gui.Desktop; +import jalview.gui.WebserviceInfo; +import jalview.util.MessageManager; +import jalview.ws.AWsJob; +import jalview.ws.JobStateSummary; +import jalview.ws.WSClientI; +import jalview.ws.jws2.dm.JabaWsParamSet; +import jalview.ws.params.WsParamSetI; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.Vector; import compbio.data.msa.MsaWS; import compbio.metadata.Argument; @@ -28,17 +50,6 @@ import compbio.metadata.ChunkHolder; import compbio.metadata.JobStatus; import compbio.metadata.Preset; -import jalview.analysis.*; -import jalview.bin.*; -import jalview.datamodel.*; -import jalview.gui.*; -import jalview.util.MessageManager; -import jalview.ws.AWsJob; -import jalview.ws.WSClientI; -import jalview.ws.JobStateSummary; -import jalview.ws.jws2.dm.JabaWsParamSet; -import jalview.ws.params.WsParamSetI; - class MsaWSThread extends AWS2Thread implements WSClientI { boolean submitGaps = false; // pass sequences including gaps to alignment @@ -221,7 +232,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI int ow = w, nw = w; for (i = 0, w = emptySeqs.size(); i < w; i++) { - String[] es = (String[]) emptySeqs.get(i); + String[] es = emptySeqs.get(i); if (es != null && es[1] != null) { int sw = es[1].length(); @@ -252,7 +263,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI } for (i = 0, w = emptySeqs.size(); i < w; i++) { - String[] es = (String[]) emptySeqs.get(i); + String[] es = emptySeqs.get(i); if (es[1] == null) { t_alseqs[i + alseq_l] = new jalview.datamodel.Sequence(es[0], @@ -474,7 +485,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI SequenceI[][] conmsa = _msa.getVisibleContigs('-'); if (conmsa != null) { - int njobs = conmsa.length; + int nvalid = 0, njobs = conmsa.length; jobs = new MsaWSJob[njobs]; for (int j = 0; j < njobs; j++) { @@ -486,6 +497,10 @@ class MsaWSThread extends AWS2Thread implements WSClientI { jobs[j] = new MsaWSJob(0, conmsa[j]); } + if (((MsaWSJob) jobs[j]).hasValidInput()) + { + nvalid++; + } ((MsaWSJob) jobs[j]).preset = preset; ((MsaWSJob) jobs[j]).arguments = paramset; ((MsaWSJob) jobs[j]).alignmentProgram = wsname; @@ -496,9 +511,20 @@ class MsaWSThread extends AWS2Thread implements WSClientI } wsinfo.setProgressText(jobs[j].getJobnum(), OutputHeader); } + validInput = nvalid > 0; } } + boolean validInput = false; + + /** + * + * @return true if the thread will perform a calculation + */ + public boolean hasValidInput() + { + return validInput; + } public boolean isCancellable() { return true; diff --git a/src/jalview/ws/rest/RestClient.java b/src/jalview/ws/rest/RestClient.java index cd4bb23..5ce1d5d 100644 --- a/src/jalview/ws/rest/RestClient.java +++ b/src/jalview/ws/rest/RestClient.java @@ -20,17 +20,6 @@ */ package jalview.ws.rest; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Hashtable; -import java.util.Vector; - -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.event.MenuEvent; -import javax.swing.event.MenuListener; - import jalview.bin.Cache; import jalview.datamodel.AlignmentView; import jalview.gui.AlignFrame; @@ -44,6 +33,17 @@ import jalview.ws.WSClient; import jalview.ws.WSClientI; import jalview.ws.WSMenuEntryProviderI; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Hashtable; +import java.util.Vector; + +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; + /** * @author JimP * @@ -107,7 +107,7 @@ public class RestClient extends WSClient implements WSClientI, if (!headless) { wsInfo = new WebserviceInfo(WebServiceJobTitle, WebServiceName + "\n" - + WebServiceReference); + + WebServiceReference, true); wsInfo.setRenderAsHtml(true); } diff --git a/test/jalview/io/BioJsHTMLOutputTest.java b/test/jalview/io/BioJsHTMLOutputTest.java new file mode 100644 index 0000000..cbda794 --- /dev/null +++ b/test/jalview/io/BioJsHTMLOutputTest.java @@ -0,0 +1,47 @@ +package jalview.io; + +import jalview.datamodel.Alignment; +import jalview.datamodel.Sequence; + +import java.io.IOException; + +import org.junit.Test; + +import com.json.JSONException; + +public class BioJsHTMLOutputTest +{ + + + @Test + public void getJalviewAlignmentAsJsonString() + { + BioJsHTMLOutput bioJsHtmlOuput = new BioJsHTMLOutput(null, null); + bioJsHtmlOuput.setGlobalColorScheme("Zappo"); + + Sequence[] seqs = new Sequence[1]; + Sequence seq = new Sequence("name", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 1, 26); + // SequenceFeature seqFeature = new SequenceFeature("type", "desc", + // "status", 1, 5, "jalview"); + // seq.addSequenceFeature(seqFeature); + seq.setDatasetSequence(seq); + seqs[0] = seq; + + Alignment al = new Alignment(seqs); + try + { + String generatedJson = bioJsHtmlOuput + .getJalviewAlignmentAsJsonString(al); + assert (generatedJson + .equalsIgnoreCase("{\"globalColorScheme\":\"zappo\",\"seqs\":[{\"id\":\"1\",\"start\":1,\"name\":\"name/1-26\",\"features\":[],\"seq\":\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",\"end\":26}]}")); + System.out.println("Output : " + generatedJson); + } catch (IOException e) + { + e.printStackTrace(); + } catch (JSONException e) + { + e.printStackTrace(); + } + } + +} diff --git a/test/jalview/io/HtmlFileTest.java b/test/jalview/io/HtmlFileTest.java new file mode 100644 index 0000000..be228b8 --- /dev/null +++ b/test/jalview/io/HtmlFileTest.java @@ -0,0 +1,16 @@ +package jalview.io; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class HtmlFileTest +{ + + @Test + public void test() + { + fail("Not yet implemented"); + } + +} diff --git a/utils/InstallAnywhere/Jalview.iap_xml b/utils/InstallAnywhere/Jalview.iap_xml index c938a0b..41ca030 100755 --- a/utils/InstallAnywhere/Jalview.iap_xml +++ b/utils/InstallAnywhere/Jalview.iap_xml @@ -1040,6 +1040,58 @@ and any path to a file to save to the file]]> + + + + + + false + + + true + + + true + + + + + + + + + + + + false + + + + + + true + + + true + + + true + + + + + + 348699 + + + false + + + 0 + + + + @@ -6185,6 +6237,7 @@ and any path to a file to read from that file]]> + @@ -6922,6 +6975,7 @@ and any path to a file to read from that file]]> +