-{"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
+{"seqs":[{"name":"FER_CAPAN/3-34","start":3,"svid":"1.0","end":34,"id":"1665704504","seq":"SVSATMISTSFMPRKPAVTSL-KPIPNVGE--ALF","order":1},{"name":"FER1_SOLLC/3-34","start":3,"svid":"1.0","end":34,"id":"1003594867","seq":"SISGTMISTSFLPRKPAVTSL-KAISNVGE--ALF","order":2},{"name":"Q93XJ9_SOLTU/3-34","start":3,"svid":"1.0","end":34,"id":"1332961135","seq":"SISGTMISTSFLPRKPVVTSL-KAISNVGE--ALF","order":3},{"name":"FER1_PEA/6-37","start":6,"svid":"1.0","end":37,"id":"1335040546","seq":"ALYGTAVSTSFLRTQPMPMSV-TTTKAFSN--GFL","order":4},{"name":"Q7XA98_TRIPR/6-39","start":6,"svid":"1.0","end":39,"id":"1777084554","seq":"ALYGTAVSTSFMRRQPVPMSV-ATTTTTKAFPSGF","order":5},{"name":"FER_TOCH/3-34","start":3,"svid":"1.0","end":34,"id":"823528539","seq":"FILGTMISKSFLFRKPAVTSL-KAISNVGE--ALF","order":6}],"appSettings":{"globalColorScheme":"zappo","webStartUrl":"www.jalview.org/services/launchApp","application":"Jalview","hiddenSeqs":"823528539","showSeqFeatures":"true","version":"2.9","hiddenCols":"32-33;34-34"},"seqGroups":[{"displayText":true,"startRes":21,"groupName":"JGroup:1883305585","endRes":29,"colourText":false,"seqsHash":["1003594867","1332961135","1335040546","1777084554"],"svid":"1.0","showNonconserved":false,"colourScheme":"Zappo","displayBoxes":true}],"alignAnnotation":[{"svid":"1.0","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"}],"svid":"1.0","seqFeatures":[{"fillColor":"#7d1633","score":0,"sequenceRef":"1332961135","featureGroup":"Jalview","svid":"1.0","description":"desciption","xStart":3,"xEnd":13,"type":"feature_x"},{"fillColor":"#7d1633","score":0,"sequenceRef":"1335040546","featureGroup":"Jalview","svid":"1.0","description":"desciption","xStart":3,"xEnd":13,"type":"feature_x"},{"fillColor":"#7d1633","score":0,"sequenceRef":"1777084554","featureGroup":"Jalview","svid":"1.0","description":"desciption","xStart":3,"xEnd":13,"type":"feature_x"}]}
\ No newline at end of file
*/
public SequenceI[] getHiddenSequences();
+ /**
+ * Retrieves displayed features from a complex file parser
+ *
+ * @return
+ */
+ public FeaturesDisplayedI getDisplayedFeatures();
}
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.api.ComplexAlignFile;
+import jalview.api.FeaturesDisplayedI;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.SequenceI;
boolean showSeqFeatures = ((ComplexAlignFile) source)
.isShowSeqFeatures();
ColourSchemeI cs = ((ComplexAlignFile) source).getColourScheme();
+ FeaturesDisplayedI fd = ((ComplexAlignFile) source)
+ .getDisplayedFeatures();
af = new AlignFrame(al, hiddenSeqs, colSel,
AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
-
af.getViewport().setShowSequenceFeatures(showSeqFeatures);
+ af.getViewport().setFeaturesDisplayed(fd);
af.changeColour(cs);
}
else
public void inputTextboxMenuItem_actionPerformed(AlignViewport viewport)
{
CutAndPasteTransfer cap = new CutAndPasteTransfer();
- cap.setForInput(viewport.getAlignPanel());
+// cap.setForInput(viewport.getAlignPanel());
+ cap.setForInput(null);
Desktop.addInternalFrame(cap,
MessageManager.getString("label.cut_paste_alignmen_file"),
true, 600, 500);
// or we simply trust the user wants
// wysiwig behaviour
- cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
+ cap.setText(new FormatAdapter(ap).formatSequences(e.getActionCommand(),
ap, true));
}
aselview.addAnnotation(aa);
}
}
-
+ viewpanel = ap;
return formatSequences(format, aselview, jvsuffix);
}
afile.setNewlineString(newline);
afile.addJVSuffix(jvsuffix);
-
afile.setExportSettings(exportSettings);
-
afile.configureForView(viewpanel);
// check whether we were given a specific alignment to export, rather than
package jalview.io;
import jalview.api.ComplexAlignFile;
+import jalview.api.FeaturesDisplayedI;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.PDBEntry;
.isShowSeqFeatures();
ColourSchemeI cs = ((ComplexAlignFile) source)
.getColourScheme();
+ FeaturesDisplayedI fd = ((ComplexAlignFile) source)
+ .getDisplayedFeatures();
alignFrame = new AlignFrame(al, hiddenSeqs, colSel,
AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
alignFrame.getViewport().setShowSequenceFeatures(
showSeqFeatures);
+ alignFrame.getViewport().setFeaturesDisplayed(fd);
alignFrame.changeColour(cs);
}
else
package jalview.io;
+import jalview.api.ComplexAlignFile;
+import jalview.api.FeaturesDisplayedI;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SequenceI;
+import jalview.schemes.ColourSchemeI;
+
import java.io.IOException;
import java.io.StringReader;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
-import jalview.api.ComplexAlignFile;
-import jalview.datamodel.ColumnSelection;
-import jalview.datamodel.SequenceI;
-import jalview.schemes.ColourSchemeI;
-
public class HtmlFile extends AlignFile implements ComplexAlignFile
{
public static final String FILE_EXT = "html";
private SequenceI[] hiddenSequences;
+ private FeaturesDisplayedI displayedFeatures;
+
public HtmlFile()
{
super();
this.colourScheme = jsonFile.getColourScheme();
this.hiddenSequences = jsonFile.getHiddenSequences();
this.columnSelection = jsonFile.getColumnSelection();
+ this.displayedFeatures = jsonFile.getDisplayedFeatures();
} catch (Exception e)
{
errormessage = "Failed to extract data from HTML document.";
this.hiddenSequences = hiddenSequences;
}
+ @Override
+ public FeaturesDisplayedI getDisplayedFeatures()
+ {
+ return displayedFeatures;
+ }
+
}
package jalview.io;
+import jalview.api.AlignExportSettingI;
+import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.api.ComplexAlignFile;
import jalview.api.FeatureRenderer;
import jalview.api.FeaturesDisplayedI;
import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.HiddenSequences;
import jalview.json.binding.v1.SequencePojo;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemeProperty;
+import jalview.viewmodel.seqfeatures.FeaturesDisplayed;
import java.awt.Color;
import java.io.IOException;
private ArrayList<SequenceI> hiddenSequences;
+
public JSONFile()
{
super();
try
{
AlignmentPojo jsonAlignmentPojo = new AlignmentPojo();
+ AlignExportSettingI exportSettings = getExportSettings();
+
+ // if no export settings were supplied use the following with all values
+ // defaulting to true
+ if (exportSettings == null)
+ {
+ exportSettings = new AlignExportSettingI()
+ {
+ @Override
+ public boolean isExportHiddenSequences()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isExportHiddenColumns()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isExportGroups()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isExportFeatures()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isExportAnnotations()
+ {
+ return true;
+ }
+ };
+ }
int count = 0;
for (SequenceI seq : seqs)
if (hiddenSections != null)
{
if (hiddenSections[0] != null
- && getExportSettings()
+ && exportSettings
.isExportHiddenColumns())
{
jsonAlignmentPojo.getAppSettings().put("hiddenCols",
String.valueOf(hiddenSections[0]));
}
if (hiddenSections[1] != null
- && getExportSettings()
+ && exportSettings
.isExportHiddenSequences())
{
jsonAlignmentPojo.getAppSettings().put("hiddenSeqs",
}
}
- if (getExportSettings().isExportAnnotations())
+ if (exportSettings.isExportAnnotations())
{
jsonAlignmentPojo
.setAlignAnnotation(annotationToJsonPojo(annotations));
}
- if (getExportSettings().isExportFeatures())
+ if (exportSettings.isExportFeatures())
{
jsonAlignmentPojo
.setSeqFeatures(sequenceFeatureToJsonPojo(seqs, fr));
}
- if (getExportSettings().isExportGroups()
+ if (exportSettings.isExportGroups()
&& seqGroups != null
&& seqGroups.size() > 0)
{
return hiddenSections;
}
- public static List<SequenceFeaturesPojo> sequenceFeatureToJsonPojo(
+ public List<SequenceFeaturesPojo> sequenceFeatureToJsonPojo(
List<SequenceI> seqs, FeatureRenderer fr)
{
- FeaturesDisplayedI displayedFeatures = (fr == null) ? null : fr
+ displayedFeatures = (fr == null) ? null : fr
.getFeaturesDisplayed();
List<SequenceFeaturesPojo> sequenceFeaturesPojo = new ArrayList<SequenceFeaturesPojo>();
for (SequenceI seq : seqs)
{
SequenceFeaturesPojo jsonFeature = new SequenceFeaturesPojo(
String.valueOf(seq.hashCode()));
+
String featureColour = (fr == null) ? null : jalview.util.Format
.getHexString(fr
.findFeatureColour(Color.white, seq,
}
}
}
- ColourSchemeI scheme = getJalviewColorScheme(colourScheme);
- SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName, scheme,
+ ColourSchemeI grpColourScheme = getJalviewColorScheme(colourScheme);
+ SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName,
+ grpColourScheme,
displayBoxes, displayText, colourText, startRes, endRes);
seqGrp.setShowNonconserved(showNonconserved);
seqGrp.setDescription(description);
{
if (jsonSeqFeatures != null)
{
+ displayedFeatures = new FeaturesDisplayed();
for (Iterator<JSONObject> seqFeatureItr = jsonSeqFeatures.iterator(); seqFeatureItr
.hasNext();)
{
sequenceFeature.setBegin(seq.findPosition(begin.intValue()));
sequenceFeature.setEnd(seq.findPosition(end.intValue()) - 1);
seq.addSequenceFeature(sequenceFeature);
+ displayedFeatures.setVisible(type);
}
}
}
this.colourScheme = colourScheme;
}
+ @Override
public FeaturesDisplayedI getDisplayedFeatures()
{
return displayedFeatures;
this.displayedFeatures = displayedFeatures;
}
- @Override
+
public void configureForView(AlignmentViewPanel avpanel)
{
super.configureForView(avpanel);
+ AlignViewportI viewport = avpanel.getAlignViewport();
+ AlignmentI alignment = viewport.getAlignment();
+ AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
- seqGroups = avpanel.getAlignment().getGroups();
- setDisplayedFeatures(getViewport().getFeaturesDisplayed());
+ seqGroups = alignment.getGroups();
fr = avpanel.cloneFeatureRenderer();
// Add non auto calculated annotation to AlignFile
- for (AlignmentAnnotation annot : getViewport().getAlignment()
- .getAlignmentAnnotation())
+ for (AlignmentAnnotation annot : annots)
{
if (annot != null && !annot.autoCalculated)
{
annotations.add(annot);
}
}
- globalColorScheme = ColourSchemeProperty.getColourName(getViewport()
+ globalColorScheme = ColourSchemeProperty.getColourName(viewport
.getGlobalColourScheme());
- setDisplayedFeatures(getViewport().getFeaturesDisplayed());
- showSeqFeatures = getViewport().isShowSequenceFeatures();
+ setDisplayedFeatures(viewport.getFeaturesDisplayed());
+ showSeqFeatures = viewport.isShowSequenceFeatures();
}
import static org.testng.AssertJUnit.assertNotNull;
+import jalview.api.AlignExportSettingI;
+import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
+import jalview.datamodel.ColumnSelection;
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 jalview.schemes.ZappoColourScheme;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
+import org.testng.Assert;
import org.testng.AssertJUnit;
-import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class JSONFileTest
private int TEST_ANOT_HEIGHT = 0;
- private AlignFrame af;
+ private int TEST_CS_HEIGHT = 0;
- AlignmentI alignment;
+ private String TEST_JSON_FILE = "examples/example.json";
- AlignmentPanel alignPanel;
+ private Alignment alignment;
- HashMap<String, SequenceI> testSeqs = new HashMap<String, SequenceI>();
- HashMap<String, AlignmentAnnotation> testAnnots = new HashMap<String, AlignmentAnnotation>();
- HashMap<String, SequenceGroup> testGrps = new HashMap<String, SequenceGroup>();
+ private HashMap<String, SequenceI> expectedSeqs = new HashMap<String, SequenceI>();
- @BeforeMethod
+ private HashMap<String, AlignmentAnnotation> expectedAnnots = new HashMap<String, AlignmentAnnotation>();
+
+ private HashMap<String, SequenceGroup> expectedGrps = new HashMap<String, SequenceGroup>();
+
+ private ColumnSelection expectedColSel = new ColumnSelection();
+
+ private SequenceI[] expectedHiddenSeqs = new SequenceI[1];
+
+ private AlignmentI testAlignment;
+
+ private int passedCount;
+
+ private JSONFile testJsonFile;
+
+ private JSONFile jf;
+
+ @BeforeTest
public void setup() throws Exception
{
// create and add sequences
seqs[4] = new Sequence("Q7XA98_TRIPR",
"ALYGTAVSTSFMRRQPVPMSV-ATTTTTKAFPSGF", 6, 39);
+ SequenceI hiddenSeq = new Sequence("FER_TOCH",
+ "FILGTMISKSFLFRKPAVTSL-KAISNVGE--ALF", 3, 34);
+ expectedHiddenSeqs[0] = hiddenSeq;
+
// create and add sequence features
SequenceFeature seqFeature2 = new SequenceFeature("feature_x",
"desciption", "status", 6, 15, "Jalview");
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.setShowSeqFeatures(true);
for (Sequence seq : seqs)
{
seq.setDatasetSequence(seq);
- testSeqs.put(seq.getName(), seq);
- // jsonFile.seqs.add(seq);
+ expectedSeqs.put(seq.getName(), seq);
}
// create and add sequence groups
scheme, true, true, false, 21, 29);
seqGrp.setShowNonconserved(false);
seqGrp.setDescription(null);
- // jsonFile.seqGroups.add(seqGrp);
- testGrps.put(seqGrp.getName(), seqGrp);
+
+ expectedGrps.put(seqGrp.getName(), seqGrp);
// create and add annotation
Annotation[] annot = new Annotation[35];
AlignmentAnnotation alignAnnot = new AlignmentAnnotation(
"Secondary Structure", "New description", annot);
- // jsonFile.annotations.add(alignAnnot);
- testAnnots.put(alignAnnot.label, alignAnnot);
+ expectedAnnots.put(alignAnnot.label, alignAnnot);
- // Alignment al = new Alignment(seqs);
- TEST_SEQ_HEIGHT = testSeqs.size();
- TEST_GRP_HEIGHT = testGrps.size();
- TEST_ANOT_HEIGHT = testAnnots.size();
- }
+ expectedColSel.hideColumns(32, 33);
+ expectedColSel.hideColumns(34, 34);
- @AfterMethod
- public void tearDown() throws Exception
- {
- }
+ TEST_SEQ_HEIGHT = expectedSeqs.size();
+ TEST_GRP_HEIGHT = expectedGrps.size();
+ TEST_ANOT_HEIGHT = expectedAnnots.size();
+ TEST_CS_HEIGHT = expectedColSel.getHiddenColumns().size();
- @Test
- public void testParse()
- {
- String jsonFile = "examples/example.json";
- AppletFormatAdapter rf = new AppletFormatAdapter();
- AlignmentI al = null;
+ AlignExportSettingI exportSettings = new AlignExportSettingI()
+ {
+ @Override
+ public boolean isExportHiddenSequences()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isExportHiddenColumns()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isExportGroups()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isExportFeatures()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isExportAnnotations()
+ {
+ return true;
+ }
+ };
+
+ AppletFormatAdapter formatAdapter = new AppletFormatAdapter();
try
{
- al = rf.readFile(jsonFile, AppletFormatAdapter.FILE,
- JSONFile.FILE_DESC);
+ alignment = (Alignment) formatAdapter.readFile(TEST_JSON_FILE,
+ AppletFormatAdapter.FILE, JSONFile.FILE_DESC);
+ jf = (JSONFile) formatAdapter.getAlignFile();
+
+ AlignFrame af = new AlignFrame(alignment, jf.getHiddenSequences(),
+ jf.getColumnSelection(), AlignFrame.DEFAULT_WIDTH,
+ AlignFrame.DEFAULT_HEIGHT);
+ af.getViewport().setShowSequenceFeatures(jf.isShowSeqFeatures());
+ af.changeColour(jf.getColourScheme());
+ af.getViewport().setFeaturesDisplayed(jf.getDisplayedFeatures());
+
+
+ formatAdapter = new AppletFormatAdapter(af.alignPanel, exportSettings);
+ String jsonOutput = formatAdapter.formatSequences(JSONFile.FILE_DESC,
+ af.alignPanel.getAlignment(), false);
+
+ formatAdapter = new AppletFormatAdapter();
+ testAlignment = formatAdapter.readFile(jsonOutput,
+ AppletFormatAdapter.PASTE, JSONFile.FILE_DESC);
+ testJsonFile = (JSONFile) formatAdapter.getAlignFile();
+ // System.out.println(jsonOutput);
} catch (IOException e)
{
e.printStackTrace();
}
- assertNotNull("Couldn't read supplied alignment data.", al);
- int passedCount = 0;
- for (SequenceI seq : al.getSequences())
+ }
+
+ @BeforeMethod
+ public void methodSetup()
+ {
+ passedCount = 0;
+ }
+
+ @AfterTest
+ public void tearDown() throws Exception
+ {
+ testJsonFile = null;
+ alignment = null;
+ expectedSeqs = null;
+ expectedAnnots = null;
+ expectedGrps = null;
+ testAlignment = null;
+ jf = null;
+ }
+
+ @Test
+ public void roundTripTest()
+ {
+ assertNotNull("JSON roundtrip test failed!", testJsonFile);
+ }
+
+ @Test
+ public void testSeqParsed()
+ {
+ assertNotNull("Couldn't read supplied alignment data.", testAlignment);
+ Assert.assertNotNull(testAlignment.getSequences());
+ for (SequenceI seq : testAlignment.getSequences())
{
- SequenceI expectedSeq = testSeqs.get(seq.getName());
- AssertJUnit.assertTrue("Failed Sequence Test for >>> " + seq.getName(),
+ SequenceI expectedSeq = expectedSeqs.get(seq.getName());
+ AssertJUnit.assertTrue(
+ "Failed Sequence Test for >>> " + seq.getName(),
isSeqMatched(expectedSeq, seq));
passedCount++;
}
AssertJUnit.assertEquals("Some Sequences did not pass the test",
TEST_SEQ_HEIGHT, passedCount);
+ }
+
+ @Test
+ public void hiddenColsTest()
+ {
+ ColumnSelection cs = testJsonFile.getColumnSelection();
+ Assert.assertNotNull(cs);
+ Assert.assertNotNull(cs.getHiddenColumns());
+ List<int[]> hiddenCols = cs.getHiddenColumns();
+ Assert.assertEquals(hiddenCols.size(), TEST_CS_HEIGHT);
+ Assert.assertEquals(hiddenCols, expectedColSel.getHiddenColumns(),
+ "Mismatched hidden columns!");
+ }
- passedCount = 0;
- for (SequenceGroup seqGrp : al.getGroups())
+ @Test
+ public void hiddenSeqsTest()
+ {
+ Assert.assertNotNull(testJsonFile.getHiddenSequences(),
+ "Hidden sequence Expected but found Null");
+ Assert.assertEquals(jf.getHiddenSequences().length, 1,
+ "Hidden sequece");
+ }
+
+ @Test
+ public void colorSchemeTest()
+ {
+ Assert.assertNotNull(testJsonFile.getColourScheme(),
+ "Colourscheme is null, parsing failed!");
+ Assert.assertTrue(
+ testJsonFile.getColourScheme() instanceof ZappoColourScheme,
+ "Zappo colour scheme expected!");
+ }
+
+ @Test
+ public void isShowSeqFeaturesSet()
+ {
+ Assert.assertTrue(testJsonFile.isShowSeqFeatures(),
+ "Sequence feature isDisplayed setting expected to be true");
+ }
+
+ @Test
+ public void testGrpParsed()
+ {
+ Assert.assertNotNull(testAlignment.getGroups());
+ for (SequenceGroup seqGrp : testAlignment.getGroups())
{
- SequenceGroup expectedGrp = testGrps.get(seqGrp.getName());
+ SequenceGroup expectedGrp = expectedGrps.get(seqGrp.getName());
AssertJUnit.assertTrue(
"Failed SequenceGroup Test for >>> " + seqGrp.getName(),
isGroupMatched(expectedGrp, seqGrp));
}
AssertJUnit.assertEquals("Some SequenceGroups did not pass the test",
TEST_GRP_HEIGHT, passedCount);
+ }
- passedCount = 0;
- for (AlignmentAnnotation annot : al.getAlignmentAnnotation())
+ @Test
+ public void testAnnotationParsed()
+ {
+ Assert.assertNotNull(testAlignment.getAlignmentAnnotation());
+ for (AlignmentAnnotation annot : testAlignment.getAlignmentAnnotation())
{
- AlignmentAnnotation expectedAnnot = testAnnots.get(annot.label);
+ AlignmentAnnotation expectedAnnot = expectedAnnots.get(annot.label);
AssertJUnit.assertTrue("Failed AlignmentAnnotation Test for >>> "
+ annot.label, isAnnotationMatched(expectedAnnot, annot));
passedCount++;
}
AssertJUnit.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,