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;
31 import jalview.io.StructureFile;
33 import java.util.ArrayList;
34 import java.util.List;
36 import org.testng.annotations.BeforeMethod;
37 import org.testng.annotations.Test;
39 public class StructureSelectionManagerTest
41 private StructureSelectionManager ssm;
43 @BeforeMethod(alwaysRun = true)
46 ssm = new StructureSelectionManager();
49 @Test(groups = { "Functional" })
50 public void testRegisterMapping()
52 AlignedCodonFrame acf1 = new AlignedCodonFrame();
53 AlignedCodonFrame acf2 = new AlignedCodonFrame();
55 ssm.registerMapping(acf1);
56 assertEquals(1, ssm.getSequenceMappings().size());
57 assertTrue(ssm.getSequenceMappings().contains(acf1));
59 ssm.registerMapping(acf2);
60 assertEquals(2, ssm.getSequenceMappings().size());
61 assertTrue(ssm.getSequenceMappings().contains(acf1));
62 assertTrue(ssm.getSequenceMappings().contains(acf2));
65 * Re-adding the first mapping does nothing
67 ssm.registerMapping(acf1);
68 assertEquals(2, ssm.getSequenceMappings().size());
69 assertTrue(ssm.getSequenceMappings().contains(acf1));
70 assertTrue(ssm.getSequenceMappings().contains(acf2));
73 @Test(groups = { "Functional" })
74 public void testRegisterMappings()
76 AlignedCodonFrame acf1 = new AlignedCodonFrame();
77 AlignedCodonFrame acf2 = new AlignedCodonFrame();
78 AlignedCodonFrame acf3 = new AlignedCodonFrame();
80 List<AlignedCodonFrame> set1 = new ArrayList<AlignedCodonFrame>();
83 List<AlignedCodonFrame> set2 = new ArrayList<AlignedCodonFrame>();
88 * Add both sets twice; each mapping should be added once only
90 ssm.registerMappings(set1);
91 ssm.registerMappings(set1);
92 ssm.registerMappings(set2);
93 ssm.registerMappings(set2);
95 assertEquals(3, ssm.getSequenceMappings().size());
96 assertTrue(ssm.getSequenceMappings().contains(acf1));
97 assertTrue(ssm.getSequenceMappings().contains(acf2));
98 assertTrue(ssm.getSequenceMappings().contains(acf3));
102 * Verify that RESNUM sequence features are present after creating a PDB
105 @Test(groups = { "Functional" })
106 public void testSetMapping_seqFeatures()
108 SequenceI seq = new Sequence(
110 "ATYNVKLITPEGEVELQVPDDVYILDQAEEDGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSYLDDGQIADGWVLTCHAYPTSDVVIETHKEEELTGA");
111 StructureSelectionManager sm = new StructureSelectionManager();
112 sm.setProcessSecondaryStructure(true);
113 sm.setAddTempFacAnnot(true);
114 StructureFile pmap = sm.setMapping(true, new SequenceI[] { seq },
115 new String[] { null }, "examples/1gaq.txt", FormatAdapter.FILE);
116 assertTrue(pmap != null);
118 assertEquals(3, pmap.getSeqs().size());
119 assertEquals("1GAQ|A", pmap.getSeqs().get(0).getName());
120 assertEquals("1GAQ|B", pmap.getSeqs().get(1).getName());
121 assertEquals("1GAQ|C", pmap.getSeqs().get(2).getName());
124 * Verify a RESNUM sequence feature in the PDBfile sequence
126 SequenceFeature sf = pmap.getSeqs().get(0).getSequenceFeatures()[0];
127 assertEquals("RESNUM", sf.getType());
128 assertEquals("1gaq", sf.getFeatureGroup());
129 assertEquals("GLU: 19 1gaqA", sf.getDescription());
132 * Verify a RESNUM sequence feature in the StructureSelectionManager mapped
135 StructureMapping map = sm.getMapping("examples/1gaq.txt")[0];
136 sf = map.sequence.getSequenceFeatures()[0];
137 assertEquals("RESNUM", sf.getType());
138 assertEquals("1gaq", sf.getFeatureGroup());
139 assertEquals("ALA: 1 1gaqB", sf.getDescription());