Merge branch 'develop' into task/JAL-4001_Plausible_API
authorBen Soares <b.soares@dundee.ac.uk>
Thu, 22 Jun 2023 20:53:32 +0000 (21:53 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Thu, 22 Jun 2023 20:53:32 +0000 (21:53 +0100)
src/jalview/bin/Commands.java
src/jalview/gui/Desktop.java
src/jalview/util/Comparison.java
src/jalview/workers/AlignCalcManager.java
test/jalview/bin/CommandsTest2.java

index bcf231e..7f493e0 100644 (file)
@@ -569,9 +569,20 @@ public class Commands
                           structureFilepath, tft, paeFilepath, false,
                           ssFromStructure, false, viewerType);
 
-          if (headless)
+          if (sv==null)
+          {
+            Console.error("Failed to import and open structure view.");
+            continue;
+          }
+          while (sv.isBusy())
           {
-            sv.setAsync(false);
+            try {
+              Thread.sleep(25);
+            }
+            catch (Exception x)
+            {
+              
+            }
           }
 
           String structureImageFilename = ArgParser.getValueFromSubValOrArg(
index 99c394b..b901ae4 100644 (file)
@@ -3627,4 +3627,24 @@ public class Desktop extends jalview.jbgui.GDesktop
       Desktop.instance = null;
     }
   }
+
+  /**
+   * checks if any progress bars are being displayed in any of the windows managed by the desktop
+   * @return
+   */
+  public boolean operationsAreInProgress()
+  {
+    JInternalFrame[] frames = getAllFrames();
+    for (JInternalFrame frame:frames)
+    {
+      if (frame instanceof IProgressIndicator)
+      {
+        if (((IProgressIndicator)frame).operationInProgress())
+        {
+          return true;
+        }
+      }
+    }
+    return operationInProgress();
+  }
 }
index 9fea705..e9ff931 100644 (file)
@@ -337,9 +337,9 @@ public class Comparison
         // a long sequence.
         // check for at least 55% nucleotide, and nucleotide and ambiguity codes
         // (including N) must make up 95%
-        return ntCount * 100 > NUCLEOTIDE_COUNT_PERCENT * allCount
+        return ntCount * 100 >= NUCLEOTIDE_COUNT_PERCENT * allCount
                 && 100 * (ntCount + nCount
-                        + ntaCount) > NUCLEOTIDE_COUNT_LONG_SEQUENCE_AMBIGUITY_PERCENT
+                        + ntaCount) >= NUCLEOTIDE_COUNT_LONG_SEQUENCE_AMBIGUITY_PERCENT
                                 * allCount;
       }
       else if (allCount > NUCLEOTIDE_COUNT_VERY_SHORT_SEQUENCE)
@@ -347,7 +347,7 @@ public class Comparison
         // a short sequence.
         // check if a short sequence is at least 55% nucleotide and the rest of
         // the symbols are all X or all N
-        if (ntCount * 100 > NUCLEOTIDE_COUNT_PERCENT * allCount
+        if (ntCount * 100 >= NUCLEOTIDE_COUNT_PERCENT * allCount
                 && (nCount == aaCount || xCount == aaCount))
         {
           return true;
index d81db8c..fc28e53 100644 (file)
@@ -25,6 +25,7 @@ import jalview.api.AlignCalcWorkerI;
 import jalview.datamodel.AlignmentAnnotation;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Hashtable;
@@ -208,9 +209,18 @@ public class AlignCalcManager implements AlignCalcManagerI
     }
     synchronized (updating)
     {
-      for (List<AlignCalcWorkerI> workers : updating.values())
+      Collection<List<AlignCalcWorkerI>> workersLists = updating.values();
+      synchronized (workersLists)
       {
-        working |= workers.size() > 0;
+        for (List<AlignCalcWorkerI> workers : workersLists)
+        {
+          if (workers!=null)
+          {
+            synchronized (workers) {
+              working |= workers.size() > 0;
+            }
+          }
+        }
       }
     }
     return working;
index 0c2071a..d6b6f3c 100644 (file)
@@ -65,14 +65,18 @@ public class CommandsTest2
     String[] args = cmdLine.split("\\s+");
 
     CommandsTest.callJalviewMain(args);
-    try
+    while (Desktop.instance!=null && Desktop.instance.operationsAreInProgress())
     {
-      // sleep for slow build server to open annotations and viewer windows
-      Thread.sleep(seqNum * 50 + annNum * 50 + viewerNum * 500);
-    } catch (InterruptedException e)
-    {
-      e.printStackTrace();
+      try
+      {
+        // sleep for slow build server to open annotations and viewer windows
+        Thread.sleep(viewerNum * 50);
+      } catch (InterruptedException e)
+      {
+        e.printStackTrace();
+      }
     }
+    ;
 
     AlignFrame[] afs = Desktop.getAlignFrames();
     Assert.assertNotNull(afs);