// TODO: JAL-2227 - import mmCIF PISA assembly & identify master/copy chains
- @Test(groups= {"Functional"})
+ @Test(groups = { "Functional" })
public void testImportPDBPreservesChainMappings() throws IOException
{
AlignmentI importedAl = new jalview.io.FormatAdapter().readFile(
// pasted files,
// see JAL-623 - pasting is still not correctly handled...
PDBEntry importedPDB = new PDBEntry("3A6S", "", Type.PDB, "Paste");
- AAStructureBindingModel binder = newBindingModel(new PDBEntry[]
+ AAStructureBindingModel binder = newBindingModel(
+ new PDBEntry[]
{ importedPDB },
new SequenceI[][]
{ importedAl.getSequencesArray() },
assertEquals(chains[0][0], "A");
assertEquals(chains[0][1], "B");
}
+
AAStructureBindingModel testee;
AlignmentI al = null;
* @param pdbFiles
* @param seqs
* @param ssm
- * @param alignPanel
+ * @param alignPanel
*/
protected AAStructureBindingModel newBindingModel(PDBEntry[] pdbFiles,
- SequenceI[][] seqs,
- StructureSelectionManager ssm, AlignmentViewPanel avp)
+ SequenceI[][] seqs, StructureSelectionManager ssm,
+ AlignmentViewPanel avp)
{
AAStructureBindingModel model = new AAStructureBindingModel(ssm,
pdbFiles, seqs, null)
}
@Override
- public SequenceRenderer getSequenceRenderer(
- AlignmentViewPanel avp)
+ public SequenceRenderer getSequenceRenderer(AlignmentViewPanel avp)
{
return avp == null ? null
- : new jalview.gui.SequenceRenderer(
- avp.getAlignViewport());
+ : new jalview.gui.SequenceRenderer(avp.getAlignViewport());
}
@Override
/*
* create a data bean to hold data per structure file
*/
- AAStructureBindingModel.SuperposeData[] structs = new AAStructureBindingModel.SuperposeData[testee.getStructureFiles().length];
+ AAStructureBindingModel.SuperposeData[] structs = new AAStructureBindingModel.SuperposeData[testee
+ .getStructureFiles().length];
for (int i = 0; i < structs.length; i++)
{
- structs[i] = new AAStructureBindingModel.SuperposeData(al.getWidth(), "0");
+ structs[i] = new AAStructureBindingModel.SuperposeData(al.getWidth(),
+ "0");
}
/*
* initialise BitSet of 'superposable columns' to true (would be false for
matched.set(i);
}
- int refStructure = testee
- .findSuperposableResidues(al, matched, structs);
+ int refStructure = testee.findSuperposableResidues(al, matched,
+ structs);
assertEquals(refStructure, 0);
@Test(groups = { "Functional" })
public void testFindSuperposableResidues_hiddenColumn()
{
- AAStructureBindingModel.SuperposeData[] structs = new AAStructureBindingModel.SuperposeData[al.getHeight()];
+ AAStructureBindingModel.SuperposeData[] structs = new AAStructureBindingModel.SuperposeData[al
+ .getHeight()];
for (int i = 0; i < structs.length; i++)
{
- structs[i] = new AAStructureBindingModel.SuperposeData(al.getWidth(), "0");
+ structs[i] = new AAStructureBindingModel.SuperposeData(al.getWidth(),
+ "0");
}
/*
* initialise BitSet of 'superposable columns' to true (would be false for
// treat column 5 of the alignment as hidden
matched.clear(4);
- int refStructure = testee
- .findSuperposableResidues(al, matched, structs);
+ int refStructure = testee.findSuperposableResidues(al, matched,
+ structs);
assertEquals(refStructure, 0);
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
*/
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 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");
+ assertEquals(helper.getAtomSpec(atomSpec, false),
+ "#0:23-25.A|#1:23-25.B");
/*
* S and G are both coloured #4949b6, structure residues 26-30
assertEquals(helper.getAtomSpec(atomSpec, false),
"#0:26-30.A|#1:26-30.B");
}
+
+ @Test(groups = { "Functional" })
+ public void testGetShownResidues()
+ {
+ /*
+ * load these sequences, with columns 2-4 (third, fourth, fifth) hidden
+ */
+ String fasta = ">seq1/12-21\nMHRSQSSSGG\n>seq2/12-21\nMVRSNGGSSS";
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(fasta,
+ DataSourceType.PASTE);
+ AlignmentI al = af.getViewport().getAlignment();
+ 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 12-21 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 + 11, 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);
+
+ /*
+ * with hidden columns shown on structure
+ */
+ binding.setShowAlignmentOnly(true);
+ AtomSpecModel model = binding.getShownResidues(af.getViewport());
+ assertEquals(model.getModelCount(), 2);
+ int modelNo = 0;
+ for (String modelId : model.getModels())
+ {
+ assertEquals(modelId, String.valueOf(modelNo));
+ Iterable<String> chains = model.getChains(modelId);
+ String expectedChain = (modelNo == 0) ? "A" : "B";
+ for (String chain : chains)
+ {
+ assertEquals(chain, expectedChain);
+ List<int[]> ranges = model.getRanges(modelId, chain);
+ assertEquals(ranges.size(), 1);
+ assertEquals(ranges.get(0)[0], 21);
+ assertEquals(ranges.get(0)[1], 30);
+ }
+ modelNo++;
+ }
+
+ /*
+ * with hidden columns hidden on structure
+ * columns 2-4 correspond to residues 23-25 on structure - now omitted
+ */
+ binding.setHideHiddenRegions(true);
+ model = binding.getShownResidues(af.getViewport());
+ assertEquals(model.getModelCount(), 2);
+ modelNo = 0;
+ for (String modelId : model.getModels())
+ {
+ assertEquals(modelId, String.valueOf(modelNo));
+ Iterable<String> chains = model.getChains(modelId);
+ String expectedChain = (modelNo == 0) ? "A" : "B";
+ for (String chain : chains)
+ {
+ assertEquals(chain, expectedChain);
+ List<int[]> ranges = model.getRanges(modelId, chain);
+ assertEquals(ranges.size(), 2);
+ assertEquals(ranges.get(0)[0], 21);
+ assertEquals(ranges.get(0)[1], 22);
+ assertEquals(ranges.get(1)[0], 26);
+ assertEquals(ranges.get(1)[1], 30);
+ }
+ modelNo++;
+ }
+ }
}
\ No newline at end of file