ColourSchemeI getGlobalColourScheme();
+ /**
+ * Returns an object that describes colouring (including any thresholding or
+ * fading) of the alignment
+ *
+ * @return
+ */
ResidueShaderI getViewportColourScheme();
AlignmentI getAlignment();
/**
*
- * @return the alignment annotatino row for the structure consensus
+ * @return the alignment annotation row for the structure consensus
* calculation
*/
AlignmentAnnotation getAlignmentStrucConsensusAnnotation();
void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus);
/**
- * set global colourscheme
+ * Sets the colour scheme for the background alignment (as distinct from
+ * sub-groups, which may have their own colour schemes). A null value is used
+ * for no residue colour (white).
*
- * @param rhc
+ * @param cs
*/
- void setGlobalColourScheme(ColourSchemeI rhc);
+ void setGlobalColourScheme(ColourSchemeI cs);
Map<SequenceI, SequenceCollectionI> getHiddenRepSequences();
&& viewport.getGlobalColourScheme() != null)
{
SliderPanel.setPIDSliderSource(alignPanel,
- viewport.getViewportColourScheme(), "Background");
+ viewport.getViewportColourScheme(), alignPanel.getViewName());
SliderPanel.showPIDSlider();
}
}
&& viewport.getGlobalColourScheme() != null)
{
SliderPanel.setConservationSlider(alignPanel,
- viewport.getViewportColourScheme(), "Background");
+ viewport.getViewportColourScheme(), alignPanel.getViewName());
SliderPanel.showConservationSlider();
}
}
if (av.getConservationSelected())
{
SliderPanel.setConservationSlider(ap, av.getViewportColourScheme(),
- "Background");
+ ap.getViewName());
}
if (av.getAbovePIDThreshold())
{
SliderPanel.setPIDSliderSource(ap, av.getViewportColourScheme(),
- "Background");
+ ap.getViewName());
}
}
public class SliderPanel extends Panel implements ActionListener,
AdjustmentListener, MouseListener
{
+ private static final String BACKGROUND = "Background";
+
AlignmentPanel ap;
boolean forConservation = true;
sp.valueField.setText(String.valueOf(ccs.getConservationInc()));
}
- conservationSlider
- .setTitle(MessageManager.formatMessage(
- "label.conservation_colour_increment",
- new String[] { source }));
+ conservationSlider.setTitle(MessageManager.formatMessage(
+ "label.conservation_colour_increment",
+ new String[] { source == null ? BACKGROUND : source }));
if (ap.av.getAlignment().getGroups() != null)
{
sp.setAllGroupsCheckEnabled(true);
pid.cs = ccs;
pid.valueField.setText(String.valueOf(ccs.getThreshold()));
}
- PIDSlider
- .setTitle(MessageManager.formatMessage(
- "label.percentage_identity_threshold",
- new String[] { source }));
+ PIDSlider.setTitle(MessageManager.formatMessage(
+ "label.percentage_identity_threshold",
+ new String[] { source == null ? BACKGROUND : source }));
if (ap.av.getAlignment().getGroups() != null)
{
* @param selected
*/
@Override
- protected void applyToAllGroups_actionPerformed(boolean selected)
+ public void applyToAllGroups_actionPerformed(boolean selected)
{
viewport.setColourAppliesToAllGroups(selected);
}
protected void modifyPID_actionPerformed()
{
SliderPanel.setPIDSliderSource(alignPanel,
- viewport.getViewportColourScheme(), "Background");
+ viewport.getViewportColourScheme(), alignPanel.getViewName());
SliderPanel.showPIDSlider();
}
protected void modifyConservation_actionPerformed()
{
SliderPanel.setConservationSlider(alignPanel,
- viewport.getViewportColourScheme(), "Background");
+ viewport.getViewportColourScheme(), alignPanel.getViewName());
SliderPanel.showConservationSlider();
}
* Action on selecting or deselecting (Colour) By Conservation
*/
@Override
- protected void conservationMenuItem_actionPerformed(boolean selected)
+ public void conservationMenuItem_actionPerformed(boolean selected)
{
modifyConservation.setEnabled(selected);
viewport.setConservationSelected(selected);
{
modifyPID.setEnabled(selected);
viewport.setAbovePIDThreshold(selected);
+ if (!selected)
+ {
+ viewport.getViewportColourScheme().setThreshold(0,
+ viewport.isIgnoreGapsConsensus());
+ }
changeColour(viewport.getGlobalColourScheme());
if (selected)
}
/*
+ * 'focus' any colour slider that is open to the selected viewport
+ */
+ if (viewport.getConservationSelected())
+ {
+ SliderPanel.setConservationSlider(alignPanel,
+ viewport.getViewportColourScheme(), alignPanel.getViewName());
+ }
+ else
+ {
+ SliderPanel.hideConservationSlider();
+ }
+ if (viewport.getAbovePIDThreshold())
+ {
+ SliderPanel.setPIDSliderSource(alignPanel,
+ viewport.getViewportColourScheme(), alignPanel.getViewName());
+ }
+ else
+ {
+ SliderPanel.hidePIDSlider();
+ }
+
+ /*
* If there is a frame linked to this one in a SplitPane, switch it to the
* same view tab index. No infinite recursion of calls should happen, since
* tabSelectionChanged() should not get invoked on setting the selected
super.setViewStyle(settingsForView);
setFont(new Font(viewStyle.getFontName(), viewStyle.getFontStyle(),
viewStyle.getFontSize()), false);
-
+ if (globalColourScheme != null)
+ {
+ globalColourScheme.setConservationApplied(settingsForView
+ .isConservationColourSelected());
+ }
}
/**
* @param e
* DOCUMENT ME!
*/
- protected void abovePIDColour_actionPerformed(boolean selected)
+ public void abovePIDColour_actionPerformed(boolean selected)
{
SequenceGroup sg = getGroup();
if (sg.cs == null)
* @param e
* DOCUMENT ME!
*/
- protected void conservationMenuItem_actionPerformed(boolean selected)
+ public void conservationMenuItem_actionPerformed(boolean selected)
{
SequenceGroup sg = getGroup();
if (sg.cs == null)
if (av.getConservationSelected())
{
SliderPanel.setConservationSlider(ap, av.getViewportColourScheme(),
- "Background");
+ ap.getViewName());
}
if (av.getAbovePIDThreshold())
{
SliderPanel.setPIDSliderSource(ap, av.getViewportColourScheme(),
- "Background");
+ ap.getViewName());
}
if ((stretchGroup != null) && (stretchGroup.getEndRes() == res))
{
*/
public class SliderPanel extends GSliderPanel
{
+ private static final String BACKGROUND = "Background";
+
static JInternalFrame conservationSlider;
static JInternalFrame PIDSlider;
ResidueShaderI cs;
- private static SliderPanel sliderPanel;
-
/**
- * Returns the currently active slider panel (or null if none).
+ * Returns the currently displayed slider panel (or null if none).
*
* @return
*/
public static SliderPanel getSliderPanel()
{
- return sliderPanel;
+ if (conservationSlider != null && conservationSlider.isVisible())
+ {
+ return (SliderPanel) conservationSlider.getContentPane();
+ }
+ if (PIDSlider != null && PIDSlider.isVisible())
+ {
+ return (SliderPanel) PIDSlider.getContentPane();
+ }
+ return null;
}
/**
}
/**
- * DOCUMENT ME!
+ * Method to 'set focus' of the Conservation slider panel
*
* @param ap
- * DOCUMENT ME!
- * @param ccs
- * DOCUMENT ME!
+ * the panel to repaint on change of slider
+ * @param rs
+ * the colour scheme to update on change of slider
* @param source
- * DOCUMENT ME!
+ * a text description for the panel's title
*
- * @return DOCUMENT ME!
+ * @return
*/
public static int setConservationSlider(AlignmentPanel ap,
- ResidueShaderI ccs, String source)
+ ResidueShaderI rs, String source)
{
- sliderPanel = null;
+ SliderPanel sliderPanel = null;
if (conservationSlider == null)
{
- sliderPanel = new SliderPanel(ap, ccs.getConservationInc(), true, ccs);
+ sliderPanel = new SliderPanel(ap, rs.getConservationInc(), true, rs);
conservationSlider = new JInternalFrame();
conservationSlider.setContentPane(sliderPanel);
conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER);
else
{
sliderPanel = (SliderPanel) conservationSlider.getContentPane();
- sliderPanel.valueField.setText(String.valueOf(ccs.getConservationInc()));
- sliderPanel.cs = ccs;
+ sliderPanel.valueField.setText(String.valueOf(rs.getConservationInc()));
+ sliderPanel.cs = rs;
+ sliderPanel.ap = ap;
+ sliderPanel.slider.setValue(rs.getConservationInc());
}
- conservationSlider
- .setTitle(MessageManager.formatMessage(
- "label.conservation_colour_increment",
- new String[] { source }));
+ conservationSlider.setTitle(MessageManager.formatMessage(
+ "label.conservation_colour_increment",
+ new String[] { source == null ? BACKGROUND : source }));
if (ap.av.getAlignment().getGroups() != null)
{
}
/**
- * DOCUMENT ME!
+ * Method to 'set focus' of the PID slider panel
*
* @param ap
- * DOCUMENT ME!
- * @param ccs
- * DOCUMENT ME!
+ * the panel to repaint on change of slider
+ * @param rs
+ * the colour scheme to update on change of slider
* @param source
- * DOCUMENT ME!
+ * a text description for the panel's title
*
- * @return DOCUMENT ME!
+ * @return
*/
public static int setPIDSliderSource(AlignmentPanel ap,
- ResidueShaderI ccs, String source)
+ ResidueShaderI rs, String source)
{
- int threshold = ccs.getThreshold();
+ int threshold = rs.getThreshold();
+
+ SliderPanel sliderPanel = null;
if (PIDSlider == null)
{
- sliderPanel = new SliderPanel(ap, threshold, false, ccs);
+ sliderPanel = new SliderPanel(ap, threshold, false, rs);
PIDSlider = new JInternalFrame();
PIDSlider.setContentPane(sliderPanel);
PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
else
{
sliderPanel = (SliderPanel) PIDSlider.getContentPane();
- sliderPanel.cs = ccs;
- sliderPanel.valueField.setText(String.valueOf(ccs.getThreshold()));
+ sliderPanel.cs = rs;
+ sliderPanel.ap = ap;
+ sliderPanel.valueField.setText(String.valueOf(rs.getThreshold()));
+ sliderPanel.slider.setValue(rs.getThreshold());
}
- PIDSlider
- .setTitle(MessageManager.formatMessage(
- "label.percentage_identity_threshold",
- new String[] { source }));
+ PIDSlider.setTitle(MessageManager.formatMessage(
+ "label.percentage_identity_threshold",
+ new String[] { source == null ? BACKGROUND : source }));
if (ap.av.getAlignment().getGroups() != null)
{
package jalview.renderer;
import jalview.analysis.Conservation;
+import jalview.api.ViewStyleI;
import jalview.datamodel.AnnotatedCollectionI;
import jalview.datamodel.ProfileI;
import jalview.datamodel.ProfilesI;
*/
public class ResidueShader implements ResidueShaderI
{
+ private static final int INITIAL_CONSERVATION = 30;
+
+ /*
+ * the colour scheme that gives the colour of each residue
+ * before applying any conservation or PID shading
+ */
private ColourSchemeI colourScheme;
+ /*
+ * the consensus data for each column
+ */
private ProfilesI consensus;
+ /*
+ * if true, apply shading of colour by conservation
+ */
private boolean conservationColouring;
+ /*
+ * the phsyico-chemical property conservation scores for columns, with values
+ * 0-9, '+' (all properties conserved), '*' (residue fully conserved) or '-' (gap)
+ * (may be null if colour by conservation is not selected)
+ */
private char[] conservation;
- private int threshold;
+ /*
+ * minimum percentage identity for colour to be applied;
+ * if above zero, residue must match consensus (or joint consensus)
+ * and column have >= pidThreshold identity with the residue
+ */
+ private int pidThreshold;
+ /*
+ * if true, ignore gaps in percentage identity calculation
+ */
private boolean ignoreGaps;
- private int inc;
+ /*
+ * setting of the By Conservation slider
+ */
+ private int conservationIncrement = INITIAL_CONSERVATION;
public ResidueShader(ColourSchemeI cs)
{
}
/**
+ * Constructor given view style settings
+ *
+ * @param viewStyle
+ */
+ public ResidueShader(ViewStyleI viewStyle)
+ {
+ // TODO remove duplicated storing of conservation / pid thresholds?
+ this();
+ setConservationApplied(viewStyle.isConservationColourSelected());
+ // setThreshold(viewStyle.getThreshold());
+ }
+
+ /**
* @see jalview.renderer.ResidueShaderI#setConsensus(jalview.datamodel.ProfilesI)
*/
@Override
@Override
public void setThreshold(int consensusThreshold, boolean ignoreGaps)
{
- threshold = consensusThreshold;
+ pidThreshold = consensusThreshold;
this.ignoreGaps = ignoreGaps;
}
@Override
public void setConservationInc(int i)
{
- inc = i;
+ conservationIncrement = i;
}
/**
@Override
public int getConservationInc()
{
- return inc;
+ return conservationIncrement;
}
/**
@Override
public int getThreshold()
{
- return threshold;
+ return pidThreshold;
}
/**
*/
protected boolean aboveThreshold(char residue, int column)
{
- if (threshold == 0)
+ if (pidThreshold == 0)
{
return true;
}
if (profile != null
&& profile.getModalResidue().contains(String.valueOf(residue)))
{
- if (profile.getPercentageIdentity(ignoreGaps) >= threshold)
+ if (profile.getPercentageIdentity(ignoreGaps) >= pidThreshold)
{
return true;
}
* as a result, scores of: 0 1 2 3 4 5 6 7 8 9
* fade to white at slider value: 18 20 22 25 29 33 40 50 67 100%
*/
- bleachFactor *= (inc / 20f);
+ bleachFactor *= (conservationIncrement / 20f);
return ColorUtils.bleachColour(currentColour, bleachFactor);
}
public class PIDColourScheme extends ResidueColourScheme
{
- public Color[] pidColours;
+ private static final Color[] pidColours = { new Color(100, 100, 255),
+ new Color(153, 153, 255), new Color(204, 204, 255), };
- public float[] thresholds;
+ private static final float[] thresholds = { 80, 60, 40, };
SequenceGroup group;
public PIDColourScheme()
{
- this.pidColours = ResidueProperties.pidColours;
- this.thresholds = ResidueProperties.pidThresholds;
}
@Override
String consensusResidue, float pid)
{
/*
- * make everything uppercase; note this does nothing (fast)
+ * make everything uppercase; note this does nothing
* if consensusResidue is already uppercase
*/
consensusResidue = consensusResidue.toUpperCase();
scoreMatrices.put("DNA", new ScoreMatrix("DNA", DNA, 1));
}
- public static final Color[] pidColours = { midBlue,
- new Color(153, 153, 255),
- // Color.lightGray,
- new Color(204, 204, 255), };
-
- public static final float[] pidThresholds = { 80, 60, 40, };
-
public static List<String> STOP = Arrays.asList("TGA", "TAA", "TAG");
public static String START = "ATG";
import jalview.datamodel.SequenceI;
import jalview.renderer.ResidueShader;
import jalview.renderer.ResidueShaderI;
-import jalview.schemes.Blosum62ColourScheme;
import jalview.schemes.ColourSchemeI;
-import jalview.schemes.PIDColourScheme;
import jalview.structure.CommandListener;
import jalview.structure.StructureSelectionManager;
import jalview.structure.VamsasSource;
// TODO: logic refactored from AlignFrame changeColour -
// TODO: autorecalc stuff should be changed to rely on the worker system
// check to see if we should implement a changeColour(cs) method rather than
- // put th logic in here
+ // put the logic in here
// - means that caller decides if they want to just modify state and defer
// calculation till later or to do all calculations in thread.
// via changecolour
/*
- * only instantiate collection colour scheme once, thereafter update it
+ * only instantiate alignment colouring once, thereafter update it;
* this means that any conservation or PID threshold settings
* persist when the alignment colour scheme is changed
*/
if (globalColourScheme == null)
{
- globalColourScheme = new ResidueShader();
+ globalColourScheme = new ResidueShader(viewStyle);
}
globalColourScheme.setColourScheme(cs);
- // boolean recalc = false;
- // TODO: do threshold and increment belong in ViewStyle or colour scheme?
- // problem: groups need this but do not currently have a ViewStyle
+ // TODO: do threshold and increment belong in ViewStyle or ResidueShader?
+ // ...problem: groups need these, but do not currently have a ViewStyle
if (cs != null)
{
- if (getConservationSelected() || getAbovePIDThreshold()
- || cs instanceof PIDColourScheme
- || cs instanceof Blosum62ColourScheme)
+ // if (getConservationSelected() || getAbovePIDThreshold()
+ // || cs instanceof PIDColourScheme
+ // || cs instanceof Blosum62ColourScheme)
+ if (getConservationSelected())
{
globalColourScheme.setConservation(hconservation);
- globalColourScheme
- .setConservationApplied(getConservationSelected());
}
globalColourScheme.alignmentChanged(alignment, hiddenRepSequences);
}
selectionGroup.setEndRes(alWidth - 1);
}
- resetAllColourSchemes();
+ updateAllColourSchemes();
calculator.restartWorkers();
// alignment.adjustSequenceAnnotations();
}
/**
* reset scope and do calculations for all applied colourschemes on alignment
*/
- void resetAllColourSchemes()
+ void updateAllColourSchemes()
{
- ResidueShaderI cs = globalColourScheme;
- if (cs != null)
+ ResidueShaderI rs = globalColourScheme;
+ if (rs != null)
{
- cs.alignmentChanged(alignment, hiddenRepSequences);
+ rs.alignmentChanged(alignment, hiddenRepSequences);
- cs.setConsensus(hconsensus);
- if (cs.conservationApplied())
+ rs.setConsensus(hconsensus);
+ if (rs.conservationApplied())
{
- cs.setConservation(Conservation.calculateConservation("All",
+ rs.setConservation(Conservation.calculateConservation("All",
alignment.getSequences(), 0, alignment.getWidth(), false,
getConsPercGaps(), false));
}
*/
package jalview.gui;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertSame;
-import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotSame;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+import jalview.bin.Cache;
+import jalview.bin.Jalview;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
import jalview.io.DataSourceType;
import jalview.io.FileLoader;
+import jalview.io.Jalview2xmlTests;
+import jalview.renderer.ResidueShaderI;
import jalview.schemes.BuriedColourScheme;
import jalview.schemes.HelixColourScheme;
import jalview.schemes.JalviewColourScheme;
import jalview.schemes.TurnColourScheme;
import jalview.util.MessageManager;
+import java.awt.Color;
import java.util.List;
+import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
seq2.addSequenceFeature(new SequenceFeature("Turn", "", 7, 9,
Float.NaN, null));
AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 });
- AlignFrame af = new AlignFrame(al, al.getWidth(), al.getHeight());
+ AlignFrame alignFrame = new AlignFrame(al, al.getWidth(), al.getHeight());
/*
* hiding a feature not present does nothing
*/
- assertFalse(af.hideFeatureColumns("exon", true));
- assertTrue(af.getViewport().getColumnSelection().isEmpty());
- assertTrue(af.getViewport().getColumnSelection().getHiddenColumns()
+ assertFalse(alignFrame.hideFeatureColumns("exon", true));
+ assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
+ assertTrue(alignFrame.getViewport().getColumnSelection().getHiddenColumns()
.isEmpty());
- assertFalse(af.hideFeatureColumns("exon", false));
- assertTrue(af.getViewport().getColumnSelection().isEmpty());
- assertTrue(af.getViewport().getColumnSelection().getHiddenColumns()
+ assertFalse(alignFrame.hideFeatureColumns("exon", false));
+ assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
+ assertTrue(alignFrame.getViewport().getColumnSelection().getHiddenColumns()
.isEmpty());
/*
* hiding a feature in all columns does nothing
*/
- assertFalse(af.hideFeatureColumns("Metal", true));
- assertTrue(af.getViewport().getColumnSelection().isEmpty());
- List<int[]> hidden = af.getViewport().getColumnSelection()
+ assertFalse(alignFrame.hideFeatureColumns("Metal", true));
+ assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
+ List<int[]> hidden = alignFrame.getViewport().getColumnSelection()
.getHiddenColumns();
assertTrue(hidden.isEmpty());
* sequence positions [2-4], [7-9] are column positions
* [1-3], [6-8] base zero
*/
- assertTrue(af.hideFeatureColumns("Turn", true));
- hidden = af.getViewport().getColumnSelection().getHiddenColumns();
- assertEquals(2, hidden.size());
- assertEquals(1, hidden.get(0)[0]);
- assertEquals(3, hidden.get(0)[1]);
- assertEquals(6, hidden.get(1)[0]);
- assertEquals(8, hidden.get(1)[1]);
+ assertTrue(alignFrame.hideFeatureColumns("Turn", true));
+ hidden = alignFrame.getViewport().getColumnSelection().getHiddenColumns();
+ assertEquals(hidden.size(), 2);
+ assertEquals(hidden.get(0)[0], 1);
+ assertEquals(hidden.get(0)[1], 3);
+ assertEquals(hidden.get(1)[0], 6);
+ assertEquals(hidden.get(1)[1], 8);
}
- @BeforeMethod
+ @BeforeClass(alwaysRun = true)
+ public static void setUpBeforeClass() throws Exception
+ {
+ /*
+ * use read-only test properties file
+ */
+ Cache.loadProperties("test/jalview/io/testProps.jvprops");
+ Jalview.main(new String[] { "-nonews" });
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown()
+ {
+ Desktop.instance.closeAll_actionPerformed(null);
+ }
+
+ /**
+ * configure (read-only) properties for test to ensure Consensus is computed
+ * for colour Above PID testing
+ */
+ @BeforeMethod(alwaysRun = true)
public void setUp()
{
+ Cache.loadProperties("test/jalview/io/testProps.jvprops");
+ Cache.applicationProperties.setProperty("SHOW_IDENTITY",
+ Boolean.TRUE.toString());
af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa",
DataSourceType.FILE);
+
+ /*
+ * wait for Consensus thread to complete
+ */
+ synchronized (this)
+ {
+ while (af.getViewport().getConsensusSeq() == null)
+ {
+ try
+ {
+ wait(50);
+ } catch (InterruptedException e)
+ {
+ }
+ }
+ }
}
/**
* Conservation)</li>
* </ul>
*/
- @Test
+ @Test(groups = "Functional")
public void testChangeColour_background_groupsAndThresholds()
{
AlignViewport av = af.getViewport();
assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
}
+
+ /**
+ * Test residue colouring with various options
+ * <ol>
+ * <li>no PID or Conservation threshold</li>
+ * <li>colour by Conservation applied</li>
+ * <li>colour by Conservation removed</li>
+ * <li>colour above PID - various values</li>
+ * <li>colour above PID removed</li>
+ * <li>Above PID plus By Conservation combined</li>
+ * <li>remove Above PID to leave just By Conservation</li>
+ * <li>re-add Above PID</li>
+ * <li>remove By Conservation to leave just Above PID</li>
+ * <li>remove Above PID to leave original colours</li>
+ * </ol>
+ */
+ @Test(groups = "Functional")
+ public void testColourThresholdActions()
+ {
+ AlignViewport av = af.getViewport();
+ AlignmentI al = av.getAlignment();
+
+ /*
+ * Colour alignment by Helix Propensity, no thresholds
+ */
+ af.applyToAllGroups_actionPerformed(false);
+ af.changeColour_actionPerformed(JalviewColourScheme.Helix.toString());
+ assertTrue(av.getGlobalColourScheme() instanceof HelixColourScheme);
+ assertFalse(av.getViewportColourScheme().conservationApplied());
+ assertEquals(av.getViewportColourScheme().getThreshold(), 0);
+
+ /*
+ * inspect the colour of
+ * FER_CAPAN.9(I), column 14 (14 base 0)
+ * FER_CAPAN.10(SER), column 16 (15 base 0)
+ */
+ SequenceI ferCapan = al.findName("FER_CAPAN");
+ ResidueShaderI rs = av.getViewportColourScheme();
+ Color c = rs.findColour('I', 14, ferCapan);
+ Color i_original = new Color(138, 117, 138);
+ assertEquals(c, i_original);
+ c = rs.findColour('S', 15, ferCapan);
+ Color s_original = new Color(54, 201, 54);
+ assertEquals(c, s_original);
+
+ /*
+ * colour by conservation with increment 10
+ */
+ af.conservationMenuItem_actionPerformed(true);
+ SliderPanel sp = SliderPanel.getSliderPanel();
+ assertTrue(sp.isForConservation());
+ assertEquals(sp.getValue(), 30); // initial slider setting
+ sp.valueChanged(10);
+ assertSame(rs, av.getViewportColourScheme());
+ c = rs.findColour('I', 14, ferCapan);
+ Color i_faded = new Color(196, 186, 196);
+ assertEquals(c, i_faded);
+ c = rs.findColour('S', 15, ferCapan);
+ Color s_faded = new Color(144, 225, 144);
+ assertEquals(c, s_faded);
+
+ /*
+ * deselect By Conservation - colour should revert
+ */
+ af.conservationMenuItem_actionPerformed(false);
+ c = rs.findColour('S', 15, ferCapan);
+ assertEquals(c, s_original);
+
+ /*
+ * now Above PID, threshold = 0%
+ * should be no change
+ */
+ af.abovePIDThreshold_actionPerformed(true);
+ sp = SliderPanel.getSliderPanel();
+ assertFalse(sp.isForConservation());
+ assertEquals(sp.getValue(), 0); // initial slider setting
+ c = rs.findColour('I', 14, ferCapan);
+ assertEquals(c, i_original);
+ c = rs.findColour('S', 15, ferCapan);
+ assertEquals(c, s_original);
+
+ /*
+ * Above PID, threshold = 1%
+ * 15.I becomes White because no match to consensus (V)
+ * 16.S remains coloured as matches 66.66% consensus
+ */
+ sp.valueChanged(1);
+ c = rs.findColour('I', 14, ferCapan);
+ assertEquals(c, Color.white);
+ c = rs.findColour('S', 15, ferCapan);
+ assertEquals(c, s_original);
+
+ /*
+ * threshold 66% - no further change yet...
+ */
+ sp.valueChanged(66);
+ c = rs.findColour('I', 14, ferCapan);
+ assertEquals(c, Color.white);
+ c = rs.findColour('S', 15, ferCapan);
+ assertEquals(c, s_original);
+
+ /*
+ * threshold 67% - now both residues are white
+ */
+ sp.valueChanged(67);
+ c = rs.findColour('I', 14, ferCapan);
+ assertEquals(c, Color.white);
+ c = rs.findColour('S', 15, ferCapan);
+ assertEquals(c, Color.white);
+
+ /*
+ * deselect Above PID - colours should revert
+ */
+ af.abovePIDThreshold_actionPerformed(false);
+ c = rs.findColour('I', 14, ferCapan);
+ assertEquals(c, i_original);
+ c = rs.findColour('S', 15, ferCapan);
+ assertEquals(c, s_original);
+
+ /*
+ * Now combine Above 50% PID and By Conservation 10%
+ * 15.I is White because no match to consensus (V)
+ * 16.S is coloured but faded
+ */
+ af.abovePIDThreshold_actionPerformed(true);
+ sp = SliderPanel.getSliderPanel();
+ assertFalse(sp.isForConservation());
+ sp.valueChanged(50);
+ af.conservationMenuItem_actionPerformed(true);
+ sp = SliderPanel.getSliderPanel();
+ assertTrue(sp.isForConservation());
+ sp.valueChanged(10);
+ c = rs.findColour('I', 14, ferCapan);
+ assertEquals(c, Color.white);
+ c = rs.findColour('S', 15, ferCapan);
+ assertEquals(c, s_faded);
+
+ /*
+ * turn off Above PID - should just leave Conservation fading as before
+ */
+ af.abovePIDThreshold_actionPerformed(false);
+ c = rs.findColour('I', 14, ferCapan);
+ assertEquals(c, i_faded);
+ c = rs.findColour('S', 15, ferCapan);
+ assertEquals(c, s_faded);
+
+ /*
+ * Now add Above 50% PID to conservation colouring
+ * - should give the same as PID followed by conservation (above)
+ */
+ af.abovePIDThreshold_actionPerformed(true);
+ SliderPanel.getSliderPanel().valueChanged(50);
+ c = rs.findColour('I', 14, ferCapan);
+ assertEquals(c, Color.white);
+ c = rs.findColour('S', 15, ferCapan);
+ assertEquals(c, s_faded);
+
+ /*
+ * turn off By Conservation
+ * should leave I white, S original (unfaded) colour
+ */
+ af.conservationMenuItem_actionPerformed(false);
+ c = rs.findColour('I', 14, ferCapan);
+ assertEquals(c, Color.white);
+ c = rs.findColour('S', 15, ferCapan);
+ assertEquals(c, s_original);
+
+ /*
+ * finally turn off Above PID to leave original colours
+ */
+ af.abovePIDThreshold_actionPerformed(false);
+ c = rs.findColour('I', 14, ferCapan);
+ assertEquals(c, i_original);
+ c = rs.findColour('S', 15, ferCapan);
+ assertEquals(c, s_original);
+ }
+
+ /**
+ * Verify that making a New View transfers alignment and group colour schemes,
+ * including any thresholds, to the new view. Because New View is performed by
+ * saving and reloading a 'project' file, this is similar to verifying a
+ * project save and reload.
+ *
+ * @see Jalview2xmlTests#testStoreAndRecoverColourThresholds()
+ */
+ @Test(groups = "Functional")
+ public void testNewView_colourThresholds()
+ {
+ AlignViewport av = af.getViewport();
+ AlignmentI al = av.getAlignment();
+
+ /*
+ * Colour alignment by Buried Index, Above 10% PID, By Conservation 20%
+ */
+ af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString());
+ assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme);
+ af.abovePIDThreshold_actionPerformed(true);
+ SliderPanel sp = SliderPanel.getSliderPanel();
+ assertFalse(sp.isForConservation());
+ sp.valueChanged(10);
+ af.conservationMenuItem_actionPerformed(true);
+ sp = SliderPanel.getSliderPanel();
+ assertTrue(sp.isForConservation());
+ sp.valueChanged(20);
+ ResidueShaderI rs = av.getViewportColourScheme();
+ assertEquals(rs.getThreshold(), 10);
+ assertTrue(rs.conservationApplied());
+ assertEquals(rs.getConservationInc(), 20);
+
+ /*
+ * create a group with Strand colouring, 30% Conservation
+ * and 40% PID threshold
+ */
+ SequenceGroup sg = new SequenceGroup();
+ sg.addSequence(al.getSequenceAt(0), false);
+ sg.setStartRes(15);
+ sg.setEndRes(25);
+ av.setSelectionGroup(sg);
+ PopupMenu popupMenu = new PopupMenu(af.alignPanel, null, null);
+ popupMenu.changeColour_actionPerformed(JalviewColourScheme.Strand
+ .toString());
+ assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
+ assertEquals(al.getGroups().size(), 1);
+ assertSame(al.getGroups().get(0), sg);
+ popupMenu.conservationMenuItem_actionPerformed(true);
+ sp = SliderPanel.getSliderPanel();
+ assertTrue(sp.isForConservation());
+ sp.valueChanged(30);
+ popupMenu.abovePIDColour_actionPerformed(true);
+ sp = SliderPanel.getSliderPanel();
+ assertFalse(sp.isForConservation());
+ sp.valueChanged(40);
+ rs = sg.getGroupColourScheme();
+ assertTrue(rs.conservationApplied());
+ assertEquals(rs.getConservationInc(), 30);
+ assertEquals(rs.getThreshold(), 40);
+
+ /*
+ * set slider panel focus to the background alignment
+ */
+ af.conservationMenuItem_actionPerformed(true);
+ sp = SliderPanel.getSliderPanel();
+ assertTrue(sp.isForConservation());
+ assertEquals(sp.getTitle(), MessageManager.formatMessage(
+ "label.conservation_colour_increment",
+ new String[] { "Background" }));
+
+ /*
+ * make a new View, verify alignment and group colour schemes
+ */
+ af.newView_actionPerformed(null);
+ assertEquals(af.alignPanel.getViewName(), "View 1");
+ AlignViewport av2 = af.getViewport();
+ assertNotSame(av, av2);
+ rs = av2.getViewportColourScheme();
+ assertNotSame(av.getViewportColourScheme(), rs);
+ assertEquals(rs.getThreshold(), 10);
+ assertTrue(rs.conservationApplied());
+ assertEquals(rs.getConservationInc(), 20);
+ assertEquals(av2.getAlignment().getGroups().size(), 1);
+ sg = av2.getAlignment().getGroups().get(0);
+ rs = sg.getGroupColourScheme();
+ assertTrue(rs.conservationApplied());
+ assertEquals(rs.getConservationInc(), 30);
+ assertEquals(rs.getThreshold(), 40);
+
+ /*
+ * check the Conservation SliderPanel (still open) is linked to
+ * and updates the new view (JAL-2385)
+ */
+ sp = SliderPanel.getSliderPanel();
+ assertTrue(sp.isForConservation());
+ assertEquals(sp.getTitle(), MessageManager.formatMessage(
+ "label.conservation_colour_increment",
+ new String[] { "View 1" }));
+ sp.valueChanged(22);
+ assertEquals(av2.getViewportColourScheme().getConservationInc(), 22);
+ }
}
@BeforeClass(alwaysRun = true)
public static void setUpBeforeClass() throws Exception
{
- Jalview.main(new String[] { "-props", "test/jalview/testProps.jvprops" });
+ Jalview.main(new String[] { "-nonews", "-props",
+ "test/jalview/testProps.jvprops" });
}
@BeforeMethod(alwaysRun = true)
import java.util.Iterator;
import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class FileFormatsTest
{
- @AfterMethod()
+ @AfterMethod(alwaysRun = true)
public void tearDown()
{
FileFormats.getInstance().reset();
}
+ @BeforeMethod(alwaysRun = true)
+ public void setUp()
+ {
+ FileFormats.getInstance().reset();
+ }
+
@Test(groups = "Functional")
public void testIsIdentifiable()
{
*/
package jalview.io;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertSame;
-import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+import jalview.gui.AlignViewport;
import jalview.gui.AlignmentPanel;
import jalview.gui.Desktop;
import jalview.gui.Jalview2XML;
import jalview.gui.JvOptionPane;
+import jalview.gui.PopupMenu;
+import jalview.gui.SliderPanel;
+import jalview.renderer.ResidueShaderI;
import jalview.schemes.AnnotationColourGradient;
+import jalview.schemes.BuriedColourScheme;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemeProperty;
import jalview.schemes.JalviewColourScheme;
import jalview.schemes.RNAHelicesColour;
+import jalview.schemes.StrandColourScheme;
import jalview.schemes.TCoffeeColourScheme;
import jalview.structure.StructureImportSettings;
import jalview.viewmodel.AlignmentViewport;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
String inFile = "examples/RF00031_folded.stk";
String tfile = File.createTempFile("JalviewTest", ".jvp")
.getAbsolutePath();
- AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
- inFile, DataSourceType.FILE);
- assertTrue("Didn't read input file " + inFile, af != null);
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(inFile,
+ DataSourceType.FILE);
+ assertNotNull(af, "Didn't read input file " + inFile);
int olddsann = countDsAnn(af.getViewport());
- assertTrue("Didn't find any dataset annotations", olddsann > 0);
+ assertTrue(olddsann > 0, "Didn't find any dataset annotations");
af.changeColour_actionPerformed(JalviewColourScheme.RNAHelices
.toString());
- assertTrue("Couldn't apply RNA helices colourscheme", af.getViewport()
- .getGlobalColourScheme() instanceof RNAHelicesColour);
- assertTrue("Failed to store as a project.",
- af.saveAlignment(tfile, FileFormat.Jalview));
+ assertTrue(
+ af.getViewport().getGlobalColourScheme() instanceof RNAHelicesColour,
+ "Couldn't apply RNA helices colourscheme");
+ assertTrue(af.saveAlignment(tfile, FileFormat.Jalview),
+ "Failed to store as a project.");
af.closeMenuItem_actionPerformed(true);
af = null;
- af = new FileLoader().LoadFileWaitTillLoaded(tfile, DataSourceType.FILE);
- assertTrue("Failed to import new project", af != null);
+ af = new FileLoader()
+ .LoadFileWaitTillLoaded(tfile, DataSourceType.FILE);
+ assertNotNull(af, "Failed to import new project");
int newdsann = countDsAnn(af.getViewport());
- assertTrue(
+ assertEquals(olddsann, newdsann,
"Differing numbers of dataset sequence annotation\nOriginally "
- + olddsann + " and now " + newdsann,
- olddsann == newdsann);
+ + olddsann + " and now " + newdsann);
System.out
.println("Read in same number of annotations as originally present ("
+ olddsann + ")");
assertTrue(
- "RNA helices colourscheme was not applied on import.",
- af.getViewport().getGlobalColourScheme() instanceof RNAHelicesColour);
+
+ af.getViewport().getGlobalColourScheme() instanceof RNAHelicesColour,
+ "RNA helices colourscheme was not applied on import.");
}
@Test(groups = { "Functional" })
String inFile = "examples/uniref50.fa", inAnnot = "examples/uniref50.score_ascii";
String tfile = File.createTempFile("JalviewTest", ".jvp")
.getAbsolutePath();
- AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
- inFile, DataSourceType.FILE);
- assertNotNull("Didn't read input file " + inFile, af);
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(inFile,
+ DataSourceType.FILE);
+ assertNotNull(af, "Didn't read input file " + inFile);
af.loadJalviewDataFile(inAnnot, DataSourceType.FILE, null, null);
- assertSame("Didn't set T-coffee colourscheme", af.getViewport()
- .getGlobalColourScheme().getClass(), TCoffeeColourScheme.class);
- assertNotNull("Recognise T-Coffee score from string",
- ColourSchemeProperty.getColourScheme(af.getViewport()
- .getAlignment(), af.getViewport()
- .getGlobalColourScheme().getSchemeName()));
-
- assertTrue("Failed to store as a project.",
- af.saveAlignment(tfile, FileFormat.Jalview));
+ assertSame(af.getViewport().getGlobalColourScheme().getClass(),
+ TCoffeeColourScheme.class, "Didn't set T-coffee colourscheme");
+ assertNotNull(ColourSchemeProperty.getColourScheme(af.getViewport()
+ .getAlignment(), af.getViewport().getGlobalColourScheme()
+ .getSchemeName()), "Recognise T-Coffee score from string");
+
+ assertTrue(af.saveAlignment(tfile, FileFormat.Jalview),
+ "Failed to store as a project.");
af.closeMenuItem_actionPerformed(true);
af = null;
- af = new FileLoader().LoadFileWaitTillLoaded(tfile,
- DataSourceType.FILE);
- assertNotNull("Failed to import new project", af);
- assertSame("Didn't set T-coffee colourscheme for imported project.", af
- .getViewport().getGlobalColourScheme().getClass(),
- TCoffeeColourScheme.class);
+ af = new FileLoader()
+ .LoadFileWaitTillLoaded(tfile, DataSourceType.FILE);
+ assertNotNull(af, "Failed to import new project");
+ assertSame(af.getViewport().getGlobalColourScheme().getClass(),
+ TCoffeeColourScheme.class,
+ "Didn't set T-coffee colourscheme for imported project.");
System.out
.println("T-Coffee score shading successfully recovered from project.");
}
String inFile = "examples/uniref50.fa", inAnnot = "examples/testdata/uniref50_iupred.jva";
String tfile = File.createTempFile("JalviewTest", ".jvp")
.getAbsolutePath();
- AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(inFile, DataSourceType.FILE);
- assertNotNull("Didn't read input file " + inFile, af);
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(inFile,
+ DataSourceType.FILE);
+ assertNotNull(af, "Didn't read input file " + inFile);
af.loadJalviewDataFile(inAnnot, DataSourceType.FILE, null, null);
AlignmentAnnotation[] aa = af.getViewport().getAlignment()
.getSequenceAt(0).getAnnotation("IUPredWS (Short)");
assertTrue(
- "Didn't find any IUPred annotation to use to shade alignment.",
- aa != null && aa.length > 0);
+
+ aa != null && aa.length > 0,
+ "Didn't find any IUPred annotation to use to shade alignment.");
AnnotationColourGradient cs = new AnnotationColourGradient(aa[0], null,
AnnotationColourGradient.ABOVE_THRESHOLD);
AnnotationColourGradient gcs = new AnnotationColourGradient(aa[0],
sg.addSequence(af.getViewport().getAlignment().getSequenceAt(1), false);
sg.addSequence(af.getViewport().getAlignment().getSequenceAt(2), true);
af.alignPanel.alignmentChanged();
- assertTrue("Failed to store as a project.",
- af.saveAlignment(tfile, FileFormat.Jalview));
+ assertTrue(af.saveAlignment(tfile, FileFormat.Jalview),
+ "Failed to store as a project.");
af.closeMenuItem_actionPerformed(true);
af = null;
- af = new FileLoader().LoadFileWaitTillLoaded(tfile, DataSourceType.FILE);
- assertTrue("Failed to import new project", af != null);
+ af = new FileLoader()
+ .LoadFileWaitTillLoaded(tfile, DataSourceType.FILE);
+ assertNotNull(af, "Failed to import new project");
// check for group and alignment colourschemes
ColourSchemeI _rcs = af.getViewport().getGlobalColourScheme();
ColourSchemeI _rgcs = af.getViewport().getAlignment().getGroups()
.get(0).getColourScheme();
- assertNotNull("Didn't recover global colourscheme", _rcs);
- assertTrue("Didn't recover annotation colour global scheme",
- _rcs instanceof AnnotationColourGradient);
+ assertNotNull(_rcs, "Didn't recover global colourscheme");
+ assertTrue(_rcs instanceof AnnotationColourGradient,
+ "Didn't recover annotation colour global scheme");
AnnotationColourGradient __rcs = (AnnotationColourGradient) _rcs;
- assertTrue("Annotation colourscheme wasn't sequence associated",
- __rcs.isSeqAssociated());
+ assertTrue(__rcs.isSeqAssociated(),
+ "Annotation colourscheme wasn't sequence associated");
boolean diffseqcols = false, diffgseqcols = false;
SequenceI[] sqs = af.getViewport().getAlignment().getSequencesArray();
diffseqcols = true;
}
}
- assertTrue("Got Different sequence colours", diffseqcols);
+ assertTrue(diffseqcols, "Got Different sequence colours");
System.out
.println("Per sequence colourscheme (Background) successfully applied and recovered.");
- assertNotNull("Didn't recover group colourscheme", _rgcs);
- assertTrue("Didn't recover annotation colour group colourscheme",
- _rgcs instanceof AnnotationColourGradient);
+ assertNotNull(_rgcs, "Didn't recover group colourscheme");
+ assertTrue(_rgcs instanceof AnnotationColourGradient,
+ "Didn't recover annotation colour group colourscheme");
__rcs = (AnnotationColourGradient) _rgcs;
- assertTrue("Group Annotation colourscheme wasn't sequence associated",
- __rcs.isSeqAssociated());
+ assertTrue(__rcs.isSeqAssociated(),
+ "Group Annotation colourscheme wasn't sequence associated");
for (int p = 0, pSize = af.getViewport().getAlignment().getWidth(); p < pSize
&& (!diffseqcols || !diffgseqcols); p++)
diffgseqcols = true;
}
}
- assertTrue("Got Different group sequence colours", diffgseqcols);
+ assertTrue(diffgseqcols, "Got Different group sequence colours");
System.out
.println("Per sequence (Group) colourscheme successfully applied and recovered.");
}
.getAlignFrames().length;
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/exampleFile_2_7.jar", DataSourceType.FILE);
- assertNotNull("Didn't read in the example file correctly.", af);
- assertTrue("Didn't gather the views in the example file.",
- Desktop.getAlignFrames().length == 1 + origCount);
+ assertNotNull(af, "Didn't read in the example file correctly.");
+ assertTrue(Desktop.getAlignFrames().length == 1 + origCount,
+ "Didn't gather the views in the example file.");
}
StructureImportSettings.setVisibleChainAnnotation(true);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/exampleFile_2_7.jar", DataSourceType.FILE);
- assertNotNull("Didn't read in the example file correctly.", af);
+ assertNotNull(af, "Didn't read in the example file correctly.");
AlignmentViewPanel sps = null;
for (AlignmentViewPanel ap : af.alignPanel.alignFrame.getAlignPanels())
{
break;
}
}
- assertNotNull("Couldn't find the structure view", sps);
+ assertNotNull(sps, "Couldn't find the structure view");
AlignmentAnnotation refan = null;
for (AlignmentAnnotation ra : sps.getAlignment()
.getAlignmentAnnotation())
break;
}
}
- assertNotNull("Annotation secondary structure not found.", refan);
+ assertNotNull(refan, "Annotation secondary structure not found.");
SequenceI sq = sps.getAlignment().findName("1A70|");
- assertNotNull("Couldn't find 1a70 null chain", sq);
+ assertNotNull(sq, "Couldn't find 1a70 null chain");
// compare the manually added temperature factor annotation
// to the track automatically transferred from the pdb structure on load
- assertNotNull("1a70 has no annotation", sq.getDatasetSequence()
- .getAnnotation());
+ assertNotNull(sq.getDatasetSequence().getAnnotation(),
+ "1a70 has no annotation");
for (AlignmentAnnotation ala : sq.getDatasetSequence().getAnnotation())
{
AlignmentAnnotation alaa;
try
{
assertTrue(
- "Mismatch at alignment position " + p,
(alaa.annotations[p] == null && refan.annotations[p] == null)
- || alaa.annotations[p].value == refan.annotations[p].value);
+ || alaa.annotations[p].value == refan.annotations[p].value,
+ "Mismatch at alignment position " + p);
} catch (NullPointerException q)
{
Assert.fail("Mismatch of alignment annotations at position "
{
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/exampleFile_2_7.jar", DataSourceType.FILE);
- assertNotNull("Didn't read in the example file correctly.", af);
+ assertNotNull(af, "Didn't read in the example file correctly.");
AlignmentViewPanel sps = null, groups = null;
for (AlignmentViewPanel ap : af.alignPanel.alignFrame.getAlignPanels())
{
groups = ap;
}
}
- assertNotNull("Couldn't find the structure view", sps);
- assertNotNull("Couldn't find the MAFFT view", groups);
+ assertNotNull(sps, "Couldn't find the structure view");
+ assertNotNull(groups, "Couldn't find the MAFFT view");
ViewStyleI structureStyle = sps.getAlignViewport().getViewStyle();
ViewStyleI groupStyle = groups.getAlignViewport().getViewStyle();
// check FileLoader returned a reference to the one alignFrame that is
// actually on the Desktop
- assertTrue(
- "Jalview2XML.loadAlignFrame() didn't return correct AlignFrame reference for multiple view window",
- af == Desktop.getAlignFrameFor(af.getViewport()));
+ assertSame(
+ af,
+ Desktop.getAlignFrameFor(af.getViewport()),
+ "Jalview2XML.loadAlignFrame() didn't return correct AlignFrame reference for multiple view window");
Desktop.explodeViews(af);
{
Assert.assertEquals(Desktop.getAlignFrames().length, 0);
}
- af = new FileLoader().LoadFileWaitTillLoaded(
- tfile.getAbsolutePath(), DataSourceType.FILE);
+ af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(),
+ DataSourceType.FILE);
Assert.assertNotNull(af);
Assert.assertEquals(
Desktop.getAlignFrames().length,
Desktop.instance.closeAll_actionPerformed(null);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/exampleFile_2_7.jar", DataSourceType.FILE);
- assertNotNull("Didn't read in the example file correctly.", af);
+ assertNotNull(af, "Didn't read in the example file correctly.");
String afid = af.getViewport().getSequenceSetId();
// remember reference sequence for each panel
Assert.assertEquals(Desktop.getAlignFrames().length, 0);
}
- af = new FileLoader().LoadFileWaitTillLoaded(
- tfile.getAbsolutePath(), DataSourceType.FILE);
+ af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(),
+ DataSourceType.FILE);
afid = af.getViewport().getSequenceSetId();
for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid))
Desktop.instance.closeAll_actionPerformed(null);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/uniref50.fa", DataSourceType.FILE);
- assertNotNull("Didn't read in the example file correctly.", af);
+ assertNotNull(af, "Didn't read in the example file correctly.");
String afid = af.getViewport().getSequenceSetId();
// make a second view of the alignment
af.newView_actionPerformed(null);
assertSame(repSeq, sg.getSeqrep());
assertTrue(sg.getSequences().contains(repSeq));
assertTrue(sg.getSequences().contains(precedingSeq));
- assertTrue("alignment has groups", alignment.getGroups().isEmpty());
+ assertTrue(alignment.getGroups().isEmpty(), "alignment has groups");
Map<SequenceI, SequenceCollectionI> hiddenRepSeqsMap = av
.getHiddenRepSequences();
assertNotNull(hiddenRepSeqsMap);
{
Assert.assertEquals(Desktop.getAlignFrames().length, 0);
}
-
- af = new FileLoader().LoadFileWaitTillLoaded(
- tfile.getAbsolutePath(), DataSourceType.FILE);
+
+ af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(),
+ DataSourceType.FILE);
afid = af.getViewport().getSequenceSetId();
for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid))
AlignmentI alignment = ap.getAlignment();
List<SequenceGroup> groups = alignment.getGroups();
assertNotNull(groups);
- assertTrue("Alignment has groups", groups.isEmpty());
+ assertTrue(groups.isEmpty(), "Alignment has groups");
Map<SequenceI, SequenceCollectionI> hiddenRepSeqsMap = av
.getHiddenRepSequences();
- assertNotNull("No hidden represented sequences", hiddenRepSeqsMap);
+ assertNotNull(hiddenRepSeqsMap, "No hidden represented sequences");
assertEquals(1, hiddenRepSeqsMap.size());
assertEquals(repSeqs.get(viewName).getDisplayId(true),
hiddenRepSeqsMap.keySet().iterator().next()
List<String> hidden = hiddenSeqNames.get(ap.getViewName());
HiddenSequences hs = alignment.getHiddenSequences();
assertEquals(
+ hidden.size(),
+ hs.getSize(),
"wrong number of restored hidden sequences in "
- + ap.getViewName(), hidden.size(), hs.getSize());
+ + ap.getViewName());
}
}
String exampleFile = "examples/3W5V.pdb";
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(exampleFile,
DataSourceType.FILE);
- assertNotNull("Didn't read in the example file correctly.", af);
+ assertNotNull(af, "Didn't read in the example file correctly.");
String afid = af.getViewport().getSequenceSetId();
AlignmentPanel[] alignPanels = Desktop.getAlignmentPanels(afid);
"Recovered PDBEntry should have a non-null file entry");
}
}
+
+ /**
+ * Configure an alignment and a sub-group each with distinct colour schemes,
+ * Conservation and PID thresholds, and confirm these are restored from the
+ * saved project.
+ *
+ * @throws IOException
+ */
+ @Test(groups = { "Functional" })
+ public void testStoreAndRecoverColourThresholds() throws IOException
+ {
+ Desktop.instance.closeAll_actionPerformed(null);
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+ "examples/uniref50.fa", DataSourceType.FILE);
+
+ AlignViewport av = af.getViewport();
+ AlignmentI al = av.getAlignment();
+
+ /*
+ * Colour alignment by Buried Index, Above 10% PID, By Conservation 20%
+ */
+ af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString());
+ assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme);
+ af.abovePIDThreshold_actionPerformed(true);
+ SliderPanel sp = SliderPanel.getSliderPanel();
+ assertFalse(sp.isForConservation());
+ sp.valueChanged(10);
+ af.conservationMenuItem_actionPerformed(true);
+ sp = SliderPanel.getSliderPanel();
+ assertTrue(sp.isForConservation());
+ sp.valueChanged(20);
+ ResidueShaderI rs = av.getViewportColourScheme();
+ assertEquals(rs.getThreshold(), 10);
+ assertTrue(rs.conservationApplied());
+ assertEquals(rs.getConservationInc(), 20);
+
+ /*
+ * create a group with Strand colouring, 30% Conservation
+ * and 40% PID threshold
+ */
+ SequenceGroup sg = new SequenceGroup();
+ sg.addSequence(al.getSequenceAt(0), false);
+ sg.setStartRes(15);
+ sg.setEndRes(25);
+ av.setSelectionGroup(sg);
+ PopupMenu popupMenu = new PopupMenu(af.alignPanel, null, null);
+ popupMenu.changeColour_actionPerformed(JalviewColourScheme.Strand
+ .toString());
+ assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
+ assertEquals(al.getGroups().size(), 1);
+ assertSame(al.getGroups().get(0), sg);
+ popupMenu.conservationMenuItem_actionPerformed(true);
+ sp = SliderPanel.getSliderPanel();
+ assertTrue(sp.isForConservation());
+ sp.valueChanged(30);
+ popupMenu.abovePIDColour_actionPerformed(true);
+ sp = SliderPanel.getSliderPanel();
+ assertFalse(sp.isForConservation());
+ sp.valueChanged(40);
+ assertTrue(sg.getGroupColourScheme().conservationApplied());
+ assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
+ assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
+
+ /*
+ * save project, close windows, reload project, verify
+ */
+ File tfile = File.createTempFile("testStoreAndRecoverColourThresholds",
+ ".jvp");
+ tfile.deleteOnExit();
+ new Jalview2XML(false).saveState(tfile);
+ Desktop.instance.closeAll_actionPerformed(null);
+ af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(),
+ DataSourceType.FILE);
+ Assert.assertNotNull(af, "Failed to reload project");
+
+ /*
+ * verify alignment (background) colouring
+ */
+ rs = af.getViewport().getViewportColourScheme();
+ assertTrue(rs.getColourScheme() instanceof BuriedColourScheme);
+ assertEquals(rs.getThreshold(), 10);
+ assertTrue(rs.conservationApplied());
+ assertEquals(rs.getConservationInc(), 20);
+
+ /*
+ * verify group colouring
+ */
+ assertEquals(1, af.getViewport().getAlignment().getGroups().size(), 1);
+ rs = af.getViewport().getAlignment().getGroups().get(0)
+ .getGroupColourScheme();
+ assertTrue(rs.getColourScheme() instanceof StrandColourScheme);
+ assertEquals(rs.getThreshold(), 40);
+ assertTrue(rs.conservationApplied());
+ assertEquals(rs.getConservationInc(), 30);
+ }
}
public class JalviewFileViewTest
{
- @Test
+ @Test(groups = "Functional")
public void testGetImageIcon()
{
JalviewFileView jfv = new JalviewFileView();
assertNull(jfv.getImageIcon("images/file.png"));
}
- @Test
+ @Test(groups = "Functional")
public void testGetExtension()
{
assertEquals(JalviewFileView.getExtension(new File("text.txt")), "txt");
"/a/longer/file/path/text")));
}
- @Test
+ @Test(groups = "Functional")
public void testGetTypeDescription()
{
JalviewFileView jfw = new JalviewFileView();
public class ScaleRendererTest
{
- @Test
+ @Test(groups = "Functional")
public void testCalculateMarks()
{
String data = ">Seq/20-45\nABCDEFGHIJKLMNOPQRSTUVWXYS\n";
* <li>case insensitive matching</li>
* <ul>
*/
- @Test
+ @Test(groups = "Functional")
public void testFindColour()
{
ColourSchemeI scheme = new PIDColourScheme();
* option on the annotation label popup menu) results in a change to the
* colouring
*/
- @Test
+ @Test(groups = "Functional")
public void testFindColour_ignoreGaps()
{
/*