2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.structure;
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertTrue;
26 import jalview.datamodel.AlignedCodonFrame;
27 import jalview.datamodel.Sequence;
28 import jalview.datamodel.SequenceFeature;
29 import jalview.datamodel.SequenceI;
30 import jalview.io.FormatAdapter;
32 import java.util.HashSet;
35 import org.testng.annotations.BeforeMethod;
36 import org.testng.annotations.Test;
38 import MCview.PDBfile;
40 public class StructureSelectionManagerTest
42 private StructureSelectionManager ssm;
44 @BeforeMethod(alwaysRun = true)
47 ssm = new StructureSelectionManager();
50 @Test(groups = { "Functional" })
51 public void testRegisterMapping()
53 AlignedCodonFrame acf1 = new AlignedCodonFrame();
54 AlignedCodonFrame acf2 = new AlignedCodonFrame();
56 ssm.registerMapping(acf1);
57 assertEquals(1, ssm.seqmappings.size());
58 assertTrue(ssm.seqmappings.contains(acf1));
60 ssm.registerMapping(acf2);
61 assertEquals(2, ssm.seqmappings.size());
62 assertTrue(ssm.seqmappings.contains(acf1));
63 assertTrue(ssm.seqmappings.contains(acf2));
66 * Re-adding the first mapping does nothing
68 ssm.registerMapping(acf1);
69 assertEquals(2, ssm.seqmappings.size());
70 assertTrue(ssm.seqmappings.contains(acf1));
71 assertTrue(ssm.seqmappings.contains(acf2));
74 @Test(groups = { "Functional" })
75 public void testRegisterMappings()
77 AlignedCodonFrame acf1 = new AlignedCodonFrame();
78 AlignedCodonFrame acf2 = new AlignedCodonFrame();
79 AlignedCodonFrame acf3 = new AlignedCodonFrame();
81 Set<AlignedCodonFrame> set1 = new HashSet<AlignedCodonFrame>();
84 Set<AlignedCodonFrame> set2 = new HashSet<AlignedCodonFrame>();
89 * Add both sets twice; each mapping should be added once only
91 ssm.registerMappings(set1);
92 ssm.registerMappings(set1);
93 ssm.registerMappings(set2);
94 ssm.registerMappings(set2);
96 assertEquals(3, ssm.seqmappings.size());
97 assertTrue(ssm.seqmappings.contains(acf1));
98 assertTrue(ssm.seqmappings.contains(acf2));
99 assertTrue(ssm.seqmappings.contains(acf3));
103 * Verify that RESNUM sequence features are present after creating a PDB
106 @Test(groups = { "Functional" })
107 public void testSetMapping_seqFeatures()
109 SequenceI seq = new Sequence(
111 "ATYNVKLITPEGEVELQVPDDVYILDQAEEDGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSYLDDGQIADGWVLTCHAYPTSDVVIETHKEEELTGA");
112 StructureSelectionManager sm = new StructureSelectionManager();
113 sm.setProcessSecondaryStructure(true);
114 sm.setAddTempFacAnnot(true);
115 PDBfile pmap = sm.setMapping(true, new SequenceI[] { seq },
116 new String[] { null }, "examples/1gaq.txt", FormatAdapter.FILE);
117 assertTrue(pmap != null);
119 assertEquals(3, pmap.getSeqs().size());
120 assertEquals("1GAQ|A", pmap.getSeqs().get(0).getName());
121 assertEquals("1GAQ|B", pmap.getSeqs().get(1).getName());
122 assertEquals("1GAQ|C", pmap.getSeqs().get(2).getName());
125 * Verify a RESNUM sequence feature in the PDBfile sequence
127 SequenceFeature sf = pmap.getSeqs().get(0).getSequenceFeatures()[0];
128 assertEquals("RESNUM", sf.getType());
129 assertEquals("1gaq", sf.getFeatureGroup());
130 assertEquals("GLU: 19 1gaqA", sf.getDescription());
133 * Verify a RESNUM sequence feature in the StructureSelectionManager mapped
136 StructureMapping map = sm.getMapping("examples/1gaq.txt")[0];
137 sf = map.sequence.getSequenceFeatures()[0];
138 assertEquals("RESNUM", sf.getType());
139 assertEquals("1gaq", sf.getFeatureGroup());
140 assertEquals("ALA: 1 1gaqB", sf.getDescription());