/classes
.externalToolBuilders/Jalview Release indices [Builder].launch
/.DS_Store
+.DS_Store
/.com.apple.timemachine.supported
--- /dev/null
+<html>
+<header><title>BioJS viewer</title></header>
+<body>
+
+<meta name="description" content="Simple BioJS example" />
+
+<!-- include MSA js + css -->
+<script src="https://s3-eu-west-1.amazonaws.com/biojs/msa/latest/msa.js"></script>
+<link type=text/css rel=stylesheet href=https://s3-eu-west-1.amazonaws.com/biojs/msa/latest/msa.css />
+
+
+<!-- optional: menubar -->
+<link type=text/css rel=stylesheet href= https://raw.githubusercontent.com/greenify/biojs-vis-msa/master/external/jquery.dropdown.css />
+
+<div id="menuDiv"></div>
+<div id="yourDiv">press "Run with JS"</div>
+</body>
+</html>
+
+
+<script src=//cdn.biojs-msa.org/msa/0.2/msa.min.gz.js></script>
+
+<script>
+// this is a way how you use a bundled file parser
+biojs.io.clustal.read("http://www.corsproxy.com/rostlab.org/~goldberg/jalv_example.clustal", function(seqs){
+
+var opts = {};
+
+// set your custom properties
+// @see: https://github.com/greenify/biojs-vis-msa/tree/master/src/g
+
+var seqOnFly = [];
+
+#sequenceData#
+//seqOnFly.push({seq:'ABCDEFGHIJKLMNOPQ', name:'seq1', id:0});
+//seqOnFly.push({seq:'ABCDEFGHIJKLMNOPQ', name:'seq2', id:1});
+
+opts.seqs = seqOnFly; //msa.utils.seqgen.getDummySequences(1000,300);
+
+//opts.seqs = seqs; //msa.utils.seqgen.getDummySequences(1000,300);
+opts.el = document.getElementById("yourDiv");
+opts.vis = {conserv: false, overviewbox: false};
+opts.zoomer = {alignmentHeight: 225, labelWidth: 130,labelFontsize: "13px",labelIdLength: 20, menuFontsize: "12px",menuMarginLeft: "3px", menuPadding: "3px 4px 3px 4px", menuItemFontsize: "14px", menuItemLineHeight: "14px"};
+
+// init msa
+var m = new msa.msa(opts);
+
+// the menu is independent to the MSA container
+var menuOpts = {};
+menuOpts.el = document.getElementById('div');
+menuOpts.msa = m;
+var defMenu = new msa.menu.defaultmenu(menuOpts);
+m.addView("menu", defMenu);
+
+// call render at the end to display the whole MSA
+m.render();
+
+});
+</script>
\ No newline at end of file
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;
.getKeyCode() >= KeyEvent.VK_NUMPAD0 && evt
.getKeyCode() <= KeyEvent.VK_NUMPAD9))
&& Character.isDigit(evt.getKeyChar()))
+ {
alignPanel.seqPanel.numberPressed(evt.getKeyChar());
+ }
switch (evt.getKeyCode())
{
case KeyEvent.VK_DOWN:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
moveSelectedSequences(false);
+ }
if (viewport.cursorMode)
+ {
alignPanel.seqPanel.moveCursor(0, 1);
+ }
break;
case KeyEvent.VK_UP:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
moveSelectedSequences(true);
+ }
if (viewport.cursorMode)
+ {
alignPanel.seqPanel.moveCursor(0, -1);
+ }
break;
case KeyEvent.VK_LEFT:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
slideSequences(false, alignPanel.seqPanel.getKeyboardNo1());
+ }
else
+ {
alignPanel.seqPanel.moveCursor(-1, 0);
+ }
break;
case KeyEvent.VK_RIGHT:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
slideSequences(true, alignPanel.seqPanel.getKeyboardNo1());
+ }
else
+ {
alignPanel.seqPanel.moveCursor(1, 0);
+ }
break;
case KeyEvent.VK_SPACE:
{
case KeyEvent.VK_LEFT:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
viewport.firePropertyChange("alignment", null, viewport
.getAlignment().getSequences());
+ }
break;
case KeyEvent.VK_RIGHT:
if (evt.isAltDown() || !viewport.cursorMode)
+ {
viewport.firePropertyChange("alignment", null, viewport
.getAlignment().getSequences());
+ }
break;
}
}
alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
}
+ @Override
+ public void bioJSMenuItem_actionPerformed(ActionEvent e)
+ {
+ new BioJsHTMLOutput(alignPanel,
+ alignPanel.seqPanel.seqCanvas.getSequenceRenderer(),
+ alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
+ }
public void createImageMap(File file, String image)
{
alignPanel.makePNGImageMap(file, image);
protected void undoMenuItem_actionPerformed(ActionEvent e)
{
if (viewport.historyList.empty())
+ {
return;
+ }
CommandI command = (CommandI) viewport.historyList.pop();
viewport.redoList.push(command);
command.undoCommand(getViewAlignments());
for (int i = 0; i < viewport.getAlignment().getHeight(); i++)
{
if (!sg.contains(viewport.getAlignment().getSequenceAt(i)))
+ {
invertGroup.add(viewport.getAlignment().getSequenceAt(i));
+ }
}
SequenceI[] seqs1 = sg.toArray(new SequenceI[0]);
SequenceI[] seqs2 = new SequenceI[invertGroup.size()];
for (int i = 0; i < invertGroup.size(); i++)
+ {
seqs2[i] = (SequenceI) invertGroup.elementAt(i);
+ }
SlideSequencesCommand ssc;
if (right)
+ {
ssc = new SlideSequencesCommand("Slide Sequences", seqs2, seqs1,
size, viewport.getGapCharacter());
+ }
else
+ {
ssc = new SlideSequencesCommand("Slide Sequences", seqs1, seqs2,
size, viewport.getGapCharacter());
+ }
int groupAdjustment = 0;
if (ssc.getGapsInsertedBegin() && right)
{
if (viewport.cursorMode)
+ {
alignPanel.seqPanel.moveCursor(size, 0);
+ }
else
+ {
groupAdjustment = size;
+ }
}
else if (!ssc.getGapsInsertedBegin() && !right)
{
if (viewport.cursorMode)
+ {
alignPanel.seqPanel.moveCursor(-size, 0);
+ }
else
+ {
groupAdjustment = -size;
+ }
}
if (groupAdjustment != 0)
}
if (!appendHistoryItem)
+ {
addHistoryItem(ssc);
+ }
repaint();
}
{
AlignmentAnnotation sann[] = sequences[i].getAnnotation();
if (sann == null)
+ {
continue;
+ }
for (int avnum = 0; avnum < alview.length; avnum++)
{
if (alview[avnum] != alignment)
if (ds.getSequences() == null
|| !ds.getSequences().contains(
sprods[s].getDatasetSequence()))
+ {
ds.addSequence(sprods[s].getDatasetSequence());
+ }
sprods[s].updatePDBIds();
}
Alignment al = new Alignment(sprods);
--- /dev/null
+package jalview.io;
+
+import static java.nio.file.Files.readAllBytes;
+import static java.nio.file.Paths.get;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignViewport;
+import jalview.gui.AlignmentPanel;
+import jalview.gui.FeatureRenderer;
+import jalview.gui.SequenceRenderer;
+import jalview.util.MessageManager;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class BioJsHTMLOutput
+{
+ private AlignViewport av;
+ private FeatureRenderer fr;
+
+ public BioJsHTMLOutput(AlignmentPanel ap, SequenceRenderer sr,
+ FeatureRenderer fr1)
+ {
+ System.out.println("BioJs working as expected so far");
+ this.av = ap.av;
+
+ this.fr = new FeatureRenderer(ap);
+ fr.transferSettings(fr1);
+ exportAsBioJsHtml();
+ }
+
+ private void exportAsBioJsHtml()
+ {
+ try
+ {
+ JalviewFileChooser jvFileChooser = getJalviewFileChooserOption();
+ int fileChooserOpt = jvFileChooser.showSaveDialog(null);
+ if (fileChooserOpt == JalviewFileChooser.APPROVE_OPTION)
+ {
+ jalview.bin.Cache.setProperty("LAST_DIRECTORY", jvFileChooser
+ .getSelectedFile().getParent());
+ String selectedFile = jvFileChooser.getSelectedFile().getPath();
+ String generartedBioJs = generateBioJsAlignmentData(av
+ .getAlignment());
+ PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter(
+ selectedFile));
+ out.print(generartedBioJs);
+ out.close();
+ jalview.util.BrowserLauncher.openURL("file:///" + selectedFile);
+ }
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ private JalviewFileChooser getJalviewFileChooserOption()
+ {
+ JalviewFileChooser chooser = new JalviewFileChooser(
+ jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
+ { "html" }, new String[]
+ { "HTML files" }, "HTML files");
+
+ chooser.setFileView(new JalviewFileView());
+ // TODO uncomment when supported by MassageManager
+ // chooser.setDialogTitle(MessageManager.getString("label.save_as_biojs_html"));
+ chooser.setDialogTitle("save as BioJs HTML");
+ chooser.setToolTipText(MessageManager.getString("action.save"));
+
+ return chooser;
+ }
+
+ private String generateBioJsAlignmentData(AlignmentI alignment)
+ throws IOException
+ {
+ StringBuilder bioJsData = new StringBuilder();
+ int count = 0;
+ for (SequenceI seq : alignment.getSequences())
+ {
+ bioJsData.append("seqOnFly.push({seq:'" + seq.getSequenceAsString()
+ + "', name:'" + seq.getName() + "', id:" + ++count + "});");
+ }
+ String bioJSTemplate = new String(
+ readAllBytes(get("resources/templates/BioJSTemplate.txt")));
+
+ return bioJSTemplate.replaceAll("#sequenceData#", bioJsData.toString());
+ }
+
+
+}
+
JMenuItem createPNG = new JMenuItem();
+ JMenuItem createBioJS = new JMenuItem();
+
protected JMenuItem font = new JMenuItem();
public JCheckBoxMenuItem seqLimits = new JCheckBoxMenuItem();
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()
font_actionPerformed(e);
}
});
-
seqLimits.setText(MessageManager
.getString("label.show_sequence_limits"));
seqLimits.setState(jalview.bin.Cache.getDefault("SHOW_JVSUFFIX", true));
jMenu2.add(htmlMenuItem);
jMenu2.add(epsFile);
jMenu2.add(createPNG);
+ jMenu2.add(createBioJS);
addSequenceMenu.add(addFromFile);
addSequenceMenu.add(addFromText);
addSequenceMenu.add(addFromURL);
{
}
+ protected void bioJSMenuItem_actionPerformed(ActionEvent e)
+ {
+
+ }
+
protected void closeMenuItem_actionPerformed(boolean b)
{
}