JAL-2780 JAL-2781 JAL-2902 refactored helper method in test for programmatically...
authorJim Procter <jprocter@issues.jalview.org>
Wed, 7 Feb 2018 13:08:22 +0000 (13:08 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 7 Feb 2018 13:08:59 +0000 (13:08 +0000)
test/jalview/structure/StructureSelectionManagerTest.java

index 2e00144..96d36ba 100644 (file)
  */
 package jalview.structure;
 
+import static org.junit.Assert.assertArrayEquals;
 import static org.testng.Assert.assertNotNull;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertTrue;
 
 import jalview.analysis.AlignmentUtils;
+import jalview.api.structures.JalviewStructureDisplayI;
 import jalview.datamodel.AlignedCodonFrame;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
@@ -238,32 +240,11 @@ public class StructureSelectionManagerTest extends Jalview2xmlBase
     AlignmentI al = alf.getViewport().getAlignment();
     SequenceI seq = al.getSequenceAt(0);
     assertEquals(470, seq.getStart());
-    SequenceI[] selectedSeqs = new SequenceI[] { seq };
-
     // load 4IM2 (full length, SIFTS)
     SiftsSettings.setMapWithSifts(true);
     StructureImportSettings.setProcessSecondaryStructure(true);
     StructureImportSettings.setVisibleChainAnnotation(true);
-
-    StructureChooser schoose = new StructureChooser(selectedSeqs, seq,
-            alf.getViewport().getAlignPanel());
-
-    try
-    {
-      Thread.sleep(5000);
-    } catch (InterruptedException q)
-    {
-    }
-    ;
-    schoose.selectStructure(PDBID);
-    schoose.ok_ActionPerformed();
-    try
-    {
-      Thread.sleep(10000);
-    } catch (InterruptedException q)
-    {
-    }
-    ;
+    openStructureViaChooser(alf, seq, PDBID);
 
     AlignmentAnnotation subseq_tf=null;
     assertTrue(seq.getDBRefs() != null && seq.getDBRefs().length > 0);
@@ -294,13 +275,7 @@ public class StructureSelectionManagerTest extends Jalview2xmlBase
     // verify location of secondary structure annotation
     // Specific positions: LYS477 (h),THR478 (no helix), ... GLY496(no helix),
     // GLU497 (helix),
-    PDBEntry pdbe = seq.getPDBEntry(PDBID);
-    StructureMapping[] sm = alf.alignPanel.getStructureSelectionManager()
-            .getMapping(pdbe.getFile());
-    assertNotNull(sm);
-    assertNotNull(sm[0]);
     
-    List<int[]> ranges = sm[0].getPDBResNumRanges(seq.getStart(),seq.getEnd());
     // check there is or is not a tempfactor for each mapped position, and that
     // values are equal for those positions.
     for (int p=seq.getStart();p<=seq.getEnd();p++)
@@ -326,4 +301,27 @@ public class StructureSelectionManagerTest extends Jalview2xmlBase
     
   }
 
+  private JalviewStructureDisplayI openStructureViaChooser(AlignFrame alf,
+          SequenceI seq,
+          String pDBID)
+  {
+
+    SequenceI[] selectedSeqs = new SequenceI[] { seq };
+
+    StructureChooser schoose = new StructureChooser(selectedSeqs, seq,
+            alf.getViewport().getAlignPanel());
+
+    try
+    {
+      Thread.sleep(5000);
+    } catch (InterruptedException q)
+    {
+    }
+    ;
+    Assert.assertTrue(schoose.selectStructure(pDBID),
+            "Couldn't select structure via structure chooser: " + pDBID);
+    schoose.showStructures(true);
+    return schoose.getOpenedStructureViewer();
+  }
+
 }