1 package jalview.structure;
3 import static org.testng.AssertJUnit.assertEquals;
4 import static org.testng.AssertJUnit.assertTrue;
6 import jalview.datamodel.AlignedCodonFrame;
7 import jalview.datamodel.Sequence;
8 import jalview.datamodel.SequenceFeature;
9 import jalview.datamodel.SequenceI;
10 import jalview.io.FormatAdapter;
12 import java.util.HashSet;
15 import org.testng.annotations.BeforeMethod;
16 import org.testng.annotations.Test;
18 import MCview.PDBfile;
20 public class StructureSelectionManagerTest
22 private StructureSelectionManager ssm;
24 @BeforeMethod(alwaysRun = true)
27 ssm = new StructureSelectionManager();
30 @Test(groups ={ "Functional" })
31 public void testRegisterMapping()
33 AlignedCodonFrame acf1 = new AlignedCodonFrame();
34 AlignedCodonFrame acf2 = new AlignedCodonFrame();
36 ssm.registerMapping(acf1);
37 assertEquals(1, ssm.seqmappings.size());
38 assertTrue(ssm.seqmappings.contains(acf1));
40 ssm.registerMapping(acf2);
41 assertEquals(2, ssm.seqmappings.size());
42 assertTrue(ssm.seqmappings.contains(acf1));
43 assertTrue(ssm.seqmappings.contains(acf2));
46 * Re-adding the first mapping does nothing
48 ssm.registerMapping(acf1);
49 assertEquals(2, ssm.seqmappings.size());
50 assertTrue(ssm.seqmappings.contains(acf1));
51 assertTrue(ssm.seqmappings.contains(acf2));
54 @Test(groups ={ "Functional" })
55 public void testRegisterMappings()
57 AlignedCodonFrame acf1 = new AlignedCodonFrame();
58 AlignedCodonFrame acf2 = new AlignedCodonFrame();
59 AlignedCodonFrame acf3 = new AlignedCodonFrame();
61 Set<AlignedCodonFrame> set1 = new HashSet<AlignedCodonFrame>();
64 Set<AlignedCodonFrame> set2 = new HashSet<AlignedCodonFrame>();
69 * Add both sets twice; each mapping should be added once only
71 ssm.registerMappings(set1);
72 ssm.registerMappings(set1);
73 ssm.registerMappings(set2);
74 ssm.registerMappings(set2);
76 assertEquals(3, ssm.seqmappings.size());
77 assertTrue(ssm.seqmappings.contains(acf1));
78 assertTrue(ssm.seqmappings.contains(acf2));
79 assertTrue(ssm.seqmappings.contains(acf3));
83 * Verify that RESNUM sequence features are present after creating a PDB
86 @Test(groups = { "Functional" })
87 public void testSetMapping_seqFeatures()
89 SequenceI seq = new Sequence(
91 "ATYNVKLITPEGEVELQVPDDVYILDQAEEDGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSYLDDGQIADGWVLTCHAYPTSDVVIETHKEEELTGA");
92 StructureSelectionManager sm = new StructureSelectionManager();
93 sm.setProcessSecondaryStructure(true);
94 sm.setAddTempFacAnnot(true);
95 PDBfile pmap = sm.setMapping(true, new SequenceI[] { seq },
96 new String[] { null }, "examples/1gaq.txt",
98 assertTrue(pmap != null);
100 assertEquals(3, pmap.getSeqs().size());
101 assertEquals("1GAQ|A", pmap.getSeqs().get(0).getName());
102 assertEquals("1GAQ|B", pmap.getSeqs().get(1).getName());
103 assertEquals("1GAQ|C", pmap.getSeqs().get(2).getName());
106 * Verify a RESNUM sequence feature in the PDBfile sequence
108 SequenceFeature sf = pmap.getSeqs().get(0).getSequenceFeatures()[0];
109 assertEquals("RESNUM", sf.getType());
110 assertEquals("1gaq", sf.getFeatureGroup());
111 assertEquals("GLU: 19 1gaqA", sf.getDescription());
114 * Verify a RESNUM sequence feature in the StructureSelectionManager mapped
117 StructureMapping map = sm.getMapping("examples/1gaq.txt")[0];
118 sf = map.sequence.getSequenceFeatures()[0];
119 assertEquals("RESNUM", sf.getType());
120 assertEquals("1gaq", sf.getFeatureGroup());
121 assertEquals("ALA: 1 1gaqB", sf.getDescription());