+ assertFalse(matched.get(0));
+ assertTrue(matched.get(1));
+ assertFalse(matched.get(2));
+ assertFalse(matched.get(3));
+ assertFalse(matched.get(4)); // superposable, but hidden, column
+ assertTrue(matched.get(5));
+ }
+
+ @Test(groups = { "Functional" })
+ public void testBuildColoursMap()
+ {
+ /*
+ * load these sequences, coloured by Strand propensity,
+ * with columns 2-4 hidden
+ */
+ String fasta = ">seq1\nMHRSQSSSGG\n>seq2\nMVRSNGGSSS";
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(fasta,
+ DataSourceType.PASTE);
+ AlignmentI al = af.getViewport().getAlignment();
+ af.changeColour_actionPerformed(JalviewColourScheme.Strand.toString());
+ ColumnSelection cs = new ColumnSelection();
+ cs.addElement(2);
+ cs.addElement(3);
+ cs.addElement(4);
+ af.getViewport().setColumnSelection(cs);
+ af.hideSelColumns_actionPerformed(null);
+ SequenceI seq1 = al.getSequenceAt(0);
+ SequenceI seq2 = al.getSequenceAt(1);
+ SequenceI[][] seqs = new SequenceI[][] { { seq1 }, { seq2 } };
+ PDBEntry[] pdbFiles = new PDBEntry[2];
+ pdbFiles[0] = new PDBEntry("PDB1", "A", Type.PDB, "seq1.pdb");
+ pdbFiles[1] = new PDBEntry("PDB2", "B", Type.PDB, "seq2.pdb");
+ StructureSelectionManager ssm = new StructureSelectionManager();
+
+ /*
+ * map residues 1-10 to residues 21-30 (atoms 105-150) in structures
+ */
+ HashMap<Integer, int[]> map = new HashMap<>();
+ for (int pos = 1; pos <= seq1.getLength(); pos++)
+ {
+ map.put(pos, new int[] { 20 + pos, 5 * (20 + pos) });
+ }
+ StructureMapping sm1 = new StructureMapping(seq1, "seq1.pdb", "pdb1",
+ "A", map, null);
+ ssm.addStructureMapping(sm1);
+ StructureMapping sm2 = new StructureMapping(seq2, "seq2.pdb", "pdb2",
+ "B", map, null);
+ ssm.addStructureMapping(sm2);
+
+ AAStructureBindingModel binding = newBindingModel(pdbFiles, seqs, ssm,
+ af.alignPanel);
+
+ /*
+ * method under test builds a map of structures residues by colour
+ * verify the map holds what it should
+ */
+ Map<Object, AtomSpecModel> colours = binding.buildColoursMap(ssm, seqs,
+ af.alignPanel);
+ ChimeraCommands helper = new ChimeraCommands();
+
+ /*
+ * M colour is #82827d (see strand.html help page)
+ * sequence residue 1 mapped to structure residue 21
+ */
+ Color mColor = new Color(0x82827d);
+ AtomSpecModel atomSpec = colours.get(mColor);
+ assertNotNull(atomSpec);
+ assertEquals(helper.getAtomSpec(atomSpec, false), "#0:21.A|#1:21.B");
+
+ /*
+ * H colour is #60609f, seq1.2 mapped to structure 0 residue 22
+ */
+ Color hColor = new Color(0x60609f);
+ atomSpec = colours.get(hColor);
+ assertNotNull(atomSpec);
+ assertEquals(helper.getAtomSpec(atomSpec, false), "#0:22.A");
+
+ /*
+ * V colour is #ffff00, seq2.2 mapped to structure 1 residue 22
+ */
+ Color vColor = new Color(0xffff00);
+ atomSpec = colours.get(vColor);
+ assertNotNull(atomSpec);
+ assertEquals(helper.getAtomSpec(atomSpec, false), "#1:22.B");
+
+ /*
+ * hidden columns are Gray (128, 128, 128)
+ * sequence positions 3-5 mapped to structure residues 23-25
+ */
+ Color gray = new Color(128, 128, 128);
+ atomSpec = colours.get(gray);
+ assertNotNull(atomSpec);
+ assertEquals(helper.getAtomSpec(atomSpec, false), "#0:23-25.A|#1:23-25.B");
+
+ /*
+ * S and G are both coloured #4949b6, structure residues 26-30
+ */
+ Color sgColour = new Color(0x4949b6);
+ atomSpec = colours.get(sgColour);
+ assertNotNull(atomSpec);
+ assertEquals(helper.getAtomSpec(atomSpec, false),
+ "#0:26-30.A|#1:26-30.B");