--- /dev/null
+{"seqs":[{"name":"FER_CAPAN/3-34","start":3,"end":34,"id":"FER_CAPAN_1580333149","seq":"SVSATMISTSFMPRKPAVTSL-KPIPNVGE--ALF","order":1},{"name":"FER1_SOLLC/3-34","start":3,"end":34,"id":"FER1_SOLLC_1952300006","seq":"SISGTMISTSFLPRKPAVTSL-KAISNVGE--ALF","order":2},{"name":"Q93XJ9_SOLTU/3-34","start":3,"end":34,"id":"Q93XJ9_SOLTU_1274067508","seq":"SISGTMISTSFLPRKPVVTSL-KAISNVGE--ALF","order":3},{"name":"FER1_PEA/6-37","start":6,"end":37,"id":"FER1_PEA_1823806146","seq":"ALYGTAVSTSFLRTQPMPMSV-TTTKAFSN--GFL","order":4},{"name":"Q7XA98_TRIPR/6-39","start":6,"end":39,"id":"Q7XA98_TRIPR_1024982041","seq":"ALYGTAVSTSFMRRQPVPMSV-ATTTTTKAFPSGF","order":5}],"seqGroups":[{"displayText":true,"startRes":21,"groupName":"JGroup:1883305585","endRes":29,"colourText":false,"seqsHash":["FER1_SOLLC_1952300006","Q93XJ9_SOLTU_1274067508","FER1_PEA_1823806146","Q7XA98_TRIPR_1024982041"],"showNonconserved":false,"colourScheme":"Zappo","displayBoxes":true}],"alignAnnotation":[{"annotations":[{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"}],"description":"New description","label":"Secondary Structure"}],"jalviewSettings":{"globalColorScheme":"foo","jalviewVersion":"Test","webStartUrl":"http://www.jalview.org/services/launchApp","showSeqFeatures":true,"wrapModeEnabled":false},"seqFeatures":[{"fillColor":"#ff0033","score":0,"sequenceRef":"Q93XJ9_SOLTU_1274067508","featureGroup":"Jalview","description":"desciption","xStart":3,"xEnd":13,"type":"feature_x"},{"fillColor":"#ff0033","score":0,"sequenceRef":"FER1_PEA_1823806146","featureGroup":"Jalview","description":"desciption","xStart":3,"xEnd":13,"type":"feature_x"},{"fillColor":"#ff0033","score":0,"sequenceRef":"Q7XA98_TRIPR_1024982041","featureGroup":"Jalview","description":"desciption","xStart":3,"xEnd":13,"type":"feature_x"}]}
\ No newline at end of file
*/
package jalview.api;
-import java.awt.Color;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
import jalview.analysis.Conservation;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceI;
import jalview.schemes.ColourSchemeI;
+import java.awt.Color;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
/**
* @author jimp
*
* Set whether view should scroll to show the highlighted region of a sequence
*/
void setFollowHighlight(boolean b);
+
+ public FeatureRenderer getFeatureRenderer();
+
+ public void setFeatureRenderer(FeatureRenderer featureRenderer);
+
}
*/
package jalview.appletgui;
-import java.awt.Font;
-
import jalview.analysis.NJTree;
import jalview.api.AlignViewportI;
+import jalview.api.FeatureRenderer;
import jalview.bin.JalviewLite;
import jalview.commands.CommandI;
import jalview.datamodel.AlignmentI;
import jalview.structure.VamsasSource;
import jalview.viewmodel.AlignmentViewport;
+import java.awt.Font;
+
public class AlignViewport extends AlignmentViewport implements
SelectionSource, VamsasSource, CommandListener
{
private AnnotationColumnChooser annotationColumnSelectionState;
+ private FeatureRenderer featureRenderer;
+
public void finalize()
{
applet = null;
}
}
+ @Override
+ public FeatureRenderer getFeatureRenderer()
+ {
+ return featureRenderer;
+ }
+
+ @Override
+ public void setFeatureRenderer(FeatureRenderer featureRenderer)
+ {
+ this.featureRenderer = featureRenderer;
+
+ }
+
}
*/
package jalview.gui;
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.Rectangle;
-import java.awt.Toolkit;
-import java.awt.datatransfer.Clipboard;
-import java.awt.datatransfer.DataFlavor;
-import java.awt.datatransfer.StringSelection;
-import java.awt.datatransfer.Transferable;
-import java.awt.dnd.DnDConstants;
-import java.awt.dnd.DropTargetDragEvent;
-import java.awt.dnd.DropTargetDropEvent;
-import java.awt.dnd.DropTargetEvent;
-import java.awt.dnd.DropTargetListener;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.print.PageFormat;
-import java.awt.print.PrinterJob;
-import java.beans.PropertyChangeEvent;
-import java.io.File;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Deque;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Set;
-import java.util.Vector;
-
-import javax.swing.JButton;
-import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JEditorPane;
-import javax.swing.JInternalFrame;
-import javax.swing.JLabel;
-import javax.swing.JLayeredPane;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JProgressBar;
-import javax.swing.JRadioButtonMenuItem;
-import javax.swing.JScrollPane;
-import javax.swing.SwingUtilities;
-
import jalview.analysis.AAFrequency;
import jalview.analysis.AlignmentSorter;
import jalview.analysis.AlignmentUtils;
import jalview.ws.jws2.jabaws2.Jws2Instance;
import jalview.ws.seqfetcher.DbSourceProxy;
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.GridLayout;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.StringSelection;
+import java.awt.datatransfer.Transferable;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DropTargetDragEvent;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.dnd.DropTargetEvent;
+import java.awt.dnd.DropTargetListener;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.print.PageFormat;
+import java.awt.print.PrinterJob;
+import java.beans.PropertyChangeEvent;
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Deque;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JEditorPane;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+import javax.swing.JLayeredPane;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+import javax.swing.JRadioButtonMenuItem;
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
+
/**
* DOCUMENT ME!
*
omitHidden = viewport.getViewAsString(false);
}
}
- FormatAdapter f = new FormatAdapter();
+ FeatureRenderer fr = new FeatureRenderer(this.alignPanel);
+ viewport.setFeatureRenderer(fr);
+ FormatAdapter f = new FormatAdapter(viewport);
String output = f.formatSequences(format,
viewport.getAlignment(), // class cast exceptions will
// occur in the distant future
protected void outputText_actionPerformed(ActionEvent e)
{
String[] omitHidden = null;
-
+ FeatureRenderer fr = new FeatureRenderer(this.alignPanel);
+ viewport.setFeatureRenderer(fr);
if (viewport.hasHiddenColumns())
{
int reply = JOptionPane
try
{
- Desktop.setCurrentAlignFrame(this);
- cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
+ cap.setText(new FormatAdapter(viewport).formatSequences(
+ e.getActionCommand(),
viewport.getAlignment(), omitHidden,
viewport.getColumnSelection()));
Desktop.addInternalFrame(cap, MessageManager.formatMessage(
*/
package jalview.gui;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.Rectangle;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Set;
-import java.util.Vector;
-
-import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
-
import jalview.analysis.AlignmentUtils;
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.analysis.NJTree;
import jalview.api.AlignViewportI;
+import jalview.api.FeatureRenderer;
import jalview.api.ViewStyleI;
import jalview.bin.Cache;
import jalview.commands.CommandI;
import jalview.viewmodel.AlignmentViewport;
import jalview.ws.params.AutoCalcSetting;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Rectangle;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.swing.JInternalFrame;
+import javax.swing.JOptionPane;
+
/**
* DOCUMENT ME!
*
private Rectangle explodedGeometry;
+ private FeatureRenderer featureRenderer;
+
String viewName;
/*
complementPanel.scrollToCentre(sr, seqOffset);
}
}
+
+ @Override
+ public FeatureRenderer getFeatureRenderer()
+ {
+ return featureRenderer;
+ }
+
+ @Override
+ public void setFeatureRenderer(FeatureRenderer featureRenderer)
+ {
+ this.featureRenderer = featureRenderer;
+ }
}
package jalview.gui;
import jalview.datamodel.Alignment;
+import jalview.io.FileParse;
import jalview.io.FormatAdapter;
+import jalview.io.HtmlFile;
import jalview.io.IdentifyFile;
import jalview.io.JSONFile;
import jalview.io.JalviewFileChooser;
AlignViewport viewport;
+ FileParse source = null;
public CutAndPasteTransfer()
{
SwingUtilities.invokeLater(new Runnable()
{
try
{
- al = new FormatAdapter().readFile(getText(), "Paste", format);
+ FormatAdapter fa = new FormatAdapter(viewport);
+ al = fa.readFile(getText(), "Paste", format);
+ source = fa.getAlignFile();
+
} catch (java.io.IOException ex)
{
JOptionPane.showInternalMessageDialog(Desktop.desktop,
af.statusBar.setText(MessageManager
.getString("label.successfully_pasted_alignment_file"));
- af.setShowSeqFeatures(JSONFile.isSeqFeaturesEnabled());
+ if (source instanceof HtmlFile)
+ {
+ ((HtmlFile) source).LoadAlignmentFeatures(af);
+ }
+ else if (source instanceof JSONFile)
+ {
+ ((JSONFile) source).LoadAlignmentFeatures(af);
+ }
- af.changeColour(JSONFile.getColourScheme());
- af.setMenusForViewport();
try
{
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;
{
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();
- }
+ // viewport.setShowSequenceFeatures(JSONFile.isSeqFeaturesEnabled());
+ // AlignFrame af = viewport.getAlignPanel().alignFrame;
+ // if (af != null)
+ // {
+ // af.changeColour(JSONFile.getColourScheme());
+ // af.setMenusForViewport();
+ // }
}
else
{
}
- public static AlignFrame getCurrentAlignFrame()
- {
- return currentAlignFrame;
- }
-
- public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
- {
- Desktop.currentAlignFrame = currentAlignFrame;
- }
+ // public static AlignFrame getCurrentAlignFrame()
+ // {
+ // return currentAlignFrame;
+ // }
+ //
+ // public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
+ // {
+ // Desktop.currentAlignFrame = currentAlignFrame;
+ // }
}
*/
public class AppletFormatAdapter
{
+ private AlignViewportI viewport;
+
+ public static String FILE = "File";
+
+ public static String URL = "URL";
+
+ public static String PASTE = "Paste";
+
+ public static String CLASSLOADER = "ClassLoader";
+
+ /**
+ * add jalview-derived non-secondary structure annotation from PDB structure
+ */
+ boolean annotFromStructure = false;
+
+ /**
+ * add secondary structure from PDB data with built-in algorithms
+ */
+ boolean localSecondaryStruct = false;
+
+ /**
+ * process PDB data with web services
+ */
+ boolean serviceSecondaryStruct = false;
+
+ private AlignFile alignFile = null;
+
+ String inFile;
+
+ /**
+ * character used to write newlines
+ */
+ protected String newline = System.getProperty("line.separator");
+
/**
* List of valid format strings used in the isValidFormat method
*/
public static String SUPPORTED_FORMATS = "Formats currently supported are\n"
+ prettyPrint(READABLE_FORMATS);
+ public AppletFormatAdapter()
+ {
+ }
+
+ public AppletFormatAdapter(AlignViewportI viewport)
+ {
+ this.viewport = viewport;
+ }
+
/**
*
* @param els
return list.toString();
}
- public static String FILE = "File";
-
- public static String URL = "URL";
-
- public static String PASTE = "Paste";
-
- public static String CLASSLOADER = "ClassLoader";
-
- /**
- * add jalview-derived non-secondary structure annotation from PDB structure
- */
- boolean annotFromStructure = false;
-
- /**
- * add secondary structure from PDB data with built-in algorithms
- */
- boolean localSecondaryStruct = false;
-
- /**
- * process PDB data with web services
- */
- boolean serviceSecondaryStruct = false;
-
- AlignFile afile = null;
-
- String inFile;
-
- /**
- * character used to write newlines
- */
- protected String newline = System.getProperty("line.separator");
public void setNewlineString(String nl)
{
Alignment al;
if (format.equals("FASTA"))
{
- afile = new FastaFile(inFile, type);
+ alignFile = new FastaFile(inFile, type);
}
else if (format.equals("MSF"))
{
- afile = new MSFfile(inFile, type);
+ alignFile = new MSFfile(inFile, type);
}
else if (format.equals("PileUp"))
{
- afile = new PileUpfile(inFile, type);
+ alignFile = new PileUpfile(inFile, type);
}
else if (format.equals("CLUSTAL"))
{
- afile = new ClustalFile(inFile, type);
+ alignFile = new ClustalFile(inFile, type);
}
else if (format.equals("BLC"))
{
- afile = new BLCFile(inFile, type);
+ alignFile = new BLCFile(inFile, type);
}
else if (format.equals("PIR"))
{
- afile = new PIRFile(inFile, type);
+ alignFile = new PIRFile(inFile, type);
}
else if (format.equals("PFAM"))
{
- afile = new PfamFile(inFile, type);
+ alignFile = new PfamFile(inFile, type);
}
else if (format.equals("JnetFile"))
{
- afile = new JPredFile(inFile, type);
- ((JPredFile) afile).removeNonSequences();
+ alignFile = new JPredFile(inFile, type);
+ ((JPredFile) alignFile).removeNonSequences();
}
else if (format.equals("PDB"))
{
- afile = new MCview.PDBfile(annotFromStructure,
+ alignFile = new MCview.PDBfile(annotFromStructure,
localSecondaryStruct, serviceSecondaryStruct, inFile, type);
// Uncomment to test Jmol data based PDB processing: JAL-1213
// afile = new jalview.ext.jmol.PDBFileWithJmol(inFile, type);
}
else if (format.equals("STH"))
{
- afile = new StockholmFile(inFile, type);
+ alignFile = new StockholmFile(inFile, type);
}
else if (format.equals("SimpleBLAST"))
{
- afile = new SimpleBlastFile(inFile, type);
+ alignFile = new SimpleBlastFile(inFile, type);
}
else if (format.equals(PhylipFile.FILE_DESC))
{
- afile = new PhylipFile(inFile, type);
+ alignFile = new PhylipFile(inFile, type);
}
else if (format.equals(JSONFile.FILE_DESC))
{
- afile = new JSONFile(inFile, type);
- al = new Alignment(afile.getSeqsAsArray());
- afile.addAnnotations(al);
- for (SequenceGroup sg : afile.getSeqGroups())
+ alignFile = new JSONFile(inFile, type);
+ al = new Alignment(alignFile.getSeqsAsArray());
+ alignFile.addAnnotations(al);
+ ((JSONFile) alignFile).setViewport(viewport);
+ for (SequenceGroup sg : alignFile.getSeqGroups())
{
al.addGroup(sg);
}
}
else if (format.equals(HtmlFile.FILE_DESC))
{
- afile = new HtmlFile(inFile, type);
- al = new Alignment(afile.getSeqsAsArray());
- afile.addAnnotations(al);
- for (SequenceGroup sg : afile.getSeqGroups())
+ alignFile = new HtmlFile(inFile, type);
+ al = new Alignment(alignFile.getSeqsAsArray());
+ alignFile.addAnnotations(al);
+ for (SequenceGroup sg : alignFile.getSeqGroups())
{
al.addGroup(sg);
}
}
else if (format.equals("RNAML"))
{
- afile = new RnamlFile(inFile, type);
+ alignFile = new RnamlFile(inFile, type);
}
- al = new Alignment(afile.getSeqsAsArray());
+ al = new Alignment(alignFile.getSeqsAsArray());
- afile.addAnnotations(al);
+ alignFile.addAnnotations(al);
return al;
} catch (Exception e)
try
{
// Possible sequence is just residues with no label
- afile = new FastaFile(">UNKNOWN\n" + inFile, "Paste");
- Alignment al = new Alignment(afile.getSeqsAsArray());
+ alignFile = new FastaFile(">UNKNOWN\n" + inFile, "Paste");
+ Alignment al = new Alignment(alignFile.getSeqsAsArray());
- afile.addSeqGroups(al);
- afile.addAnnotations(al);
+ alignFile.addSeqGroups(al);
+ alignFile.addAnnotations(al);
return al;
} catch (Exception ex)
Alignment al;
if (format.equals("FASTA"))
{
- afile = new FastaFile(source);
+ alignFile = new FastaFile(source);
}
else if (format.equals("MSF"))
{
- afile = new MSFfile(source);
+ alignFile = new MSFfile(source);
}
else if (format.equals("PileUp"))
{
- afile = new PileUpfile(source);
+ alignFile = new PileUpfile(source);
}
else if (format.equals("CLUSTAL"))
{
- afile = new ClustalFile(source);
+ alignFile = new ClustalFile(source);
}
else if (format.equals("BLC"))
{
- afile = new BLCFile(source);
+ alignFile = new BLCFile(source);
}
else if (format.equals("PIR"))
{
- afile = new PIRFile(source);
+ alignFile = new PIRFile(source);
}
else if (format.equals("PFAM"))
{
- afile = new PfamFile(source);
+ alignFile = new PfamFile(source);
}
else if (format.equals("JnetFile"))
{
- afile = new JPredFile(source);
- ((JPredFile) afile).removeNonSequences();
+ alignFile = new JPredFile(source);
+ ((JPredFile) alignFile).removeNonSequences();
}
else if (format.equals("PDB"))
{
- afile = new MCview.PDBfile(annotFromStructure,
+ alignFile = new MCview.PDBfile(annotFromStructure,
localSecondaryStruct, serviceSecondaryStruct, source);
}
else if (format.equals("STH"))
{
- afile = new StockholmFile(source);
+ alignFile = new StockholmFile(source);
}
else if (format.equals("RNAML"))
{
- afile = new RnamlFile(source);
+ alignFile = new RnamlFile(source);
}
else if (format.equals("SimpleBLAST"))
{
- afile = new SimpleBlastFile(source);
+ alignFile = new SimpleBlastFile(source);
}
else if (format.equals(PhylipFile.FILE_DESC))
{
- afile = new PhylipFile(source);
+ alignFile = new PhylipFile(source);
}
else if (format.equals(JSONFile.FILE_DESC))
{
- afile = new JSONFile(source);
- al = new Alignment(afile.getSeqsAsArray());
- afile.addAnnotations(al);
- afile.addSeqGroups(al);
+ alignFile = new JSONFile(source);
+ // ((JSONFile) afile).setViewport(viewport);
+ al = new Alignment(alignFile.getSeqsAsArray());
+ alignFile.addAnnotations(al);
+ alignFile.addSeqGroups(al);
return al;
}
else if (format.equals(HtmlFile.FILE_DESC))
{
- afile = new HtmlFile(source);
+ alignFile = new HtmlFile(source);
}
- al = new Alignment(afile.getSeqsAsArray());
- afile.addAnnotations(al);
+ al = new Alignment(alignFile.getSeqsAsArray());
+ alignFile.addAnnotations(al);
return al;
} catch (Exception e)
try
{
// Possible sequence is just residues with no label
- afile = new FastaFile(">UNKNOWN\n" + inFile, "Paste");
- Alignment al = new Alignment(afile.getSeqsAsArray());
- afile.addAnnotations(al);
- afile.addSeqGroups(al);
+ alignFile = new FastaFile(">UNKNOWN\n" + inFile, "Paste");
+ Alignment al = new Alignment(alignFile.getSeqsAsArray());
+ alignFile.addAnnotations(al);
+ alignFile.addSeqGroups(al);
return al;
} catch (Exception ex)
else if (format.equalsIgnoreCase(JSONFile.FILE_DESC))
{
afile = new JSONFile();
+ afile.setViewport(viewport);
// Add groups to AlignFile
afile.seqGroups = alignment.getGroups();
}
return null;
}
+
+ public AlignFile getAlignFile()
+ {
+ return alignFile;
+ }
+
+ public void setAlignFile(AlignFile alignFile)
+ {
+ this.alignFile = alignFile;
+ }
}
// open a new source and read from it
FormatAdapter fa = new FormatAdapter();
al = fa.readFile(file, protocol, format);
- source = fa.afile; // keep reference for later if necessary.
+ source = fa.getAlignFile(); // keep reference for later if necessary.
}
} catch (java.io.IOException ex)
{
*/
package jalview.io;
+import jalview.api.AlignViewportI;
import jalview.util.MessageManager;
import java.io.BufferedReader;
public File inFile = null;
+ private AlignViewportI viewport;
+
public int index = 1; // sequence counter for FileParse object created from
// same data source
}
return null;
}
+
+ public AlignViewportI getViewport()
+ {
+ return viewport;
+ }
+
+ public void setViewport(AlignViewportI viewport)
+ {
+ this.viewport = viewport;
+ }
}
*/
public class FormatAdapter extends AppletFormatAdapter
{
+ public FormatAdapter(AlignViewportI viewport)
+ {
+ super(viewport);
+ init();
+ }
public FormatAdapter()
{
super();
+ init();
+ }
+
+ private void init()
+ {
if (jalview.bin.Cache.getDefault("STRUCT_FROM_PDB", true))
{
annotFromStructure = jalview.bin.Cache.getDefault("ADD_TEMPFACT_ANN",
serviceSecondaryStruct = false;
}
}
+
public String formatSequences(String format, SequenceI[] seqs,
String[] omitHiddenColumns)
{
public static final String FILE_DESC = "HTML";
- private ColourSchemeI cs;
+ private ColourSchemeI colourScheme;
+
+ private boolean showSeqFeatures;
public HtmlFile()
{
seqs = jsonFile.seqs;
seqGroups = jsonFile.seqGroups;
annotations = jsonFile.annotations;
+ showSeqFeatures = jsonFile.isShowSeqFeatures();
+ colourScheme = jsonFile.getColourScheme();
} catch (Exception e)
{
e.printStackTrace();
public void LoadAlignmentFeatures(AlignFrame af)
{
- af.setShowSeqFeatures(JSONFile.isSeqFeaturesEnabled());
- af.changeColour(JSONFile.getColourScheme());
+ af.setShowSeqFeatures(isShowSeqFeatures());
+ af.changeColour(getColourScheme());
af.setMenusForViewport();
}
"Print method of HtmlFile not yet supported!");
}
+ public boolean isShowSeqFeatures()
+ {
+ return showSeqFeatures;
+ }
+
+ public void setShowSeqFeatures(boolean showSeqFeatures)
+ {
+ this.showSeqFeatures = showSeqFeatures;
+ }
+
+ public ColourSchemeI getColourScheme()
+ {
+ return colourScheme;
+ }
+
+ public void setColourScheme(ColourSchemeI colourScheme)
+ {
+ this.colourScheme = colourScheme;
+ }
+
}
package jalview.io;
-import jalview.datamodel.Alignment;
-import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignViewport;
import jalview.gui.AlignmentPanel;
import jalview.gui.AnnotationPanel;
-import jalview.gui.Desktop;
import jalview.gui.FeatureRenderer;
import jalview.gui.HTMLOptions;
import jalview.math.AlignmentDimension;
this.av = ap.av;
this.ap = ap;
+ av.setFeatureRenderer(new FeatureRenderer(ap));
this.annotationPanel = ap.getAnnotationPanel();
generateHtmlSvgOutput(file);
}
String titleSvgData = g1.getSVGDocument();
String alignSvgData = g2.getSVGDocument();
- String jsonData = getJSONData();
+ String jsonData = JSONFile.getJSONData(av);
String htmlData = getHtml(titleSvgData, alignSvgData, jsonData);
out.write(htmlData.getBytes());
return Printable.PAGE_EXISTS;
}
- private String getJSONData()
- {
- JSONFile jsonFile = new JSONFile();
- Alignment al = new Alignment(av.getAlignment().getSequencesArray());
- jsonFile.seqGroups = av.getAlignment().getGroups();
- // jsonFile.addAnnotations(al);
- jsonFile.setDisplayedFeatures(av.getFeaturesDisplayed());
- Desktop.setCurrentAlignFrame(av.getAlignPanel().alignFrame);
- for (SequenceI seq : av.getAlignment().getSequences())
- {
- jsonFile.seqs.add(seq);
- }
-
- // Add non auto calculated annotation to AlignFile
- for (AlignmentAnnotation annot : av.getAlignment()
- .getAlignmentAnnotation())
- {
- if (annot != null && !annot.autoCalculated)
- {
- if (annot.label.equals("PDB.CATempFactor"))
- {
- continue;
- }
- jsonFile.annotations.add(annot);
- }
- }
-
- // jsonFile.setGlobalColorScheme(av.getGlobalColourScheme());
- String jsonString = jsonFile.print();
- System.out.println(">>>>>>>>>>> JSONFile : " + jsonString);
- return jsonString;
- }
-
private String getHtml(String titleSvg, String alignmentSvg,
String jsonData)
{
package jalview.io;
+import jalview.api.AlignViewportI;
+import jalview.api.FeatureRenderer;
import jalview.api.FeaturesDisplayedI;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
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.SequencePojo;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemeProperty;
-import jalview.viewmodel.AlignmentViewport;
+import java.awt.Color;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Hashtable;
public class JSONFile extends AlignFile
{
- private static ColourSchemeI colourScheme;
+ private ColourSchemeI colourScheme;
- private static boolean seqFeaturesEnabled;
+ // private static boolean seqFeaturesEnabled;
private String jalviewVersion;
- private String webStartLaunchServletUrl = "http://www.jalview.org/services/launchApp";
+ private String webStartLaunchServletUrl;
public static final String FILE_EXT = "json";
private FeaturesDisplayedI displayedFeatures;
- private AlignmentViewport av;
+ // private AlignViewportI viewport;
+
+ private FeatureRenderer fr;
private JSONExportSettings jsonExportSettings;
}
AlignmentPojo jsonAlignmentPojo = new AlignmentPojo();
- if (Desktop.getCurrentAlignFrame() != null)
+ if (getViewport() != null)
{
- globalColorScheme = ColourSchemeProperty.getColourName(Desktop
- .getCurrentAlignFrame().getViewport()
+ globalColorScheme = ColourSchemeProperty
+ .getColourName(getViewport()
.getGlobalColourScheme());
- this.av = Desktop.getCurrentAlignFrame().getCurrentView();
- setDisplayedFeatures(av.getFeaturesDisplayed());
- showSeqFeatures = Desktop.getCurrentAlignFrame().showSeqFeatures
- .isSelected();
+ setDisplayedFeatures(getViewport().getFeaturesDisplayed());
+ showSeqFeatures = getViewport().isShowSequenceFeatures();
+ fr = getViewport().getFeatureRenderer();
+ // setSeqFeaturesEnabled(viewport.isShowSequenceFeatures());
}
int count = 0;
if (jsonExportSettings.isExportJalviewSettings())
{
+ jalviewVersion = jalview.bin.Cache.getProperty("VERSION");
+ webStartLaunchServletUrl = jalview.bin.Cache.getDefault(
+ "www.jalview.org", "http://www.jalview.org")
+ + "/services/launchApp";
+
JalviewSettingsPojo jvSettings = new JalviewSettingsPojo();
jvSettings.setGlobalColorScheme(globalColorScheme);
jvSettings.setJalviewVersion(jalviewVersion);
if (jsonExportSettings.isExportSequenceFeatures())
{
- jsonAlignmentPojo.setSeqFeatures(sequenceFeatureToJsonPojo(seqs,
- getDisplayedFeatures()));
+ jsonAlignmentPojo
+ .setSeqFeatures(sequenceFeatureToJsonPojo(seqs, fr));
}
if (jsonExportSettings.isExportGroups() && seqGroups != null
}
public static List<SequenceFeaturesPojo> sequenceFeatureToJsonPojo(
- List<SequenceI> seqs, FeaturesDisplayedI displayedFeatures)
+ List<SequenceI> seqs, FeatureRenderer fr)
{
+ FeaturesDisplayedI displayedFeatures = (fr == null) ? null : fr
+ .getFeaturesDisplayed();
List<SequenceFeaturesPojo> sequenceFeaturesPojo = new ArrayList<SequenceFeaturesPojo>();
for (SequenceI seq : seqs)
{
{
SequenceFeaturesPojo jsonFeature = new SequenceFeaturesPojo(
seq.getName() + "_" + seq.hashCode());
+ String featureColour = (fr == null) ? null : jalview.util.Format
+ .getHexString(fr
+ .findFeatureColour(Color.white, seq,
+ seq.findIndex(sf.getBegin())));
jsonFeature.setXstart(seq.findIndex(sf.getBegin()) - 1);
jsonFeature.setXend(seq.findIndex(sf.getEnd()));
jsonFeature.setType(sf.getType());
jsonFeature.setLinks(sf.links);
jsonFeature.setOtherDetails(sf.otherDetails);
jsonFeature.setScore(sf.getScore());
+ jsonFeature.setFillColor(featureColour);
jsonFeature.setFeatureGroup(sf.getFeatureGroup());
sequenceFeaturesPojo.add(jsonFeature);
}
Boolean showFeatures = Boolean.valueOf(jvSettingsJsonObj.get(
"showSeqFeatures").toString());
setColourScheme(getJalviewColorScheme(jsColourScheme));
- JSONFile.setSeqFeaturesEnabled(showFeatures);
+ // JSONFile.setSeqFeaturesEnabled(showFeatures);
+ setShowSeqFeatures(showFeatures);
}
seqMap = new Hashtable<String, Sequence>();
}
}
- public ColourSchemeI getJalviewColorScheme(String bioJsColourSchemeName)
+ public static ColourSchemeI getJalviewColorScheme(
+ String bioJsColourSchemeName)
{
ColourSchemeI jalviewColor = null;
for (JalviewBioJsColorSchemeMapper cs : JalviewBioJsColorSchemeMapper
public void LoadAlignmentFeatures(AlignFrame af)
{
- af.setShowSeqFeatures(JSONFile.isSeqFeaturesEnabled());
+ af.setShowSeqFeatures(isShowSeqFeatures());
af.changeColour(getColourScheme());
af.setMenusForViewport();
}
this.globalColorScheme = globalColorScheme;
}
- public static ColourSchemeI getColourScheme()
+ public 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)
+ public void setColourScheme(ColourSchemeI colourScheme)
{
- JSONFile.seqFeaturesEnabled = seqFeaturesEnabled;
+ this.colourScheme = colourScheme;
}
public FeaturesDisplayedI getDisplayedFeatures()
this.jsonExportSettings = jsonExportSettings;
}
+ public static String getJSONData(AlignViewportI av)
+ {
+ JSONFile jsonFile = new JSONFile();
+ jsonFile.setViewport(av);
+ jsonFile.seqGroups = av.getAlignment().getGroups();
+ jsonFile.setDisplayedFeatures(av.getFeaturesDisplayed());
+
+ for (SequenceI seq : av.getAlignment().getSequences())
+ {
+ jsonFile.seqs.add(seq);
+ }
+
+ // Add non auto calculated annotation to AlignFile
+ for (AlignmentAnnotation annot : av.getAlignment()
+ .getAlignmentAnnotation())
+ {
+ if (annot != null && !annot.autoCalculated)
+ {
+ if (annot.label.equals("PDB.CATempFactor"))
+ {
+ continue;
+ }
+ jsonFile.annotations.add(annot);
+ }
+ }
+ String jsonString = jsonFile.print();
+ return jsonString;
+ }
+
+ public boolean isShowSeqFeatures()
+ {
+ return showSeqFeatures;
+ }
+
+ public void setShowSeqFeatures(boolean showSeqFeatures)
+ {
+ this.showSeqFeatures = showSeqFeatures;
+ }
+
public class JSONExportSettings
{
private boolean exportSequence;
private Hashtable otherDetails;
+ private String fillColor;
+
private String featureGroup;
private Vector<String> links;
this.sequenceRef = sequenceRef;
}
- // public String getFillColor()
- // {
- // return "#" + fillColor;
- // }
- //
- // public void setFillColor(String fillColor)
- // {
- // this.fillColor = fillColor;
- // }
+ public String getFillColor()
+ {
+ return "#" + fillColor;
+ }
+
+ public void setFillColor(String fillColor)
+ {
+ this.fillColor = fillColor;
+ }
public int getXstart()
{
package jalview.io;
-import jalview.datamodel.Alignment;
-import jalview.datamodel.Sequence;
+import org.junit.Ignore;
+import org.junit.Test;
-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.json.simple.parser.ParseException;
-import org.junit.Assert;
-
-import com.json.JSONException;
public class BioJsHTMLOutputTest
{
- // @Test
+ @Test
+ @Ignore
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
- {
-
- JSONParser jsonParser = new JSONParser();
- String actualJsonString = bioJsHtmlOuput
- .getJalviewAlignmentAsJsonString(al);
-
- JSONObject actualJsonObj = (JSONObject) jsonParser.parse(actualJsonString);
-
- // System.out.println("Output : " + actualJsonString);
- Assert.assertTrue(actualJsonObj.get("globalColorScheme") != null);
- Assert.assertTrue((actualJsonObj.get("globalColorScheme").toString()).equals("zappo"));
-
- Assert.assertTrue(actualJsonObj.get("webStartUrl") != null);
- Assert.assertTrue((actualJsonObj.get("webStartUrl").toString())
- .equals("http://www.jalview.org/services/launchApp"));
-
- JSONArray actualSeqJsonObj = (JSONArray) actualJsonObj.get("seqs");
- Assert.assertTrue(actualSeqJsonObj != null);
- Assert.assertTrue(actualSeqJsonObj.size() == 1);
-
- @SuppressWarnings("unchecked")
- Iterator<JSONObject> jsonIter = actualSeqJsonObj.iterator();
- JSONObject jsonSeq = jsonIter.next();
- Assert.assertTrue(jsonSeq != null);
-
- Assert.assertTrue("'name' cannot be null!",
- jsonSeq.get("name") != null);
- Assert.assertTrue("Expected name mismatched!",
- (jsonSeq.get("name").toString())
- .equals("name/1-26"));
-
- Assert.assertTrue("'seq' cannot be null!", jsonSeq.get("seq") != null);
- Assert.assertTrue("Expected sequence mismatched!", (jsonSeq
- .get("seq").toString())
- .equals("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
-
- Assert.assertTrue("'id' cannot be null!", jsonSeq.get("id") != null);
- Assert.assertTrue("Expected id mismatched!",
- (jsonSeq.get("id").toString()).equals("1"));
-
- Assert.assertTrue("'start' cannot be null!",
- jsonSeq.get("start") != null);
- Assert.assertTrue("Expected start mismatched!",
- (jsonSeq.get("start").toString()).equals("1"));
-
- Assert.assertTrue("'end' cannot be null!", jsonSeq.get("end") != null);
- Assert.assertTrue("Expected end mismatched!",
- (jsonSeq.get("end").toString()).equals("26"));
-
- Assert.assertTrue("'features' cannot be null!",
- jsonSeq.get("features") != null);
- Assert.assertTrue("Expected features mismatched!",
- jsonSeq.get("features").toString().equals("[]"));
- } catch (IOException e)
- {
- e.printStackTrace();
- } catch (JSONException e)
- {
- e.printStackTrace();
- } catch (ParseException e)
- {
- e.printStackTrace();
- }
}
}
package jalview.io;
+
+import static org.junit.Assert.assertNotNull;
+import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
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.AlignmentPanel;
import jalview.schemes.ColourSchemeI;
import jalview.viewmodel.seqfeatures.FeaturesDisplayed;
+import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import org.junit.After;
import org.junit.Assert;
public class JSONFileTest
{
- private JSONFile jsonFile;
private int TEST_SEQ_HEIGHT = 0;
private int TEST_ANOT_HEIGHT = 0;
+ private AlignFrame af;
+
+ AlignmentI alignment;
+
+ AlignmentPanel alignPanel;
+
+ HashMap<String, SequenceI> testSeqs = new HashMap<String, SequenceI>();
+ HashMap<String, AlignmentAnnotation> testAnnots = new HashMap<String, AlignmentAnnotation>();
+ HashMap<String, SequenceGroup> testGrps = new HashMap<String, SequenceGroup>();
+
@Before
- public void setUp() throws Exception
+ public void setup() throws Exception
{
- jsonFile = new JSONFile();
-
// create and add sequences
Sequence[] seqs = new Sequence[5];
seqs[0] = new Sequence("FER_CAPAN",
// create and add sequence features
SequenceFeature seqFeature2 = new SequenceFeature("feature_x",
- "desciption", "status", 22, 29, "jalview");
+ "desciption", "status", 6, 15, "Jalview");
SequenceFeature seqFeature3 = new SequenceFeature("feature_x",
- "desciption", "status", 25, 32, "jalview");
+ "desciption", "status", 9, 18, "Jalview");
SequenceFeature seqFeature4 = new SequenceFeature("feature_x",
- "desciption", "status", 25, 32, "jalview");
+ "desciption", "status", 9, 18, "Jalview");
seqs[2].addSequenceFeature(seqFeature2);
seqs[3].addSequenceFeature(seqFeature3);
seqs[4].addSequenceFeature(seqFeature4);
// add created features to features displayed
FeaturesDisplayed fDis = new FeaturesDisplayed();
fDis.setVisible("feature_x");
- jsonFile.setDisplayedFeatures(fDis);
- JSONFile.setSeqFeaturesEnabled(true);
+ // jsonFile.setDisplayedFeatures(fDis);
+ // jsonFile.setShowSeqFeatures(true);
for (Sequence seq : seqs)
{
seq.setDatasetSequence(seq);
- jsonFile.seqs.add(seq);
+ testSeqs.put(seq.getName(), seq);
+ // jsonFile.seqs.add(seq);
}
// create and add sequence groups
ArrayList<SequenceI> grpSeqs = new ArrayList<SequenceI>();
- grpSeqs.add(seqs[0]);
grpSeqs.add(seqs[1]);
grpSeqs.add(seqs[2]);
- ColourSchemeI scheme = jsonFile.getJalviewColorScheme("zappo");
- SequenceGroup seqGrp = new SequenceGroup(grpSeqs, "JGroup:1114606272",
- scheme, true, true, false, 2, 9);
+ grpSeqs.add(seqs[3]);
+ grpSeqs.add(seqs[4]);
+ ColourSchemeI scheme = JSONFile.getJalviewColorScheme("zappo");
+ SequenceGroup seqGrp = new SequenceGroup(grpSeqs, "JGroup:1883305585",
+ scheme, true, true, false, 21, 29);
seqGrp.setShowNonconserved(false);
seqGrp.setDescription(null);
- jsonFile.seqGroups.add(seqGrp);
+ // jsonFile.seqGroups.add(seqGrp);
+ testGrps.put(seqGrp.getName(), seqGrp);
// create and add annotation
Annotation[] annot = new Annotation[35];
annot[2] = new Annotation("α", "", 'H', 0);
annot[3] = new Annotation("α", "", 'H', 0);
annot[4] = new Annotation("α", "", 'H', 0);
- annot[5] = new Annotation("α", "", 'H', 0);
+ annot[5] = new Annotation("", "", '\u0000', 0);
annot[6] = new Annotation("", "", '\u0000', 0);
annot[7] = new Annotation("", "", '\u0000', 0);
- annot[8] = new Annotation("", "", '\u0000', 0);
- annot[9] = new Annotation("", "", '\u0000', 0);
+ annot[8] = new Annotation("β", "", 'E', 0);
+ annot[9] = new Annotation("β", "", 'E', 0);
annot[10] = new Annotation("β", "", 'E', 0);
annot[11] = new Annotation("β", "", 'E', 0);
- annot[12] = new Annotation("", "", '\u0000', 0);
- annot[13] = new Annotation("", "", '\u0000', 0);
- annot[14] = new Annotation("", "", '\u0000', 0);
- annot[15] = new Annotation("", "", '\u0000', 0);
- annot[16] = new Annotation("α", "", 'H', 0);
- annot[17] = new Annotation("α", "", 'H', 0);
- annot[18] = new Annotation("α", "", 'H', 0);
- annot[19] = new Annotation("α", "", 'H', 0);
- annot[20] = new Annotation("α", "", 'H', 0);
-
+ annot[12] = new Annotation("β", "", 'E', 0);
+ annot[13] = new Annotation("β", "", 'E', 0);
+ annot[14] = new Annotation("β", "", 'E', 0);
+ annot[15] = new Annotation("β", "", 'E', 0);
+ annot[16] = new Annotation("", "", '\u0000', 0);
+ annot[17] = new Annotation("", "", '\u0000', 0);
+ annot[18] = new Annotation("", "", '\u0000', 0);
+ annot[19] = new Annotation("", "", '\u0000', 0);
+ annot[20] = new Annotation("", "", '\u0000', 0);
annot[21] = new Annotation("", "", '\u0000', 0);
annot[22] = new Annotation("", "", '\u0000', 0);
annot[23] = new Annotation("", "", '\u0000', 0);
annot[24] = new Annotation("", "", '\u0000', 0);
annot[25] = new Annotation("", "", '\u0000', 0);
- annot[26] = new Annotation("", "", '\u0000', 0);
- annot[27] = new Annotation("", "", '\u0000', 0);
- annot[28] = new Annotation("", "", '\u0000', 0);
- annot[29] = new Annotation("", "", '\u0000', 0);
- annot[30] = new Annotation("", "", '\u0000', 0);
+ annot[26] = new Annotation("α", "", 'H', 0);
+ annot[27] = new Annotation("α", "", 'H', 0);
+ annot[28] = new Annotation("α", "", 'H', 0);
+ annot[29] = new Annotation("α", "", 'H', 0);
+ annot[30] = new Annotation("α", "", 'H', 0);
annot[31] = new Annotation("", "", '\u0000', 0);
- annot[32] = new Annotation("β", "", 'E', 0);
- annot[33] = new Annotation("β", "", 'E', 0);
- annot[34] = new Annotation("β", "", 'E', 0);
+ annot[32] = new Annotation("", "", '\u0000', 0);
+ annot[33] = new Annotation("", "", '\u0000', 0);
+ annot[34] = new Annotation("", "", '\u0000', 0);
AlignmentAnnotation alignAnnot = new AlignmentAnnotation(
"Secondary Structure", "New description", annot);
- jsonFile.annotations.add(alignAnnot);
+ // jsonFile.annotations.add(alignAnnot);
+ testAnnots.put(alignAnnot.label, alignAnnot);
// Alignment al = new Alignment(seqs);
- TEST_SEQ_HEIGHT = jsonFile.seqs.size();
- TEST_GRP_HEIGHT = jsonFile.seqGroups.size();
- TEST_ANOT_HEIGHT = jsonFile.annotations.size();
+ TEST_SEQ_HEIGHT = testSeqs.size();
+ TEST_GRP_HEIGHT = testGrps.size();
+ TEST_ANOT_HEIGHT = testAnnots.size();
}
@After
}
@Test
- public void test()
+ public void testParse()
{
- String jsonOuput = jsonFile.print();
- // System.out.println(">>>>>>>>>>>>>> " + jsonOuput);
- JSONFile output = new JSONFile().parse(jsonOuput);
+ String jsonFile = "examples/example.json";
+ AppletFormatAdapter rf = new AppletFormatAdapter();
+ Alignment al = null;
+ try
+ {
+ al = rf.readFile(jsonFile, AppletFormatAdapter.FILE,
+ JSONFile.FILE_DESC);
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ assertNotNull("Couldn't read supplied alignment data.", al);
- int matchedCounter = 0;
- for (SequenceI in : jsonFile.getSeqs())
+ int passedCount = 0;
+ for (SequenceI seq : al.getSequences())
{
- for (SequenceI out : output.getSeqs())
- {
- if (in.getName().equals(out.getName())
- && in.getSequenceAsString().equals(
- out.getSequenceAsString())
- && in.getStart() == out.getStart()
- && in.getEnd() == out.getEnd() && featuresMatched(in, out))
- {
- // System.out.println(">>>> Seq Match Detected");
- ++matchedCounter;
- }
- }
+ SequenceI expectedSeq = testSeqs.get(seq.getName());
+ Assert.assertTrue("Failed Sequence Test for >>> " + seq.getName(),
+ isSeqMatched(expectedSeq, seq));
+ passedCount++;
}
- Assert.assertTrue(matchedCounter == TEST_SEQ_HEIGHT);
+ Assert.assertEquals("Some Sequences did not pass the test",
+ TEST_SEQ_HEIGHT, passedCount);
- matchedCounter = 0;
- for (SequenceGroup in : jsonFile.getSeqGroups())
+ passedCount = 0;
+ for (SequenceGroup seqGrp : al.getGroups())
{
- for (SequenceGroup out : output.getSeqGroups())
- {
- if (in.getName().equals(out.getName())
- && in.getColourText() == out.getColourText()
- && in.getDisplayBoxes() == out.getDisplayBoxes()
- && in.getIgnoreGapsConsensus() == out
- .getIgnoreGapsConsensus() && in.cs.equals(out.cs)
- && in.getSequences().size() == out.getSequences().size())
- {
- // System.out.println(">>>> Grp Match Detected");
- ++matchedCounter;
- }
- }
+ SequenceGroup expectedGrp = testGrps.get(seqGrp.getName());
+ Assert.assertTrue(
+ "Failed SequenceGroup Test for >>> " + seqGrp.getName(),
+ isGroupMatched(expectedGrp, seqGrp));
+ passedCount++;
}
- Assert.assertTrue(matchedCounter == TEST_GRP_HEIGHT);
+ Assert.assertEquals("Some SequenceGroups did not pass the test",
+ TEST_GRP_HEIGHT, passedCount);
- matchedCounter = 0;
- for (AlignmentAnnotation in : jsonFile.annotations)
+ passedCount = 0;
+ for (AlignmentAnnotation annot : al.getAlignmentAnnotation())
{
- for (AlignmentAnnotation out : output.annotations)
+ AlignmentAnnotation expectedAnnot = testAnnots.get(annot.label);
+ Assert.assertTrue("Failed AlignmentAnnotation Test for >>> "
+ + annot.label, isAnnotationMatched(expectedAnnot, annot));
+ passedCount++;
+ }
+ Assert.assertEquals("Some Sequences did not pass the test",
+ TEST_ANOT_HEIGHT, passedCount);
+
+ // af = new AlignFrame(al, 700, 500);
+ // AlignViewport viewport = af.getViewport();
+ // alignPanel = new AlignmentPanel(af, viewport);
+ }
+
+ public boolean isAnnotationMatched(AlignmentAnnotation eAnnot,
+ AlignmentAnnotation annot)
+ {
+ if (!eAnnot.label.equals(annot.label)
+ || !eAnnot.description.equals(annot.description)
+ || eAnnot.annotations.length != annot.annotations.length)
+ {
+ return false;
+ }
+
+ for (int x = 0; x < annot.annotations.length; x++)
+ {
+ Annotation y = annot.annotations[x];
+ Annotation z = annot.annotations[x];
+
+ if (!y.displayCharacter.equals(z.displayCharacter)
+ || y.value != z.value
+ || y.secondaryStructure != z.secondaryStructure)
{
- try
- {
- // System.out.println("label >>>>> " + in.label + " | " + out.label);
- // System.out.println("label >>>>> " + in.description + " | "
- // + out.description);
- // System.out.println("label >>>>> " + in.annotations.length + " | "
- // + out.annotations.length);
- if (in.label.equals(out.label)
- && in.description.equals(out.description)
- && in.annotations.length == out.annotations.length)
- {
- ++matchedCounter;
- }
- } catch (Exception e)
- {
- e.printStackTrace();
- }
+ return false;
}
}
- // System.out.println("matched >>>>> " + matchedCounter + " | "
- // + TEST_ANOT_HEIGHT);
- Assert.assertTrue(matchedCounter == TEST_ANOT_HEIGHT);
+ return true;
+ }
+
+ public boolean isSeqMatched(SequenceI expectedSeq, SequenceI actualSeq)
+ {
+ System.out.println("Testing >>> " + actualSeq.getName());
+
+ if (expectedSeq.getName().equals(actualSeq.getName())
+ && expectedSeq.getSequenceAsString().equals(
+ actualSeq.getSequenceAsString())
+ && expectedSeq.getStart() == actualSeq.getStart()
+ && expectedSeq.getEnd() == actualSeq.getEnd()
+ && featuresMatched(expectedSeq, actualSeq))
+ {
+ return true;
+ }
+ return false;
+ }
+ public boolean isGroupMatched(SequenceGroup expectedGrp,
+ SequenceGroup actualGrp)
+ {
+
+ System.out.println("Testing >>> " + actualGrp.getName());
+ System.out.println(expectedGrp.getName() + " | " + actualGrp.getName());
+ System.out.println(expectedGrp.getColourText() + " | "
+ + actualGrp.getColourText());
+ System.out.println(expectedGrp.getDisplayBoxes() + " | "
+ + actualGrp.getDisplayBoxes());
+ System.out.println(expectedGrp.getIgnoreGapsConsensus() + " | "
+ + actualGrp.getIgnoreGapsConsensus());
+ System.out.println(expectedGrp.getSequences().size() + " | "
+ + actualGrp.getSequences().size());
+ System.out.println(expectedGrp.getStartRes() + " | "
+ + actualGrp.getStartRes());
+ System.out.println(expectedGrp.getEndRes() + " | "
+ + actualGrp.getEndRes());
+
+ if (expectedGrp.getName().equals(actualGrp.getName())
+ && expectedGrp.getColourText() == actualGrp.getColourText()
+ && expectedGrp.getDisplayBoxes() == actualGrp.getDisplayBoxes()
+ && expectedGrp.getIgnoreGapsConsensus() == actualGrp
+ .getIgnoreGapsConsensus()
+ && expectedGrp.cs.equals(actualGrp.cs)
+ && expectedGrp.getSequences().size() == actualGrp
+ .getSequences().size()
+ && expectedGrp.getStartRes() == actualGrp.getStartRes()
+ && expectedGrp.getEndRes() == actualGrp.getEndRes())
+ {
+ return true;
+ }
+ return false;
}
private boolean featuresMatched(SequenceI seq1, SequenceI seq2)
int testSize = inFeature.length;
int matchedCount = 0;
- // System.out.println(">>>>>>>>>>>>> 1");
for (SequenceFeature in : inFeature)
{
- for (SequenceFeature out : inFeature)
+ for (SequenceFeature out : outFeature)
{
+ System.out.println(out.getType() + " | " + in.getType());
+ System.out.println(out.getBegin() + " | " + in.getBegin());
+ System.out.println(out.getEnd() + " | " + in.getEnd());
+
if (inFeature.length == outFeature.length
&& in.getBegin() == out.getBegin()
&& in.getEnd() == out.getEnd()
&& in.getScore() == out.getScore()
- && in.getFeatureGroup().equals(out.getFeatureGroup()))
+ && in.getFeatureGroup().equals(out.getFeatureGroup())
+ && in.getType().equals(out.getType()))
{
++matchedCount;
}
}
}
+ System.out.println("matched count >>>>>> " + matchedCount);
if (testSize == matchedCount)
{
matched = true;