function openJalviewUsingCurrentUrl(){
- var jalviewData = JSON.parse(document.getElementById("seqData").value)
- var jalviewVersion = jalviewData['jalviewVersion'];
- var url = jalviewData['webStartUrl'];
+ var json = JSON.parse(document.getElementById("seqData").value)
+ var jalviewVersion = json['jalviewSettings'].jalviewVersion;
+ var url = json['jalviewSettings'].webStartUrl;
var myForm = document.createElement("form");
myForm.action = url;
// init msa
var m = new msa.msa(opts);
-m.g.colorscheme.set("scheme", jalviewData['globalColorScheme']);
+m.g.colorscheme.set("scheme", jalviewData['jalviewSettings'].globalColorScheme);
var x = 0;
-jalviewData.seqs.forEach( function (seq)
+//jalviewData.seqs.forEach( function (seq)
+//{
+//m.seqs.at(x++).set("features", new msa.model.featurecol(seq.features));
+//});
+
+//console.debug(">>>>>>>>>>>>>" + m.seqs.length);
+//console.debug(">>>>>>>>>>>>> Found features : " + jalviewData.seqFeatures.length);
+m.seqs.forEach( function (seq )
{
-m.seqs.at(x++).set("features", new msa.model.featurecol(seq.features));
+ var seqFeats = [];
+ for (i = 0; i < jalviewData.seqFeatures.length; i++) {
+ console.debug('comparing >>>>>>>> '+ seq.id)
+ if(jalviewData.seqFeatures[i].sequenceRef === seq.id){
+ // console.debug('>>>>>>>> '+jalviewData.seqFeatures[i].sequenceRef+' | '+ seq.id)
+ seqFeats.push(jalviewData.seqFeatures[i]);
+ }
+ }
+console.debug('matched features count : '+seqFeats.length);
+seq.set("features", new msa.model.featurecol(seqFeats));
});
// the menu is independent to the MSA container
package jalview.io;
-import jalview.api.FeaturesDisplayedI;
-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.AlignmentPojo;
-import jalview.json.binding.v1.SequenceFeaturesPojo;
-import jalview.json.binding.v1.SequencePojo;
-import jalview.schemes.ColourSchemeProperty;
import jalview.util.MessageManager;
-import jalview.viewmodel.AlignmentViewport;
-import java.awt.Color;
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 com.json.JSONException;
public class BioJsHTMLOutput
{
- private AlignmentViewport av;
-
- private jalview.api.FeatureRenderer fr;
-
- private String globalColorScheme;
-
- private FeaturesDisplayedI displayedFeatures;
+ private AlignViewport av;
- 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 = ap.cloneFeatureRenderer();
- displayedFeatures = av.getFeaturesDisplayed();
+ av.setFeatureRenderer(new FeatureRenderer(ap));
}
+ exportJalviewAlignmentAsBioJsHtmlFile();
}
private void exportJalviewAlignmentAsBioJsHtmlFile()
try
{
String outputFile = getOutputFile();
- String jalviewAlignmentJson = getJalviewAlignmentAsJsonString(av
- .getAlignment());
+ String jalviewAlignmentJson = JSONFile.getJSONData(av);
String bioJSTemplateString = getBioJsTemplateAsString(this);
String generatedBioJsWithJalviewAlignmentAsJson = bioJSTemplateString
.replaceAll(
{
throw new NoFileSelectedException("No file was selected.");
}
-
return selectedFile;
}
- public String getJalviewAlignmentAsJsonString(AlignmentI alignment)
- throws IOException, JSONException
- {
- AlignmentPojo bjsAlignment = new AlignmentPojo();
-
- // 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());
-
- SequencePojo seqPojo = new SequencePojo();
- seqPojo.setId(String.valueOf(++count));
- seqPojo.setEnd(seq.getEnd());
- seqPojo.setStart(seq.getStart());
- seqPojo.setName(name.toString());
- seqPojo.setSeq(seq.getSequenceAsString());
-
- SequenceFeature[] seqFeatures = seq.getSequenceFeatures();
- if (seqFeatures != null)
- {
- ArrayList<SequenceFeaturesPojo> bjsSeqFeatures = new ArrayList<SequenceFeaturesPojo>();
- for (SequenceFeature sf : seqFeatures)
- {
- if (displayedFeatures != null
- && displayedFeatures.isVisible(sf.getType()))
- {
-
- // TODO: translate graduated/complex colourschemes to biojs model
- String featureColour = jalview.util.Format.getHexString(fr
- .findFeatureColour(Color.white, seq,
- seq.findIndex(sf.getBegin())));
- // SequenceFeaturesPojo bjsFeature = new SequenceFeaturesPojo();
- // bjsFeature.setFillColor(featureColour);
- // bjsFeature.setXstart(seq.findIndex(sf.getBegin()) - 1);
- // bjsFeature.setXend(seq.findIndex(sf.getEnd()));
- // bjsFeature.setType(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
}
return sb.toString();
}
-
- public String getGlobalColorScheme()
- {
- return globalColorScheme;
- }
-
- public void setGlobalColorScheme(String globalColorScheme)
- {
- this.globalColorScheme = globalColorScheme;
- }
-
}