try
{
+ Desktop.setCurrentAlignFrame(this);
cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
viewport.getAlignment(), omitHidden,
viewport.getColumnSelection()));
public void setShowSeqFeatures(boolean b)
{
- showSeqFeatures.setSelected(true);
- viewport.setShowSequenceFeatures(true);
+ showSeqFeatures.setSelected(b);
+ viewport.setShowSequenceFeatures(b);
}
/*
import jalview.datamodel.Alignment;
import jalview.io.FormatAdapter;
import jalview.io.IdentifyFile;
+import jalview.io.JSONFile;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import jalview.jbgui.GCutAndPasteTransfer;
af.statusBar.setText(MessageManager
.getString("label.successfully_pasted_alignment_file"));
+ af.setShowSeqFeatures(JSONFile.isSeqFeaturesEnabled());
+
+ af.changeColour(JSONFile.getColourScheme());
+ af.setMenusForViewport();
+
try
{
af.setMaximum(jalview.bin.Cache.getDefault("SHOW_FULLSCREEN",
}
}
+
/**
* DOCUMENT ME!
*
*/
package jalview.gui;
+import jalview.api.AlignViewportI;
+import jalview.api.AlignmentViewPanel;
+import jalview.bin.Cache;
+import jalview.io.FileLoader;
+import jalview.io.FormatAdapter;
+import jalview.io.IdentifyFile;
+import jalview.io.JSONFile;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.jbgui.GSplitFrame;
+import jalview.jbgui.GStructureViewer;
+import jalview.structure.StructureSelectionManager;
+import jalview.util.ImageMaker;
+import jalview.util.MessageManager;
+import jalview.viewmodel.AlignmentViewport;
+import jalview.ws.params.ParamManager;
+
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
-import jalview.api.AlignViewportI;
-import jalview.api.AlignmentViewPanel;
-import jalview.bin.Cache;
-import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
-import jalview.io.IdentifyFile;
-import jalview.io.JalviewFileChooser;
-import jalview.io.JalviewFileView;
-import jalview.jbgui.GSplitFrame;
-import jalview.jbgui.GStructureViewer;
-import jalview.structure.StructureSelectionManager;
-import jalview.util.ImageMaker;
-import jalview.util.MessageManager;
-import jalview.viewmodel.AlignmentViewport;
-import jalview.ws.params.ParamManager;
-
/**
* Jalview Desktop
*
private static final int THREE = 3;
+ private static AlignFrame currentAlignFrame;
+
public static jalview.ws.jws1.Discoverer discoverer;
public static Object[] jalviewClipboard;
{
new FileLoader().LoadFile(viewport, choice, FormatAdapter.FILE,
format);
+ viewport.setShowSequenceFeatures(JSONFile.isSeqFeaturesEnabled());
+ AlignFrame af = viewport.getAlignPanel().alignFrame;
+ if (af != null)
+ {
+ af.changeColour(JSONFile.getColourScheme());
+ af.setMenusForViewport();
+ }
}
else
{
myTopFrame.setDisplayedView(myTopFrame.alignPanel);
}
+
+ public static AlignFrame getCurrentAlignFrame()
+ {
+ return currentAlignFrame;
+ }
+
+ public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
+ {
+ Desktop.currentAlignFrame = currentAlignFrame;
+ }
+
+
}
*/
package jalview.gui;
-import java.awt.Color;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.Vector;
-
-import javax.swing.ButtonGroup;
-import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JColorChooser;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JPopupMenu;
-import javax.swing.JRadioButtonMenuItem;
-
import jalview.analysis.AAFrequency;
import jalview.analysis.AlignmentAnnotationUtils;
import jalview.analysis.AlignmentUtils;
import jalview.util.MessageManager;
import jalview.util.UrlLink;
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.Vector;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JColorChooser;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPopupMenu;
+import javax.swing.JRadioButtonMenuItem;
+
/**
* DOCUMENT ME!
*
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.util.MessageManager;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.List;
import java.util.Vector;
/**
protected Vector<AlignmentAnnotation> annotations;
/**
+ * SequenceGroups to be added to the alignment object
+ */
+ protected List<SequenceGroup> seqGroups;
+
+ /**
* Properties to be added to generated alignment object
*/
protected Hashtable properties;
return seqs;
}
+ public List<SequenceGroup> getSeqGroups()
+ {
+ return seqGroups;
+ }
+
/**
* Return the Sequences in the seqs Vector as an array of Sequences
*/
}
+ public void addSeqGroups(AlignmentI al)
+ {
+ this.seqGroups = al.getGroups();
+
+ }
+
/**
* Add any additional information extracted from the file to the alignment
* properties.
{
seqs = new Vector();
annotations = new Vector();
+ seqGroups = new ArrayList<SequenceGroup>();
parseCalled=false;
}
*/
public static final String[] READABLE_FORMATS = new String[]
{ "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "STH",
- "PDB", "JnetFile", "RNAML", PhylipFile.FILE_DESC, "HTML" };
+ "PDB", "JnetFile", "RNAML", PhylipFile.FILE_DESC, JSONFile.FILE_DESC,
+ "HTML" };
/**
* List of readable format file extensions by application in order
*/
public static final String[] READABLE_EXTENSIONS = new String[]
{ "fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa",
- "sto,stk", "xml,rnaml", PhylipFile.FILE_EXT, "jar,jvp", "html" };
+ "sto,stk", "xml,rnaml", PhylipFile.FILE_EXT, JSONFile.FILE_EXT,
+ "jar,jvp", "html" };
/**
* List of readable formats by application in order corresponding to
*/
public static final String[] READABLE_FNAMES = new String[]
{ "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "Stockholm",
- "RNAML", PhylipFile.FILE_DESC, "Jalview", "HTML" };
+ "RNAML", PhylipFile.FILE_DESC, JSONFile.FILE_DESC, "Jalview", "HTML" };
/**
* List of valid format strings for use by callers of the formatSequences
*/
public static final String[] WRITEABLE_FORMATS = new String[]
{ "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "AMSA",
- "STH", PhylipFile.FILE_DESC };
+ "STH", PhylipFile.FILE_DESC, JSONFile.FILE_DESC };
/**
* List of extensions corresponding to file format types in WRITABLE_FNAMES
*/
public static final String[] WRITABLE_EXTENSIONS = new String[]
{ "fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa",
- "sto,stk", PhylipFile.FILE_EXT, "jvp" };
+ "sto,stk", PhylipFile.FILE_EXT, JSONFile.FILE_EXT, "jvp" };
/**
* List of writable formats by the application. Order must correspond with the
*/
public static final String[] WRITABLE_FNAMES = new String[]
{ "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "STH",
- PhylipFile.FILE_DESC, "Jalview" };
+ PhylipFile.FILE_DESC, JSONFile.FILE_DESC, "Jalview" };
public static String INVALID_CHARACTERS = "Contains invalid characters";
{
afile = new PhylipFile(inFile, type);
}
- // else if (format.equals(HtmlFile.FILE_DESC))
- // {
- // afile = new HtmlFile(inFile, type);
- // }
+ else if (format.equals(JSONFile.FILE_DESC))
+ {
+ afile = new JSONFile(inFile, type);
+ }
else if (format.equals("RNAML"))
{
afile = new RnamlFile(inFile, type);
Alignment al = new Alignment(afile.getSeqsAsArray());
afile.addAnnotations(al);
+ afile.addSeqGroups(al);
return al;
} catch (Exception e)
// Possible sequence is just residues with no label
afile = new FastaFile(">UNKNOWN\n" + inFile, "Paste");
Alignment al = new Alignment(afile.getSeqsAsArray());
+
+ afile.addSeqGroups(al);
afile.addAnnotations(al);
return al;
{
afile = new PhylipFile(source);
}
- // else if (format.equals(HtmlFile.FILE_DESC))
- // {
- // afile = new HtmlFile(source);
- // }
+ else if (format.equals(JSONFile.FILE_DESC))
+ {
+ afile = new JSONFile(source);
+ }
Alignment al = new Alignment(afile.getSeqsAsArray());
afile.addAnnotations(al);
+ afile.addSeqGroups(al);
return al;
} catch (Exception e)
afile = new FastaFile(">UNKNOWN\n" + inFile, "Paste");
Alignment al = new Alignment(afile.getSeqsAsArray());
afile.addAnnotations(al);
+ afile.addSeqGroups(al);
return al;
} catch (Exception ex)
try
{
AlignFile afile = null;
-
if (format.equalsIgnoreCase("FASTA"))
{
afile = new FastaFile();
{
afile = new PhylipFile();
}
- // else if (format.equalsIgnoreCase(HtmlFile.FILE_DESC))
- // {
- // afile = new HtmlFile();
- // }
+ else if (format.equalsIgnoreCase(JSONFile.FILE_DESC))
+ {
+ afile = new JSONFile();
+ // Add groups to AlignFile
+ afile.seqGroups = alignment.getGroups();
+
+ // Add non auto calculated annotation to AlignFile
+ for (AlignmentAnnotation annot : alignment.getAlignmentAnnotation())
+ {
+ if (annot != null && !annot.autoCalculated)
+ {
+ if (annot.label.equals("PDB.CATempFactor"))
+ {
+ continue;
+ }
+ afile.annotations.add(annot);
+ }
+ }
+ }
else if (format.equalsIgnoreCase("RNAML"))
{
afile = new RnamlFile();
afile.setSeqs(alignment.getSequencesArray());
+
String afileresp = afile.print();
if (afile.hasWarningMessage())
{
import jalview.exceptions.NoFileSelectedException;
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.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;
public String getJalviewAlignmentAsJsonString(AlignmentI alignment)
throws IOException, JSONException
{
- BioJsAlignmentPojo bjsAlignment = new BioJsAlignmentPojo();
+ AlignmentPojo bjsAlignment = new AlignmentPojo();
- bjsAlignment.setGlobalColorScheme(getGlobalColorScheme());
- bjsAlignment.setJalviewVersion(jalviewVersion);
- bjsAlignment.setWebStartUrl(webStartLaunchServletUrl);
+ // bjsAlignment.setGlobalColorScheme(getGlobalColorScheme());
+ // bjsAlignment.setJalviewVersion(jalviewVersion);
+ // bjsAlignment.setWebStartUrl(webStartLaunchServletUrl);
int count = 0;
for (SequenceI seq : alignment.getSequences())
name.append(seq.getName()).append("/").append(seq.getStart())
.append("-").append(seq.getEnd());
- BioJsSeqPojo seqPojo = new BioJsSeqPojo();
+ SequencePojo seqPojo = new SequencePojo();
seqPojo.setId(String.valueOf(++count));
seqPojo.setEnd(seq.getEnd());
seqPojo.setStart(seq.getStart());
SequenceFeature[] seqFeatures = seq.getSequenceFeatures();
if (seqFeatures != null)
{
- ArrayList<BioJsFeaturePojo> bjsSeqFeatures = new ArrayList<BioJsFeaturePojo>();
+ ArrayList<SequenceFeaturesPojo> bjsSeqFeatures = new ArrayList<SequenceFeaturesPojo>();
for (SequenceFeature sf : seqFeatures)
{
if (displayedFeatures != null
String featureColour = jalview.util.Format.getHexString(fr
.findFeatureColour(Color.white, seq,
seq.findIndex(sf.getBegin())));
- 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);
+ // 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);
+ // seqPojo.setFeatures(bjsSeqFeatures);
}
bjsAlignment.getSeqs().add(seqPojo);
}
import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
-import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;
}
if (sq.getPDBId() != null)
{
- for (PDBEntry pdbe : (List<PDBEntry>) sq.getPDBId())
+ for (PDBEntry pdbe : sq.getPDBId())
{
StructureSelectionManager.getStructureSelectionManager(
Desktop.instance).registerPDBEntry(pdbe);
if (source instanceof HtmlFile)
{
((HtmlFile) source).LoadAlignmentFeatures(alignFrame);
-
}
+ else if (source instanceof JSONFile)
+ {
+ ((JSONFile) source).LoadAlignmentFeatures(alignFrame);
+ }
+
if (raiseGUI)
{
// add the window to the GUI
throws java.io.IOException
{
Alignment al;
- if (format.equals("HTML"))
+ if (format.equals(JSONFile.FILE_DESC))
{
- afile = new HtmlFile(inFile, type);
+ afile = new JSONFile(inFile, type);
al = new Alignment(afile.getSeqsAsArray());
afile.addAnnotations(al);
+ for (SequenceGroup sg : afile.getSeqGroups())
+ {
+ al.addGroup(sg);
+ }
}
else
{
al = super.readFile(inFile, type, format);
}
-
return al;
}
throws java.io.IOException
{
Alignment al;
- if (format.equals("HTML"))
+ if (format.equals(JSONFile.FILE_DESC))
{
- afile = new HtmlFile(source);
+ afile = new JSONFile(source);
al = new Alignment(afile.getSeqsAsArray());
afile.addAnnotations(al);
+ afile.addSeqGroups(al);
}
else
{
return formatSequences(format, getCacheSuffixDefault(format), av, selectedOnly);
}
+
}
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;
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<JSONObject> 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);
- }
+ new JSONFile().parse(alignmentJsonString);
+
+ // 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<JSONObject> 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<JSONObject> 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 SequenceFeature[] getJalviewSequenceFeatures(
+ // JSONArray jsonSeqFeatures, Sequence seq)
+ // {
+ // SequenceFeature[] seqFeatures = null;
+ // int count = 0;
+ // if (jsonSeqFeatures != null)
+ // {
+ // seqFeatures = new SequenceFeature[jsonSeqFeatures.size()];
+ // for (@SuppressWarnings("unchecked")
+ // Iterator<JSONObject> 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.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;
- }
+ // 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()
break;
}
+ if (data.indexOf("{\"") > -1)
+ {
+ reply = JSONFile.FILE_DESC;
+ break;
+ }
// if (data.matches("<(\"[^\"]*\"|'[^']*'|[^'\">])*>"))
if (data.matches("<(?i)html(\"[^\"]*\"|'[^']*'|[^'\">])*>"))
{
--- /dev/null
+package jalview.io;
+
+import jalview.api.FeaturesDisplayedI;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.Annotation;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
+import jalview.json.binding.v1.AlignmentAnnotationPojo;
+import jalview.json.binding.v1.AlignmentPojo;
+import jalview.json.binding.v1.AnnotationPojo;
+import jalview.json.binding.v1.JalviewSettingsPojo;
+import jalview.json.binding.v1.JalviewSettingsPojo.JalviewBioJsColorSchemeMapper;
+import jalview.json.binding.v1.SequenceFeaturesPojo;
+import jalview.json.binding.v1.SequenceGrpPojo;
+import jalview.json.binding.v1.SequencePojo;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.ColourSchemeProperty;
+import jalview.viewmodel.AlignmentViewport;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+
+public class JSONFile extends AlignFile
+{
+ private static ColourSchemeI colourScheme;
+
+ private static boolean seqFeaturesEnabled;
+
+ private String jalviewVersion;
+
+ private String webStartLaunchServletUrl = "http://www.jalview.org/services/launchApp";
+
+ public static final String FILE_EXT = "json";
+
+ public static final String FILE_DESC = "JSON";
+
+ private String globalColorScheme;
+
+ private boolean showSeqFeatures;
+
+ private Hashtable<String, Sequence> seqMap;
+
+ private FeaturesDisplayedI displayedFeatures;
+
+ private AlignmentViewport av;
+
+ private jalview.api.FeatureRenderer fr;
+
+ public JSONFile()
+ {
+ super();
+ }
+
+ public JSONFile(FileParse source) throws IOException
+ {
+ super(source);
+ }
+
+ public JSONFile(String inFile, String type) throws IOException
+ {
+ super(inFile, type);
+ }
+
+ @Override
+ public void parse() throws IOException
+ {
+ StringBuilder jsonStringBuilder = new StringBuilder();
+ String currentLine;
+ while ((currentLine = nextLine()) != null)
+ {
+ jsonStringBuilder.append(currentLine);
+ }
+ parse(jsonStringBuilder.toString());
+
+ }
+
+ @Override
+ public String print()
+ {
+ try
+ {
+ JSONExportSettings exportSettings = new JSONExportSettings();
+ exportSettings.setExportAnnotations(true);
+ exportSettings.setExportGroups(true);
+ exportSettings.setExportJalviewSettings(true);
+ exportSettings.setExportSequenceFeatures(true);
+
+ AlignmentPojo jsonAlignmentPojo = new AlignmentPojo();
+ if (Desktop.getCurrentAlignFrame() != null)
+ {
+ globalColorScheme = ColourSchemeProperty.getColourName(Desktop
+ .getCurrentAlignFrame().getViewport()
+ .getGlobalColourScheme());
+ this.av = Desktop.getCurrentAlignFrame().getCurrentView();
+ this.fr = Desktop.getCurrentAlignFrame().alignPanel
+ .cloneFeatureRenderer();
+ displayedFeatures = av.getFeaturesDisplayed();
+ showSeqFeatures = Desktop.getCurrentAlignFrame().showSeqFeatures
+ .isSelected();
+ }
+
+ int count = 0;
+ for (SequenceI seq : seqs)
+ {
+ StringBuilder name = new StringBuilder();
+ name.append(seq.getName()).append("/").append(seq.getStart())
+ .append("-").append(seq.getEnd());
+ SequencePojo jsonSeqPojo = new SequencePojo();
+ jsonSeqPojo.setId(seq.getName() + "_" + seq.hashCode());
+ jsonSeqPojo.setOrder(++count);
+ jsonSeqPojo.setEnd(seq.getEnd());
+ jsonSeqPojo.setStart(seq.getStart());
+ jsonSeqPojo.setName(name.toString());
+ jsonSeqPojo.setSeq(seq.getSequenceAsString());
+ jsonAlignmentPojo.getSeqs().add(jsonSeqPojo);
+ }
+
+ if (exportSettings.isExportJalviewSettings())
+ {
+ JalviewSettingsPojo jvSettings = new JalviewSettingsPojo();
+ jvSettings.setGlobalColorScheme(globalColorScheme);
+ jvSettings.setJalviewVersion(jalviewVersion);
+ jvSettings.setWebStartUrl(webStartLaunchServletUrl);
+ jvSettings.setShowSeqFeatures(showSeqFeatures);
+ jsonAlignmentPojo.setJalviewSettings(jvSettings);
+ }
+
+ if (exportSettings.isExportAnnotations())
+ {
+ jsonAlignmentPojo
+ .setAlignAnnotation(annotationToJsonPojo(annotations));
+ }
+
+ if (exportSettings.isExportSequenceFeatures())
+ {
+ jsonAlignmentPojo.setSeqFeatures(sequenceFeatureToJsonPojo(seqs,
+ displayedFeatures));
+ }
+
+ if (exportSettings.isExportGroups() && seqGroups.size() > 0)
+ {
+ ArrayList<SequenceGrpPojo> sequenceGroupsPojo = new ArrayList<SequenceGrpPojo>();
+ for (SequenceGroup seqGrp : seqGroups)
+ {
+ SequenceGrpPojo seqGrpPojo = new SequenceGrpPojo();
+ seqGrpPojo.setGroupName(seqGrp.getName());
+ seqGrpPojo.setColourScheme(ColourSchemeProperty
+ .getColourName(seqGrp.cs));
+ seqGrpPojo.setColourText(seqGrp.getColourText());
+ seqGrpPojo.setDescription(seqGrp.getDescription());
+ seqGrpPojo.setDisplayBoxes(seqGrp.getDisplayBoxes());
+ seqGrpPojo.setDisplayText(seqGrp.getDisplayText());
+ seqGrpPojo.setEndRes(seqGrp.getEndRes());
+ seqGrpPojo.setStartRes(seqGrp.getStartRes());
+ seqGrpPojo.setShowNonconserved(seqGrp.getShowNonconserved());
+ for (SequenceI seq : seqGrp.getSequences())
+ {
+ seqGrpPojo.getSeqsHash().add(
+ seq.getName() + "_" + seq.hashCode());
+ }
+ jsonAlignmentPojo.getSeqGroups().add(seqGrpPojo);
+ }
+ }
+ com.json.JSONObject generatedJSon = new com.json.JSONObject(
+ jsonAlignmentPojo);
+ String jsonOutput = generatedJSon.toString();
+ return jsonOutput.replaceAll("xstart", "xStart").replaceAll("xend",
+ "xEnd");
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ public static List<SequenceFeaturesPojo> sequenceFeatureToJsonPojo(
+ List<SequenceI> seqs, FeaturesDisplayedI displayedFeatures)
+ {
+ List<SequenceFeaturesPojo> sequenceFeaturesPojo = new ArrayList<SequenceFeaturesPojo>();
+ for (SequenceI seq : seqs)
+ {
+ SequenceI dataSetSequence = seq.getDatasetSequence();
+ SequenceFeature[] seqFeatures = (dataSetSequence == null) ? null
+ : seq.getDatasetSequence().getSequenceFeatures();
+ for (SequenceFeature sf : seqFeatures)
+ {
+ if (displayedFeatures != null
+ && displayedFeatures.isVisible(sf.getType()))
+ {
+ // String fillColor = ((fr != null) ? jalview.util.Format
+ // .getHexString(fr.findFeatureColour(Color.white, seq,
+ // seq.findIndex(sf.getBegin()))) : null);
+ SequenceFeaturesPojo jsonFeature = new SequenceFeaturesPojo(
+ seq.getName() + "_" + seq.hashCode());
+ jsonFeature.setXstart(seq.findIndex(sf.getBegin()) - 1);
+ jsonFeature.setXend(seq.findIndex(sf.getEnd()));
+ jsonFeature.setType(sf.getType());
+ jsonFeature.setDescription(sf.getDescription());
+ jsonFeature.setLinks(sf.links);
+ jsonFeature.setOtherDetails(sf.otherDetails);
+ jsonFeature.setScore(sf.getScore());
+ // jsonFeature.setFillColor(fillColor);
+ jsonFeature.setFeatureGroup(sf.getFeatureGroup());
+ sequenceFeaturesPojo.add(jsonFeature);
+ }
+ }
+ }
+ return sequenceFeaturesPojo;
+ }
+
+ public static List<AlignmentAnnotationPojo> annotationToJsonPojo(
+ Vector<AlignmentAnnotation> annotations)
+ {
+ List<AlignmentAnnotationPojo> jsonAnnotations = new ArrayList<AlignmentAnnotationPojo>();
+ for (AlignmentAnnotation annot : annotations)
+ {
+ AlignmentAnnotationPojo alignAnnotPojo = new AlignmentAnnotationPojo();
+ alignAnnotPojo.setDescription(annot.description);
+ alignAnnotPojo.setLabel(annot.label);
+ for (Annotation annotation : annot.annotations)
+ {
+ AnnotationPojo annotationPojo = new AnnotationPojo();
+ if (annotation != null)
+ {
+ annotationPojo.setDescription(annotation.description);
+ annotationPojo.setValue(annotation.value);
+ annotationPojo
+ .setSecondaryStructure(annotation.secondaryStructure);
+ annotationPojo.setDisplayCharacter(annotation.displayCharacter);
+ alignAnnotPojo.getAnnotations().add(annotationPojo);
+ }
+ else
+ {
+ alignAnnotPojo.getAnnotations().add(annotationPojo);
+ }
+ }
+ jsonAnnotations.add(alignAnnotPojo);
+ }
+ return jsonAnnotations;
+ }
+
+ public void parse(String jsonAlignmentString)
+ {
+ try
+ {
+ JSONParser jsonParser = new JSONParser();
+ JSONObject alignmentJsonObj = (JSONObject) jsonParser
+ .parse(jsonAlignmentString);
+ JSONArray seqJsonArray = (JSONArray) alignmentJsonObj.get("seqs");
+ JSONArray alAnnotJsonArray = (JSONArray) alignmentJsonObj
+ .get("alignAnnotation");
+ JSONArray jsonSeqArray = (JSONArray) alignmentJsonObj
+ .get("seqFeatures");
+ JSONArray seqGrpJsonArray = (JSONArray) alignmentJsonObj
+ .get("seqGroups");
+ JSONObject jvSettingsJsonObj = (JSONObject) alignmentJsonObj
+ .get("jalviewSettings");
+
+ if (jvSettingsJsonObj != null)
+ {
+ String jsColourScheme = (String) jvSettingsJsonObj
+ .get("globalColorScheme");
+ Boolean showFeatures = Boolean.valueOf(jvSettingsJsonObj.get(
+ "showSeqFeatures").toString());
+ setColourScheme(getJalviewColorScheme(jsColourScheme));
+ JSONFile.setSeqFeaturesEnabled(showFeatures);
+ // Desktop.setCurrentSeqFeaturesVisible(showFeatures);
+ }
+
+ seqMap = new Hashtable<String, Sequence>();
+ // Desktop.setCurrentGlobalColourScheme(cs);
+ for (Iterator<JSONObject> sequenceIter = seqJsonArray.iterator(); sequenceIter
+ .hasNext();)
+ {
+ JSONObject sequence = sequenceIter.next();
+ String sequcenceString = sequence.get("seq").toString();
+ String sequenceName = sequence.get("name").toString();
+ String seqUniqueId = sequence.get("id").toString();
+ int start = Integer.valueOf(sequence.get("start").toString());
+ int end = Integer.valueOf(sequence.get("end").toString());
+ Sequence seq = new Sequence(sequenceName, sequcenceString, start,
+ end);
+ seqs.add(seq);
+ seqMap.put(seqUniqueId, seq);
+ }
+ parseFeatures(jsonSeqArray);
+
+ for (Iterator<JSONObject> seqGrpIter = seqGrpJsonArray.iterator(); seqGrpIter
+ .hasNext();)
+ {
+ JSONObject seqGrpObj = seqGrpIter.next();
+ String grpName = seqGrpObj.get("groupName").toString();
+ String colourScheme = seqGrpObj.get("colourScheme").toString();
+ String description = (seqGrpObj.get("description") == null) ? null
+ : seqGrpObj.get("description").toString();
+ boolean displayBoxes = Boolean.valueOf(seqGrpObj
+ .get("displayBoxes").toString());
+ boolean displayText = Boolean.valueOf(seqGrpObj.get("displayText")
+ .toString());
+ boolean colourText = Boolean.valueOf(seqGrpObj.get("colourText")
+ .toString());
+ boolean showNonconserved = Boolean.valueOf(seqGrpObj.get(
+ "showNonconserved").toString());
+ int startRes = Integer
+ .valueOf(seqGrpObj.get("startRes").toString());
+ int endRes = Integer.valueOf(seqGrpObj.get("endRes").toString());
+ JSONArray seqsHashArray = (JSONArray) seqGrpObj.get("seqsHash");
+
+ ArrayList<SequenceI> grpSeqs = new ArrayList<SequenceI>();
+ if (seqsHashArray.size() > 0)
+ {
+ Iterator<String> seqHashIter = seqsHashArray.iterator();
+ while (seqHashIter.hasNext())
+ {
+ String seqHash = seqHashIter.next();
+ Sequence sequence = seqMap.get(seqHash);
+ if (sequence != null)
+ {
+ grpSeqs.add(sequence);
+ }
+ }
+ }
+ ColourSchemeI scheme = getJalviewColorScheme(colourScheme);
+ SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName, scheme,
+ displayBoxes, displayText, colourText, startRes, endRes);
+ seqGrp.setShowNonconserved(showNonconserved);
+ seqGrp.setDescription(description);
+ this.seqGroups.add(seqGrp);
+
+ }
+
+ for (Iterator<JSONObject> alAnnotIter = alAnnotJsonArray.iterator(); alAnnotIter
+ .hasNext();)
+ {
+ JSONObject alAnnot = alAnnotIter.next();
+ JSONArray annotJsonArray = (JSONArray) alAnnot.get("annotations");
+ Annotation[] annotations = new Annotation[annotJsonArray.size()];
+ int count = 0;
+ for (Iterator<JSONObject> annotIter = annotJsonArray.iterator(); annotIter
+ .hasNext();)
+ {
+ JSONObject annot = annotIter.next();
+ if (annot == null)
+ {
+ annotations[count] = null;
+ }
+ else
+ {
+ float val = annot.get("value") == null ? null : Float
+ .valueOf(annot.get("value").toString());
+ String desc = annot.get("description") == null ? null : annot
+ .get("description").toString();
+
+ char ss = annot.get("secondaryStructure") == null ? null
+ : annot.get("secondaryStructure").toString().charAt(0);
+ String displayChar = annot.get("displayCharacter").toString();
+
+ annotations[count] = new Annotation(displayChar, desc, ss, val);
+ }
+ ++count;
+ }
+
+ AlignmentAnnotation alignAnnot = new AlignmentAnnotation(alAnnot
+ .get("label").toString(), alAnnot.get("description")
+ .toString(), annotations);
+ this.annotations.add(alignAnnot);
+ }
+
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+
+ private void parseFeatures(JSONArray jsonSeqFeatures)
+ {
+ if (jsonSeqFeatures != null)
+ {
+ for (@SuppressWarnings("unchecked")
+ Iterator<JSONObject> seqFeatureItr = jsonSeqFeatures.iterator(); seqFeatureItr
+ .hasNext();)
+ {
+ JSONObject jsonFeature = seqFeatureItr.next();
+ Long begin = (Long) jsonFeature.get("xStart");
+ Long end = (Long) jsonFeature.get("xEnd");
+ String type = (String) jsonFeature.get("type");
+ String color = (String) jsonFeature.get("fillColor");
+ String featureGrp = (String) jsonFeature.get("featureGroup");
+ String descripiton = (String) jsonFeature.get("description");
+ String seqRef = (String) jsonFeature.get("sequenceRef");
+ Float score = Float.valueOf(jsonFeature.get("score").toString());
+ // Hashtable otherDetails = (Hashtable) jsonFeature
+ // .get("otherDetails");
+ // sequenceFeature.otherDetails = otherDetails;
+
+ Sequence seq = seqMap.get(seqRef);
+ SequenceFeature sequenceFeature = new SequenceFeature();
+ JSONArray linksJsonArray = (JSONArray) jsonFeature.get("links");
+ if (linksJsonArray != null && linksJsonArray.size() > 0)
+ {
+ Iterator<String> linkList = linksJsonArray.iterator();
+ while (linkList.hasNext())
+ {
+ String link = linkList.next();
+ sequenceFeature.addLink(link);
+ }
+ }
+ sequenceFeature.setFeatureGroup(featureGrp);
+ sequenceFeature.setScore(score);
+ sequenceFeature.setDescription(descripiton);
+ sequenceFeature.setType(type);
+ sequenceFeature.setBegin(seq.findPosition(begin.intValue()));
+ sequenceFeature.setEnd(seq.findPosition(end.intValue()) - 1);
+ seq.addSequenceFeature(sequenceFeature);
+ }
+ }
+ }
+
+ private ColourSchemeI getJalviewColorScheme(String bioJsColourSchemeName)
+ {
+ ColourSchemeI jalviewColor = null;
+ for (JalviewBioJsColorSchemeMapper cs : JalviewBioJsColorSchemeMapper
+ .values())
+ {
+ if (cs.getBioJsName().equalsIgnoreCase(bioJsColourSchemeName))
+ {
+ jalviewColor = cs.getJvColourScheme();
+ break;
+ }
+ }
+ return jalviewColor;
+ }
+
+ public void LoadAlignmentFeatures(AlignFrame af)
+ {
+ af.setShowSeqFeatures(JSONFile.isSeqFeaturesEnabled());
+ af.changeColour(getColourScheme());
+ af.setMenusForViewport();
+ }
+
+ public String getGlobalColorScheme()
+ {
+ return globalColorScheme;
+ }
+
+ public void setGlobalColorScheme(String globalColorScheme)
+ {
+ this.globalColorScheme = globalColorScheme;
+ }
+
+ public static ColourSchemeI getColourScheme()
+ {
+ return colourScheme;
+ }
+
+ public static void setColourScheme(ColourSchemeI colourScheme)
+ {
+ JSONFile.colourScheme = colourScheme;
+ }
+
+ public static boolean isSeqFeaturesEnabled()
+ {
+ return seqFeaturesEnabled;
+ }
+
+ public static void setSeqFeaturesEnabled(boolean seqFeaturesEnabled)
+ {
+ JSONFile.seqFeaturesEnabled = seqFeaturesEnabled;
+ }
+
+ public class JSONExportSettings
+ {
+ private boolean exportSequence;
+
+ private boolean exportSequenceFeatures;
+
+ private boolean exportAnnotations;
+
+ private boolean exportGroups;
+
+ private boolean exportJalviewSettings;
+
+ public boolean isExportSequence()
+ {
+ return exportSequence;
+ }
+
+ public void setExportSequence(boolean exportSequence)
+ {
+ this.exportSequence = exportSequence;
+ }
+
+ public boolean isExportSequenceFeatures()
+ {
+ return exportSequenceFeatures;
+ }
+
+ public void setExportSequenceFeatures(boolean exportSequenceFeatures)
+ {
+ this.exportSequenceFeatures = exportSequenceFeatures;
+ }
+
+ public boolean isExportAnnotations()
+ {
+ return exportAnnotations;
+ }
+
+ public void setExportAnnotations(boolean exportAnnotations)
+ {
+ this.exportAnnotations = exportAnnotations;
+ }
+
+ public boolean isExportGroups()
+ {
+ return exportGroups;
+ }
+
+ public void setExportGroups(boolean exportGroups)
+ {
+ this.exportGroups = exportGroups;
+ }
+
+ public boolean isExportJalviewSettings()
+ {
+ return exportJalviewSettings;
+ }
+
+ public void setExportJalviewSettings(boolean exportJalviewSettings)
+ {
+ this.exportJalviewSettings = exportJalviewSettings;
+ }
+ }
+}
--- /dev/null
+package jalview.json.binding.v1;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class AlignmentAnnotationPojo
+{
+ private String label;
+
+ private String description;
+
+ private List<AnnotationPojo> annotations = new ArrayList();
+
+ public String getLabel()
+ {
+ return label;
+ }
+
+ public void setLabel(String label)
+ {
+ this.label = label;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String annotationId)
+ {
+ this.description = annotationId;
+ }
+
+ public List<AnnotationPojo> getAnnotations()
+ {
+ return annotations;
+ }
+
+ public void setAnnotations(List<AnnotationPojo> annotations)
+ {
+ this.annotations = annotations;
+ }
+}
--- /dev/null
+package jalview.json.binding.v1;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class AlignmentPojo
+{
+ private List<SequencePojo> seqs = new ArrayList<SequencePojo>();
+
+ private List<AlignmentAnnotationPojo> alignAnnotation = new ArrayList<AlignmentAnnotationPojo>();
+
+ private List<SequenceGrpPojo> seqGroups = new ArrayList<SequenceGrpPojo>();
+
+ private List<SequenceFeaturesPojo> seqFeatures = new ArrayList<SequenceFeaturesPojo>();
+
+ private JalviewSettingsPojo jalviewSettings;
+
+ public AlignmentPojo()
+ {
+ }
+
+ public List<SequencePojo> getSeqs()
+ {
+ return seqs;
+ }
+
+ public void setSeqs(ArrayList<SequencePojo> seqs)
+ {
+ this.seqs = seqs;
+ }
+
+ public JalviewSettingsPojo getJalviewSettings()
+ {
+ return jalviewSettings;
+ }
+
+ public void setJalviewSettings(JalviewSettingsPojo jalviewSettings)
+ {
+ this.jalviewSettings = jalviewSettings;
+ }
+
+ public List<AlignmentAnnotationPojo> getAlignAnnotation()
+ {
+ return alignAnnotation;
+ }
+
+ public void setAlignAnnotation(
+ List<AlignmentAnnotationPojo> alignAnnotation)
+ {
+ this.alignAnnotation = alignAnnotation;
+ }
+
+ public List<SequenceGrpPojo> getSeqGroups()
+ {
+ return seqGroups;
+ }
+
+ public void setSeqGroups(List<SequenceGrpPojo> seqGroups)
+ {
+ this.seqGroups = seqGroups;
+ }
+
+ public List<SequenceFeaturesPojo> getSeqFeatures()
+ {
+ return seqFeatures;
+ }
+
+ public void setSeqFeatures(List<SequenceFeaturesPojo> seqFeatures)
+ {
+ this.seqFeatures = seqFeatures;
+ }
+
+
+}
--- /dev/null
+package jalview.json.binding.v1;
+
+
+public class AnnotationPojo
+{
+ private String displayCharacter = "";
+
+ private String description;
+
+ private char secondaryStructure;
+
+ private float value;
+
+
+ public String getDisplayCharacter()
+ {
+ return displayCharacter;
+ }
+
+ public void setDisplayCharacter(String displayCharacter)
+ {
+ this.displayCharacter = displayCharacter;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public char getSecondaryStructure()
+ {
+ return secondaryStructure;
+ }
+
+ public void setSecondaryStructure(char secondaryStructure)
+ {
+ this.secondaryStructure = secondaryStructure;
+ }
+
+ public float getValue()
+ {
+ return value;
+ }
+
+ public void setValue(float value)
+ {
+ this.value = value;
+ }
+}
+++ /dev/null
-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;
- }
-
-
-}
import jalview.schemes.TurnColourScheme;
import jalview.schemes.ZappoColourScheme;
-import java.util.ArrayList;
-
-public class BioJsAlignmentPojo
+public class JalviewSettingsPojo
{
private String globalColorScheme = "none";
private String jalviewVersion;
private String webStartUrl;
- private ArrayList<BioJsSeqPojo> seqs = new ArrayList<BioJsSeqPojo>();
- public BioJsAlignmentPojo()
- {
+ private boolean showSeqFeatures;
- }
- public ArrayList<BioJsSeqPojo> getSeqs()
- {
- return seqs;
- }
+ private boolean wrapModeEnabled;
- public void setSeqs(ArrayList<BioJsSeqPojo> seqs)
+ public JalviewSettingsPojo()
{
- this.seqs = seqs;
+
}
+
public String getGlobalColorScheme()
{
return globalColorScheme;
}
+
public void setGlobalColorScheme(String globalColorScheme)
{
for (JalviewBioJsColorSchemeMapper cs : JalviewBioJsColorSchemeMapper
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;
this.webStartUrl = webStartUrl;
}
+ public boolean isShowSeqFeatures()
+ {
+ return showSeqFeatures;
+ }
+
+ public void setShowSeqFeatures(boolean showSeqFeatures)
+ {
+ this.showSeqFeatures = showSeqFeatures;
+ }
+
+ public boolean isWrapModeEnabled()
+ {
+ return wrapModeEnabled;
+ }
+
+ public void setWrapModeEnabled(boolean wrapModeEnabled)
+ {
+ this.wrapModeEnabled = wrapModeEnabled;
+ }
+
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(
+ "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(
"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(
+ 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());
+ "% Identity", "pid", new PIDColourScheme());
private String jalviewName;
+
private String bioJsName;
private ColourSchemeI jvColourScheme;
--- /dev/null
+package jalview.json.binding.v1;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+public class SequenceFeaturesPojo
+{
+
+ private int xstart;
+
+ private int xend;
+
+ private String sequenceRef;
+
+ private String type;
+
+ // private String fillColor;
+
+ private Float score;
+
+ private String description;
+
+ private Hashtable otherDetails;
+
+ private String featureGroup;
+
+ private Vector<String> links;
+
+ public SequenceFeaturesPojo()
+ {
+ }
+
+ public SequenceFeaturesPojo(String sequenceRef)
+ {
+ this.sequenceRef = sequenceRef;
+ }
+
+ // 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;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public Float getScore()
+ {
+ return score;
+ }
+
+ public void setScore(Float score)
+ {
+ this.score = score;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public Hashtable getOtherDetails()
+ {
+ return otherDetails;
+ }
+
+ public void setOtherDetails(Hashtable otherDetails)
+ {
+ this.otherDetails = otherDetails;
+ }
+
+ public Vector<String> getLinks()
+ {
+ return links;
+ }
+
+ public void setLinks(Vector<String> links)
+ {
+ this.links = links;
+ }
+
+ public String getFeatureGroup()
+ {
+ return featureGroup;
+ }
+
+ public void setFeatureGroup(String featureGroup)
+ {
+ this.featureGroup = featureGroup;
+ }
+
+ public String getSequenceRef()
+ {
+ return sequenceRef;
+ }
+
+ public void setSequenceRef(String sequenceRef)
+ {
+ this.sequenceRef = sequenceRef;
+ }
+}
--- /dev/null
+package jalview.json.binding.v1;
+
+import java.util.ArrayList;
+
+public class SequenceGrpPojo
+{
+ private String colourScheme;
+
+ private String groupName;
+
+ private String description;
+
+ private boolean displayBoxes;
+
+ private boolean displayText;
+
+ private boolean colourText;
+
+ private boolean showNonconserved;
+
+ private int startRes;
+
+ private int endRes;
+
+ private ArrayList<String> seqsHash = new ArrayList<String>();
+
+ public String getColourScheme()
+ {
+ return colourScheme;
+ }
+
+ public void setColourScheme(String colourScheme)
+ {
+ this.colourScheme = colourScheme;
+ }
+
+ public String getGroupName()
+ {
+ return groupName;
+ }
+
+ public void setGroupName(String groupName)
+ {
+ this.groupName = groupName;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public boolean isDisplayBoxes()
+ {
+ return displayBoxes;
+ }
+
+ public void setDisplayBoxes(boolean displayBoxes)
+ {
+ this.displayBoxes = displayBoxes;
+ }
+
+ public boolean isDisplayText()
+ {
+ return displayText;
+ }
+
+ public void setDisplayText(boolean displayText)
+ {
+ this.displayText = displayText;
+ }
+
+ public boolean isColourText()
+ {
+ return colourText;
+ }
+
+ public void setColourText(boolean colourText)
+ {
+ this.colourText = colourText;
+ }
+
+ public boolean isShowNonconserved()
+ {
+ return showNonconserved;
+ }
+
+ public void setShowNonconserved(boolean showNonconserved)
+ {
+ this.showNonconserved = showNonconserved;
+ }
+
+ public int getStartRes()
+ {
+ return startRes;
+ }
+
+ public void setStartRes(int startRes)
+ {
+ this.startRes = startRes;
+ }
+
+ public int getEndRes()
+ {
+ return endRes;
+ }
+
+ public void setEndRes(int endRes)
+ {
+ this.endRes = endRes;
+ }
+
+ public ArrayList<String> getSeqsHash()
+ {
+ return seqsHash;
+ }
+
+ public void setSeqsHash(ArrayList<String> seqsHash)
+ {
+ this.seqsHash = seqsHash;
+ }
+}
package jalview.json.binding.v1;
-import java.util.ArrayList;
-public class BioJsSeqPojo
+public class SequencePojo
{
private String seq;
private String id;
+ private int order;
+
private int start;
private int end;
- private ArrayList<BioJsFeaturePojo> features = new ArrayList<BioJsFeaturePojo>();
+ // private ArrayList<SequenceFeaturesPojo> features = new
+ // ArrayList<SequenceFeaturesPojo>();
- public BioJsSeqPojo()
+ public SequencePojo()
{
}
- public BioJsSeqPojo(int start, int end, String id, String name, String seq)
+ public SequencePojo(int start, int end, String id, String name, String seq)
{
this.id = id;
this.name = name;
this.end = end;
}
- public ArrayList<BioJsFeaturePojo> getFeatures()
+ // public ArrayList<SequenceFeaturesPojo> getFeatures()
+ // {
+ // return features;
+ // }
+ //
+ // public void setFeatures(ArrayList<SequenceFeaturesPojo> features)
+ // {
+ // this.features = features;
+ // }
+
+ public int getOrder()
{
- return features;
+ return order;
}
- public void setFeatures(ArrayList<BioJsFeaturePojo> features)
+ public void setOrder(int order)
{
- this.features = features;
+ this.order = order;
}
}