private AlignmentSorter()
{
- // singleton
+ // private singleton
}
+
+ private static AlignmentSorter getInstance()
+ {
+ Instance j = Instance.getInstance();
+ return (j.alignmentSorter == null
+ ? j.alignmentSorter = new AlignmentSorter()
+ : j.alignmentSorter);
+ }
+
/**
* types of feature ordering: Sort by score : average score - or total score -
* over all features in region Sort by feature label text: (or if null -
public static final String FEATURE_DENSITY = "density";
- public static AlignmentSorter getInstance()
- {
- Instance j = Instance.getInstance();
- return (j.alignmentSorter == null
- ? j.alignmentSorter = new AlignmentSorter()
- : j.alignmentSorter);
- }
-
/*
* todo: refactor searches to follow a basic pattern: (search property, last
* search state, current sort direction)
import jalview.datamodel.SequenceI;
import jalview.util.DBRefUtils;
import jalview.util.MapList;
-import jalview.ws.SequenceFetcherFactory;
-import jalview.ws.seqfetcher.ASequenceFetcher;
+import jalview.ws.SequenceFetcher;
import java.util.ArrayList;
import java.util.Iterator;
private void retrieveCrossRef(List<DBRefEntry> sourceRefs, SequenceI seq,
List<DBRefEntry> xrfs, boolean fromDna, AlignedCodonFrame cf)
{
- ASequenceFetcher sftch = SequenceFetcherFactory.getSequenceFetcher();
SequenceI[] retrieved = null;
SequenceI dss = seq.getDatasetSequence() == null ? seq
: seq.getDatasetSequence();
}
try
{
- retrieved = sftch.getSequences(sourceRefs, !fromDna);
+ retrieved = SequenceFetcher.getInstance()
+ .getSequences(sourceRefs, !fromDna);
} catch (Exception e)
{
System.err.println(
private void removeAlreadyRetrievedSeqs(List<DBRefEntry> sourceRefs,
boolean fromDna)
{
- List<DBRefEntry> dbrSourceSet = new ArrayList<DBRefEntry>(sourceRefs);
+ List<DBRefEntry> dbrSourceSet = new ArrayList<>(sourceRefs);
List<SequenceI> dsSeqs = dataset.getSequences();
for (int ids = 0, nds = dsSeqs.size(); ids < nds; ids++)
{
*/
public class ScoreModels
{
- private final ScoreMatrix BLOSUM62;
-
- private final ScoreMatrix PAM250;
-
- private final ScoreMatrix DNA;
-
/**
* Answers the singleton instance of this class, with lazy initialisation
* (built-in score models are loaded on the first call to this method)
: j.scoreModels);
}
- private Map<String, ScoreModelI> models;
-
/**
* Private constructor to enforce use of singleton. Registers Jalview's
* "built-in" score models:
registerScoreModel(new FeatureDistanceModel());
}
+ private final ScoreMatrix BLOSUM62;
+
+ private final ScoreMatrix PAM250;
+
+ private final ScoreMatrix DNA;
+
+ private Map<String, ScoreModelI> models;
+
/**
* Tries to load a score matrix from the given resource file, and if
* successful, registers it.
public class Cache
{
+ private Cache()
+ {
+ // private singleton
+ }
+
/**
* In Java, this will be a static field instance, which will be
* application-specific; in JavaScript it will be an applet-specific instance
*
* @return
*/
- public static Cache getInstance()
+ private static Cache getInstance()
{
Instance i = Instance.getInstance();
return (i.cache == null ? i.cache = new Cache() : i.cache);
*/
public static Logger log;
- private Cache()
- {
- // singleton
- }
-
/** Jalview Properties */
// BH 2019.05.08 was static
@SuppressWarnings("serial")
import jalview.fts.service.uniprot.UniProtFTSRestClient;
import jalview.gui.Desktop;
import jalview.httpserver.HttpServer;
-import jalview.io.gff.SequenceOntologyI;
+import jalview.io.gff.SequenceOntologyFactory;
import jalview.rest.RestHandler;
+import jalview.schemes.ColourSchemes;
import jalview.structure.StructureImportSettings;
import jalview.structure.StructureSelectionManager;
import jalview.urls.IdOrgSettings;
-import jalview.ws.SequenceFetcher;
import jalview.ws.jws1.Discoverer;
import jalview.ws.jws2.Jws2Discoverer;
import jalview.ws.jws2.jabaws2.Jws2InstanceFactory;
import jalview.ws.rest.RestClient;
import jalview.ws.sifts.SiftsSettings;
-import java.awt.Color;
import java.util.IdentityHashMap;
/**
- * a class to hold singleton instances so that they are not shared
+ * A class to hold singleton instances so that they are not shared among
+ * multiple JavaScript apps on a page. Fields are all formerly static class or
+ * object references are preserved in this singleton as "pseudo" static
+ * references that will be unique for each JavaScript applet or Java
+ * application.
+ *
+ * There are three kinds of references:
+ *
+ * Class references for classes with public getInstance() calls and a private
+ * constructor.
+ *
+ * Class references for classes with private getInstance() calls and a private
+ * constructor.
+ *
+ * Object references held here for a class as "pseudo" static field and
+ * referenced by Instance.getInstance().fieldName. These classes
*
* @author hansonr
*
*/
-public class Instance {
+public class Instance
+{
+
+ private Instance()
+ {
+ // singleton -- use getInstance();
+ }
private static Instance instance;
+ /**
+ *
+ * Creates a static reference to this class, either as a static field (Java)
+ * or as an element in the applet's ThreadGroup object.
+ *
+ * @return new Instance()
+ */
public static Instance getInstance()
{
Instance i;
@SuppressWarnings("unused")
ThreadGroup g = Thread.currentThread().getThreadGroup();
/**
- * @j2sNative i = g._instance;
+ * @j2sNative i = g._jalviewInstance;
*/
{
i = instance;
{
i = instance = new Instance();
/**
- * @j2sNative g._instance = i;
+ * @j2sNative g._jalviewInstance = i;
*/
}
return i;
}
- /**
- * singleton instance of this class in Java only
- */
-
public Jalview jalview;
public Desktop desktop;
- public static Jalview getJalview()
- {
- Instance i = getInstance();
- if (i.jalview == null)
- {
- new Jalview();
- }
- return i.jalview;
- }
- public static void setJalview(Jalview j)
- {
- getInstance().jalview = j;
- }
- public static Desktop getDesktop()
- {
- Instance i = getInstance();
- return (i.desktop == null ? (i.desktop = new Desktop(true))
- : i.desktop);
- }
+ // The following are PUBLIC singletons; their class has a private constructor
+ // that is assigned by the class as part of a public static getInstance()
+ // call.
- public static void setDesktop(Desktop d)
- {
- getInstance().desktop = d;
- }
+ public ColourSchemes colourSchemes;
- public Cache cache;
+ public Discoverer discoverer;
- public AlignmentSorter alignmentSorter;
+ public HttpServer httpServer;
- public Color[] rnaHelices = null;
+ public RestClient restClient;
- public Discoverer discoverer;
+ public RestHandler restHandler;
- public EnsemblInfo ensemblInfo;
+ public ScoreModels scoreModels;
- public HttpServer httpServer;
+ public jalview.ws.SequenceFetcher sequenceFetcher;
- public IdOrgSettings idOrgSettings;
+ public SiftsSettings siftsSettings;
- public Jws2Discoverer j2s2discoverer;
- public Jws2InstanceFactory jws2InstanceFactory;
+ // The following are PRIVATE singletons; their class has only static public
+ // methods and a private constructor that is assigned by the class as part of
+ // a private static getInstance() call.
- public PDBFTSRestClient pdbFTSRestClient;
+ public AlignmentSorter alignmentSorter;
- public RestClient restClient;
+ public Cache cache;
- public RestHandler restHandler;
+ public EnsemblInfo ensemblInfo;
- public ScoreModels scoreModels;
+ public IdOrgSettings idOrgSettings;
- public SequenceFetcher sequenceFetcher;
+ public Jws2Discoverer j2s2discoverer;
- public SequenceOntologyI sequenceOntology;
+ public Jws2InstanceFactory jws2InstanceFactory;
- public SiftsSettings siftsSettings;
+ public PDBFTSRestClient pdbFTSRestClient;
+
+ public SequenceOntologyFactory sequenceOntologyFactory;
public StructureImportSettings structureImportSettings;
public UniProtFTSRestClient uniprotFTSRestClient;
+ // The following formerly static Object references are
+ // preserved in this singleton as "pseudo" static references
+ // that will be unique for each JavaScript applet or Java application.
+
+ /**
+ * StructureSelectionManager "static"
+ */
public IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> structureSelections;
}
public class Jalview
{
+ public static Jalview getInstance()
+ {
+ Instance i = Instance.getInstance();
+ return (i.jalview == null ? i.jalview = new Jalview() : i.jalview);
+ }
+
public Jalview()
{
- Instance.setJalview(this);
+ Instance.getInstance().jalview = this;
}
static
public static boolean isHeadlessMode()
{
- return Instance.getJalview().headless;
+ return getInstance().headless;
}
private Desktop desktop;
public static AlignFrame getCurrentAlignFrame()
{
- return Instance.getJalview().currentAlignFrame;
+ return getInstance().currentAlignFrame;
}
public static void setCurrentAlignFrame(AlignFrame currentAlignFrame)
{
- Instance.getJalview().currentAlignFrame = currentAlignFrame;
+ getInstance().currentAlignFrame = currentAlignFrame;
}
static
{
try
{
- Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
+ Jws2Discoverer.getInstance().setPreferredUrl(jabawsUrl);
System.out.println(
"CMD [-jabaws " + jabawsUrl + "] executed successfully!");
} catch (MalformedURLException e)
}
}
- // BH 2019.05.10 moved here from StructureSelectionManager because this is a
- // singleton; allows it to be cleaned up when the application is closed.
-
}
{
return true;
}
- SequenceOntologyI so = SequenceOntologyFactory.getInstance();
+ SequenceOntologyI so = SequenceOntologyFactory.getSequenceOntology();
for (String term : soTerm)
{
if (type.equals(term) || so.isA(type, term))
@Override
protected boolean retainFeature(SequenceFeature sf, String accessionId)
{
- if (SequenceOntologyFactory.getInstance().isA(sf.getType(),
+ if (SequenceOntologyFactory.getSequenceOntology().isA(sf.getType(),
SequenceOntologyI.CDS))
{
return false;
@Override
protected boolean retainFeature(SequenceFeature sf, String accessionId)
{
- SequenceOntologyI so = SequenceOntologyFactory.getInstance();
+ SequenceOntologyI so = SequenceOntologyFactory.getSequenceOntology();
String type = sf.getType();
if (so.isA(type, SequenceOntologyI.GENE))
{
{
return new FeatureSettingsAdapter()
{
- SequenceOntologyI so = SequenceOntologyFactory.getInstance();
+ SequenceOntologyI so = SequenceOntologyFactory.getSequenceOntology();
@Override
public boolean isFeatureDisplayed(String type)
: j.ensemblInfo);
}
- /*
- * cached results of REST /info/divisions service, currently
- * <pre>
- * {
- * { "ENSEMBLFUNGI", "http://rest.ensemblgenomes.org"},
- * "ENSEMBLBACTERIA", "http://rest.ensemblgenomes.org"},
- * "ENSEMBLPROTISTS", "http://rest.ensemblgenomes.org"},
- * "ENSEMBLMETAZOA", "http://rest.ensemblgenomes.org"},
- * "ENSEMBLPLANTS", "http://rest.ensemblgenomes.org"},
- * "ENSEMBL", "http://rest.ensembl.org" }
- * }
- * </pre>
- * The values for EnsemblGenomes are retrieved by a REST call, that for
- * Ensembl is added programmatically for convenience of lookup
- */
- private Map<String, String> divisions = new HashMap<>();
-
private EnsemblInfo()
{
+ // use getInstance()
/*
* for convenience, pre-fill ensembl.org as the domain for "ENSEMBL"
}
}
+ /*
+ * cached results of REST /info/divisions service, currently
+ * <pre>
+ * {
+ * { "ENSEMBLFUNGI", "http://rest.ensemblgenomes.org"},
+ * "ENSEMBLBACTERIA", "http://rest.ensemblgenomes.org"},
+ * "ENSEMBLPROTISTS", "http://rest.ensemblgenomes.org"},
+ * "ENSEMBLMETAZOA", "http://rest.ensemblgenomes.org"},
+ * "ENSEMBLPLANTS", "http://rest.ensemblgenomes.org"},
+ * "ENSEMBL", "http://rest.ensembl.org" }
+ * }
+ * </pre>
+ * The values for EnsemblGenomes are retrieved by a REST call, that for
+ * Ensembl is added programmatically for convenience of lookup
+ */
+ private Map<String, String> divisions = new HashMap<>();
+
@Override
public String getDbName()
{
* for sequence_variant on reverse strand, have to convert the allele
* values to their complements
*/
- if (!forwardStrand && SequenceOntologyFactory.getInstance()
+ if (!forwardStrand && SequenceOntologyFactory.getSequenceOntology()
.isA(sf.getType(), SequenceOntologyI.SEQUENCE_VARIANT))
{
reverseComplementAlleles(copy);
public static boolean isTranscript(String featureType)
{
return SequenceOntologyI.NMD_TRANSCRIPT_VARIANT.equals(featureType)
- || SequenceOntologyFactory.getInstance().isA(featureType,
+ || SequenceOntologyFactory.getSequenceOntology().isA(featureType,
SequenceOntologyI.TRANSCRIPT);
}
}
*/
public SequenceOntology()
{
- termsFound = new ArrayList<String>();
- termsNotFound = new ArrayList<String>();
- termsByDescription = new HashMap<String, Term>();
- termIsA = new HashMap<Term, List<Term>>();
+ termsFound = new ArrayList<>();
+ termsNotFound = new ArrayList<>();
+ termsByDescription = new HashMap<>();
+ termIsA = new HashMap<>();
loadOntologyZipFile("so-xp-simple.obo");
}
*/
protected synchronized void findParents(Term childTerm)
{
- List<Term> result = new ArrayList<Term>();
+ List<Term> result = new ArrayList<>();
for (Triple triple : ontology.getTriples(childTerm, null, isA))
{
Term parent = triple.getObject();
private PDBFTSRestClient()
{
- // singleton
+ // singleton -- use getInstance()
}
/**
public class UniProtFTSRestClient extends FTSRestClient
{
- private static final String DEFAULT_UNIPROT_DOMAIN = "https://www.uniprot.org";
-
- static
- {
- Platform.addJ2SDirectDatabaseCall(DEFAULT_UNIPROT_DOMAIN);
- }
public static FTSRestClientI getInstance()
{
: j.uniprotFTSRestClient);
}
- public final String uniprotSearchEndpoint;
-
private UniProtFTSRestClient()
{
+ // singleton -- use getInstance()
+
uniprotSearchEndpoint = Cache.getDefault("UNIPROT_DOMAIN",
DEFAULT_UNIPROT_DOMAIN) + "/uniprot/";
}
+ private static final String DEFAULT_UNIPROT_DOMAIN = "https://www.uniprot.org";
+
+ public final String uniprotSearchEndpoint;
+
+ static
+ {
+ Platform.addJ2SDirectDatabaseCall(DEFAULT_UNIPROT_DOMAIN);
+ }
@SuppressWarnings("unchecked")
@Override
public FTSRestResponse executeRequest(FTSRestRequest uniprotRestRequest)
import jalview.api.ViewStyleI;
import jalview.api.analysis.SimilarityParamsI;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.bin.Jalview;
import jalview.commands.CommandI;
import jalview.commands.EditCommand;
private void addServiceListeners()
{
final java.beans.PropertyChangeListener thisListener;
- Instance.getDesktop().addJalviewPropertyChangeListener("services",
+ Desktop.getInstance().addJalviewPropertyChangeListener("services",
thisListener = new java.beans.PropertyChangeListener()
{
@Override
javax.swing.event.InternalFrameEvent evt)
{
// System.out.println("deregistering discoverer listener");
- Instance.getDesktop().removeJalviewPropertyChangeListener("services",
+ Desktop.getInstance().removeJalviewPropertyChangeListener("services",
thisListener);
closeMenuItem_actionPerformed(true);
}
@Override
public void addFromFile_actionPerformed(ActionEvent e)
{
- Instance.getDesktop().inputLocalFileMenuItem_actionPerformed(viewport);
+ Desktop.getInstance().inputLocalFileMenuItem_actionPerformed(viewport);
}
@Override
try
{
frames[i].setSelected(true);
- Instance.getDesktop().closeAssociatedWindows();
+ Desktop.getInstance().closeAssociatedWindows();
} catch (java.beans.PropertyVetoException ex)
{
}
}
}
- Instance.getDesktop().closeAssociatedWindows();
+ Desktop.getInstance().closeAssociatedWindows();
FileLoader loader = new FileLoader();
DataSourceType protocol = fileName.startsWith("http:")
@Override
public void addFromText_actionPerformed(ActionEvent e)
{
- Instance.getDesktop()
+ Desktop.getInstance()
.inputTextboxMenuItem_actionPerformed(viewport.getAlignPanel());
}
@Override
public void addFromURL_actionPerformed(ActionEvent e)
{
- Instance.getDesktop().inputURLMenuItem_actionPerformed(viewport);
+ Desktop.getInstance().inputURLMenuItem_actionPerformed(viewport);
}
@Override
StringSelection ss = new StringSelection(output);
- Desktop d = Instance.getDesktop();
+ Desktop d = Desktop.getInstance();
try
{
d.internalCopy = true;
.setContents(new StringSelection(""), null);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss,
- Instance.getDesktop());
+ Desktop.getInstance());
} catch (OutOfMemoryError er)
{
new OOMWarning("copying region", er);
boolean annotationAdded = false;
AlignmentI alignment = null;
- Desktop d = Instance.getDesktop();
+ Desktop d = Desktop.getInstance();
if (d.jalviewClipboard != null)
{
DEFAULT_HEIGHT);
String newtitle = new String("Flanking alignment");
- Desktop d = Instance.getDesktop();
+ Desktop d = Desktop.getInstance();
if (d.jalviewClipboard != null && d.jalviewClipboard[2] != null)
{
@Override
public void gatherViews_actionPerformed(ActionEvent e)
{
- Instance.getDesktop().gatherViews(this);
+ Desktop.getInstance().gatherViews(this);
}
/**
// boolean new_sspred = false;
if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
- Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
+ Jws2Discoverer jws2servs = Jws2Discoverer.getInstance();
if (jws2servs != null)
{
if (jws2servs.hasServices())
// associating PDB files which have no IDs.
for (SequenceI toassoc : (SequenceI[]) fm[2])
{
- PDBEntry pe = new AssociatePdbFileWithSeq()
+ PDBEntry pe = AssociatePdbFileWithSeq
.associatePdbWithSeq(fm[0].toString(),
- (DataSourceType) fm[1], toassoc, false,
- Instance.getDesktop());
+ (DataSourceType) fm[1], toassoc, false);
if (pe != null)
{
System.err.println("Associated file : "
@Override
public void run()
{
- final jalview.ws.SequenceFetcher sf = jalview.gui.SequenceFetcher
- .getSequenceFetcherSingleton();
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{
- String[] dbclasses = sf.getNonAlignmentSources();
+ String[] dbclasses = jalview.ws.SequenceFetcher.getInstance()
+ .getNonAlignmentSources();
List<DbSourceProxy> otherdb;
JMenu dfetch = new JMenu();
JMenu ifetch = new JMenu();
int dbi = 0;
for (String dbclass : dbclasses)
{
- otherdb = sf.getSourceProxy(dbclass);
+ otherdb = jalview.ws.SequenceFetcher.getInstance()
+ .getSourceProxy(dbclass);
// add a single entry for this class, or submenu allowing 'fetch
// all' or pick one
if (otherdb == null || otherdb.size() < 1)
import jalview.api.FeaturesDisplayedI;
import jalview.api.ViewStyleI;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.commands.CommandI;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.Alignment;
*/
if (align != null)
{
- StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop());
- ssm.registerMappings(align.getCodonFrames());
+ Desktop.getStructureSelectionManager()
+ .registerMappings(align.getCodonFrames());
}
/*
List<AlignedCodonFrame> mappings = al.getCodonFrames();
if (mappings != null)
{
- StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop());
+ StructureSelectionManager ssm = Desktop
+ .getStructureSelectionManager();
for (AlignedCodonFrame acf : mappings)
{
if (noReferencesTo(acf))
@Override
public void sendSelection()
{
- jalview.structure.StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop())
- .sendSelection(new SequenceGroup(getSelectionGroup()),
- new ColumnSelection(getColumnSelection()),
- new HiddenColumns(getAlignment().getHiddenColumns()),
- this);
+ Desktop.getStructureSelectionManager().sendSelection(
+ new SequenceGroup(getSelectionGroup()),
+ new ColumnSelection(getColumnSelection()),
+ new HiddenColumns(getAlignment().getHiddenColumns()), this);
}
/**
@Override
public StructureSelectionManager getStructureSelectionManager()
{
- return StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop());
+ return Desktop.getStructureSelectionManager();
}
@Override
import jalview.analysis.AlignSeq;
import jalview.analysis.AlignmentUtils;
-import jalview.bin.Instance;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
seqs, omitHidden, alignmentStartEnd);
Toolkit.getDefaultToolkit().getSystemClipboard()
- .setContents(new StringSelection(output), Instance.getDesktop());
+ .setContents(new StringSelection(output), Desktop.getInstance());
HiddenColumns hiddenColumns = null;
av.getAlignment().getHiddenColumns());
}
- Instance.getDesktop().jalviewClipboard = new Object[] { seqs, ds, // what is
+ Desktop.getInstance().jalviewClipboard = new Object[] { seqs, ds, // what is
// the
// dataset
// of a consensus
*/
package jalview.gui;
-import jalview.api.StructureSelectionManagerProvider;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.io.DataSourceType;
import jalview.io.StructureFile;
-import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
-import javax.swing.JOptionPane;
-
/**
- * GUI related routines for associating PDB files with sequences
+ * GUI related routines for associating PDB files with sequences. A single
+ * static method.
*
* @author JimP
*
public class AssociatePdbFileWithSeq
{
+ private AssociatePdbFileWithSeq()
+ {
+ // inaccessible
+ }
+
/**
- * assocate the given PDB file with
+ * Associate the given PDB file name or URL with a sequence. Do not map
+ * mouse-over events.
*
- * @param choice
+ * @param fileName
+ * or URL
+ * @param type
+ * will be DataType.FILE or DataType.URL
* @param sequence
+ * to associate
+ * @param prompt
+ * true if the user should be asked what to do if the specified file
+ * does not seem to contain PDB information (StructureChooser only)
+ * @return null if file is not found
*/
- public PDBEntry associatePdbWithSeq(String choice, DataSourceType file,
- SequenceI sequence, boolean prompt,
- StructureSelectionManagerProvider ssmp)
+ public static PDBEntry associatePdbWithSeq(String fileName,
+ DataSourceType type, SequenceI sequence, boolean prompt)
{
PDBEntry entry = new PDBEntry();
StructureFile pdbfile = null;
- pdbfile = StructureSelectionManager.getStructureSelectionManager(ssmp)
- .setMapping(false, new SequenceI[]
- { sequence }, null, choice, file);
+ pdbfile = Desktop.getStructureSelectionManager().setMapping(false,
+ new SequenceI[]
+ { sequence }, null, fileName, type);
if (pdbfile == null)
{
// stacktrace already thrown so just return
return null;
}
- if (pdbfile.getId() == null)
- {
- String reply = null;
-
- if (prompt)
- {
- reply = JvOptionPane.showInternalInputDialog(Desktop.getDesktopPane(),
- MessageManager
- .getString("label.couldnt_find_pdb_id_in_file"),
- MessageManager.getString("label.no_pdb_id_in_file"),
- JvOptionPane.QUESTION_MESSAGE);
- }
- if (reply == null)
- {
- return null;
- }
-
- entry.setId(reply);
- }
- else
+ String id = pdbfile.getId();
+ if (id == null && (id = (prompt
+ ? JvOptionPane.showInternalInputDialog(Desktop.getDesktopPane(),
+ MessageManager
+ .getString("label.couldnt_find_pdb_id_in_file"),
+ MessageManager.getString("label.no_pdb_id_in_file"),
+ JvOptionPane.QUESTION_MESSAGE)
+ : null)) == null)
{
- entry.setId(pdbfile.getId());
+ return null;
}
+ entry.setId(id);
entry.setType(PDBEntry.Type.FILE);
-
- if (pdbfile != null)
- {
- entry.setFile(choice);
- sequence.getDatasetSequence().addPDBId(entry);
- StructureSelectionManager.getStructureSelectionManager(ssmp)
- .registerPDBEntry(entry);
- }
+ entry.setFile(fileName);
+ sequence.getDatasetSequence().addPDBId(entry);
+ Desktop.getStructureSelectionManager().registerPDBEntry(entry);
return entry;
}
}
import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureSettingsModelI;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.DBRefEntry;
import jalview.ext.ensembl.EnsemblInfo;
import jalview.ext.ensembl.EnsemblMap;
import jalview.io.gff.SequenceOntologyI;
-import jalview.structure.StructureSelectionManager;
import jalview.util.DBRefUtils;
import jalview.util.MapList;
import jalview.util.MappingUtils;
/*
* get display scheme (if any) to apply to features
*/
- FeatureSettingsModelI featureColourScheme = new SequenceFetcher()
+ FeatureSettingsModelI featureColourScheme = SequenceFetcher
+ .getInstance()
.getFeatureColourScheme(source);
AlignmentI xrefsAlignment = makeCrossReferencesAlignment(dataset,
copyAlignment
.setGapCharacter(alignFrame.viewport.getGapCharacter());
- StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop());
-
/*
* register any new mappings for sequence mouseover etc
* (will not duplicate any previously registered mappings)
*/
- ssm.registerMappings(dataset.getCodonFrames());
+ Desktop.getStructureSelectionManager()
+ .registerMappings(dataset.getCodonFrames());
if (copyAlignment.getHeight() <= 0)
{
implements DropTargetListener, ClipboardOwner, IProgressIndicator,
jalview.api.StructureSelectionManagerProvider
{
+
private final static int DEFAULT_MIN_WIDTH = 300;
private final static int DEFAULT_MIN_HEIGHT = 250;
public static MyDesktopPane getDesktopPane()
{
- return Instance.getDesktop().desktopPane;
+ return Desktop.getInstance().desktopPane;
+ }
+
+ public static StructureSelectionManager getStructureSelectionManager()
+ {
+ return StructureSelectionManager
+ .getStructureSelectionManager(Desktop.getInstance());
}
static int openFrameCount = 0;
public MyDesktopPane desktopPane;
+ public static Desktop getInstance()
+ {
+ Instance i = Instance.getInstance();
+ return (i.desktop == null ? (i.desktop = new Desktop(true))
+ : i.desktop);
+ }
+
+ /**
+ * For testing.
+ *
+ * @param forInstance
+ */
public Desktop(boolean forInstance)
{
instanceOnly = true;
* block are spawned off as threads rather than waited for during this
* constructor.
*/
- Instance.setDesktop(this);
+ Instance.getInstance().desktop = this;
+
if (!Platform.isJS())
{
doVamsasClientCheck();
public void doConfigureStructurePrefs()
{
// configure services
- StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(this);
+ StructureSelectionManager ssm = getStructureSelectionManager();
if (jalview.bin.Cache.getDefault(Preferences.ADD_SS_ANN, true))
{
ssm.setAddTempFacAnnot(jalview.bin.Cache
// A HEADLESS STATE WHEN NO DESKTOP EXISTS. MUST RETURN
// IF JALVIEW IS RUNNING HEADLESS
// ///////////////////////////////////////////////
- if (Instance.getDesktop().instanceOnly || Jalview.isHeadlessMode())
+ if (Desktop.getInstance().instanceOnly || Jalview.isHeadlessMode())
{
return;
}
{
menuItem.removeActionListener(menuItem.getActionListeners()[0]);
}
- Instance.getDesktop().windowMenu.remove(menuItem);
+ Desktop.getInstance().windowMenu.remove(menuItem);
};
});
getDesktopPane().add(frame);
- Instance.getDesktop().windowMenu.add(menuItem);
+ Desktop.getInstance().windowMenu.add(menuItem);
frame.toFront();
try
{
if (!internalCopy)
{
- Instance.getDesktop().jalviewClipboard = null;
+ Desktop.getInstance().jalviewClipboard = null;
}
internalCopy = false;
* reset state of singleton objects as appropriate (clear down session state
* when all windows are closed)
*/
- StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(this);
- if (ssm != null)
- {
- ssm.resetAll();
- }
+ getStructureSelectionManager().resetAll();
}
@Override
if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
- t2 = jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
+ t2 = jalview.ws.jws2.Jws2Discoverer.getInstance()
.startDiscoverer(changeSupport);
}
Thread t3 = null;
{
if (evt.getNewValue() == null || evt.getNewValue() instanceof Vector)
{
- final String ermsg = jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
+ final String ermsg = jalview.ws.jws2.Jws2Discoverer.getInstance()
.getErrorMessages();
if (ermsg != null)
{
*/
public static void showUrl(final String url)
{
- showUrl(url, Instance.getDesktop());
+ showUrl(url, Desktop.getInstance());
}
/**
public static ParamManager getUserParameterStore()
{
- Desktop d = Instance.getDesktop();
+ Desktop d = Desktop.getInstance();
if (d.wsparamManager == null)
{
d.wsparamManager = new WsParamSetManager();
public static groovy.ui.Console getGroovyConsole()
{
- return Instance.getDesktop().groovyConsole;
+ return Desktop.getInstance().groovyConsole;
}
/**
*/
package jalview.gui;
-import jalview.bin.Instance;
import jalview.util.MessageManager;
import java.awt.Container;
boolean block, String title, int width, int height)
{
- frame = new JDialog(Instance.getDesktop(), modal);
+ frame = new JDialog(Desktop.getInstance(), modal);
frame.setTitle(title);
- if (Instance.getDesktop() != null)
+ if (Desktop.getInstance() != null)
{
- Rectangle deskr = Instance.getDesktop().getBounds();
+ Rectangle deskr = Desktop.getInstance().getBounds();
frame.setBounds(new Rectangle((int) (deskr.getCenterX() - width / 2),
(int) (deskr.getCenterY() - height / 2), width, height));
}
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.gui.Help.HelpId;
import jalview.gui.StructureViewer.ViewerType;
import jalview.io.BackupFiles;
Integer.toString(getComboIntStringKey(backupfilesPresetsCombo)));
Cache.saveProperties();
- Instance.getDesktop().doConfigureStructurePrefs();
+ Desktop.getInstance().doConfigureStructurePrefs();
try
{
frame.setClosed(true);
* If the selected source is Uniprot or PDB, a free text search panel is opened
* instead to perform the search and selection.
*/
+@SuppressWarnings("serial")
public class SequenceFetcher extends JPanel implements Runnable
{
- private static jalview.ws.SequenceFetcher sfetch = null;
JLabel exampleAccession;
volatile boolean _isConstructing = false;
/**
- * Returns the shared instance of the SequenceFetcher client
- *
- * @return
- */
- public static jalview.ws.SequenceFetcher getSequenceFetcherSingleton()
- {
- if (sfetch == null)
- {
- sfetch = new jalview.ws.SequenceFetcher();
- }
- return sfetch;
- }
-
- /**
* Constructor given a client to receive any status or progress messages
* (currently either the Desktop, or an AlignFrame panel)
*
final String selectedDb, final String queryString)
{
this.progressIndicator = guiIndic;
- getSequenceFetcherSingleton();
+
this.guiWindow = progressIndicator;
if (progressIndicator instanceof AlignFrame)
database = new JComboBox<>();
database.setFont(JvSwingUtils.getLabelFont());
database.setPrototypeDisplayValue("ENSEMBLGENOMES ");
- String[] sources = new jalview.ws.SequenceFetcher().getSupportedDb();
+ String[] sources = jalview.ws.SequenceFetcher.getInstance()
+ .getSupportedDb();
Arrays.sort(sources, String.CASE_INSENSITIVE_ORDER);
database.addItem(MessageManager.getString("action.select_ddbb"));
for (String source : sources)
{
StringBuilder sb = new StringBuilder();
HashSet<String> hs = new HashSet<>();
- for (DbSourceProxy dbs : sfetch.getSourceProxy(db))
+ for (DbSourceProxy dbs : jalview.ws.SequenceFetcher.getInstance()
+ .getSourceProxy(db))
{
String tq = dbs.getTestQuery();
if (hs.add(tq)) // not a duplicate source
List<String> presultTitle = new ArrayList<>();
List<AlignmentI> presult = new ArrayList<>();
List<AlignmentI> aresult = new ArrayList<>();
- List<DbSourceProxy> sources = sfetch
+ List<DbSourceProxy> sources = jalview.ws.SequenceFetcher.getInstance()
.getSourceProxy((String) database.getSelectedItem());
Iterator<DbSourceProxy> proxies = sources.iterator();
String[] qries = textArea.getText().trim().split(";");
package jalview.gui;
import jalview.analysis.Conservation;
-import jalview.bin.Instance;
import jalview.datamodel.SequenceGroup;
import jalview.jbgui.GSliderPanel;
import jalview.renderer.ResidueShaderI;
public static SliderPanel getSliderPanel()
{
- JInternalFrame conservationSlider = Instance
- .getDesktop().conservationSlider;
+ JInternalFrame conservationSlider = Desktop
+ .getInstance().conservationSlider;
- JInternalFrame PIDSlider = Instance.getDesktop().PIDSlider;
+ JInternalFrame PIDSlider = Desktop.getInstance().PIDSlider;
if (conservationSlider != null && conservationSlider.isVisible())
{
{
SliderPanel sliderPanel = null;
- JInternalFrame conservationSlider = Instance
- .getDesktop().conservationSlider;
+ JInternalFrame conservationSlider = Desktop
+ .getInstance().conservationSlider;
if (conservationSlider == null)
{
sliderPanel = new SliderPanel(ap, rs.getConservationInc(), true, rs);
- conservationSlider = Instance
- .getDesktop().conservationSlider = new JInternalFrame();
+ conservationSlider = Desktop
+ .getInstance().conservationSlider = new JInternalFrame();
conservationSlider.setContentPane(sliderPanel);
conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER);
}
*/
public static void hidePIDSlider()
{
- JInternalFrame PIDSlider = Instance.getDesktop().PIDSlider;
+ JInternalFrame PIDSlider = Desktop.getInstance().PIDSlider;
if (PIDSlider != null)
{
try
{
PIDSlider.setClosed(true);
- Instance.getDesktop().PIDSlider = null;
+ Desktop.getInstance().PIDSlider = null;
} catch (PropertyVetoException ex)
{
}
*/
public static void hideConservationSlider()
{
- JInternalFrame conservationSlider = Instance
- .getDesktop().conservationSlider;
+ JInternalFrame conservationSlider = Desktop
+ .getInstance().conservationSlider;
if (conservationSlider != null)
{
try
{
conservationSlider.setClosed(true);
- Instance.getDesktop().conservationSlider = null;
+ Desktop.getInstance().conservationSlider = null;
} catch (PropertyVetoException ex)
{
}
{
hidePIDSlider();
- JInternalFrame conservationSlider = Instance
- .getDesktop().conservationSlider;
+ JInternalFrame conservationSlider = Desktop
+ .getInstance().conservationSlider;
if (!conservationSlider.isVisible())
{
@Override
public void internalFrameClosed(InternalFrameEvent e)
{
- Instance.getDesktop().conservationSlider = null;
+ Desktop.getInstance().conservationSlider = null;
}
});
conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER);
SliderPanel sliderPanel = null;
- JInternalFrame PIDSlider = Instance.getDesktop().PIDSlider;
+ JInternalFrame PIDSlider = Desktop.getInstance().PIDSlider;
if (PIDSlider == null)
{
sliderPanel = new SliderPanel(ap, threshold, false, rs);
- PIDSlider = Instance.getDesktop().PIDSlider = new JInternalFrame();
+ PIDSlider = Desktop.getInstance().PIDSlider = new JInternalFrame();
PIDSlider.setContentPane(sliderPanel);
PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
}
{
hideConservationSlider();
- JInternalFrame PIDSlider = Instance.getDesktop().PIDSlider;
+ JInternalFrame PIDSlider = Desktop.getInstance().PIDSlider;
if (!PIDSlider.isVisible())
{
@Override
public void internalFrameClosed(InternalFrameEvent e)
{
- Instance.getDesktop().PIDSlider = null;
+ Desktop.getInstance().PIDSlider = null;
}
});
PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
public static int getConservationValue()
{
- return getValue(Instance.getDesktop().conservationSlider);
+ return getValue(Desktop.getInstance().conservationSlider);
}
static int getValue(JInternalFrame slider)
public static int getPIDValue()
{
- return getValue(Instance.getDesktop().PIDSlider);
+ return getValue(Desktop.getInstance().PIDSlider);
}
/**
public String getTitle()
{
String title = null;
- JInternalFrame conservationSlider = Instance
- .getDesktop().conservationSlider;
- JInternalFrame PIDSlider = Instance.getDesktop().PIDSlider;
+ JInternalFrame conservationSlider = Desktop
+ .getInstance().conservationSlider;
+ JInternalFrame PIDSlider = Desktop.getInstance().PIDSlider;
if (isForConservation())
{
*/
package jalview.gui;
-import jalview.bin.Instance;
import jalview.util.Platform;
import java.awt.BorderLayout;
System.err.println("Error when loading images!");
}
} while (!mt.checkAll());
- Instance.getDesktop().setIconImage(logo);
+ Desktop.getInstance().setIconImage(logo);
}
} catch (Exception ex)
{
@SuppressWarnings("unused")
protected boolean refreshText()
{
- String newtext = Instance.getDesktop().getAboutMessage(true).toString();
+ String newtext = Desktop.getInstance().getAboutMessage(true).toString();
// System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
if (oldtext != newtext.length())
{
authlist.setSize(new Dimension(750, 375));
add(authlist, BorderLayout.CENTER);
revalidate();
- iframe.setBounds((Instance.getDesktop().getWidth() - 750) / 2,
- (Instance.getDesktop().getHeight() - 375) / 2, 750,
+ iframe.setBounds((Desktop.getInstance().getWidth() - 750) / 2,
+ (Desktop.getInstance().getHeight() - 375) / 2, 750,
authlist.getHeight() + iconimg.getHeight());
iframe.validate();
iframe.setVisible(true);
}
closeSplash();
- Instance.getDesktop().startDialogQueue();
+ Desktop.getInstance().startDialogQueue();
}
/**
package jalview.gui;
import jalview.api.SplitContainerI;
-import jalview.bin.Instance;
import jalview.datamodel.AlignmentI;
import jalview.jbgui.GAlignFrame;
import jalview.jbgui.GSplitFrame;
// allow about 65 pixels for Desktop decorators on Windows
int newHeight = Math.min(height,
- Instance.getDesktop().getHeight() - DESKTOP_DECORATORS_HEIGHT);
+ Desktop.getInstance().getHeight() - DESKTOP_DECORATORS_HEIGHT);
if (newHeight != height)
{
int oldDividerLocation = getDividerLocation();
{
// TODO if CommandListener is only ever 1:1 for complementary views,
// may change broadcast pattern to direct messaging (more efficient)
- final StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop());
+ final StructureSelectionManager ssm = Desktop
+ .getStructureSelectionManager();
ssm.addCommandListener(((AlignFrame) getTopFrame()).getViewport());
ssm.addCommandListener(((AlignFrame) getBottomFrame()).getViewport());
}
*/
adjustLayout();
- final StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop());
+ final StructureSelectionManager ssm = Desktop
+ .getStructureSelectionManager();
ssm.addCommandListener(newTopPanel.av);
ssm.addCommandListener(newBottomPanel.av);
}
*/
protected void expandViews_actionPerformed()
{
- Instance.getDesktop().explodeViews(this);
+ Desktop.getInstance().explodeViews(this);
}
/**
*/
protected void gatherViews_actionPerformed()
{
- Instance.getDesktop().gatherViews(this);
+ Desktop.getInstance().gatherViews(this);
}
/**
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.bin.Jalview;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.DBRefSource;
*/
protected void discoverStructureViews()
{
- if (Instance.getDesktop() != null)
+ if (Desktop.getInstance() != null)
{
targetView.removeAllItems();
- Desktop d = Instance.getDesktop();
+ Desktop d = Desktop.getInstance();
if (d.lastTargetedView != null && !d.lastTargetedView.isVisible())
{
d.lastTargetedView = null;
}
int linkedViewsAt = 0;
- for (StructureViewerBase view : Instance.getDesktop()
+ for (StructureViewerBase view : Desktop.getInstance()
.getStructureViewers(null, null))
{
StructureViewer viewHandler = (d.lastTargetedView != null
{
selectedSequence = userSelectedSeq;
}
- PDBEntry fileEntry = new AssociatePdbFileWithSeq()
+ PDBEntry fileEntry = AssociatePdbFileWithSeq
.associatePdbWithSeq(selectedPdbFileName,
- DataSourceType.FILE, selectedSequence, true,
- Instance.getDesktop());
+ DataSourceType.FILE, selectedSequence, true);
sViewer = launchStructureViewer(
ssm, new PDBEntry[]
}
setProgressBar(null, progressId);
// remember the last viewer we used...
- Instance.getDesktop().lastTargetedView = theViewer;
+ Desktop.getInstance().lastTargetedView = theViewer;
return theViewer;
}
import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.HiddenColumns;
*/
protected List<StructureViewerBase> getViewersFor(AlignmentPanel alp)
{
- return Instance.getDesktop().getStructureViewers(alp, this.getClass());
+ return Desktop.getInstance().getStructureViewers(alp, this.getClass());
}
@Override
package jalview.gui;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.HiddenColumns;
if (reply == JvOptionPane.YES_OPTION)
{
Cache.log.debug("Prompting for vamsas store filename.");
- Instance.getDesktop().vamsasSave_actionPerformed(null);
+ Desktop.getInstance().vamsasSave_actionPerformed(null);
Cache.log
.debug("Finished attempt at storing document.");
}
public void disableGui(boolean b)
{
- Instance.getDesktop().setVamsasUpdate(b);
+ Desktop.getInstance().setVamsasUpdate(b);
}
Hashtable _backup_vobj2jv;
}
try
{
- final IPickManager pm = vclient.getPickManager();
- final StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop());
- final VamsasApplication me = this;
+ IPickManager pm = vclient.getPickManager();
+ StructureSelectionManager ssm = Desktop
+ .getStructureSelectionManager();
+ VamsasApplication me = this;
pm.registerMessageHandler(new IMessageHandler()
{
String last = null;
*/
package jalview.gui;
-import jalview.bin.Instance;
import jalview.gui.OptsAndParamsPage.OptionBox;
import jalview.gui.OptsAndParamsPage.ParamBox;
import jalview.util.MessageManager;
public boolean showRunDialog()
{
- frame = new JDialog(Instance.getDesktop(), true);
+ frame = new JDialog(Desktop.getInstance(), true);
frame.setTitle(MessageManager.formatMessage("label.edit_params_for",
new String[]
{ service.getActionText() }));
- Rectangle deskr = Instance.getDesktop().getBounds();
+ Rectangle deskr = Desktop.getInstance().getBounds();
Dimension pref = this.getPreferredSize();
frame.setBounds(
new Rectangle((int) (deskr.getCenterX() - pref.width / 2),
dialogpanel.add(canceljob);
// JAL-1580: setMaximumSize() doesn't work, so just size for the worst case:
// check for null is for JUnit usage
- final int windowHeight = Instance.getDesktop() == null ? 540
- : Instance.getDesktop().getHeight();
+ final int windowHeight = Desktop.getInstance() == null ? 540
+ : Desktop.getInstance().getHeight();
setPreferredSize(new Dimension(540, windowHeight));
add(dialogpanel, BorderLayout.SOUTH);
validate();
public static void main(String[] args)
{
jalview.ws.jws2.Jws2Discoverer disc = jalview.ws.jws2.Jws2Discoverer
- .getDiscoverer();
+ .getInstance();
int p = 0;
if (args.length > 0)
{
Vector<String> services = new Vector<>();
services.addElement(args[p++]);
- Jws2Discoverer.getDiscoverer().setServiceUrls(services);
+ Jws2Discoverer.getInstance().setServiceUrls(services);
}
try
{
package jalview.gui;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import jalview.util.MessageManager;
chooser.setDialogTitle(MessageManager
.getString("label.choose_filename_for_param_file"));
chooser.setToolTipText(MessageManager.getString("action.save"));
- int value = chooser.showSaveDialog(Instance.getDesktop());
+ int value = chooser.showSaveDialog(Desktop.getInstance());
if (value == JalviewFileChooser.APPROVE_OPTION)
{
outfile = chooser.getSelectedFile();
File pfile = new File(filename);
if (pfile.exists() && pfile.canWrite())
{
- if (JvOptionPane.showConfirmDialog(Instance.getDesktop(),
+ if (JvOptionPane.showConfirmDialog(Desktop.getInstance(),
"Delete the preset's file, too ?", "Delete User Preset ?",
JvOptionPane.OK_CANCEL_OPTION) == JvOptionPane.OK_OPTION)
{
package jalview.gui;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.jbgui.GWsPreferences;
import jalview.util.MessageManager;
import jalview.ws.jws2.Jws2Discoverer;
private void initFromPreferences()
{
- wsUrls = Jws2Discoverer.getDiscoverer().getServiceUrls();
+ wsUrls = Jws2Discoverer.getInstance().getServiceUrls();
if (!wsUrls.isEmpty())
{
oldUrls = new Vector<String>(wsUrls);
int r = 0;
for (String url : wsUrls)
{
- int status = Jws2Discoverer.getDiscoverer().getServerStatusFor(url);
+ int status = Jws2Discoverer.getInstance().getServerStatusFor(url);
tdat[r][1] = new Integer(status);
tdat[r++][0] = url;
}
private void updateServiceList()
{
- Jws2Discoverer.getDiscoverer().setServiceUrls(wsUrls);
+ Jws2Discoverer.getInstance().setServiceUrls(wsUrls);
}
private void updateRsbsServiceList()
if (lastrefresh != update)
{
lastrefresh = update;
- Instance.getDesktop().startServiceDiscovery(true); // wait around for all
+ Desktop.getInstance().startServiceDiscovery(true); // wait around for all
// threads to complete
updateList();
public void run()
{
long ct = System.currentTimeMillis();
- Instance.getDesktop().setProgressBar(MessageManager
+ Desktop.getInstance().setProgressBar(MessageManager
.getString("status.refreshing_web_service_menus"), ct);
if (lastrefresh != update)
{
lastrefresh = update;
- Instance.getDesktop().startServiceDiscovery(true);
+ Desktop.getInstance().startServiceDiscovery(true);
updateList();
}
- Instance.getDesktop().setProgressBar(null, ct);
+ Desktop.getInstance().setProgressBar(null, ct);
}
}).start();
@Override
protected void resetWs_actionPerformed(ActionEvent e)
{
- Jws2Discoverer.getDiscoverer().setServiceUrls(null);
- List<String> nwsUrls = Jws2Discoverer.getDiscoverer().getServiceUrls();
+ Jws2Discoverer.getInstance().setServiceUrls(null);
+ List<String> nwsUrls = Jws2Discoverer.getInstance().getServiceUrls();
if (!wsUrls.equals(nwsUrls))
{
update++;
*/
public class HttpServer
{
- /*
- * 'context root' - actually just prefixed to the path for each handler for
- * now - see registerHandler
- */
- private static final String JALVIEW_PATH = "jalview";
/**
* Returns the singleton instance of this class.
}
}
+ /**
+ * Private constructor to enforce use of singleton; use getInstance().
+ *
+ * @throws BindException
+ * if no free port can be assigned
+ */
+ private HttpServer() throws BindException
+ {
+ // use getInstance()
+
+ startServer();
+
+ /*
+ * Provides a REST server by default; add more programmatically as required
+ */
+ registerHandler(RestHandler.getInstance());
+ }
+
+ /*
+ * 'context root' - actually just prefixed to the path for each handler for
+ * now - see registerHandler
+ */
+ private static final String JALVIEW_PATH = "jalview";
+
/*
* The Http server
*/
private URI contextRoot;
/**
- * Private constructor to enforce use of singleton
- *
- * @throws BindException
- * if no free port can be assigned
- */
- private HttpServer() throws BindException
- {
- startServer();
-
- /*
- * Provides a REST server by default; add more programmatically as required
- */
- registerHandler(RestHandler.getInstance());
- }
-
- /**
* Start the http server
*
* @throws BindException
import jalview.api.FeaturesDisplayedI;
import jalview.api.FeaturesSourceI;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.bin.Jalview;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.HiddenColumns;
import jalview.json.binding.biojson.v1.ColourSchemeMapper;
import jalview.project.Jalview2XML;
import jalview.schemes.ColourSchemeI;
-import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.ws.utils.UrlDownloadClient;
Runtime rt = Runtime.getRuntime();
try
{
- if (Instance.getDesktop() != null)
+ if (Desktop.getInstance() != null)
{
- Instance.getDesktop().startLoading(file);
+ Desktop.getInstance().startLoading(file);
}
if (format == null)
{
if (format == null)
{
- Instance.getDesktop().stopLoading();
+ Desktop.getInstance().stopLoading();
System.err.println("The input file \"" + file
+ "\" has null or unidentifiable data content!");
if (!Jalview.isHeadlessMode())
{
// register PDB entries with desktop's structure selection
// manager
- StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop())
+ Desktop.getStructureSelectionManager()
.registerPDBEntry(pdbe);
}
}
}
else
{
- if (Instance.getDesktop() != null)
+ if (Desktop.getInstance() != null)
{
- Instance.getDesktop().stopLoading();
+ Desktop.getInstance().stopLoading();
}
final String errorMessage = MessageManager.getString(
}
}
// remove the visual delay indicator
- if (Instance.getDesktop() != null)
+ if (Desktop.getInstance() != null)
{
- Instance.getDesktop().stopLoading();
+ Desktop.getInstance().stopLoading();
}
}
package jalview.io;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.GraphLine;
// FIND ANY ASSOCIATED TREES
if (Desktop.getDesktopPane() != null)
{
- javax.swing.JInternalFrame[] frames = Instance.getDesktop()
+ javax.swing.JInternalFrame[] frames = Desktop.getInstance()
.getAllFrames();
for (int t = 0; t < frames.length; t++)
// active
if (mappings != null)
{
- jalview.structure.StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop())
+ Desktop.getStructureSelectionManager()
.registerMappings(mappings);
}
}
String atts = gff[ATTRIBUTES_COL];
Map<String, List<String>> attributes = parseNameValuePairs(atts);
- SequenceOntologyI so = SequenceOntologyFactory.getInstance();
+ SequenceOntologyI so = SequenceOntologyFactory.getSequenceOntology();
if (so.isA(soTerm, SequenceOntologyI.PROTEIN_MATCH))
{
sf = processProteinMatch(attributes, seq, gff, align, newseqs,
desc = target.split(" ")[0];
}
- SequenceOntologyI so = SequenceOntologyFactory.getInstance();
+ SequenceOntologyI so = SequenceOntologyFactory.getSequenceOntology();
String type = sf.getType();
if (so.isA(type, SequenceOntologyI.SEQUENCE_VARIANT))
{
*/
public static boolean recognises(String[] columns)
{
- SequenceOntologyI so = SequenceOntologyFactory.getInstance();
+ SequenceOntologyI so = SequenceOntologyFactory.getSequenceOntology();
String type = columns[TYPE_COL];
if (so.isA(type, SequenceOntologyI.PROTEIN_MATCH)
|| (".".equals(columns[SOURCE_COL])
public class SequenceOntologyFactory
{
- private SequenceOntologyFactory()
+ public static synchronized SequenceOntologyI getSequenceOntology()
{
- // noninstantiable
+ SequenceOntologyFactory j = getInstance();
+ return (j.sequenceOntology == null
+ ? j.sequenceOntology = new SequenceOntologyLite()
+ : j.sequenceOntology);
}
- // private static SequenceOntologyI instance; // moved to Jalview.instance for
- // JavaScript
- public static synchronized SequenceOntologyI getInstance()
+ /**
+ * For testng only
+ *
+ * @param so
+ */
+ public static void setInstance(SequenceOntologyI so)
{
- Instance j = Instance.getInstance();
- if (j.sequenceOntology == null)
- {
- j.sequenceOntology = new SequenceOntologyLite();
- }
- return j.sequenceOntology;
+ getInstance().sequenceOntology = so;
}
- public static void setInstance(SequenceOntologyI so)
+ private SequenceOntologyI sequenceOntology;
+
+ private SequenceOntologyFactory()
{
- Instance.getInstance().sequenceOntology = so;
+ // private singleton
}
+
+ private static synchronized SequenceOntologyFactory getInstance()
+ {
+ Instance j = Instance.getInstance();
+ return (j.sequenceOntologyFactory == null
+ ? j.sequenceOntologyFactory = new SequenceOntologyFactory()
+ : j.sequenceOntologyFactory);
+ }
+
}
*/
package jalview.io.vamsas;
-import jalview.bin.Instance;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.Mapping;
import jalview.datamodel.SequenceI;
+import jalview.gui.Desktop;
import jalview.io.VamsasAppDatastore;
import java.util.ArrayList;
}
}
+ @Override
public void addToDocument()
{
add(mjvmapping, from, ds);
}
+ @Override
public void addFromDocument()
{
add((SequenceMapping) vobj);
}
+ @Override
public void conflict()
{
conflict(mjvmapping, (SequenceMapping) vobj);
}
+ @Override
public void updateToDoc()
{
update(mjvmapping, (SequenceMapping) vobj);
}
+ @Override
public void updateFromDoc()
{
update((SequenceMapping) vobj, (jalview.datamodel.Mapping) jvobj);
acf.addMap(from, to, mapping);
}
bindjvvobj(mapping, sequenceMapping);
- jalview.structure.StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop())
- .registerMapping(acf);
+ Desktop.getStructureSelectionManager().registerMapping(acf);
// Try to link up any conjugate database references in the two sequences
// matchConjugateDBRefs(from, to, mapping);
// Try to propagate any dbrefs across this mapping.
+ from.getName() + " and " + to.getName());
}
List<DBRefEntry> fdb = from.getDBRefs();
- List<DBRefEntry> tdb = new ArrayList<DBRefEntry>(to.getDBRefs());
+ List<DBRefEntry> tdb = new ArrayList<>(to.getDBRefs());
int tdblen = to.getDBRefs().size();
//
//
import jalview.api.analysis.SimilarityParamsI;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.schemes.FeatureColour;
import jalview.schemes.ResidueProperties;
import jalview.schemes.UserColourScheme;
-import jalview.structure.StructureSelectionManager;
import jalview.structures.models.AAStructureBindingModel;
import jalview.util.Format;
import jalview.util.MessageManager;
if (calcIdParam.getVersion().equals("1.0"))
{
final String[] calcIds = calcIdParam.getServiceURL().toArray(new String[0]);
- Jws2Instance service = Jws2Discoverer.getDiscoverer()
+ Jws2Instance service = Jws2Discoverer.getInstance()
.getPreferredServiceFor(calcIds);
if (service != null)
{
{
// used to attempt to parse as V1 castor-generated xml
}
- if (Instance.getDesktop() != null)
+ if (Desktop.getInstance() != null)
{
- Instance.getDesktop().stopLoading();
+ Desktop.getInstance().stopLoading();
}
if (af != null)
{
*/
for (AlignFrame fr : gatherToThisFrame.values())
{
- Instance.getDesktop().gatherViews(fr);
+ Desktop.getInstance().gatherViews(fr);
}
restoreSplitFrames();
{
if (ds.getCodonFrames() != null)
{
- StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop())
+ Desktop.getStructureSelectionManager()
.registerMappings(ds.getCodonFrames());
}
}
reportErrors();
}
- if (Instance.getDesktop() != null)
+ if (Desktop.getInstance() != null)
{
- Instance.getDesktop().stopLoading();
+ Desktop.getInstance().stopLoading();
}
return af;
*/
for (SplitFrame sf : gatherTo)
{
- Instance.getDesktop().gatherViews(sf);
+ Desktop.getInstance().gatherViews(sf);
}
splitFrameCandidates.clear();
{
entry.setProperty(prop.getName(), prop.getValue());
}
- StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop())
- .registerPDBEntry(entry);
+ Desktop.getStructureSelectionManager().registerPDBEntry(entry);
// adds PDBEntry to datasequence's set (since Jalview 2.10)
if (al.getSequenceAt(i).getDatasetSequence() != null)
{
import javax.servlet.http.HttpServletResponse;
/**
- * A simple handler to process (or delegate) HTTP requests on /jalview/rest
+ * A simple handler to process (or delegate) HTTP requests on /jalview/rest.
+ * Accessed only by HttpServer.
*/
public class RestHandler extends AbstractRequestHandler
{
package jalview.schemes;
import jalview.api.AlignViewportI;
-import jalview.bin.Instance;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AnnotatedCollectionI;
if (annotation.isRNA())
{
// reset colour palette
- ColourSchemeProperty.resetRnaHelicesShading();
- ColourSchemeProperty.initRnaHelicesShading(1 + (int) aamax);
+ ColourSchemes.resetRnaHelicesShading();
+ ColourSchemes.initRnaHelicesShading(1 + (int) aamax);
}
}
}
if (rna)
{
- ColourSchemeProperty.initRnaHelicesShading(1 + (int) aamax);
+ ColourSchemes.initRnaHelicesShading(1 + (int) aamax);
}
}
}
{
if (ann.isRNA())
{
- result = Instance.getInstance().rnaHelices[(int) aj.value];
+ result = ColourSchemes.getInstance().rnaHelices[(int) aj.value];
}
else
{
package jalview.schemes;
import jalview.api.AlignViewportI;
-import jalview.bin.Instance;
import jalview.datamodel.AnnotatedCollectionI;
-import jalview.util.ColorUtils;
-
-import java.awt.Color;
/**
* ColourSchemeProperty binds names to hardwired colourschemes and tries to deal
public class ColourSchemeProperty
{
+ private ColourSchemeProperty()
+ {
+ // requires static call to getColourScheme(...).
+ }
+
/**
* Returns a colour scheme for the given name, with which the given data may
* be coloured. The name is not case-sensitive, and may be one of
return ucs;
}
- public static void initRnaHelicesShading(int n)
- {
- int i = 0;
- Instance j = Instance.getInstance();
-
- if (j.rnaHelices == null)
- {
- j.rnaHelices = new Color[n + 1];
- }
- else if (j.rnaHelices != null && j.rnaHelices.length <= n)
- {
- Color[] t = new Color[n + 1];
- System.arraycopy(j.rnaHelices, 0, t, 0, j.rnaHelices.length);
- i = j.rnaHelices.length;
- j.rnaHelices = t;
- }
- else
- {
- return;
- }
- // Generate random colors and store
- for (; i <= n; i++)
- {
- j.rnaHelices[i] = ColorUtils.generateRandomColor(Color.white);
- }
- }
-
- /**
- * delete the existing cached RNA helices colours
- */
- public static void resetRnaHelicesShading()
- {
- Instance.getInstance().rnaHelices = null;
- }
-
/**
* Returns the name of the colour scheme (or "None" if it is null)
*
package jalview.schemes;
import jalview.api.AlignViewportI;
+import jalview.bin.Instance;
import jalview.datamodel.AnnotatedCollectionI;
import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceI;
+import jalview.util.ColorUtils;
+import java.awt.Color;
import java.util.LinkedHashMap;
import java.util.Map;
public class ColourSchemes
{
- /*
- * singleton instance of this class
- */
- private static ColourSchemes instance = new ColourSchemes();
-
- /*
- * a map from scheme name (lower-cased) to an instance of it
- */
- private Map<String, ColourSchemeI> schemes;
/**
* Returns the singleton instance of this class
*/
public static ColourSchemes getInstance()
{
- return instance;
+ Instance j = Instance.getInstance();
+ return (j.colourSchemes == null ? j.colourSchemes = new ColourSchemes()
+ : j.colourSchemes);
}
private ColourSchemes()
}
/**
+ * ColourSchemeProperty "static"
+ */
+ public Color[] rnaHelices = null;
+
+ /**
+ * delete the existing cached RNA helices colours
+ */
+ public static void resetRnaHelicesShading()
+ {
+ getInstance().rnaHelices = null;
+ }
+
+ public static void initRnaHelicesShading(int n)
+ {
+ int i = 0;
+ ColourSchemes j = getInstance();
+
+ if (j.rnaHelices == null)
+ {
+ j.rnaHelices = new Color[n + 1];
+ }
+ else if (j.rnaHelices != null && j.rnaHelices.length <= n)
+ {
+ Color[] t = new Color[n + 1];
+ System.arraycopy(j.rnaHelices, 0, t, 0, j.rnaHelices.length);
+ i = j.rnaHelices.length;
+ j.rnaHelices = t;
+ }
+ else
+ {
+ return;
+ }
+ // Generate random colors and store
+ for (; i <= n; i++)
+ {
+ j.rnaHelices[i] = ColorUtils.generateRandomColor(Color.white);
+ }
+ }
+
+ /**
+ * a map from scheme name (lower-cased) to an instance of it
+ */
+ private Map<String, ColourSchemeI> schemes;
+
+ /**
* Loads an instance of each standard or user-defined colour scheme
*
* @return
package jalview.schemes;
import jalview.api.AlignViewportI;
-import jalview.bin.Instance;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AnnotatedCollectionI;
{
super(ResidueProperties.nucleotideIndex);
this.annotation = annotation;
- ColourSchemeProperty.resetRnaHelicesShading();
+ ColourSchemes.resetRnaHelicesShading();
refresh();
}
public RNAHelicesColour(AnnotatedCollectionI alignment)
{
super(ResidueProperties.nucleotideIndex);
- ColourSchemeProperty.resetRnaHelicesShading();
+ ColourSchemes.resetRnaHelicesShading();
alignmentChanged(alignment, null);
}
}
}
- ColourSchemeProperty.initRnaHelicesShading(numHelix);
+ ColourSchemes.initRnaHelicesShading(numHelix);
}
}
currentHelix = positionsToHelix.get(j);
if (currentHelix != null)
{
- currentColour = Instance.getInstance().rnaHelices[Integer
+ currentColour = ColourSchemes.getInstance().rnaHelices[Integer
.parseInt(currentHelix)];
}
return currentColour;
private StructureImportSettings()
{
- // singleton
+ // private singleton
}
private static StructureImportSettings getInstance()
public class StructureSelectionManager
{
+ public static StructureSelectionManager getStructureSelectionManager(
+ StructureSelectionManagerProvider context)
+ {
+ IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> map = Instance
+ .getInstance().structureSelections;
+
+ if (map == null)
+ {
+ map = Instance
+ .getInstance().structureSelections = new IdentityHashMap<>();
+ }
+ StructureSelectionManager instance = map.get(context);
+ if (instance == null)
+ {
+ // BH: actually, not possible except for coding error; this is an attempt
+ // to discover that.
+ if (context == null && !map.isEmpty())
+ {
+ throw new Error(MessageManager.getString(
+ "error.implementation_error_structure_selection_manager_null"),
+ new NullPointerException(MessageManager
+ .getString("exception.ssm_context_is_null")));
+ }
+ map.put(context, instance = new StructureSelectionManager());
+ }
+ return instance;
+ }
+
+ /**
+ * release all references associated with this manager provider
+ *
+ * @param provider
+ */
+
+ public static void release(StructureSelectionManagerProvider provider)
+ {
+ IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> map = Instance
+ .getInstance().structureSelections;
+ if (map != null)
+ {
+ map.remove(provider);
+ }
+ }
+
public StructureSelectionManager()
{
}
* Import structure data and register a structure mapping for broadcasting
* colouring, mouseovers and selection events (convenience wrapper).
*
+ * This is the standard entry point.
+ *
* @param sequence
* - one or more sequences to be mapped to pdbFile
* @param targetChains
* broadcasting colouring, mouseovers and selection events (convenience
* wrapper).
*
+ *
+ *
* @param forStructureView
- * when true, record the mapping for use in mouseOvers
+ * when true (testng only), record the mapping for use in mouseOvers
+ * (testng only)
* @param sequence
* - one or more sequences to be mapped to pdbFile
* @param targetChains
* mapping operation
* @return null or the structure data parsed as a pdb file
*/
- synchronized public StructureFile computeMapping(
+ synchronized private StructureFile computeMapping(
boolean forStructureView, SequenceI[] sequenceArray,
String[] targetChainIds, String pdbFile, DataSourceType sourceType,
IProgressIndicator progress)
}
/**
- * Resets this object to its initial state by removing all registered
- * listeners, codon mappings, PDB file mappings
+ * Reset this object to its initial state by removing all registered
+ * listeners, codon mappings, PDB file mappings.
+ *
+ * Called only by Desktop and testng.
+ *
*/
public void resetAll()
{
- if (mappings != null)
- {
- mappings.clear();
- }
- if (seqmappings != null)
- {
- seqmappings.clear();
- }
- if (sel_listeners != null)
- {
- sel_listeners.clear();
- }
- if (listeners != null)
- {
- listeners.clear();
- }
- if (commandListeners != null)
- {
- commandListeners.clear();
- }
- if (view_listeners != null)
- {
- view_listeners.clear();
- }
- if (pdbFileNameId != null)
- {
- pdbFileNameId.clear();
- }
- if (pdbIdFileName != null)
- {
- pdbIdFileName.clear();
- }
+ mappings.clear();
+ seqmappings.clear();
+ sel_listeners.clear();
+ listeners.clear();
+ commandListeners.clear();
+ view_listeners.clear();
+ pdbFileNameId.clear();
+ pdbIdFileName.clear();
}
public void addSelectionListener(SelectionListener selecter)
return seqmappings;
}
- public static StructureSelectionManager getStructureSelectionManager(
- StructureSelectionManagerProvider context)
- {
- IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> map = Instance
- .getInstance().structureSelections;
-
- if (map == null)
- {
- map = Instance
- .getInstance().structureSelections = new IdentityHashMap<>();
- }
- StructureSelectionManager instance = map.get(context);
- if (instance == null)
- {
- // BH: actually, not possible except for coding error; this is an attempt
- // to discover that.
- if (context == null && !map.isEmpty())
- {
- throw new Error(MessageManager.getString(
- "error.implementation_error_structure_selection_manager_null"),
- new NullPointerException(MessageManager
- .getString("exception.ssm_context_is_null")));
- }
- map.put(context,
- instance = new StructureSelectionManager());
- }
- return instance;
- }
-
- /**
- * release all references associated with this manager provider
- *
- * @param provider
- */
-
- public static void release(StructureSelectionManagerProvider provider)
- {
- IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> map = Instance
- .getInstance().structureSelections;
- if (map != null)
- {
- map.remove(provider);
- }
- }
-
}
*/
public class IdOrgSettings
{
- private String url;
- private String location;
private IdOrgSettings()
{
- // singleton
+ // private singleton
}
private static IdOrgSettings getInstance()
: j.idOrgSettings);
}
+ private String url;
+
+ private String location;
+
public static void setUrl(String seturl)
{
getInstance().url = seturl;
}
this.dataset = ds;
// TODO Jalview 2.5 lots of this code should be in the gui package!
- sfetcher = jalview.gui.SequenceFetcher.getSequenceFetcherSingleton();
+ sfetcher = SequenceFetcher.getInstance();
// set default behaviour for transferring excess sequence data to the
// dataset
trimDsSeqs = Cache.getDefault(TRIM_RETRIEVED_SEQUENCES, true);
{
int n;
if (sequencesArray == null || (n = sequencesArray.length) == 0)
- return sequencesArray;
+ {
+ return sequencesArray;
+ }
ArrayList<SequenceI> nseq = new ArrayList<>();
for (int i = 0;i < n; i++)
{
*/
package jalview.ws;
+import jalview.bin.Instance;
import jalview.datamodel.DBRefSource;
import jalview.ext.ensembl.EnsemblGene;
import jalview.ws.dbsources.Uniprot;
import java.util.List;
/**
- * This implements the run-time discovery of sequence database clients.
+ * Thread safe construction of database proxies. This implements the run-time
+ * discovery of sequence database clients.
*
+ * TODO: extend to a configurable database plugin mechanism where classes are
+ * instantiated by reflection and queried for their DbRefSource and version
+ * association.
*/
public class SequenceFetcher extends ASequenceFetcher
{
+
+ /**
+ * Returns a new SequenceFetcher singleton, or a mock object if one has been
+ * set. Used by CrossRef and java.gui.SequenceFetcher.
+ *
+ * @return
+ */
+ public static SequenceFetcher getInstance()
+ {
+ Instance j = Instance.getInstance();
+ return (j.sequenceFetcher == null
+ ? j.sequenceFetcher = new SequenceFetcher()
+ : j.sequenceFetcher);
+ }
+
/**
- * Thread safe construction of database proxies TODO: extend to a configurable
- * database plugin mechanism where classes are instantiated by reflection and
- * queried for their DbRefSource and version association.
+ *
+ * This public constructor is only is for use by testng to anonymously
+ * subclass SequenceFetcher.
+ *
*
*/
public SequenceFetcher()
addAllDatabases();
}
+ /**
+ * Set the instance object to use (intended for unit testing with mock
+ * objects).
+ *
+ * Be sure to reset to null in the tearDown method of any tests!
+ *
+ * @param sf
+ */
+ public static void setSequenceFetcher(SequenceFetcher sf)
+ {
+ Instance.getInstance().sequenceFetcher = sf;
+ }
+
public void addAllDatabases()
{
addDBRefSourceImpl(EnsemblGene.class); // includes EnsemblGenomes.class
*/
package jalview.ws;
-import jalview.bin.Instance;
-import jalview.ws.seqfetcher.ASequenceFetcher;
-
public class SequenceFetcherFactory
{
-
- /**
- * Returns a new SequenceFetcher object, or a mock object if one has been set
- *
- * @return
- */
- public static ASequenceFetcher getSequenceFetcher()
- {
- Instance j = Instance.getInstance();
- return (j.sequenceFetcher == null
- ? j.sequenceFetcher = new SequenceFetcher()
- : j.sequenceFetcher);
- }
-
- /**
- * Set the instance object to use (intended for unit testing with mock
- * objects).
- *
- * Be sure to reset to null in the tearDown method of any tests!
- *
- * @param sf
- */
- public static void setSequenceFetcher(SequenceFetcher sf)
- {
- Instance.getInstance().sequenceFetcher = sf;
- }
+ // BH the two methods in this class merged into SequenceFetcher
}
public class Discoverer implements Runnable
{
- private Discoverer()
- {
- };
-
public static Discoverer getInstance()
{
Instance j = Instance.getInstance();
: j.discoverer);
}
+ private Discoverer()
+ {
+ // use getInstance()
+ }
+
private java.net.URL RootServiceURL = null;
private Vector<URL> ServiceURLList = null;
{
// check service is actually in the list of currently avaialable
// services
- if (!Jws2Discoverer.getDiscoverer().getServices().contains(service))
+ if (!Jws2Discoverer.getInstance().getServices().contains(service))
{
// it isn't ..
service = null;
if (service == null)
{
// get the default service for AACon
- service = Jws2Discoverer.getDiscoverer().getPreferredServiceFor(null,
+ service = Jws2Discoverer.getInstance().getPreferredServiceFor(null,
aaui.getServiceType());
}
if (service == null)
*/
public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
{
+
+ /**
+ * Returns the singleton instance of this class.
+ *
+ * @return
+ */
+ public static Jws2Discoverer getInstance()
+ {
+ Instance j = Instance.getInstance();
+ return (j.j2s2discoverer == null
+ ? j.j2s2discoverer = new Jws2Discoverer()
+ : j.j2s2discoverer);
+ }
+
+ /**
+ * Private constructor enforces use of singleton via getDiscoverer()
+ */
+ private Jws2Discoverer()
+ {
+ // use getInstance();
+ }
+
public static final String COMPBIO_JABAWS = "http://www.compbio.dundee.ac.uk/jabaws";
/*
protected Vector<Jws2Instance> services;
/**
- * Private constructor enforces use of singleton via getDiscoverer()
- */
- private Jws2Discoverer()
- {
- }
-
- /**
* change listeners are notified of "services" property changes
*
* @param listener
testUrls.add(url);
}
}
- Thread runner = getDiscoverer()
+ Thread runner = getInstance()
.startDiscoverer(new PropertyChangeListener()
{
@Override
public void propertyChange(PropertyChangeEvent evt)
{
- if (getDiscoverer().services != null)
+ if (getInstance().services != null)
{
System.out.println("Changesupport: There are now "
- + getDiscoverer().services.size() + " services");
+ + getInstance().services.size() + " services");
int i = 1;
- for (Jws2Instance instance : getDiscoverer().services)
+ for (Jws2Instance instance : getInstance().services)
{
System.out.println("Service " + i++ + " "
+ instance.getClass() + "@" + instance.getHost()
}
}
- /**
- * Returns the singleton instance of this class.
- *
- * @return
- */
- public static Jws2Discoverer getDiscoverer()
- {
- Instance j = Instance.getInstance();
- return (j.j2s2discoverer == null
- ? j.j2s2discoverer = new Jws2Discoverer()
- : j.j2s2discoverer);
- }
-
public boolean hasServices()
{
return !running && services != null && services.size() > 0;
package jalview.ws.jws2;
import jalview.api.AlignCalcWorkerI;
-import jalview.bin.Instance;
import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
import jalview.gui.JvSwingUtils;
import jalview.util.MessageManager;
import jalview.ws.jws2.dm.AAConSettings;
@Override
public void actionPerformed(ActionEvent arg0)
{
- Instance.getDesktop().showUrl(service.docUrl);
+ Desktop.getInstance().showUrl(service.docUrl);
}
});
annotservice.setToolTipText(
*/
package jalview.ws.jws2.jabaws2;
-import jalview.bin.Instance;
import jalview.gui.AlignFrame;
import jalview.gui.Desktop;
import jalview.util.MessageManager;
try
{
paramStore = new JabaParamStore(this,
- (Instance.getDesktop() != null ? Desktop.getUserParameterStore()
+ (Desktop.getInstance() != null ? Desktop.getUserParameterStore()
: null));
} catch (Exception ex)
{
public class Jws2InstanceFactory
{
- private HashMap<String, AlignAnalysisUIText> aaConGUI;
-
- private HashSet<String> ignoreGUI;
+ private Jws2InstanceFactory()
+ {
+ // private singleton
+ }
- public static Jws2InstanceFactory getInstance()
+ private static Jws2InstanceFactory getInstance()
{
Instance j = Instance.getInstance();
return (j.jws2InstanceFactory == null
: j.jws2InstanceFactory);
}
+ private HashMap<String, AlignAnalysisUIText> aaConGUI;
+
+ private HashSet<String> ignoreGUI;
+
private static String category_rewrite(String cat_name)
{
return (cat_name != null && cat_name.equals("Prediction"))
*/
protected ASequenceFetcher()
{
- super();
-
/*
* comparator to sort proxies by tier and name
*/
*/
private static File mockSiftsFile;
+ private static final int BUFFER_SIZE = 4096;
+
+ public static final int UNASSIGNED = Integer.MIN_VALUE;
+
+ private static final int PDB_RES_POS = 0;
+
+ private static final int PDB_ATOM_POS = 1;
+
+ private static final int PDBE_POS = 2;
+
+ private static final String NOT_OBSERVED = "Not_Observed";
+
+ protected static final String SIFTS_FTP_BASE_URL = "http://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/";
+
+ protected final static String NEWLINE = System.lineSeparator();
+
private Entry siftsEntry;
private StructureFile pdb;
*/
private jalview.datamodel.Mapping seqFromPdbMapping;
- private static final int BUFFER_SIZE = 4096;
-
- public static final int UNASSIGNED = Integer.MIN_VALUE;
-
- private static final int PDB_RES_POS = 0;
-
- private static final int PDB_ATOM_POS = 1;
-
- private static final int PDBE_POS = 2;
-
- private static final String NOT_OBSERVED = "Not_Observed";
-
- protected static final String SIFTS_FTP_BASE_URL = "http://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/";
-
- protected final static String NEWLINE = System.lineSeparator();
-
private String curSourceDBRef;
private HashSet<String> curDBRefAccessionIdsString;
public class SiftsSettings
{
- private boolean mapWithSifts = false;
-
- private String siftDownloadDirectory;
-
- private int cacheThresholdInDays;
- private int failSafePIDThreshold;
-
- private static SiftsSettings getInstance()
+ /**
+ * public only for testng
+ *
+ * @return
+ */
+ public static SiftsSettings getInstance()
{
{
Instance j = Instance.getInstance();
}
}
+
+ private SiftsSettings()
+ {
+ // singleton; use getInstance()
+ }
+
+ private boolean mapWithSifts = false;
+
+ private String siftDownloadDirectory;
+
+ private int cacheThresholdInDays;
+
+ private int failSafePIDThreshold;
+
public static boolean isMapWithSifts()
{
return getInstance().mapWithSifts;
import jalview.util.DBRefUtils;
import jalview.util.MapList;
import jalview.ws.SequenceFetcher;
-import jalview.ws.SequenceFetcherFactory;
-import jalview.ws.params.InvalidArgumentException;
import java.util.ArrayList;
import java.util.Arrays;
return new SequenceI[] { pep1, pep2 };
}
};
- SequenceFetcherFactory.setSequenceFetcher(mockFetcher);
+ SequenceFetcher.setSequenceFetcher(mockFetcher);
/*
* find UNIPROT xrefs for nucleotide sequence
@AfterClass(alwaysRun = true)
public void tearDown()
{
- SequenceFetcherFactory.setSequenceFetcher(null);
+ SequenceFetcher.setSequenceFetcher(null);
}
/**
return new SequenceI[] { pep1, pep2 };
}
};
- SequenceFetcherFactory.setSequenceFetcher(mockFetcher);
+ SequenceFetcher.setSequenceFetcher(mockFetcher);
/*
* find UNIPROT xrefs for gene and transcripts
}
}
};
- SequenceFetcherFactory.setSequenceFetcher(mockFetcher);
+
+ SequenceFetcher.setSequenceFetcher(mockFetcher);
/*
* find EMBL xrefs for Uniprot seqs and verify that
@AfterClass(alwaysRun = true)
public static void tearDownAfterClass() throws Exception
{
- jalview.bin.Instance.getDesktop().closeAll_actionPerformed(null);
+ jalview.gui.Desktop.getInstance().closeAll_actionPerformed(null);
}
@Test(groups = { "Functional" })
import jalview.api.FeatureRenderer;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.bin.Jalview;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
import jalview.gui.JvOptionPane;
import jalview.gui.Preferences;
import jalview.gui.StructureViewer;
@AfterClass(alwaysRun = true)
public static void tearDownAfterClass() throws Exception
{
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
}
@AfterMethod(alwaysRun = true)
import jalview.api.FeatureColourI;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.bin.Jalview;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
}
/**
import static org.testng.AssertJUnit.assertTrue;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.bin.Jalview;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.Alignment;
/*
* remove any sequence mappings left lying around by other tests
*/
- StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop());
- ssm.resetAll();
+ Desktop.getStructureSelectionManager().resetAll();
}
@BeforeMethod(alwaysRun = true)
* Verify that creating the alignment for the new View has registered the
* mappings
*/
- StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop());
- List<AlignedCodonFrame> sequenceMappings = ssm.getSequenceMappings();
+ List<AlignedCodonFrame> sequenceMappings = Desktop
+ .getStructureSelectionManager().getSequenceMappings();
assertEquals(2, sequenceMappings.size());
assertTrue(sequenceMappings.contains(acf1));
assertTrue(sequenceMappings.contains(acf2));
@Test(groups = { "Functional" })
public void testDeregisterMapping_withNoReference()
{
- Desktop d = Instance.getDesktop();
+ Desktop d = Desktop.getInstance();
assertNotNull(d);
- StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop());
+ StructureSelectionManager ssm = Desktop.getStructureSelectionManager();
ssm.resetAll();
AlignFrame af1 = new FileLoader().LoadFileWaitTillLoaded(
@Test(groups = { "Functional" })
public void testDeregisterMapping_withReference()
{
- Desktop d = Instance.getDesktop();
+ Desktop d = Desktop.getInstance();
assertNotNull(d);
- StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop());
+ StructureSelectionManager ssm = Desktop.getStructureSelectionManager();
ssm.resetAll();
AlignFrame af1 = new FileLoader().LoadFileWaitTillLoaded(
import jalview.analysis.AlignmentGenerator;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.bin.Jalview;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceGroup;
doStuffInJalview(f);
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
checkUsedMemory(35L);
}
* sanity check - fails if any frame was added after
* closeAll_actionPerformed
*/
- assertEquals(Instance.getDesktop().getAllFrames().length, 0);
+ assertEquals(Desktop.getInstance().getAllFrames().length, 0);
/*
* if this assertion fails
import jalview.api.AlignViewportI;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.bin.Jalview;
import jalview.commands.EditCommand;
import jalview.commands.EditCommand.Action;
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
}
@Test(groups = "Functional")
@AfterClass(alwaysRun = true)
public static void tearDownAfterClass() throws Exception
{
- jalview.bin.Instance.getDesktop().closeAll_actionPerformed(null);
+ jalview.gui.Desktop.getInstance().closeAll_actionPerformed(null);
}
import jalview.analysis.CrossRef;
import jalview.api.AlignmentViewPanel;
-import jalview.bin.Instance;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentTest;
{
// retrieve dbref
- SequenceFetcher sf = new SequenceFetcher(Instance.getDesktop(),
+ SequenceFetcher sf = new SequenceFetcher(Desktop.getInstance(),
forSource, forAccession);
sf.run();
AlignFrame[] afs = Desktop.getAlignFrames();
}
else
{
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
// recover stored project
af = new FileLoader(false).LoadFileWaitTillLoaded(
savedProjects.get(first).toString(), DataSourceType.FILE);
}
else
{
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
pass3 = 0;
// recover stored project
File storedProject = savedProjects.get(nextxref);
}
else
{
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
// recover stored project
File storedProject = savedProjects.get(nextnextxref);
if (storedProject == null)
import jalview.api.FeatureColourI;
import jalview.api.FeatureRenderer;
-import jalview.bin.Instance;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceDummy;
import jalview.datamodel.features.FeatureMatcherSetI;
import jalview.datamodel.features.SequenceFeatures;
import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
import jalview.gui.JvOptionPane;
import jalview.schemes.FeatureColour;
-import jalview.structure.StructureSelectionManager;
import jalview.util.matcher.Condition;
import jalview.viewmodel.seqfeatures.FeatureRendererModel;
import jalview.viewmodel.seqfeatures.FeatureRendererModel.FeatureSettingsBean;
/*
* remove any sequence mappings created so they don't pollute other tests
*/
- StructureSelectionManager ssm = StructureSelectionManager
- .getStructureSelectionManager(Instance.getDesktop());
- ssm.resetAll();
+ Desktop.getStructureSelectionManager().resetAll();
}
@BeforeClass(alwaysRun = true)
package jalview.io;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.bin.Jalview;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.SequenceI;
@AfterClass(alwaysRun = true)
public static void tearDownAfterClass() throws Exception
{
- jalview.bin.Instance.getDesktop().closeAll_actionPerformed(null);
+ jalview.gui.Desktop.getInstance().closeAll_actionPerformed(null);
}
@BeforeTest(alwaysRun = true)
public static void clearDesktop()
{
- if (Instance.getDesktop() != null && Desktop.getFrames() != null
+ if (Desktop.getInstance() != null && Desktop.getFrames() != null
&& Desktop.getFrames().length > 0)
{
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
}
}
@AfterClass(alwaysRun = true)
public static void tearDownAfterClass() throws Exception
{
- jalview.bin.Instance.getDesktop().closeAll_actionPerformed(null);
+ jalview.gui.Desktop.getInstance().closeAll_actionPerformed(null);
}
import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureColourI;
import jalview.api.ViewStyleI;
-import jalview.bin.Instance;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.HiddenSequences;
@Test(groups = { "Functional" }, enabled = true)
public void testStoreAndRecoverExpandedviews() throws Exception
{
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/exampleFile_2_7.jar", DataSourceType.FILE);
{
Assert.fail("Didn't save the expanded view state", e);
}
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
if (Desktop.getAlignFrames() != null)
{
Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@Test(groups = { "Functional" })
public void testStoreAndRecoverReferenceSeqSettings() throws Exception
{
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/exampleFile_2_7.jar", DataSourceType.FILE);
assertNotNull(af, "Didn't read in the example file correctly.");
{
Assert.fail("Didn't save the expanded view state", e);
}
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
if (Desktop.getAlignFrames() != null)
{
Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@Test(groups = { "Functional" })
public void testStoreAndRecoverGroupRepSeqs() throws Exception
{
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/uniref50.fa", DataSourceType.FILE);
assertNotNull(af, "Didn't read in the example file correctly.");
{
Assert.fail("Didn't save the expanded view state", e);
}
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
if (Desktop.getAlignFrames() != null)
{
Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@Test(groups = { "Functional" })
public void testStoreAndRecoverPDBEntry() throws Exception
{
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
String exampleFile = "examples/3W5V.pdb";
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(exampleFile,
DataSourceType.FILE);
{
Assert.fail("Didn't save the state", e);
}
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
if (Desktop.getAlignFrames() != null)
{
Assert.assertEquals(Desktop.getAlignFrames().length, 0);
@Test(groups = { "Functional" })
public void testStoreAndRecoverColourThresholds() throws IOException
{
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/uniref50.fa", DataSourceType.FILE);
".jvp");
tfile.deleteOnExit();
new Jalview2XML(false).saveState(tfile);
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(),
DataSourceType.FILE);
Assert.assertNotNull(af, "Failed to reload project");
@Test(groups = { "Functional" })
public void testMergeDatasetsforManyViews() throws IOException
{
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
// complex project - one dataset, several views on several alignments
AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
@Test(groups = "Functional")
public void testPcaViewAssociation() throws IOException
{
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
final String PCAVIEWNAME = "With PCA";
// create a new tempfile
File tempfile = File.createTempFile("jvPCAviewAssoc", "jvp");
}
// load again.
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
tempfile.getCanonicalPath(), DataSourceType.FILE);
- JInternalFrame[] frames = Instance.getDesktop().getAllFrames();
+ JInternalFrame[] frames = Desktop.getInstance().getAllFrames();
// PCA and the tabbed alignment view should be the only two windows on the
// desktop
assertEquals(frames.length, 2,
import jalview.api.AlignViewportI;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.bin.Jalview;
import jalview.datamodel.AnnotatedCollectionI;
import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
import jalview.gui.SequenceRenderer;
import jalview.io.DataSourceType;
import jalview.io.FileLoader;
@AfterClass(alwaysRun = true)
public static void tearDownAfterClass() throws Exception
{
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
}
@Test(groups = "Functional")
import jalview.analysis.AlignmentUtils;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
-import jalview.bin.Instance;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
{
// for some reason 'BeforeMethod' (which should be inherited from
// Jalview2XmlBase isn't always called)...
- Instance.getDesktop().closeAll_actionPerformed(null);
+ Desktop.getInstance().closeAll_actionPerformed(null);
try {
Thread.sleep(200);
} catch (Exception foo) {};
Cache.setPropertyNoSave("ADD_SS_ANN",
Boolean.TRUE.toString());
- sf = new SequenceFetcher();
+ sf = SequenceFetcher.getInstance();
}
/**
}
if (argv != null && argv.length > 0)
{
- List<DbSourceProxy> sps = new SequenceFetcher()
+ List<DbSourceProxy> sps = SequenceFetcher.getInstance()
.getSourceProxy(argv[0]);
if (sps != null)
{
for (DbSourceProxy sp : sps)
{
- AlignmentI al = null;
+ // AlignmentI al = null;
try
{
testRetrieval(argv[0], sp,
{
System.err.println("Can't resolve " + argv[0]
+ " as a database name. Allowed values are :\n"
- + new SequenceFetcher().getSupportedDb());
+ + SequenceFetcher.getInstance().getSupportedDb());
}
System.out.println(usage);
return;
}
- ASequenceFetcher sfetcher = new SequenceFetcher();
+ ASequenceFetcher sfetcher = SequenceFetcher.getInstance();
String[] dbSources = sfetcher.getSupportedDb();
for (int dbsource = 0; dbsource < dbSources.length; dbsource++)
{
Cache.setPropertyNoSave("ADD_SS_ANN",
Boolean.TRUE.toString());
- sf = new SequenceFetcher();
+ sf = SequenceFetcher.getInstance();
}
@DataProvider(name = "AccessionData")
public static Jws2Discoverer getJabawsDiscoverer(boolean localhost)
{
jalview.ws.jws2.Jws2Discoverer disc = jalview.ws.jws2.Jws2Discoverer
- .getDiscoverer();
+ .getInstance();
String svcurls = "";
if (localhost)
{
services.add(url);
}
;
- Jws2Discoverer.getDiscoverer().setServiceUrls(services);
+ Jws2Discoverer.getInstance().setServiceUrls(services);
}
try
{
@Test(groups = { "Functional" })
public void testStandardProtDbs()
{
- List<String> defdb = new ArrayList<String>();
+ List<String> defdb = new ArrayList<>();
defdb.addAll(Arrays.asList(DBRefSource.PROTEINDBS));
defdb.add(DBRefSource.PDB);
- List<DbSourceProxy> srces = new ArrayList<DbSourceProxy>();
- SequenceFetcher sfetcher = new SequenceFetcher();
+ List<DbSourceProxy> srces = new ArrayList<>();
+ SequenceFetcher sfetcher = SequenceFetcher.getInstance();
boolean pdbFound = false;
for (String ddb : defdb)
public void testEmblUniprotProductRecovery() throws Exception
{
String retrievalId = "V00488";
- DbSourceProxy embl = new SequenceFetcher().getSourceProxy(
+ DbSourceProxy embl = SequenceFetcher.getInstance().getSourceProxy(
DBRefSource.EMBL).get(0);
assertNotNull("Couldn't find the EMBL retrieval client", embl);
verifyProteinNucleotideXref(retrievalId, embl);
public void testEmblCDSUniprotProductRecovery() throws Exception
{
String retrievalId = "AAH29712";
- DbSourceProxy embl = new SequenceFetcher().getSourceProxy(
+ DbSourceProxy embl = SequenceFetcher.getInstance()
+ .getSourceProxy(
DBRefSource.EMBLCDS).get(0);
assertNotNull("Couldn't find the EMBL retrieval client", embl);
verifyProteinNucleotideXref(retrievalId, embl);
int u = SiftsClient.UNASSIGNED;
- HashMap<Integer, int[]> expectedMapping = new HashMap<Integer, int[]>();
+ HashMap<Integer, int[]> expectedMapping = new HashMap<>();
@BeforeTest(alwaysRun = true)
public void populateExpectedMapping() throws SiftsException
Cache.loadProperties("test/jalview/io/testProps.jvprops");
// SIFTs entries are updated weekly - so use saved SIFTs file to enforce
// test reproducibility
- new SiftsSettings();
SiftsSettings.setSiftDownloadDirectory(jalview.bin.Cache.getDefault(
"sifts_download_dir", DEFAULT_SIFTS_DOWNLOAD_DIR));
SiftsSettings.setMapWithSifts(true);
@Test(groups = { "Network" })
private void getAtomIndexTest()
{
- ArrayList<Atom> atoms = new ArrayList<Atom>();
+ ArrayList<Atom> atoms = new ArrayList<>();
Atom atom = new Atom(u, u, u);
atom.resNumber = 43;
atom.atomIndex = 7;
atoms.add(atom);
int actualAtomIndex = siftsClient.getAtomIndex(1, atoms);
- Assert.assertEquals(actualAtomIndex, siftsClient.UNASSIGNED);
+ Assert.assertEquals(actualAtomIndex, SiftsClient.UNASSIGNED);
actualAtomIndex = siftsClient.getAtomIndex(43, atoms);
Assert.assertEquals(actualAtomIndex, 7);
}