/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b1)
- * Copyright (C) 2015 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
import jalview.datamodel.Annotation;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FormatAdapter;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JPanel;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
*/
public class AnnotationChooserTest
{
+
+ @BeforeClass(alwaysRun = true)
+ public void setUpJvOptionPane()
+ {
+ JvOptionPane.setInteractiveMode(false);
+ JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+ }
+
// 4 sequences x 13 positions
final static String TEST_DATA = ">FER_CAPAA Ferredoxin\n"
+ "TIETHKEAELVG-\n"
@BeforeMethod(alwaysRun = true)
public void setUp() throws IOException
{
+ Cache.loadProperties("test/jalview/io/testProps.jvprops");
// pin down annotation sort order for test
- Cache.applicationProperties.setProperty(Preferences.SORT_ANNOTATIONS,
+ Cache.setPropertyNoSave(Preferences.SORT_ANNOTATIONS,
SequenceAnnotationOrder.NONE.name());
final String TRUE = Boolean.TRUE.toString();
- Cache.applicationProperties.setProperty(
+ Cache.setPropertyNoSave(
Preferences.SHOW_AUTOCALC_ABOVE, TRUE);
- Cache.applicationProperties.setProperty("SHOW_QUALITY", TRUE);
- Cache.applicationProperties.setProperty("SHOW_CONSERVATION", TRUE);
- Cache.applicationProperties.setProperty("SHOW_IDENTITY", TRUE);
+ Cache.setPropertyNoSave("SHOW_QUALITY", TRUE);
+ Cache.setPropertyNoSave("SHOW_CONSERVATION", TRUE);
+ Cache.setPropertyNoSave("SHOW_IDENTITY", TRUE);
- AlignmentI al = new jalview.io.FormatAdapter().readFile(TEST_DATA,
- AppletFormatAdapter.PASTE, "FASTA");
+ AlignmentI al = new FormatAdapter().readFile(TEST_DATA,
+ DataSourceType.PASTE, FileFormat.Fasta);
af = new AlignFrame(al, 700, 500);
parentPanel = new AlignmentPanel(af, af.getViewport());
addAnnotations();
types = AnnotationChooser.getAnnotationTypes(
parentPanel.getAlignment(), false);
- assertEquals("Not six annotation types", 6, types.size());
+ assertEquals("Not six annotation types", 7, types.size());
assertTrue("IUPRED missing", types.contains("IUPRED"));
assertTrue("JMol missing", types.contains("JMol"));
assertTrue("Beauty missing", types.contains("Beauty"));
assertTrue("Consensus missing", types.contains("Consensus"));
assertTrue("Quality missing", types.contains("Quality"));
assertTrue("Conservation missing", types.contains("Conservation"));
+ assertTrue("Occupancy missing", types.contains("Occupancy"));
}
/**
AlignmentAnnotation[] anns = parentPanel.getAlignment()
.getAlignmentAnnotation();
- assertTrue(anns[5].visible); // JMol for seq3
- assertTrue(anns[7].visible); // JMol for seq1
+ int autocalc = countAutocalc(anns);
+ assertTrue(anns[autocalc + 2].visible); // JMol for seq3
+ assertTrue(anns[autocalc + 4].visible); // JMol for seq1
setSelected(getTypeCheckbox("JMol"), true);
assertTrue(anns[0].visible); // Conservation
assertTrue(anns[1].visible); // Quality
assertTrue(anns[2].visible); // Consensus
- assertTrue(anns[3].visible); // IUPred for seq0
- assertTrue(anns[4].visible); // Beauty
- assertFalse(anns[5].visible); // JMol for seq3 - not selected but hidden
- assertTrue(anns[6].visible); // IUPRED for seq2
- assertFalse(anns[7].visible); // JMol for seq1 - selected and hidden
+ assertTrue(anns[3].visible); // Occupancy
+ assertTrue(anns[4].visible); // IUPred for seq0
+ assertTrue(anns[5].visible); // Beauty
+ assertFalse(anns[6].visible); // JMol for seq3 - not selected but hidden
+ assertTrue(anns[7].visible); // IUPRED for seq2
+ assertFalse(anns[8].visible); // JMol for seq1 - selected and hidden
}
/**
AlignmentAnnotation[] anns = parentPanel.getAlignment()
.getAlignmentAnnotation();
- assertTrue(anns[7].visible); // JMol for seq1
+ int autocalc = countAutocalc(anns);
+ assertTrue(anns[autocalc + 4].visible); // JMol for seq1
setSelected(getTypeCheckbox("JMol"), true);
assertTrue(anns[0].visible); // Conservation
assertTrue(anns[1].visible); // Quality
assertTrue(anns[2].visible); // Consensus
- assertTrue(anns[3].visible); // IUPred for seq0
- assertTrue(anns[4].visible); // Beauty
- assertTrue(anns[5].visible); // JMol for seq3 not in selection group
- assertTrue(anns[6].visible); // IUPRED for seq2
- assertFalse(anns[7].visible); // JMol for seq1 in selection group
+ assertTrue(anns[3].visible); // Occupancy
+ assertTrue(anns[4].visible); // IUPred for seq0
+ assertTrue(anns[5].visible); // Beauty
+ assertTrue(anns[6].visible); // JMol for seq3 not in selection group
+ assertTrue(anns[7].visible); // IUPRED for seq2
+ assertFalse(anns[8].visible); // JMol for seq1 in selection group
}
/**
// select JMol - all hidden
setSelected(typeCheckbox, true);
- assertFalse(anns[5].visible); // JMol for seq3
- assertFalse(anns[7].visible); // JMol for seq1
+ int autocalc = countAutocalc(anns);
+ assertFalse(anns[autocalc + 2].visible); // JMol for seq3
+ assertFalse(anns[autocalc + 4].visible); // JMol for seq1
// deselect JMol - all unhidden
setSelected(typeCheckbox, false);
- assertTrue(anns[0].visible); // Conservation
- assertTrue(anns[1].visible); // Quality
- assertTrue(anns[2].visible); // Consensus
- assertTrue(anns[3].visible); // IUPred for seq0
- assertTrue(anns[4].visible); // Beauty
- assertTrue(anns[5].visible); // JMol for seq3
- assertTrue(anns[6].visible); // IUPRED for seq2
- assertTrue(anns[7].visible); // JMol for seq1
+ for (AlignmentAnnotation ann : anns)
+ {
+ assertTrue(ann.visible);
+ }
+ }
+
+ /**
+ * Returns a count of autocalculated annotations in the set provided
+ *
+ * @param anns
+ * @return
+ */
+ private int countAutocalc(AlignmentAnnotation[] anns)
+ {
+ int count = 0;
+ for (AlignmentAnnotation ann : anns)
+ {
+ if (ann.autoCalculated)
+ {
+ count++;
+ }
+ }
+ return count;
}
/**
setSelected(allSequencesCheckbox, true);
setSelected(hideCheckbox, true);
setSelected(getTypeCheckbox("JMol"), true);
- assertFalse(anns[5].visible); // JMol for seq3
- assertFalse(anns[7].visible); // JMol for seq1
+ int autocalc = countAutocalc(anns);
+ assertFalse(anns[autocalc + 2].visible); // JMol for seq3
+ assertFalse(anns[autocalc + 4].visible); // JMol for seq1
// ...now show them...
setSelected(showCheckbox, true);
- assertTrue(anns[0].visible); // Conservation
- assertTrue(anns[1].visible); // Quality
- assertTrue(anns[2].visible); // Consensus
- assertTrue(anns[3].visible); // IUPred for seq0
- assertTrue(anns[4].visible); // Beauty
- assertTrue(anns[5].visible); // JMol for seq3
- assertTrue(anns[6].visible); // IUPRED for seq2
- assertTrue(anns[7].visible); // JMol for seq1
+ for (AlignmentAnnotation ann : anns)
+ {
+ assertTrue(ann.visible);
+ }
}
/**
setSelected(hideCheckbox, true);
setSelected(getTypeCheckbox("JMol"), true);
- assertTrue(anns[5].visible); // JMol for seq3
- assertFalse(anns[7].visible); // JMol for seq1
+ int autocalc = countAutocalc(anns);
+ assertTrue(anns[autocalc + 2].visible); // JMol for seq3
+ assertFalse(anns[autocalc + 4].visible); // JMol for seq1
// ...now show them...
setSelected(showCheckbox, true);
- assertTrue(anns[0].visible); // Conservation
- assertTrue(anns[1].visible); // Quality
- assertTrue(anns[2].visible); // Consensus
- assertTrue(anns[3].visible); // IUPred for seq0
- assertTrue(anns[4].visible); // Beauty
- assertTrue(anns[5].visible); // JMol for seq3
- assertTrue(anns[6].visible); // IUPRED for seq2
- assertTrue(anns[7].visible); // JMol for seq1
+ for (AlignmentAnnotation ann : anns)
+ {
+ assertTrue(ann.visible);
+ }
}
/**
final Checkbox typeCheckbox = getTypeCheckbox("JMol");
// select JMol - all shown
setSelected(typeCheckbox, true);
- assertTrue(anns[5].visible); // JMol for seq3
- assertTrue(anns[7].visible); // JMol for seq1
+ int autocalc = countAutocalc(anns);
+ assertTrue(anns[autocalc + 2].visible); // JMol for seq3
+ assertTrue(anns[autocalc + 4].visible); // JMol for seq1
// deselect JMol - all hidden
setSelected(typeCheckbox, false);
assertTrue(anns[0].visible); // Conservation
assertTrue(anns[1].visible); // Quality
assertTrue(anns[2].visible); // Consensus
- assertTrue(anns[3].visible); // IUPred for seq0
- assertTrue(anns[4].visible); // Beauty
- assertFalse(anns[5].visible); // JMol for seq3
- assertTrue(anns[6].visible); // IUPRED for seq2
- assertFalse(anns[7].visible); // JMol for seq1
+ assertTrue(anns[3].visible); // Occupancy
+ assertTrue(anns[4].visible); // IUPred for seq0
+ assertTrue(anns[5].visible); // Beauty
+ assertFalse(anns[6].visible); // JMol for seq3
+ assertTrue(anns[7].visible); // IUPRED for seq2
+ assertFalse(anns[8].visible); // JMol for seq1
}
/**
// select JMol - should remain visible
setSelected(getTypeCheckbox("JMol"), true);
- assertTrue(anns[5].visible); // JMol for seq3
- assertTrue(anns[7].visible); // JMol for seq1
+ int autocalc = countAutocalc(anns);
+ assertTrue(anns[autocalc + 2].visible); // JMol for seq3
+ assertTrue(anns[autocalc + 4].visible); // JMol for seq1
// deselect JMol - should be hidden for selected sequences only
setSelected(getTypeCheckbox("JMol"), false);
assertTrue(anns[0].visible); // Conservation
assertTrue(anns[1].visible); // Quality
assertTrue(anns[2].visible); // Consensus
- assertTrue(anns[3].visible); // IUPred for seq0
- assertTrue(anns[4].visible); // Beauty
- assertTrue(anns[5].visible); // JMol for seq3 not in selection group
- assertTrue(anns[6].visible); // IUPRED for seq2
- assertFalse(anns[7].visible); // JMol for seq1 in selection group
+ assertTrue(anns[3].visible); // Occupancy
+ assertTrue(anns[4].visible); // IUPred for seq0
+ assertTrue(anns[5].visible); // Beauty
+ assertTrue(anns[6].visible); // JMol for seq3 not in selection group
+ assertTrue(anns[7].visible); // IUPRED for seq2
+ assertFalse(anns[8].visible); // JMol for seq1 in selection group
}
/**
AlignmentAnnotation[] anns = parentPanel.getAlignment()
.getAlignmentAnnotation();
- // remember 3 annotations to skip (Conservation/Quality/Consensus)
- assertFalse(testee.isInActionScope(anns[3]));
- assertFalse(testee.isInActionScope(anns[4]));
- assertFalse(testee.isInActionScope(anns[5]));
- assertTrue(testee.isInActionScope(anns[6]));
- assertTrue(testee.isInActionScope(anns[7]));
+ int autocalc = countAutocalc(anns);
+ assertFalse(testee.isInActionScope(anns[autocalc]));
+ assertFalse(testee.isInActionScope(anns[autocalc + 1]));
+ assertFalse(testee.isInActionScope(anns[autocalc + 2]));
+ assertTrue(testee.isInActionScope(anns[autocalc + 3]));
+ assertTrue(testee.isInActionScope(anns[autocalc + 4]));
}
/**
AlignmentAnnotation[] anns = parentPanel.getAlignment()
.getAlignmentAnnotation();
- // remember 3 annotations to skip (Conservation/Quality/Consensus)
- assertTrue(testee.isInActionScope(anns[3]));
- assertTrue(testee.isInActionScope(anns[4]));
- assertTrue(testee.isInActionScope(anns[5]));
- assertFalse(testee.isInActionScope(anns[6]));
- assertFalse(testee.isInActionScope(anns[7]));
+ int autocalc = countAutocalc(anns);
+ assertTrue(testee.isInActionScope(anns[autocalc]));
+ assertTrue(testee.isInActionScope(anns[autocalc + 1]));
+ assertTrue(testee.isInActionScope(anns[autocalc + 2]));
+ assertFalse(testee.isInActionScope(anns[autocalc + 3]));
+ assertFalse(testee.isInActionScope(anns[autocalc + 4]));
}
/**
assertTrue(anns[0].visible); // Conservation
assertTrue(anns[1].visible); // Quality
assertTrue(anns[2].visible); // Consensus
- assertFalse(anns[3].visible); // IUPRED
- assertTrue(anns[4].visible); // Beauty (not seq-related)
- assertFalse(anns[5].visible); // JMol
- assertFalse(anns[6].visible); // IUPRED
- assertFalse(anns[7].visible); // JMol
+ assertTrue(anns[3].visible); // Occupancy
+ assertFalse(anns[4].visible); // IUPRED
+ assertTrue(anns[5].visible); // Beauty (not seq-related)
+ assertFalse(anns[6].visible); // JMol
+ assertFalse(anns[7].visible); // IUPRED
+ assertFalse(anns[8].visible); // JMol
// reset - should all be visible
testee.resetOriginalState();