import java.util.Vector;
import javax.swing.LookAndFeel;
+import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import groovy.lang.Binding;
private boolean noAnnotation;
+ public static final String TERMINATOR_LINE = "Jalview argument parsing complete.";
+
public boolean getStartCalculations()
{
return !noCalculation;
|| "true".equals(System.getProperty("java.awt.headless")))
{
headless = true;
+ setSynchronous(true);
}
if (isJS)
System.exit(0);
}
-
// anything else!
final String jabawsUrl = aparser.getValue(ArgsParser.JABAWS);
try
{
if (!isJS && Platform.isWin())
- {
+ {
UIManager.setLookAndFeel(
headless ? "javax.swing.plaf.metal.MetalLookAndFeel"
: UIManager.getSystemLookAndFeelClassName());
-// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
} catch (Exception ex)
{
SequenceOntologyFactory.setSequenceOntology(new SequenceOntology());
}
- if (!headless)
+ if (headless)
+ {
+ // If this is not tested, then
+
+ if (aparser.contains(ArgsParser.NOUSAGESTATS))
+ {
+ System.err.println("CMD [-nousagestats] executed successfully!");
+ }
+ if (aparser.contains(ArgsParser.NOQUESTIONNAIRE))
+ {
+ System.err.println("CMD [-noquestionnaire] executed successfully!");
+ }
+
+ }
+ else
{
desktop = Desktop.getInstance();
desktop.setInBatchMode(true); // indicate we are starting up
}
parseArguments(aparser, true);
+ System.err.println(TERMINATOR_LINE);
}
/**
// + " " + status);
}
-}
+ /**
+ * flag to allow selected Runnable and Thread processes to run synchronously
+ *
+ * JAL-3563
+ *
+ */
+ private static boolean isSynchronous = false;
+
+ /**
+ * Set Jalview to run selected processes synchronously in test and headless
+ * environments.
+ *
+ * JAL-3563
+ *
+ * @param b
+ * @author Bob Hanson
+ */
+ public static void setSynchronous(boolean b)
+ {
+
+ isSynchronous = b;
+
+ }
+
+ /**
+ * Allows optional synchronous running of a Runnable that would otherwise use
+ * SwingUtilities.invokeLater.
+ *
+ * JAL-3563
+ *
+ * @param t
+ * @author Bob Hanson
+ */
+ public static boolean isSynchronous()
+ {
+ return isSynchronous;
+ }
+
+ /**
+ * Allows optional synchronous running of a Runnable that would otherwise use
+ * SwingUtilities.invokeLater.
+ *
+ * JAL-3563
+ *
+ * @param t
+ * @author Bob Hanson
+ */
+ public static void execRunnable(Runnable r)
+ {
+ if (isSynchronous())
+ {
+ r.run();
+ }
+ else
+ {
+ SwingUtilities.invokeLater(r);
+ }
+ }
+
+ /**
+ * Allows optional synchronous running of a thread that would otherwise be run
+ * using start().
+ *
+ * JAL-3563
+ *
+ * @param t
+ * @author Bob Hanson
+ */
+ public static void execThread(Thread t)
+ {
+ if (isSynchronous())
+ {
+ t.run();
+ }
+ else
+ {
+ t.start();
+ }
+ }
+}
\ No newline at end of file
import jalview.api.analysis.SimilarityParamsI;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
+import jalview.bin.Jalview;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import java.util.jar.JarOutputStream;
import javax.swing.JInternalFrame;
-import javax.swing.SwingUtilities;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Marshaller;
{
try
{
+
// BH 2019 -- can't wait
- SwingUtilities.invokeLater(new Runnable()
+ Jalview.execRunnable(new Runnable()
{
@Override
public void run()
* data source provider
* @return alignment frame created from view stored in DOM
*/
- AlignFrame loadFromObject(JalviewModel jalviewModel, String file,
+ private AlignFrame loadFromObject(JalviewModel jalviewModel, String file,
boolean loadTreesAndStructures, jarInputStreamProvider jprovider)
{
-// Platform.timeCheck("Jalview2XML.loadFromObject0", Platform.TIME_MARK);
+ // Platform.timeCheck("Jalview2XML.loadFromObject0", Platform.TIME_MARK);
- SequenceSet vamsasSet = jalviewModel.getVamsasModel().getSequenceSet().get(0);
+ SequenceSet vamsasSet = jalviewModel.getVamsasModel().getSequenceSet()
+ .get(0);
List<Sequence> vamsasSeqs = vamsasSet.getSequence();
-
// JalviewModelSequence jms = object.getJalviewModelSequence();
// Viewport view = (jms.getViewportCount() > 0) ? jms.getViewport(0)
: view.getId() + uniqueSetSuffix);
}
-// Platform.timeCheck("Jalview2XML.loadFromObject1", Platform.TIME_MARK);
+ // Platform.timeCheck("Jalview2XML.loadFromObject1", Platform.TIME_MARK);
// ////////////////////////////////
// LOAD SEQUENCES
}
}
-// Platform.timeCheck("Jalview2XML.loadFromObject-seq",
-// Platform.TIME_MARK);
+ // Platform.timeCheck("Jalview2XML.loadFromObject-seq",
+ // Platform.TIME_MARK);
// /
// Create the alignment object from the sequence set
// ///////////////////////////////
recoverDatasetFor(vamsasSet, al, isdsal, uniqueSeqSetId);
}
-// Platform.timeCheck("Jalview2XML.loadFromObject-align",
-// Platform.TIME_MARK);
+ // Platform.timeCheck("Jalview2XML.loadFromObject-align",
+ // Platform.TIME_MARK);
if (referenceseqForView != null)
{
al.setSeqrep(referenceseqForView);
al.setProperty(ssp.getKey(), ssp.getValue());
}
-// Platform.timeCheck("Jalview2XML.loadFromObject-setseqprop",
-// Platform.TIME_MARK);
+ // Platform.timeCheck("Jalview2XML.loadFromObject-setseqprop",
+ // Platform.TIME_MARK);
// ///////////////////////////////
Hashtable pdbloaded = new Hashtable(); // TODO nothing writes to this??
// now, for 2.10 projects, this is also done if the xml doc includes
// dataset sequences not actually present in any particular view.
//
-// Platform.timeCheck("J2XML features0", Platform.TIME_RESET);
+ // Platform.timeCheck("J2XML features0", Platform.TIME_RESET);
for (int i = 0; i < vamsasSeqs.size(); i++)
{
JSeq jseq = jseqs.get(i);
}
// adds feature to datasequence's feature set (since Jalview 2.10)
-// Platform.timeCheck(null, Platform.TIME_SET);
+ // Platform.timeCheck(null, Platform.TIME_SET);
al.getSequenceAt(i).addSequenceFeature(sf);
-// Platform.timeCheck(null, Platform.TIME_MARK);
+ // Platform.timeCheck(null, Platform.TIME_MARK);
}
}
if (vamsasSeqs.get(i).getDBRef().size() > 0)
{
entry.setProperty(prop.getName(), prop.getValue());
}
- Desktop.getStructureSelectionManager()
- .registerPDBEntry(entry);
+ Desktop.getStructureSelectionManager().registerPDBEntry(entry);
// adds PDBEntry to datasequence's set (since Jalview 2.10)
if (al.getSequenceAt(i).getDatasetSequence() != null)
{
}
-// Platform.timeCheck("features done", Platform.TIME_GET);
-// Platform.timeCheck("Jalview2XML.loadFromObject-endmultiview",
-// Platform.TIME_MARK);
+ // Platform.timeCheck("features done", Platform.TIME_GET);
+ // Platform.timeCheck("Jalview2XML.loadFromObject-endmultiview",
+ // Platform.TIME_MARK);
} // end !multipleview
// ///////////////////////////////
else
{
// defer to later
- frefedSequence.add(
- newAlcodMapRef(map.getDnasq(), cf, mapping));
+ frefedSequence
+ .add(newAlcodMapRef(map.getDnasq(), cf, mapping));
}
}
}
al.addCodonFrame(cf);
}
}
-// Platform.timeCheck("Jalview2XML.loadFromObject-seqmap",
-// Platform.TIME_MARK);
+ // Platform.timeCheck("Jalview2XML.loadFromObject-seqmap",
+ // Platform.TIME_MARK);
}
// ////////////////////////////////
}
// Construct new annotation from model.
List<AnnotationElement> ae = annotation.getAnnotationElement();
-// System.err.println(
-// "Jalview2XML processing " + ae.size() + " annotations");
+ // System.err.println(
+ // "Jalview2XML processing " + ae.size() + " annotations");
jalview.datamodel.Annotation[] anot = null;
java.awt.Color firstColour = null;
jaa.setCalcId(annotation.getCalcId());
if (annotation.getProperty().size() > 0)
{
- for (Annotation.Property prop : annotation
- .getProperty())
+ for (Annotation.Property prop : annotation.getProperty())
{
jaa.setProperty(prop.getName(), prop.getValue());
}
al.addAnnotation(jaa);
}
}
-// Platform.timeCheck("Jalview2XML.loadFromObject-annot",
-// Platform.TIME_MARK);
+ // Platform.timeCheck("Jalview2XML.loadFromObject-annot",
+ // Platform.TIME_MARK);
}
// ///////////////////////
// LOAD GROUPS
sg.setShowNonconserved(safeBoolean(jGroup.isShowUnconserved()));
sg.thresholdTextColour = safeInt(jGroup.getTextColThreshold());
// attributes with a default in the schema are never null
- sg.setShowConsensusHistogram(jGroup.isShowConsensusHistogram());
- sg.setshowSequenceLogo(jGroup.isShowSequenceLogo());
- sg.setNormaliseSequenceLogo(jGroup.isNormaliseSequenceLogo());
+ sg.setShowConsensusHistogram(jGroup.isShowConsensusHistogram());
+ sg.setshowSequenceLogo(jGroup.isShowSequenceLogo());
+ sg.setNormaliseSequenceLogo(jGroup.isNormaliseSequenceLogo());
sg.setIgnoreGapsConsensus(jGroup.isIgnoreGapsinConsensus());
if (jGroup.getConsThreshold() != null
&& jGroup.getConsThreshold().intValue() != 0)
if (addAnnotSchemeGroup)
{
// reconstruct the annotation colourscheme
- sg.setColourScheme(constructAnnotationColour(
- jGroup.getAnnotationColours(), null, al, jalviewModel, false));
+ sg.setColourScheme(
+ constructAnnotationColour(jGroup.getAnnotationColours(),
+ null, al, jalviewModel, false));
}
}
-// Platform.timeCheck("Jalview2XML.loadFromObject-groups",
-// Platform.TIME_MARK);
+ // Platform.timeCheck("Jalview2XML.loadFromObject-groups",
+ // Platform.TIME_MARK);
}
if (view == null)
{
}
}
-// Platform.timeCheck("Jalview2XML.loadFromObject-viewport",
-// Platform.TIME_MARK);
+ // Platform.timeCheck("Jalview2XML.loadFromObject-viewport",
+ // Platform.TIME_MARK);
}
/**
* indicate that annotation colours are applied across all groups (pre
final AlignFrame af0 = af;
final AlignViewport av0 = av;
final AlignmentPanel ap0 = ap;
-// Platform.timeCheck("Jalview2XML.loadFromObject-beforetree",
-// Platform.TIME_MARK);
+ // Platform.timeCheck("Jalview2XML.loadFromObject-beforetree",
+ // Platform.TIME_MARK);
if (loadTreesAndStructures)
{
if (!jalviewModel.getTree().isEmpty())
{
- SwingUtilities.invokeLater(new Runnable()
+ Jalview.execRunnable(new Runnable()
{
@Override
public void run()
{
-// Platform.timeCheck(null, Platform.TIME_MARK);
+ // Platform.timeCheck(null, Platform.TIME_MARK);
loadTrees(jalviewModel, view, af0, av0, ap0);
-// Platform.timeCheck("Jalview2XML.loadTrees", Platform.TIME_MARK);
+ // Platform.timeCheck("Jalview2XML.loadTrees", Platform.TIME_MARK);
}
});
}
if (!jalviewModel.getPcaViewer().isEmpty())
{
- SwingUtilities.invokeLater(new Runnable()
+ Jalview.execRunnable(new Runnable()
{
@Override
public void run()
{
-// Platform.timeCheck(null, Platform.TIME_MARK);
+ // Platform.timeCheck(null, Platform.TIME_MARK);
loadPCAViewers(jalviewModel, ap0);
-// Platform.timeCheck("Jalview2XML.loadPCA", Platform.TIME_MARK);
+ // Platform.timeCheck("Jalview2XML.loadPCA", Platform.TIME_MARK);
}
});
}
- SwingUtilities.invokeLater(new Runnable()
+ Jalview.execRunnable(new Runnable()
{
@Override
public void run()
{
-// Platform.timeCheck(null, Platform.TIME_MARK);
+ // Platform.timeCheck(null, Platform.TIME_MARK);
loadPDBStructures(jprovider, jseqs, af0, ap0);
-// Platform.timeCheck("Jalview2XML.loadPDB", Platform.TIME_MARK);
+ // Platform.timeCheck("Jalview2XML.loadPDB", Platform.TIME_MARK);
}
});
- SwingUtilities.invokeLater(new Runnable()
+ Jalview.execRunnable(new Runnable()
{
@Override
public void run()
loadRnaViewers(jprovider, jseqs, ap0);
}
});
+
}
// and finally return.
// but do not set holdRepaint true just yet, because this could be the
svattrib.getWidth(), svattrib.getHeight());
// try
// {
- javax.swing.SwingUtilities.invokeLater(new Runnable()
+ Jalview.execRunnable(new Runnable()
{
@Override
public void run()
}
}
}
- });
+ });
+ // javax.swing.SwingUtilities.invokeLater(r);
// } catch (InvocationTargetException ex)
// {
// warn("Unexpected error when opening Jmol view.", ex);
import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureColourI;
import jalview.api.ViewStyleI;
+import jalview.bin.Jalview;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.HiddenSequences;
import jalview.schemes.StrandColourScheme;
import jalview.schemes.TCoffeeColourScheme;
import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureMapping;
import jalview.util.matcher.Condition;
import jalview.viewmodel.AlignmentViewport;
{
JvOptionPane.setInteractiveMode(false);
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+ Jalview.setSynchronous(true);
}
@Test(groups = { "Functional" })
String inFile = "examples/RF00031_folded.stk";
String tfile = File.createTempFile("JalviewTest", ".jvp")
.getAbsolutePath();
+ // Jalview.setSynchronous(true);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(inFile,
DataSourceType.FILE);
assertNotNull(af, "Didn't read input file " + inFile);
assertTrue(af.isSaveAlignmentSuccessful(),
"Failed to store as a project.");
af.closeMenuItem_actionPerformed(true);
- af = null;
af = new FileLoader().LoadFileWaitTillLoaded(tfile,
DataSourceType.FILE);
assertNotNull(af, "Failed to import new project");
inAnnot = "examples/uniref50.score_ascii";
String tfile = File.createTempFile("JalviewTest", ".jvp")
.getAbsolutePath();
+ // Jalview.setSynchronous(true);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(inFile,
DataSourceType.FILE);
assertNotNull(af, "Didn't read input file " + inFile);
assertTrue(af.isSaveAlignmentSuccessful(),
"Failed to store as a project.");
af.closeMenuItem_actionPerformed(true);
- af = null;
af = new FileLoader().LoadFileWaitTillLoaded(tfile,
DataSourceType.FILE);
assertNotNull(af, "Failed to import new project");
inAnnot = "examples/testdata/uniref50_iupred.jva";
String tfile = File.createTempFile("JalviewTest", ".jvp")
.getAbsolutePath();
+ // Jalview.setSynchronous(true);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(inFile,
DataSourceType.FILE);
assertNotNull(af, "Didn't read input file " + inFile);
{
int origCount = Desktop.getAlignFrames() == null ? 0
: Desktop.getAlignFrames().length;
+ // Jalview.setSynchronous(true);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/exampleFile_2_7.jar", DataSourceType.FILE);
assertNotNull(af, "Didn't read in the example file correctly.");
{
StructureImportSettings.setProcessSecondaryStructure(true);
StructureImportSettings.setVisibleChainAnnotation(true);
+ // Jalview.setSynchronous(true);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/exampleFile_2_7.jar", DataSourceType.FILE);
assertNotNull(af, "Didn't read in the example file correctly.");
// count number of PDB mappings the structure selection manager holds -
String pdbFile = af.getCurrentView().getStructureSelectionManager()
.findFileForPDBId("1A70");
- assertEquals(
- af.getCurrentView().getStructureSelectionManager()
- .getMapping(pdbFile).length,
+ StructureMapping[] x = af.getCurrentView()
+ .getStructureSelectionManager()//
+ .getMapping(pdbFile);
+ assertEquals(x.length,
2, "Expected only two mappings for 1A70");
}
{
StructureImportSettings.setProcessSecondaryStructure(true);
StructureImportSettings.setVisibleChainAnnotation(true);
+ // Jalview.setSynchronous(true);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/exampleFile_2_7.jar", DataSourceType.FILE);
assertNotNull(af, "Didn't read in the example file correctly.");
@Test(groups = { "Functional" })
public void testCopyViewSettings() throws Exception
{
+ // Jalview.setSynchronous(true);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/exampleFile_2_7.jar", DataSourceType.FILE);
assertNotNull(af, "Didn't read in the example file correctly.");
public void testStoreAndRecoverExpandedviews() throws Exception
{
Desktop.getInstance().closeAll_actionPerformed(null);
-
+ // Jalview.setSynchronous(true);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/exampleFile_2_7.jar", DataSourceType.FILE);
Assert.assertEquals(Desktop.getAlignFrames().length, 1);
public void testStoreAndRecoverReferenceSeqSettings() throws Exception
{
Desktop.getInstance().closeAll_actionPerformed(null);
+ // Jalview.setSynchronous(true);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/exampleFile_2_7.jar", DataSourceType.FILE);
assertNotNull(af, "Didn't read in the example file correctly.");
public void testStoreAndRecoverGroupRepSeqs() throws Exception
{
Desktop.getInstance().closeAll_actionPerformed(null);
+ // Jalview.setSynchronous(true);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/uniref50.fa", DataSourceType.FILE);
assertNotNull(af, "Didn't read in the example file correctly.");
{
Desktop.getInstance().closeAll_actionPerformed(null);
String exampleFile = "examples/3W5V.pdb";
+ // Jalview.setSynchronous(true);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(exampleFile,
DataSourceType.FILE);
assertNotNull(af, "Didn't read in the example file correctly.");
public void testStoreAndRecoverColourThresholds() throws IOException
{
Desktop.getInstance().closeAll_actionPerformed(null);
+ // Jalview.setSynchronous(true);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/uniref50.fa", DataSourceType.FILE);
@Test(groups = { "Functional" })
public void testSaveLoadFeatureColoursAndFilters() throws IOException
{
+ // Jalview.setSynchronous(true);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
">Seq1\nACDEFGHIKLM", DataSourceType.PASTE);
SequenceI seq1 = af.getViewport().getAlignment().getSequenceAt(0);
public void testMergeDatasetsforViews() throws IOException
{
// simple project - two views on one alignment
+ // Jalview.setSynchronous(true);
AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
"examples/testdata/projects/twoViews.jvp", DataSourceType.FILE);
assertNotNull(af);
Desktop.getInstance().closeAll_actionPerformed(null);
// complex project - one dataset, several views on several alignments
+ // Jalview.setSynchronous(true);
AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
"examples/testdata/projects/manyViews.jvp",
DataSourceType.FILE);
public void testPcaViewAssociation() throws IOException
{
Desktop.getInstance().closeAll_actionPerformed(null);
+ // Jalview.setSynchronous(true);
final String PCAVIEWNAME = "With PCA";
// create a new tempfile
File tempfile = File.createTempFile("jvPCAviewAssoc", "jvp");