<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> This data was generated from Jalview<div>
<div id="yourDiv">press "Run with JS"</div>
+<input type='hidden' id='seqData' name='seqData' value='#sequenceData#'/>
</body>
</html>
// set your custom properties
// @see: https://github.com/greenify/biojs-vis-msa/tree/master/src/g
-var seqOnFly = [];
-#sequenceData#
-opts.seqs = seqOnFly;
+//var seqOnFly = [];
+
+//alert(document.getElementById("seqData").value);
+
+opts.seqs = JSON.parse(document.getElementById("seqData").value);
//opts.seqs = seqs; //msa.utils.seqgen.getDummySequences(1000,300);
opts.el = document.getElementById("yourDiv");
import jalview.gui.AlignmentPanel;
import jalview.gui.FeatureRenderer;
import jalview.gui.SequenceRenderer;
+import jalview.json.binding.v1.BioJsAlignmentPojo;
+import jalview.json.binding.v1.BioJsSeqPojo;
import jalview.util.MessageManager;
import java.io.IOException;
import java.io.PrintWriter;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+
+import com.json.JSONException;
+import com.json.JSONObject;
+
public class BioJsHTMLOutput
{
private AlignViewport av;
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);
}
private String generateBioJsAlignmentData(AlignmentI alignment)
- throws IOException
+ throws IOException, JSONException
{
- StringBuilder bioJsData = new StringBuilder();
+ BioJsAlignmentPojo bjsAlignment = new BioJsAlignmentPojo();
+
int count = 0;
for (SequenceI seq : alignment.getSequences())
{
- bioJsData.append("seqOnFly.push({seq:'" + seq.getSequenceAsString()
- + "', name:'" + seq.getName() + "', id:" + ++count + "});");
+ bjsAlignment.getSeqs().add(
+ new BioJsSeqPojo(String.valueOf(++count), seq.getName(), seq
+ .getSequenceAsString()));
}
+
+ String seqs = new JSONObject(bjsAlignment).getString("seqs");
String bioJSTemplate = new String(
readAllBytes(get("resources/templates/BioJSTemplate.txt")));
- return bioJSTemplate.replaceAll("#sequenceData#", bioJsData.toString());
+ return bioJSTemplate.replaceAll("#sequenceData#", seqs);
}
+ public static void main(String[] args) throws IOException
+ {
+ Document doc = Jsoup.parse(new String(
+ readAllBytes(get("resources/templates/BioJSTemplate.txt"))));
+
+ Element content = doc.getElementById("seqData");
+ System.out.println(content.val());
+ }
}
--- /dev/null
+package jalview.json.binding.v1;
+
+
+public class BioJsSeqPojo
+{
+ private String seq;
+
+ private String name;
+
+ private String id;
+
+ public BioJsSeqPojo()
+ {
+ }
+
+ public BioJsSeqPojo(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;
+ }
+}