More succinct singleton class instances stored in jalview.bin.Jalview.
All 2200 instances of "static" checked.
import jalview.analysis.scoremodels.PIDModel;
import jalview.analysis.scoremodels.SimilarityParams;
+import jalview.bin.Jalview;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentOrder;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.datamodel.SequenceNode;
-import jalview.util.Platform;
import jalview.util.QuickSort;
import java.util.ArrayList;
public static final String FEATURE_DENSITY = "density";
- static AlignmentSorter instance;
-
public static AlignmentSorter getInstance()
{
-
- // BH 2019.05.08 need to isolate static fields in JavaScript
-
- AlignmentSorter i = instance;
- @SuppressWarnings("unused")
- ThreadGroup g = null;
- if (Platform.isJS())
- {
- g = Thread.currentThread().getThreadGroup();
- /**
- * @j2sNative i = g._jalviewAlignmentSorterInstance;
- *
- */
- }
- if (i == null)
- {
- i = new AlignmentSorter();
-
- if (Platform.isJS())
- {
- /**
- * @j2sNative g._jalviewAlignmentSorterInstance = i;
- *
- */
- }
- else
- {
- instance = i;
- }
- }
- return i;
+ Jalview j = Jalview.getInstance();
+ return (j.alignmentSorter == null
+ ? j.alignmentSorter = new AlignmentSorter()
+ : j.alignmentSorter);
}
/*
import jalview.api.AlignmentViewPanel;
import jalview.api.analysis.ScoreModelI;
+import jalview.bin.Jalview;
import jalview.io.DataSourceType;
import jalview.io.FileParse;
import jalview.io.ScoreMatrixFile;
-import jalview.util.Platform;
import java.io.IOException;
import java.util.LinkedHashMap;
private final ScoreMatrix DNA;
- private static ScoreModels instance;
-
/**
* Answers the singleton instance of this class, with lazy initialisation
* (built-in score models are loaded on the first call to this method)
*/
public static ScoreModels getInstance()
{
- ScoreModels m = instance;
- @SuppressWarnings("unused")
- ThreadGroup g = null;
- if (Platform.isJS())
- {
- g = Thread.currentThread().getThreadGroup();
- /**
- * @j2sNative m = g._jalviewScoreModelsInstance;
- *
- */
- }
- if (m == null)
- {
- m = new ScoreModels();
- if (Platform.isJS())
- {
- /**
- * @j2sNative g._jalviewScoreModelsInstance = m;
- *
- */
- }
- else
- {
- instance = m;
- }
- }
- return m;
+ Jalview j = Jalview.getInstance();
+ return (j.scoreModels == null ? j.scoreModels = new ScoreModels()
+ : j.scoreModels);
}
private Map<String, ScoreModelI> models;
*/
public void reset()
{
- instance = new ScoreModels();
+ Jalview.getInstance().scoreModels = new ScoreModels();
}
/**
*/
public static Cache getInstance()
{
-
- // BH 2019.05.08 need to isolate static fields in JavaScript
-
- Cache i = instance;
- @SuppressWarnings("unused")
- ThreadGroup g = null;
- if (Platform.isJS())
- {
- g = Thread.currentThread().getThreadGroup();
- /**
- * @j2sNative i = g._jalviewCacheInstance;
- *
- */
- }
- if (i == null)
- {
- i = new Cache();
- if (Platform.isJS())
- {
- /**
- * @j2sNative g._jalviewCacheInstance = i;
- *
- */
- }
- else
- {
- instance = i;
- }
- }
- return i;
+ Jalview j = Jalview.getInstance();
+ return (j.cache == null ? j.cache = new Cache() : j.cache);
}
/**
jalview.bin.Cache.log = Logger.getLogger("jalview.bin.Jalview");
laxis.setLevel(Level.toLevel(
- Cache.getDefault("logs.Axis.Level", Level.INFO.toString())));
- lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level",
- Level.INFO.toString())));
+ getDefault("logs.Axis.Level", Level.INFO.toString())));
+ lcastor.setLevel(Level.toLevel(
+ getDefault("logs.Castor.Level", Level.INFO.toString())));
lcastor = Logger.getLogger("org.exolab.castor.xml");
- lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level",
- Level.INFO.toString())));
+ lcastor.setLevel(Level.toLevel(
+ getDefault("logs.Castor.Level", Level.INFO.toString())));
// lcastor = Logger.getLogger("org.exolab.castor.xml.Marshaller");
- // lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level",
+ // lcastor.setLevel(Level.toLevel(getDefault("logs.Castor.Level",
// Level.INFO.toString())));
jalview.bin.Cache.log.setLevel(Level.toLevel(Cache
.getDefault("logs.Jalview.level", Level.INFO.toString())));
}
new BuildDetails(codeVersion, null, codeInstallation);
- SiftsSettings
- .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
+ SiftsSettings.setMapWithSifts(getDefault("MAP_WITH_SIFTS", false));
SiftsSettings.setSiftDownloadDirectory(jalview.bin.Cache
.getDefault("sifts_download_dir", DEFAULT_SIFTS_DOWNLOAD_DIR));
SiftsSettings.setFailSafePIDThreshold(
- jalview.bin.Cache.getDefault("sifts_fail_safe_pid_threshold",
+ getDefault("sifts_fail_safe_pid_threshold",
DEFAULT_FAIL_SAFE_PID_THRESHOLD));
SiftsSettings.setCacheThresholdInDays(
- jalview.bin.Cache.getDefault("sifts_cache_threshold_in_days",
+ getDefault("sifts_cache_threshold_in_days",
DEFAULT_CACHE_THRESHOLD_IN_DAYS));
IdOrgSettings.setUrl(getDefault("ID_ORG_HOSTURL",
StructureImportSettings
.setDefaultPDBFileParser(DEFAULT_PDB_FILE_PARSER);
// StructureImportSettings
- // .setDefaultPDBFileParser(jalview.bin.Cache.getDefault(
+ // .setDefaultPDBFileParser(jalview.bin.getDefault(
// "DEFAULT_PDB_FILE_PARSER", DEFAULT_PDB_FILE_PARSER));
// jnlpVersion will be null if we're using InstallAnywhere
// Dont do this check if running in headless mode
setProperty("VERSION", codeVersion);
// LOAD USERDEFINED COLOURS
- jalview.bin.Cache
- .initUserColourSchemes(getProperty("USER_DEFINED_COLOURS"));
- jalview.io.PIRFile.useModellerOutput = Cache.getDefault("PIR_MODELLER",
- false);
+ initUserColourSchemes(getProperty("USER_DEFINED_COLOURS"));
}
-
private void deleteBuildProperties()
{
applicationProperties.remove("LATEST_VERSION");
.newInstance(new Object[]
{ "Jalview Desktop",
(vrs = jalview.bin.Cache.getProperty("VERSION") + "_"
- + jalview.bin.Cache.getDefault("BUILD_DATE",
- "unknown")),
+ + getDefault("BUILD_DATE", "unknown")),
"UA-9060947-1" });
jgoogleanalyticstracker
.getMethod("trackAsynchronously", new Class[]
*/
package jalview.bin;
+import jalview.analysis.AlignmentSorter;
+import jalview.analysis.scoremodels.ScoreModels;
+import jalview.api.StructureSelectionManagerProvider;
+import jalview.ext.ensembl.EnsemblInfo;
import jalview.ext.so.SequenceOntology;
+import jalview.fts.service.pdb.PDBFTSRestClient;
+import jalview.fts.service.uniprot.UniProtFTSRestClient;
import jalview.gui.AlignFrame;
import jalview.gui.Desktop;
import jalview.gui.PromptUserConfig;
+import jalview.httpserver.HttpServer;
import jalview.io.AppletFormatAdapter;
import jalview.io.BioJsHTMLOutput;
import jalview.io.DataSourceType;
import jalview.io.IdentifyFile;
import jalview.io.NewickFile;
import jalview.io.gff.SequenceOntologyFactory;
+import jalview.io.gff.SequenceOntologyI;
+import jalview.rest.RestHandler;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemeProperty;
+import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureSelectionManager;
+import jalview.urls.IdOrgSettings;
import jalview.util.MessageManager;
import jalview.util.Platform;
+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.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.security.Permissions;
import java.security.Policy;
import java.util.HashMap;
+import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Vector;
import java.util.logging.ConsoleHandler;
}
}
+ // singleton instances
+
+ public Cache cache;
+
+ public AlignmentSorter alignmentSorter;
+
+ public EnsemblInfo ensemblInfo;
+
+ public HttpServer httpServer;
+
+ public IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> structureSelections;
+
+ public PDBFTSRestClient pdbFTSRestClient;
+
+ public RestHandler restHandler;
+
+ public ScoreModels scoreModels;
+
+ public SequenceFetcher sequenceFetcher;
+
+ public SequenceOntologyI sequenceOntology;
+
+ public UniProtFTSRestClient uniprotFTSRestClient;
+
+ public StructureSelectionManager nullProvider;
+
+ public Color[] rnaHelices = null;
+
+ public StructureImportSettings structureImportSettings;
+
+ public IdOrgSettings idOrgSettings;
+
+ public SiftsSettings siftsSettings;
+
+ public RestClient restClient;
+
+ public Jws2Discoverer j2s2discoverer;
+
+ public Jws2InstanceFactory jws2InstanceFactory;
+
+ public Discoverer discoverer;
+
}
package jalview.ext.ensembl;
+import jalview.bin.Jalview;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.DBRefSource;
public class EnsemblInfo extends EnsemblRestClient
{
- private static EnsemblInfo instance;
-
- /**
- * Some question as to whether it is necessary to do this for each applet. IN
- * PRINCIPLE, applets could set different properties for the origin of Ensembl
- * data. But I suggest this is unlikely. If we DO care about that possibility,
- * then we need to set doICare to Platform.isJS();
- *
- */
- private final static boolean doICare = false;// Platform.isJS();
-
/**
* On first request only, populate the lookup map by fetching the list of
* divisions known to EnsemblGenomes.
*/
private static EnsemblInfo getInstance()
{
-
- // BH 2019.05.08 need to isolate static fields in JavaScript
-
- EnsemblInfo i = instance;
- @SuppressWarnings("unused")
- ThreadGroup g = null;
-
- if (doICare)
- {
- g = Thread.currentThread().getThreadGroup();
- /**
- * @j2sNative i = g._jalviewEnsemblInstance;
- *
- */
- }
- if (i == null)
- {
- i = new EnsemblInfo();
-
- if (doICare)
- {
- /**
- * @j2sNative g._jalviewEnsemblInstance = i;
- *
- */
- }
- else
- {
- instance = i;
- }
- }
- return i;
+ Jalview j = Jalview.getInstance();
+ return (j.ensemblInfo == null ? j.ensemblInfo = new EnsemblInfo()
+ : j.ensemblInfo);
}
/*
*/
package jalview.fts.service.pdb;
+import jalview.bin.Jalview;
import jalview.datamodel.SequenceI;
import jalview.fts.api.FTSData;
import jalview.fts.api.FTSDataColumnI;
public class PDBFTSRestClient extends FTSRestClient
{
- private static FTSRestClientI instance = null;
-
public static FTSRestClientI getInstance()
{
-
- // BH 2019.05.08 need to isolate static fields in JavaScript
-
- FTSRestClientI i = instance;
- @SuppressWarnings("unused")
- ThreadGroup g = null;
- if (Platform.isJS())
- {
- g = Thread.currentThread().getThreadGroup();
- /**
- * @j2sNative i = g._jalviewPDBFTSRestClientInstance;
- *
- */
- }
- if (i == null)
- {
- i = new PDBFTSRestClient();
-
- if (Platform.isJS())
- {
- /**
- * @j2sNative g._jalviewPDBFTSRestClientInstance = i;
- *
- */
- }
- else
- {
- instance = i;
- }
- }
- return i;
+ Jalview j = Jalview.getInstance();
+ return (j.pdbFTSRestClient == null
+ ? j.pdbFTSRestClient = new PDBFTSRestClient()
+ : j.pdbFTSRestClient);
}
public static final String PDB_SEARCH_ENDPOINT = "https://www.ebi.ac.uk/pdbe/search/pdb/select?";
package jalview.fts.service.uniprot;
import jalview.bin.Cache;
+import jalview.bin.Jalview;
import jalview.fts.api.FTSData;
import jalview.fts.api.FTSDataColumnI;
import jalview.fts.api.FTSRestClientI;
Platform.addJ2SDirectDatabaseCall(DEFAULT_UNIPROT_DOMAIN);
}
- private static FTSRestClientI instance = null;
-
public static FTSRestClientI getInstance()
{
-
- // BH 2019.05.08 need to isolate static fields in JavaScript
-
- FTSRestClientI i = instance;
- @SuppressWarnings("unused")
- ThreadGroup g = null;
- if (Platform.isJS())
- {
- g = Thread.currentThread().getThreadGroup();
- /**
- * @j2sNative i = g._jalviewUniProtFTSRestClientInstance;
- *
- */
- }
- if (i == null)
- {
- i = new UniProtFTSRestClient();
-
- if (Platform.isJS())
- {
- /**
- * @j2sNative g._jalviewUniProtFTSRestClientInstance = i;
- *
- */
- }
- else
- {
- instance = i;
- }
- }
- return i;
+ Jalview j = Jalview.getInstance();
+ return (j.uniprotFTSRestClient == null ? j.uniprotFTSRestClient = new UniProtFTSRestClient()
+ : j.uniprotFTSRestClient);
}
public final String uniprotSearchEndpoint;
final JMenu dismenu = new JMenu("Protein Disorder");
// JAL-940 - only show secondary structure prediction services from
// the legacy server
+ Hashtable<String, Vector<ServiceHandle>> services = Discoverer
+ .getInstance().getServices();
if (// Cache.getDefault("SHOW_JWS1_SERVICES", true)
- // &&
- Discoverer.services != null && (Discoverer.services.size() > 0))
+ // &&
+ services != null && (services.size() > 0))
{
// TODO: refactor to allow list of AbstractName/Handler bindings to
// be
// No MSAWS used any more:
// Vector msaws = null; // (Vector)
// Discoverer.services.get("MsaWS");
- Vector<ServiceHandle> secstrpr = Discoverer.services
- .get("SecStrPred");
+ Vector<ServiceHandle> secstrpr = services.get("SecStrPred");
if (secstrpr != null)
{
// Add any secondary structure prediction services
webService.add(me.webServiceNoServices);
}
// TODO: move into separate menu builder class.
- boolean new_sspred = false;
+ // boolean new_sspred = false;
if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
private static int fileLoadingCount = 0;
+ public JInternalFrame conservationSlider, PIDSlider;
+
class MyDesktopManager implements DesktopManager
{
.formatMessage("status.opening_params", new Object[]
{ url }), this.hashCode());
}
- jalview.util.BrowserLauncher.openURL(url);
+ BrowserLauncher.openURL(url);
} catch (Exception ex)
{
JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
private groovy.ui.Console groovyConsole;
+ public StructureViewer lastTargetedView;
+
/**
* add another dialog thread to the queue
*
}
PopupMenu pop = new PopupMenu(alignPanel, sq, features,
- Preferences.getGroupURLLinks());
+ Preferences.getGroupURLLinks() // empty list; not implemented
+ );
pop.show(this, e.getX(), e.getY());
}
{
try
{
- jalview.util.BrowserLauncher.openURL(url);
+ Platform.openURL(url);
} catch (Exception ex)
{
JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
}
/**
- * add a late bound groupURL item to the given linkMenu
+ * For the popup menu on the idPanel.
+ *
+ * Add a late bound groupURL item to the given linkMenu
*
* @param linkMenu
* @param label
{
try
{
+ // Object[] { int[] { number of matches seqs },
+ // boolean[] { which matched },
+ // StringBuffer[] { segment generated from inputs },
+ // String[] { url }
+ // }
+
+ // TODO bug: urlstub is { int[], boolean[] } but constructFrom
+ // requires something else.
+
showLink(urlgenerator.constructFrom(urlstub));
} catch (UrlStringTooLongException e2)
{
* non-positional features if in the Id panel, features at the
* clicked residue if in the sequence panel
* @param groupLinks
+ * not implemented -- empty list
*/
public PopupMenu(final AlignmentPanel alignPanel, final SequenceI seq,
List<SequenceFeature> features, List<String> groupLinks)
// add any groupURLs to the groupURL submenu and make it visible
if (groupLinks != null && groupLinks.size() > 0)
{
+ // not implemented -- empty list
buildGroupURLMenu(sg, groupLinks);
}
// Add a 'show all structures' for the current selection
showOrHideMenu.add(item);
}
+ /**
+ *
+ * @param sg
+ * @param groupLinks
+ * not implemented -- empty list
+ */
private void buildGroupURLMenu(SequenceGroup sg, List<String> groupLinks)
{
}
}
}
+ if (groupLinks.size() == 0)
+ {
+ return;
+ }
// now create group links for all distinct ID/sequence sets.
boolean addMenu = false; // indicates if there are any group links to give
// to user
+
+ // not implmeented -- empty list
for (String link : groupLinks)
{
GroupUrlLink urlLink = null;
{
urlset = urlLink.makeUrlStubs(ids, seqstr,
"FromJalview" + System.currentTimeMillis(), false);
+ // { int[], boolean[] } only here
} catch (UrlStringTooLongException e)
{
}
groupLinksMenu.add(linkMenus[m]);
}
}
-
groupMenu.add(groupLinksMenu);
}
}
import jalview.urls.api.UrlProviderFactoryI;
import jalview.urls.api.UrlProviderI;
import jalview.urls.desktop.DesktopUrlProviderFactory;
+import jalview.util.BrowserLauncher;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.util.UrlConstants;
* (TODO: proper escape for using | to separate ids or sequences
*/
- public static final List<String> groupURLLinks;
+ public static final List<String> groupURLLinks; // not implemented
+
static
{
// get links selected to be in the menu (SEQUENCE_LINKS)
* .properties file as '|' separated strings
*/
- groupURLLinks = new ArrayList<>();
+ groupURLLinks = new ArrayList<>(); // not implemented
}
JInternalFrame frame;
Cache.setPropertyNoSave("SVG_RENDERING",
((OptionsParam) svgRendering.getSelectedItem()).getCode());
- /*
- * Save Connections settings
+ if (!Platform.isJS())
+ /**
+ * @j2sNative
*/
- Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
-
- jalview.util.BrowserLauncher.resetBrowser();
+ {
+ // Java only
+ // Save Connections settings
+ Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
+ BrowserLauncher.resetBrowser();
+ }
// save user-defined and selected links
String menuLinks = sequenceUrlLinks.writeUrlsAsString(true);
Boolean.toString(modellerOutput.isSelected()));
Cache.setPropertyNoSave("EXPORT_EMBBED_BIOJSON",
Boolean.toString(embbedBioJSON.isSelected()));
- jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
-
Cache.setPropertyNoSave("FIGURE_AUTOIDWIDTH",
Boolean.toString(autoIdWidth.isSelected()));
userIdWidth_actionPerformed();
super.showunconserved_actionPerformed(e);
}
+ /**
+ * not implemented -- returns empty list
+ *
+ * @return
+ */
public static List<String> getGroupURLLinks()
{
return groupURLLinks;
import jalview.renderer.ResidueShaderI;
import jalview.util.MessageManager;
-import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyVetoException;
* @author $author$
* @version $Revision$
*/
+@SuppressWarnings("serial")
public class SliderPanel extends GSliderPanel
{
private static final String BACKGROUND = "Background";
- static JInternalFrame conservationSlider;
-
- static JInternalFrame PIDSlider;
-
AlignmentPanel ap;
boolean forConservation = true;
*/
public static SliderPanel getSliderPanel()
{
+
+ JInternalFrame conservationSlider = Desktop
+ .getInstance().conservationSlider;
+
+ JInternalFrame PIDSlider = Desktop.getInstance().PIDSlider;
+
if (conservationSlider != null && conservationSlider.isVisible())
{
return (SliderPanel) conservationSlider.getContentPane();
{
SliderPanel sliderPanel = null;
+ JInternalFrame conservationSlider = Desktop
+ .getInstance().conservationSlider;
+
if (conservationSlider == null)
{
sliderPanel = new SliderPanel(ap, rs.getConservationInc(), true, rs);
- conservationSlider = new JInternalFrame();
+ conservationSlider = Desktop
+ .getInstance().conservationSlider = new JInternalFrame();
conservationSlider.setContentPane(sliderPanel);
conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER);
}
*/
public static void hidePIDSlider()
{
+ JInternalFrame PIDSlider = Desktop.getInstance().PIDSlider;
+
if (PIDSlider != null)
{
try
{
PIDSlider.setClosed(true);
- PIDSlider = null;
+ Desktop.getInstance().PIDSlider = null;
} catch (PropertyVetoException ex)
{
}
*/
public static void hideConservationSlider()
{
+ JInternalFrame conservationSlider = Desktop
+ .getInstance().conservationSlider;
+
if (conservationSlider != null)
{
try
{
conservationSlider.setClosed(true);
- conservationSlider = null;
+ Desktop.getInstance().conservationSlider = null;
} catch (PropertyVetoException ex)
{
}
{
hidePIDSlider();
+ JInternalFrame conservationSlider = Desktop
+ .getInstance().conservationSlider;
+
if (!conservationSlider.isVisible())
{
Desktop.addInternalFrame(conservationSlider,
@Override
public void internalFrameClosed(InternalFrameEvent e)
{
- conservationSlider = null;
+ Desktop.getInstance().conservationSlider = null;
}
});
conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER);
SliderPanel sliderPanel = null;
+ JInternalFrame PIDSlider = Desktop.getInstance().PIDSlider;
+
if (PIDSlider == null)
{
sliderPanel = new SliderPanel(ap, threshold, false, rs);
- PIDSlider = new JInternalFrame();
+ PIDSlider = Desktop.getInstance().PIDSlider = new JInternalFrame();
PIDSlider.setContentPane(sliderPanel);
PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
}
{
hideConservationSlider();
+ JInternalFrame PIDSlider = Desktop.getInstance().PIDSlider;
+
if (!PIDSlider.isVisible())
{
Desktop.addInternalFrame(PIDSlider, PIDSlider.getTitle(), true,
@Override
public void internalFrameClosed(InternalFrameEvent e)
{
- PIDSlider = null;
+ Desktop.getInstance().PIDSlider = null;
}
});
PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER);
public static int getConservationValue()
{
- return getValue(conservationSlider);
+ return getValue(Desktop.getInstance().conservationSlider);
}
static int getValue(JInternalFrame slider)
public static int getPIDValue()
{
- return getValue(PIDSlider);
+ return getValue(Desktop.getInstance().PIDSlider);
}
/**
public String getTitle()
{
String title = null;
+ JInternalFrame conservationSlider = Desktop
+ .getInstance().conservationSlider;
+ JInternalFrame PIDSlider = Desktop.getInstance().PIDSlider;
+
if (isForConservation())
{
if (conservationSlider != null)
{
private static final String AUTOSUPERIMPOSE = "AUTOSUPERIMPOSE";
- private static int MAX_QLENGTH = 7820;
+ private static final int MAX_QLENGTH = 7820;
- private SequenceI selectedSequence;
+ protected SequenceI selectedSequence;
- private SequenceI[] selectedSequences;
+ public SequenceI[] selectedSequences;
private IProgressIndicator progressIndicator;
- private Collection<FTSData> discoveredStructuresSet;
+ protected Collection<FTSData> discoveredStructuresSet;
- private FTSRestRequest lastPdbRequest;
+ protected FTSRestRequest lastPdbRequest;
- private FTSRestClientI pdbRestClient;
+ protected FTSRestClientI pdbRestClient;
- private String selectedPdbFileName;
+ protected String selectedPdbFileName;
- private boolean isValidPBDEntry;
+ protected boolean isValidPBDEntry;
- private boolean cachedPDBExists;
-
- private static StructureViewer lastTargetedView = null;
+ protected boolean cachedPDBExists;
public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
AlignmentPanel ap)
* structures may be added. If this list is empty then it, and the 'Add'
* button, are hidden.
*/
- private void discoverStructureViews()
+ protected void discoverStructureViews()
{
if (Desktop.getInstance() != null)
{
targetView.removeAllItems();
- if (lastTargetedView != null && !lastTargetedView.isVisible())
+ Desktop d = Desktop.getInstance();
+ if (d.lastTargetedView != null && !d.lastTargetedView.isVisible())
{
- lastTargetedView = null;
+ d.lastTargetedView = null;
}
int linkedViewsAt = 0;
for (StructureViewerBase view : Desktop.getInstance()
.getStructureViewers(null, null))
{
- StructureViewer viewHandler = (lastTargetedView != null
- && lastTargetedView.sview == view) ? lastTargetedView
+ StructureViewer viewHandler = (d.lastTargetedView != null
+ && d.lastTargetedView.sview == view) ? d.lastTargetedView
: StructureViewer.reconfigure(view);
if (view.isLinkedWith(ap))
if (targetView.getItemCount() > 0)
{
targetView.setVisible(true);
- if (lastTargetedView != null)
+ if (d.lastTargetedView != null)
{
- targetView.setSelectedItem(lastTargetedView);
+ targetView.setSelectedItem(d.lastTargetedView);
}
else
{
/**
* structure viewer opened by this dialog, or null
*/
- private StructureViewer sViewer = null;
+ protected StructureViewer sViewer = null;
public void showStructures(boolean waitUntilFinished)
{
}
}
- private PDBEntry getFindEntry(String id, Vector<PDBEntry> pdbEntries)
+ protected PDBEntry getFindEntry(String id, Vector<PDBEntry> pdbEntries)
{
Objects.requireNonNull(id);
Objects.requireNonNull(pdbEntries);
* @param sequences
* @return
*/
- private StructureViewer launchStructureViewer(
+ protected StructureViewer launchStructureViewer(
StructureSelectionManager ssm,
final PDBEntry[] pdbEntriesToView,
final AlignmentPanel alignPanel, SequenceI[] sequences)
}
setProgressBar(null, progressId);
// remember the last viewer we used...
- lastTargetedView = theViewer;
+ Desktop.getInstance().lastTargetedView = theViewer;
return theViewer;
}
protected void txt_search_ActionPerformed()
{
String text = txt_search.getText().trim();
- if (text.length() >= PDB_ID_MIN)
+ if (text.length() >= PDB_ID_MIN)
+ {
new Thread()
{
}
}.start();
}
+ }
@Override
protected void tabRefresh()
package jalview.gui;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
-import javax.swing.JOptionPane;
-
public class UserQuestionnaireCheck implements Runnable
{
/**
return prompt;
}
+ @Override
public void run()
{
if (url == null)
if (reply == JvOptionPane.YES_OPTION)
{
jalview.bin.Cache.log.debug("Opening " + qurl);
- jalview.util.BrowserLauncher.openURL(qurl);
+ Platform.openURL(qurl);
}
}
} catch (Exception e)
*/
package jalview.httpserver;
+import jalview.bin.Jalview;
import jalview.rest.RestHandler;
import java.net.BindException;
*/
private static final String JALVIEW_PATH = "jalview";
- /*
- * Singleton instance of this server
+ /**
+ * Returns the singleton instance of this class.
+ *
+ * @return
+ * @throws BindException
*/
- private static HttpServer instance;
+ public static HttpServer getInstance() throws BindException
+ {
+ synchronized (HttpServer.class)
+ {
+ Jalview j = Jalview.getInstance();
+ return (j.httpServer == null ? j.httpServer = new HttpServer()
+ : j.httpServer);
+ }
+ }
/*
* The Http server
/*
* Lookup of ContextHandler by its wrapped handler
*/
- Map<Handler, ContextHandler> myHandlers = new HashMap<Handler, ContextHandler>();
+ Map<Handler, ContextHandler> myHandlers = new HashMap<>();
/*
* The context root for the server
private URI contextRoot;
/**
- * Returns the singleton instance of this class.
- *
- * @return
- * @throws BindException
- */
- public static HttpServer getInstance() throws BindException
- {
- synchronized (HttpServer.class)
- {
- if (instance == null)
- {
- instance = new HttpServer();
- }
- return instance;
- }
- }
-
- /**
* Private constructor to enforce use of singleton
*
* @throws BindException
import jalview.gui.AlignmentPanel;
import jalview.gui.IProgressIndicator;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import java.io.BufferedReader;
import java.io.File;
{
try
{
- jalview.util.BrowserLauncher
- .openURL("file:///" + getExportedFile());
+ Platform.openURL("file:///" + getExportedFile());
} catch (IOException e)
{
e.printStackTrace();
package jalview.io;
import java.io.File;
-import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
public class JalviewFileFilter extends FileFilter
{
- public static Hashtable suffixHash = new Hashtable();
+ // public static Hashtable suffixHash = new Hashtable();
private Map<String, JalviewFileFilter> filters = null;
*/
package jalview.io;
+import jalview.bin.Cache;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
import jalview.util.Comparison;
import java.io.IOException;
-import java.util.Vector;
public class PIRFile extends AlignFile
{
- public static boolean useModellerOutput = false;
-
- Vector words = new Vector(); // Stores the words in a line after splitting
+ // Vector words = new Vector(); // Stores the words in a line after splitting
public PIRFile()
{
StringBuffer out = new StringBuffer();
int i = 0;
ModellerDescription md;
-
+ boolean useModellerOutput = Cache.getDefault("PIR_MODELLER", false);
while ((i < s.length) && (s[i] != null))
{
String seq = s[i].getSequenceAsString();
}
else
{
-
if (useModellerOutput)
{
out.append(">P1;" + s[i].getName());
public final static String TCOFFEE_SCORE = "TCoffeeScore";
- static Pattern SCORES_WITH_RESIDUE_NUMS = Pattern
+ private final static Pattern SCORES_WITH_RESIDUE_NUMS = Pattern
.compile("^\\d+\\s([^\\s]+)\\s+\\d+$");
/** The {@link Header} structure holder */
{
return null;
}
- List<String> result = new ArrayList<String>(scores.size());
+ List<String> result = new ArrayList<>(scores.size());
for (Map.Entry<String, StringBuilder> it : scores.entrySet())
{
result.add(it.getValue().toString());
error = true;
return;
}
- scores = new LinkedHashMap<String, StringBuilder>();
+ scores = new LinkedHashMap<>();
/*
* initilize the structure
int score;
- LinkedHashMap<String, Integer> scores = new LinkedHashMap<String, Integer>();
+ LinkedHashMap<String, Integer> scores = new LinkedHashMap<>();
public int getScoreAvg()
{
public Block(int size)
{
this.size = size;
- this.items = new HashMap<String, String>(size);
+ this.items = new HashMap<>(size);
}
String getScoresFor(String id)
}
// bitfields - should be a template in j1.5
- private static int HASSECSTR = 0;
+ private static final int HASSECSTR = 0;
- private static int HASVALS = 1;
+ private static final int HASVALS = 1;
- private static int HASHPHOB = 2;
+ private static final int HASHPHOB = 2;
- private static int HASDC = 3;
+ private static final int HASDC = 3;
- private static int HASDESCSTR = 4;
+ private static final int HASDESCSTR = 4;
- private static int HASTWOSTATE = 5; // not used yet.
+ private static final int HASTWOSTATE = 5; // not used yet.
/**
* parses the AnnotationElements - if they exist - into
*/
package jalview.io.gff;
+import jalview.bin.Jalview;
+
/**
* A factory class that returns a model of the Sequence Ontology. By default a
* hard-coded subset is used (for the applet, or testing), or setInstance() can
*/
public class SequenceOntologyFactory
{
- private static SequenceOntologyI instance;
+ // private static SequenceOntologyI instance; // moved to Jalview.instance for
+ // JavaScript
public static synchronized SequenceOntologyI getInstance()
{
- if (instance == null)
+ Jalview j = Jalview.getInstance();
+ if (j.sequenceOntology == null)
{
- instance = new SequenceOntologyLite();
+ j.sequenceOntology = new SequenceOntologyLite();
}
- return instance;
+ return j.sequenceOntology;
}
public static void setInstance(SequenceOntologyI so)
{
- instance = so;
+ Jalview.getInstance().sequenceOntology = so;
}
}
* @author $author$
* @version $Revision$
*/
+@SuppressWarnings("serial")
public class GSliderPanel extends JPanel
{
private static final Font VERDANA_11 = new java.awt.Font("Verdana", 0, 11);
protected static final int FRAME_HEIGHT = 120;
// this is used for conservation colours, PID colours and redundancy threshold
- protected JSlider slider = new JSlider();
+ public JSlider slider = new JSlider();
- protected JTextField valueField = new JTextField();
+ public JTextField valueField = new JTextField();
protected JLabel label = new JLabel();
protected String frameTitle = MessageManager
.getString("label.structure_chooser");
- protected JInternalFrame mainFrame = new JInternalFrame(frameTitle);
+ public JInternalFrame mainFrame = new JInternalFrame(frameTitle);
- protected JComboBox<FilterOption> cmb_filterOption = new JComboBox<>();
+ public JComboBox<FilterOption> cmb_filterOption = new JComboBox<>();
- protected AlignmentPanel ap;
+ public AlignmentPanel ap;
- protected StringBuilder errorWarning = new StringBuilder();
+ public StringBuilder errorWarning = new StringBuilder();
protected JButton btn_add;
protected JCheckBox chk_superpose = new JCheckBox(
MessageManager.getString("label.superpose_structures"));
- protected JTextField txt_search = new JTextField(14);
+ public JTextField txt_search = new JTextField(14);
protected JPanel pnl_switchableViews = new JPanel(new CardLayout());
protected CardLayout layout_switchableViews = (CardLayout) (pnl_switchableViews
.getLayout());
- protected JCheckBox chk_invertFilter = new JCheckBox(
+ public JCheckBox chk_invertFilter = new JCheckBox(
MessageManager.getString("label.invert"));
protected ImageIcon loadingImage = new ImageIcon(
protected ImageIcon warningImage = new ImageIcon(
getClass().getResource("/images/warning.gif"));
- protected JLabel lbl_loading = new JLabel(loadingImage);
+ public JLabel lbl_loading = new JLabel(loadingImage);
protected JLabel lbl_pdbManualFetchStatus = new JLabel(errorImage);
protected JLabel lbl_fromFileStatus = new JLabel(errorImage);
- protected AssociateSeqPanel idInputAssSeqPanel = new AssociateSeqPanel();
+ public AssociateSeqPanel idInputAssSeqPanel = new AssociateSeqPanel();
- protected AssociateSeqPanel fileChooserAssSeqPanel = new AssociateSeqPanel();
+ public AssociateSeqPanel fileChooserAssSeqPanel = new AssociateSeqPanel();
protected JComboBox<StructureViewer> targetView = new JComboBox<>();
- protected JTable tbl_local_pdb = new JTable();
+ public JTable tbl_local_pdb = new JTable();
protected JTabbedPane pnl_filter = new JTabbedPane();
- protected FTSDataColumnPreferences pdbDocFieldPrefs = new FTSDataColumnPreferences(
+ public FTSDataColumnPreferences pdbDocFieldPrefs = new FTSDataColumnPreferences(
PreferenceSource.STRUCTURE_CHOOSER,
PDBFTSRestClient.getInstance());
protected FTSDataColumnI[] previousWantedFields;
- protected static Map<String, Integer> tempUserPrefs = new HashMap<>();
+ public static Map<String, Integer> tempUserPrefs = new HashMap<>();
private JTable tbl_summary = new JTable()
{
}
-protected void closeAction(int preferredHeight)
+ public void closeAction(int preferredHeight)
{
// System.out.println(">>>>>>>>>> closing internal frame!!!");
// System.out.println("width : " + mainFrame.getWidth());
*/
package jalview.rest;
+import jalview.bin.Jalview;
import jalview.httpserver.AbstractRequestHandler;
import java.io.IOException;
private static final String MY_NAME = "Rest";
/**
- * Singleton instance of this class
- */
- private static RestHandler instance = null;
-
- /**
* Returns the singleton instance of this class
*
* @return
{
synchronized (RestHandler.class)
{
- if (instance == null)
- {
- instance = new RestHandler();
- }
+ Jalview j = Jalview.getInstance();
+ return (j.restHandler == null ? j.restHandler = new RestHandler()
+ : j.restHandler);
}
- return instance;
}
/**
package jalview.schemes;
import jalview.api.AlignViewportI;
+import jalview.bin.Jalview;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AnnotatedCollectionI;
{
if (ann.isRNA())
{
- result = ColourSchemeProperty.rnaHelices[(int) aj.value];
+ result = Jalview.getInstance().rnaHelices[(int) aj.value];
}
else
{
package jalview.schemes;
import jalview.api.AlignViewportI;
+import jalview.bin.Jalview;
import jalview.datamodel.AnnotatedCollectionI;
import jalview.util.ColorUtils;
return ucs;
}
- public static Color rnaHelices[] = null;
-
public static void initRnaHelicesShading(int n)
{
- int j = 0;
- if (rnaHelices == null)
+ int i = 0;
+ Jalview j = Jalview.getInstance();
+
+ if (j.rnaHelices == null)
{
- rnaHelices = new Color[n + 1];
+ j.rnaHelices = new Color[n + 1];
}
- else if (rnaHelices != null && rnaHelices.length <= n)
+ else if (j.rnaHelices != null && j.rnaHelices.length <= n)
{
Color[] t = new Color[n + 1];
- System.arraycopy(rnaHelices, 0, t, 0, rnaHelices.length);
- j = rnaHelices.length;
- rnaHelices = t;
+ 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 (; j <= n; j++)
+ for (; i <= n; i++)
{
- rnaHelices[j] = ColorUtils.generateRandomColor(Color.white);
+ j.rnaHelices[i] = ColorUtils.generateRandomColor(Color.white);
}
}
*/
public static void resetRnaHelicesShading()
{
- rnaHelices = null;
+ Jalview.getInstance().rnaHelices = null;
}
/**
package jalview.schemes;
import jalview.api.AlignViewportI;
+import jalview.bin.Jalview;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AnnotatedCollectionI;
currentHelix = positionsToHelix.get(j);
if (currentHelix != null)
{
- currentColour = ColourSchemeProperty.rnaHelices[Integer
+ currentColour = Jalview.getInstance().rnaHelices[Integer
.parseInt(currentHelix)];
}
return currentColour;
* Color.white, // R Color.white, // Y Color.white, // N Color.white, // Gap
*/
- public static String STOP = "STOP";
+ public static final String STOP = "STOP";
- public static List<String> STOP_CODONS = Arrays.asList("TGA", "TAA", "TAG");
+ public static final List<String> STOP_CODONS = Arrays.asList("TGA", "TAA",
+ "TAG");
- public static String START = "ATG";
+ public static final String START = "ATG";
// Stores residue codes/names and colours and other things
- public static Map<String, Map<String, Integer>> propHash = new Hashtable<>();
+ public static final Map<String, Map<String, Integer>> propHash = new Hashtable<>();
- public static Map<String, Integer> hydrophobic = new Hashtable<>();
+ public static final Map<String, Integer> hydrophobic = new Hashtable<>();
- public static Map<String, Integer> polar = new Hashtable<>();
+ public static final Map<String, Integer> polar = new Hashtable<>();
- public static Map<String, Integer> small = new Hashtable<>();
+ public static final Map<String, Integer> small = new Hashtable<>();
- public static Map<String, Integer> positive = new Hashtable<>();
+ public static final Map<String, Integer> positive = new Hashtable<>();
- public static Map<String, Integer> negative = new Hashtable<>();
+ public static final Map<String, Integer> negative = new Hashtable<>();
- public static Map<String, Integer> charged = new Hashtable<>();
+ public static final Map<String, Integer> charged = new Hashtable<>();
- public static Map<String, Integer> aromatic = new Hashtable<>();
+ public static final Map<String, Integer> aromatic = new Hashtable<>();
- public static Map<String, Integer> aliphatic = new Hashtable<>();
+ public static final Map<String, Integer> aliphatic = new Hashtable<>();
- public static Map<String, Integer> tiny = new Hashtable<>();
+ public static final Map<String, Integer> tiny = new Hashtable<>();
- public static Map<String, Integer> proline = new Hashtable<>();
+ public static final Map<String, Integer> proline = new Hashtable<>();
static
{
* lookup of (A-Z) alternative secondary structure symbols'
* equivalents in DSSP3 notation
*/
- private static char[] toDssp3State;
+ private final static char[] toDssp3State;
static
{
toDssp3State = new char[9]; // for 'A'-'I'; extend if needed
*/
package jalview.structure;
+import jalview.bin.Jalview;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.PDBEntry.Type;
*/
public class StructureImportSettings
{
+
+ private static StructureImportSettings getInstance()
+ {
+ Jalview j = Jalview.getInstance();
+ return (j.structureImportSettings == null
+ ? j.structureImportSettings = new StructureImportSettings()
+ : j.structureImportSettings);
+ }
+
/**
* set to true to add derived sequence annotations (temp factor read from
* file, or computed secondary structure) to the alignment
*/
- private static boolean visibleChainAnnotation = false;
+ private boolean visibleChainAnnotation = false;
/**
* Set true to predict secondary structure (using JMol for protein, Annotate3D
* for RNA)
*/
- private static boolean processSecStr = false;
+ private boolean processSecStr = false;
/**
* Set true (with predictSecondaryStructure=true) to predict secondary
* structure using an external service (currently Annotate3D for RNA only)
*/
- private static boolean externalSecondaryStructure = false;
+ private boolean externalSecondaryStructure = false;
- private static boolean showSeqFeatures = true;
+ private boolean showSeqFeatures = true;
public enum StructureParser
{
* Determines the default file format for structure files to be downloaded
* from the PDB sequence fetcher. Possible options include: PDB|mmCIF
*/
- private static PDBEntry.Type defaultStructureFileFormat = Type.PDB;
+ private PDBEntry.Type defaultStructureFileFormat = Type.PDB;
/**
* Determines the parser used for parsing PDB format file. Possible options
* are : JMolParser|JalveiwParser
*/
- private static StructureParser defaultPDBFileParser = StructureParser.JMOL_PARSER;
+ private StructureParser defaultPDBFileParser = StructureParser.JMOL_PARSER;
public static void addSettings(boolean addAlignmentAnnotations,
boolean processSecStr, boolean externalSecStr)
{
- StructureImportSettings.visibleChainAnnotation = addAlignmentAnnotations;
- StructureImportSettings.processSecStr = processSecStr;
- StructureImportSettings.externalSecondaryStructure = externalSecStr;
- StructureImportSettings.showSeqFeatures = true;
+ StructureImportSettings s = getInstance();
+ s.visibleChainAnnotation = addAlignmentAnnotations;
+ s.processSecStr = processSecStr;
+ s.externalSecondaryStructure = externalSecStr;
+ s.showSeqFeatures = true;
}
public static boolean isVisibleChainAnnotation()
{
- return visibleChainAnnotation;
+ return getInstance().visibleChainAnnotation;
}
public static void setVisibleChainAnnotation(
boolean visibleChainAnnotation)
{
- StructureImportSettings.visibleChainAnnotation = visibleChainAnnotation;
+ getInstance().visibleChainAnnotation = visibleChainAnnotation;
}
public static boolean isProcessSecondaryStructure()
{
- return processSecStr;
+ return getInstance().processSecStr;
}
public static void setProcessSecondaryStructure(
boolean processSecondaryStructure)
{
- StructureImportSettings.processSecStr = processSecondaryStructure;
+ getInstance().processSecStr = processSecondaryStructure;
}
public static boolean isExternalSecondaryStructure()
{
- return externalSecondaryStructure;
+ return getInstance().externalSecondaryStructure;
}
public static void setExternalSecondaryStructure(
boolean externalSecondaryStructure)
{
- StructureImportSettings.externalSecondaryStructure = externalSecondaryStructure;
+ getInstance().externalSecondaryStructure = externalSecondaryStructure;
}
public static boolean isShowSeqFeatures()
{
- return showSeqFeatures;
+ return getInstance().showSeqFeatures;
}
public static void setShowSeqFeatures(boolean showSeqFeatures)
{
- StructureImportSettings.showSeqFeatures = showSeqFeatures;
+ getInstance().showSeqFeatures = showSeqFeatures;
}
public static PDBEntry.Type getDefaultStructureFileFormat()
{
- return defaultStructureFileFormat;
+ return getInstance().defaultStructureFileFormat;
}
public static void setDefaultStructureFileFormat(
String defaultStructureFileFormat)
{
- StructureImportSettings.defaultStructureFileFormat = PDBEntry.Type
+ getInstance().defaultStructureFileFormat = PDBEntry.Type
.valueOf(defaultStructureFileFormat.toUpperCase());
}
public static String getDefaultPDBFileParser()
{
- return defaultPDBFileParser.toString();
+ return getInstance().defaultPDBFileParser.toString();
}
public static void setDefaultPDBFileParser(
StructureParser defaultPDBFileParser)
{
- StructureImportSettings.defaultPDBFileParser = defaultPDBFileParser;
+ getInstance().defaultPDBFileParser = defaultPDBFileParser;
}
public static void setDefaultPDBFileParser(String defaultPDBFileParser)
{
- StructureImportSettings.defaultPDBFileParser = StructureParser
+ getInstance().defaultPDBFileParser = StructureParser
.valueOf(defaultPDBFileParser.toUpperCase());
}
import jalview.analysis.AlignSeq;
import jalview.api.StructureSelectionManagerProvider;
+import jalview.bin.Jalview;
import jalview.commands.CommandI;
import jalview.commands.EditCommand;
import jalview.commands.OrderCommand;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
{
public final static String NEWLINE = System.lineSeparator();
- static IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> instances;
-
private List<StructureMapping> mappings = new ArrayList<>();
private boolean processSecondaryStructure = false;
|| pdbIdFileName.containsKey(idOrFile);
}
- private static StructureSelectionManager nullProvider = null;
-
public static StructureSelectionManager getStructureSelectionManager(
StructureSelectionManagerProvider context)
{
+ Jalview j = Jalview.getInstance();
if (context == null)
{
- if (nullProvider == null)
+ if (j.nullProvider == null)
{
- if (instances != null)
+ if (j.structureSelections != null)
{
throw new Error(MessageManager.getString(
"error.implementation_error_structure_selection_manager_null"),
}
else
{
- nullProvider = new StructureSelectionManager();
+ j.nullProvider = new StructureSelectionManager();
}
- return nullProvider;
+ return j.nullProvider;
}
}
- if (instances == null)
+ if (j.structureSelections == null)
{
- instances = new java.util.IdentityHashMap<>();
+ j.structureSelections = new java.util.IdentityHashMap<>();
}
- StructureSelectionManager instance = instances.get(context);
+ StructureSelectionManager instance = Jalview
+ .getInstance().structureSelections.get(context);
if (instance == null)
{
- if (nullProvider != null)
+ if (j.nullProvider != null)
{
- instance = nullProvider;
+ instance = j.nullProvider;
}
else
{
instance = new StructureSelectionManager();
}
- instances.put(context, instance);
+ j.structureSelections.put(context, instance);
}
return instance;
}
return relaySeqMappings;
}
- Vector listeners = new Vector();
+ Vector<Object> listeners = new Vector<>();
/**
* register a listener for alignment sequence mouseover events
{
// synchronized (instances)
{
- if (instances == null)
+ if (Jalview.getInstance().structureSelections == null)
{
return;
}
- StructureSelectionManager mnger = (instances.get(jalviewLite));
+ StructureSelectionManager mnger = (Jalview
+ .getInstance().structureSelections.get(jalviewLite));
if (mnger != null)
{
- instances.remove(jalviewLite);
+ Jalview.getInstance().structureSelections.remove(jalviewLite);
try
{
mnger.finalize();
package jalview.urls;
+import jalview.bin.Jalview;
+
/**
* Holds settings for identifiers.org e.g. url, download location
*
*/
public class IdOrgSettings
{
- private static String url;
+ private String url;
+ private String location;
- private static String location;
+ public static IdOrgSettings getInstance()
+ {
+ Jalview j = Jalview.getInstance();
+ return (j.idOrgSettings == null ? j.idOrgSettings = new IdOrgSettings()
+ : j.idOrgSettings);
+ }
public static void setUrl(String seturl)
{
- url = seturl;
+ getInstance().url = seturl;
}
public static void setDownloadLocation(String setloc)
{
- location = setloc;
+ getInstance().location = setloc;
}
public static String getUrl()
{
- return url;
+ return getInstance().url;
}
public static String getDownloadLocation()
{
- return location;
+ return getInstance().location;
}
}
import java.lang.reflect.Method;
/**
- * BrowserLauncher is a class that provides one static method, openURL, which
- * opens the default web browser for the current user of the system to the given
- * URL. It may support other protocols depending on the system -- mailto, ftp,
+ *
+ * SwingJS note: Do not use methods in this class directly. Use
+ *
+ * Platform.openURL(String url) only.
+ *
+ * JavaScript does not see this class.
+ *
+ * BrowserLauncher is a class that provides two static methods:
+ *
+ * openURL(String url), which opens the default web browser for the current user
+ * of the system to the given URL, and
+ *
+ * resetBrowser(), which allows switching browsers in Java.
+ *
+ *
+ * openURL may support other protocols depending on the system -- mailto, ftp,
* etc. -- but that has not been rigorously tested and is not guaranteed to
* work.
* <p>
private static boolean loadedWithoutErrors;
/** The com.apple.mrj.MRJFileUtils class */
- private static Class mrjFileUtilsClass;
+ private static Class<?> mrjFileUtilsClass;
/** The com.apple.mrj.MRJOSType class */
- private static Class mrjOSTypeClass;
+ private static Class<?> mrjOSTypeClass;
/** The com.apple.MacOS.AEDesc class */
- private static Class aeDescClass;
+ private static Class<?> aeDescClass;
/** The <init>(int) method of com.apple.MacOS.AETarget */
- private static Constructor aeTargetConstructor;
+ private static Constructor<?> aeTargetConstructor;
/** The <init>(int, int, int) method of com.apple.MacOS.AppleEvent */
- private static Constructor appleEventConstructor;
+ private static Constructor<?> appleEventConstructor;
/** The <init>(String) method of com.apple.MacOS.AEDesc */
- private static Constructor aeDescConstructor;
+ private static Constructor<?> aeDescConstructor;
/** The findFolder method of com.apple.mrj.MRJFileUtils */
private static Method findFolder;
loadedWithoutErrors = true;
- if (!Platform.isJS())
- /**
- * Java only
- *
- * @j2sIgnore
- *
- */
- {
String osName = System.getProperty("os.name");
if (osName.startsWith("Mac OS"))
{ // if we haven't hit any errors yet
loadedWithoutErrors = loadClasses();
}
- }
}
/**
private static boolean loadClasses()
{
- if (!Platform.isJS())
- /**
- * Java only
- *
- * @j2sIgnore
- *
- */
- {
switch (jvm)
{
case MRJ_2_0:
try
{
- Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget");
- Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils");
- Class appleEventClass = Class.forName("com.apple.MacOS.AppleEvent");
- Class aeClass = Class.forName("com.apple.MacOS.ae");
+ Class<?> aeTargetClass = Class.forName("com.apple.MacOS.AETarget");
+ Class<?> osUtilsClass = Class.forName("com.apple.MacOS.OSUtils");
+ Class<?> appleEventClass = Class
+ .forName("com.apple.MacOS.AppleEvent");
+ Class<?> aeClass = Class.forName("com.apple.MacOS.ae");
aeDescClass = Class.forName("com.apple.MacOS.AEDesc");
aeTargetConstructor = aeTargetClass
try
{
- Class linker = Class.forName("com.apple.mrj.jdirect.Linker");
- Constructor constructor = linker
+ Class<?> linker = Class.forName("com.apple.mrj.jdirect.Linker");
+ Constructor<?> constructor = linker
.getConstructor(new Class[]
{ Class.class });
linkage = constructor
break;
}
- }
return true;
}
*/
private static Object locateBrowser()
{
- if (!Platform.isJS())
- /**
- * Java only
- *
- * @j2sIgnore
- *
- */
- {
if (browser != null)
{
return browser;
break;
}
-
- }
-
return browser;
-
}
/**
*/
public static void openURL(String url) throws IOException
{
-
if (Platform.isJS())
{
Platform.openURL(url);
return;
}
- else
- /**
- * Java only
- *
- * @j2sIgnore
- */
- {
-
if (!loadedWithoutErrors)
{
throw new IOException(MessageManager
break;
default:
-
// This should never occur, but if it does, we'll try the simplest thing
// possible
Runtime.getRuntime().exec(new String[] { (String) browser, url });
-
break;
}
- }
}
*/
package jalview.util;
-import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
import java.util.Hashtable;
+/**
+ * This class is not implemented because Preferences never puts anything in
+ * groupURLLinks.
+ *
+ * @author hansonr
+ *
+ */
public class GroupUrlLink
{
+ @SuppressWarnings("serial")
public class UrlStringTooLongException extends Exception
{
public UrlStringTooLongException(int lng)
private String invalidMessage = null;
/**
- * tokens that can be replaced in the URL.
- */
- private static String[] tokens;
-
- /**
* position of each token (which can appear once only) in the url
*/
private int[] segs;
* contains tokens in the order they appear in the URL template.
*/
private String[] mtch;
- static
- {
- if (tokens == null)
- {
- tokens = new String[] { "SEQUENCEIDS", "SEQUENCES", "DATASETID" };
- }
- }
/**
- * test for GroupURLType bitfield (with default tokens)
- */
- public static final int SEQUENCEIDS = 1;
-
- /**
- * test for GroupURLType bitfield (with default tokens)
- */
- public static final int SEQUENCES = 2;
-
- /**
- * test for GroupURLType bitfield (with default tokens)
+ * tokens that can be replaced in the URL.
*/
- public static final int DATASETID = 4;
-
+ private static final String[] tokens = new String[] { "SEQUENCEIDS",
+ "SEQUENCES", "DATASETID" };
+
+ // /**
+ // * test for GroupURLType bitfield (with default tokens)
+ // */
+ // private static final int SEQUENCEIDS = 1;
+ //
+ // /**
+ // * test for GroupURLType bitfield (with default tokens)
+ // */
+ // private static final int SEQUENCES = 2;
+ //
+ // /**
+ // * test for GroupURLType bitfield (with default tokens)
+ // */
+ // private static final int DATASETID = 4;
+ //
// private int idseg = -1, seqseg = -1;
/**
+ *
+ * called by PopupMenu.buildGroupURLMenu()
+ *
* parse the given linkString of the form '<label>|<url>|separator
* char[|optional sequence separator char]' into parts. url may contain a
* string $SEQUENCEIDS<=optional regex=>$ where <=optional regex=> must be of
}
/**
+ *
+ * called by PopupMenu.addShowLink()
+ *
* @return the url_prefix
*/
public String getUrl_prefix()
}
/**
+ * called by PopupMenu.buildGroupURLMenu()
+ *
* @return the target
*/
public String getTarget()
}
/**
+ *
+ * called by PopupMenu.buildGroupURLMenu()
+ *
* @return the label
*/
public String getLabel()
}
/**
- * @return the sequence ID regexReplace
- */
- public String getIDRegexReplace()
- {
- return _replaceFor(tokens[0]);
- }
-
- private String _replaceFor(String token)
- {
- for (int i = 0; i < mtch.length; i++)
- {
- if (segs[i] > -1 && mtch[i].equals(token))
- {
- return regexReplace[i];
- }
- }
- return null;
- }
-
- /**
- * @return the sequence ID regexReplace
- */
- public String getSeqRegexReplace()
- {
- return _replaceFor(tokens[1]);
- }
-
- /**
+ *
+ * called by PopupMenu.buildGroupURLMenu()
+ *
* @return the invalidMessage
*/
public String getInvalidMessage()
}
/**
+ * called by PopupMenu.buildGroupURLMenu()
+ *
* Check if URL string was parsed properly.
*
* @return boolean - if false then <code>getInvalidMessage</code> returns an
}
/**
- * return one or more URL strings by applying regex to the given idstring
*
- * @param idstrings
- * array of id strings to pass to service
- * @param seqstrings
- * array of seq strings to pass to service
+ * called by PopupMenu.buildGroupURLMenu()
+ *
+ * This method is never called, because PopupMenu.buildGroupMenu() is never
+ * called. It relates to the popup menu for the idPanel.
+ *
+ * @param ids
+ * @param seqstr
+ * @param string
* @param onlyIfMatches
- * - when true url strings are only made if regex is defined and
- * matches for all qualified tokens in groupURL - TODO: consider if
- * onlyIfMatches is really a useful parameter!
- * @return null or Object[] { int[] { number of seqs substituted},boolean[] {
- * which seqs were substituted }, StringBuffer[] { substituted lists
- * for each token }, String[] { url } }
+ * @return URL stub objects ready to pass to constructFrom in the form of
+ * Object[] { int[], boolean[], Hashtable<String, String[]>,
+ * boolean[] }
* @throws UrlStringTooLongException
*/
- public Object[] makeUrls(String[] idstrings, String[] seqstrings,
- String dsstring, boolean onlyIfMatches)
- throws UrlStringTooLongException
+ public Object[] makeUrlStubs(String[] ids, String[] seqstr, String string,
+ boolean onlyIfMatches) throws UrlStringTooLongException
{
- Hashtable rstrings = replacementArgs(idstrings, seqstrings, dsstring);
- return makeUrls(rstrings, onlyIfMatches);
+ Hashtable<String, String[]> rstrings = replacementArgs(ids, seqstr,
+ string);
+ boolean createFullURL = false;
+ Object[] stubs = makeUrlsIf(createFullURL, rstrings, onlyIfMatches);
+ // stubs is just { int[] boolean[] }
+ return stubs == null ? null
+ : new Object[]
+ { stubs[0], stubs[1], rstrings,
+ new boolean[]
+ { onlyIfMatches } }; // int[] boolean[] Hashtable boolean[]
}
/**
* @param dsstring
* @return
*/
- private Hashtable replacementArgs(String[] idstrings, String[] seqstrings,
- String dsstring)
+ private Hashtable<String, String[]> replacementArgs(String[] idstrings,
+ String[] seqstrings, String dsstring)
{
- Hashtable rstrings = new Hashtable();
+ Hashtable<String, String[]> rstrings = new Hashtable<>();
rstrings.put(tokens[0], idstrings);
rstrings.put(tokens[1], seqstrings);
rstrings.put(tokens[2], new String[] { dsstring });
return rstrings;
}
- public Object[] makeUrls(Hashtable repstrings, boolean onlyIfMatches)
- throws UrlStringTooLongException
- {
- return makeUrlsIf(true, repstrings, onlyIfMatches);
- }
-
/**
+ * Called from PopupMenu.addShowLink action listener
*
- * @param ids
- * @param seqstr
- * @param string
- * @param b
- * @return URL stub objects ready to pass to constructFrom
- * @throws UrlStringTooLongException
- */
- public Object[] makeUrlStubs(String[] ids, String[] seqstr, String string,
- boolean b) throws UrlStringTooLongException
- {
- Hashtable rstrings = replacementArgs(ids, seqstr, string);
- Object[] stubs = makeUrlsIf(false, rstrings, b);
- if (stubs != null)
- {
- return new Object[] { stubs[0], stubs[1], rstrings,
- new boolean[]
- { b } };
- }
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
* generate the URL for the given URL stub object array returned from
* makeUrlStubs
*
* @param stubs
- * @return URL string.
+ * Object[] { int[] { number of matches seqs }, boolean[] { which
+ * matched }, (if createFullUrl also has StringBuffer[] { segment
+ * generated from inputs that is used in URL }, String[] { url })}
+ * @return URL string
* @throws UrlStringTooLongException
*/
+ @SuppressWarnings("unchecked")
public String constructFrom(Object[] stubs)
throws UrlStringTooLongException
{
- Object[] results = makeUrlsIf(true, (Hashtable) stubs[2],
- ((boolean[]) stubs[3])[0]);
- return ((String[]) results[3])[0];
+ // Object[] {
+ // int[] { number of matches seqs },
+ // boolean[] { which matched }
+ // }
+
+ boolean createFullURL = true;
+ Hashtable<String, String[]> repstrings = (Hashtable<String, String[]>) stubs[2];
+ boolean onlyIfMatches = ((boolean[]) stubs[3])[0];
+ String url = ((String[]) makeUrlsIf(createFullURL, repstrings,
+ onlyIfMatches)[3])[0];
+ return url;
}
/**
* }, String[] { url })}
* @throws UrlStringTooLongException
*/
- protected Object[] makeUrlsIf(boolean createFullUrl, Hashtable repstrings,
+ private Object[] makeUrlsIf(boolean createFullUrl,
+ Hashtable<String, String[]> repstrings,
boolean onlyIfMatches) throws UrlStringTooLongException
{
int pass = 0;
int mins = 0, maxs = 0; // allowed two values, 1 or n-sequences.
for (int i = 0; i < mtch.length; i++)
{
- idseq[i] = (String[]) repstrings.get(mtch[i]);
+ idseq[i] = repstrings.get(mtch[i]);
if (idseq[i].length >= 1)
{
if (mins == 0 && idseq[i].length == 1)
{
// just return the essential info about what the URL would be generated
// from
- return new Object[] { new int[] { seqsmatched }, thismatched };
+ return new Object[] { new int[] { seqsmatched }, thismatched // boolean[]
+ };
}
// otherwise, create the URL completely.
}
}
- return new Object[] { new int[] { seqsmatched }, thismatched, matched,
+ // full return
+ return new Object[] { new int[] { seqsmatched }, thismatched, // boolean[]
+ matched, // StringBuffer[]
new String[]
{ submiturl.toString() } };
}
/**
*
+ * Called by PopupMenu.addShowLinks()
+ *
* @param urlstub
* @return number of distinct sequence (id or seuqence) replacements predicted
* for this stub
}
/**
+ * called by PopupMenu.buildGroupURLMenu()
+ *
* get token types present in this url as a bitfield indicating presence of
* each token from tokens (LSB->MSB).
*
return r;
}
+ /**
+ * called by PopupMenu.buildGroupURLMenu()
+ *
+ * covenience method to generate the id and sequence string vector from a set
+ * of seuqences using each sequence's getName() and getSequenceAsString()
+ * method
+ *
+ * @param seqs
+ * @return String[][] {{sequence ids},{sequence strings}}
+ */
+ public static String[][] formStrings(SequenceI[] seqs)
+ {
+ String[][] idset = new String[2][seqs.length];
+ for (int i = 0; i < seqs.length; i++)
+ {
+ idset[0][i] = seqs[i].getName();
+ idset[1][i] = seqs[i].getSequenceAsString();
+ }
+ return idset;
+ }
+
+ // commented out test code
+ //
+ // /**
+ // *
+ // * @param argv
+ // * @j2sIgnore
+ // */
+ // public static void main(String argv[])
+ // {
+ // // note - JAL-1383 - these services are all dead
+ // String[] links = new String[] {
+ // "EnVision2|IDS|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=linkInDatasetFromJalview&input=$SEQUENCEIDS$&inputType=0|,",
+ // "EnVision2|Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=linkInDatasetFromJalview&input=$SEQUENCES$&inputType=1|,",
+ // "EnVision2|IDS|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=$DATASETID$&input=$SEQUENCEIDS$&inputType=0|,",
+ // "EnVision2|Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=$DATASETID$&input=$SEQUENCES$&inputType=1|,",
+ // "EnVision2|IDS|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=$SEQUENCEIDS$&datasetName=linkInDatasetFromJalview&input=$SEQUENCEIDS$&inputType=0|,",
+ // "EnVision2|Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=$SEQUENCEIDS$&datasetName=$DATASETID$&input=$SEQUENCES$&inputType=1|,",
+ // "EnVision2
+ // Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Default&datasetName=JalviewSeqs$DATASETID$&input=$SEQUENCES=/([a-zA-Z]+)/=$&inputType=1|,",
+ // "EnVision2
+ // Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Default&datasetName=JalviewSeqs$DATASETID$&input=$SEQUENCES=/[A-Za-z]+/=$&inputType=1|,"
+ // /*
+ // *
+ // http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?input=P38389,P38398
+ // * &inputType=0&workflow=Enfin%20Default%20Workflow&datasetName=
+ // * linkInDatasetFromPRIDE
+ // */
+ // };
+ //
+ // SequenceI[] seqs = new SequenceI[] {
+ // new Sequence("StupidLabel:gi|9234|pdb|102L|A",
+ // "asdiasdpasdpadpwpadasdpaspdw"), };
+ // String[][] seqsandids = formStrings(seqs);
+ // for (int i = 0; i < links.length; i++)
+ // {
+ // GroupUrlLink ul = new GroupUrlLink(links[i]);
+ // if (ul.isValid())
+ // {
+ // System.out.println("\n\n\n");
+ // System.out.println(
+ // "Link " + i + " " + links[i] + " : " + ul.toString());
+ // System.out.println(" pref : " + ul.getUrl_prefix());
+ // System.out.println(" IdReplace : " + ul.getIDRegexReplace());
+ // System.out.println(" SeqReplace : " + ul.getSeqRegexReplace());
+ // System.out.println(" Suffixes : " + ul.getUrl_suffix());
+ //
+ // System.out.println(
+ // "<insert input id and sequence strings here> Without onlyIfMatches:");
+ // Object[] urls;
+ // try
+ // {
+ // urls = ul.makeUrls(seqsandids[0], seqsandids[1], "mydataset",
+ // false);
+ // testUrls(ul, seqsandids, urls);
+ // } catch (UrlStringTooLongException ex)
+ // {
+ // System.out.println("too long exception " + ex);
+ // }
+ // System.out.println(
+ // "<insert input id and sequence strings here> With onlyIfMatches set:");
+ // try
+ // {
+ // urls = ul.makeUrls(seqsandids[0], seqsandids[1], "mydataset",
+ // true);
+ // testUrls(ul, seqsandids, urls);
+ // } catch (UrlStringTooLongException ex)
+ // {
+ // System.out.println("too long exception " + ex);
+ // }
+ // }
+ // else
+ // {
+ // System.err.println("Invalid URLLink : " + links[i] + " : "
+ // + ul.getInvalidMessage());
+ // }
+ // }
+ // }
+ // /**
+ // * @return the sequence ID regexReplace
+ // */
+ // private String getIDRegexReplace()
+ // {
+ // String token = tokens[0];
+ // for (int i = 0; i < mtch.length; i++)
+ // {
+ // if (segs[i] > -1 && mtch[i].equals(token))
+ // {
+ // return regexReplace[i];
+ // }
+ // }
+ // return null;
+ // }
+ //
+ // /**
+ // * @return the sequence ID regexReplace
+ // */
+ // private String getSeqRegexReplace()
+ // {
+ // return _replaceFor(tokens[1]);
+ // }
+ //
+ // /**
+ // * report stats about the generated url string given an input set
+ // *
+ // * @param ul
+ // * @param idstring
+ // * @param url
+ // */
+ // private static void testUrls(GroupUrlLink ul, String[][] idstring,
+ // Object[] url)
+ // {
+ //
+ // if (url == null)
+ // {
+ // System.out.println("Created NO urls.");
+ // }
+ // else
+ // {
+ // System.out.println("Created a url from " + ((int[]) url[0])[0]
+ // + "out of " + idstring[0].length + " sequences.");
+ // System.out.println("Sequences that did not match:");
+ // for (int sq = 0; sq < idstring[0].length; sq++)
+ // {
+ // if (!((boolean[]) url[1])[sq])
+ // {
+ // System.out.println("Seq " + sq + ": " + idstring[0][sq] + "\t: "
+ // + idstring[1][sq]);
+ // }
+ // }
+ // System.out.println("Sequences that DID match:");
+ // for (int sq = 0; sq < idstring[0].length; sq++)
+ // {
+ // if (((boolean[]) url[1])[sq])
+ // {
+ // System.out.println("Seq " + sq + ": " + idstring[0][sq] + "\t: "
+ // + idstring[1][sq]);
+ // }
+ // }
+ // System.out.println("The generated URL:");
+ // System.out.println(((String[]) url[3])[0]);
+ // }
+ // }
+ //
+ // public void setLabel(String newlabel)
+ // {
+ // this.label = newlabel;
+ // }
+ // /**
+ // * return one or more URL strings by applying regex to the given idstring
+ // *
+ // * @param idstrings
+ // * array of id strings to pass to service
+ // * @param seqstrings
+ // * array of seq strings to pass to service
+ // * @param onlyIfMatches
+ // * - when true url strings are only made if regex is defined and
+ // * matches for all qualified tokens in groupURL - TODO: consider if
+ // * onlyIfMatches is really a useful parameter!
+ // * @return null or Object[] { int[] { number of seqs substituted},boolean[]
+ // {
+ // * which seqs were substituted }, StringBuffer[] { substituted lists
+ // * for each token }, String[] { url } }
+ // * @throws UrlStringTooLongException
+ // */
+ // private Object[] makeUrls(String[] idstrings, String[] seqstrings,
+ // String dsstring, boolean onlyIfMatches)
+ // throws UrlStringTooLongException
+ // {
+ // Hashtable<String, String[]> rstrings = replacementArgs(idstrings,
+ // seqstrings, dsstring);
+ // return makeUrls(rstrings, onlyIfMatches);
+ // }
+ //
+ // /**
+ // *
+ // * @param repstrings
+ // * @param onlyIfMatches
+ // * @return Object[] {int[], boolean[], StringBuffer[], String[] }
+ // * @throws UrlStringTooLongException
+ // */
+ // private Object[] makeUrls(Hashtable<String, String[]> repstrings,
+ // boolean onlyIfMatches)
+ // throws UrlStringTooLongException
+ // {
+ // return makeUrlsIf(true, repstrings, onlyIfMatches);
+ // }
+ //
+
@Override
public String toString()
{
return result.toString();
}
- /**
- * report stats about the generated url string given an input set
- *
- * @param ul
- * @param idstring
- * @param url
- */
- private static void testUrls(GroupUrlLink ul, String[][] idstring,
- Object[] url)
- {
-
- if (url == null)
- {
- System.out.println("Created NO urls.");
- }
- else
- {
- System.out.println("Created a url from " + ((int[]) url[0])[0]
- + "out of " + idstring[0].length + " sequences.");
- System.out.println("Sequences that did not match:");
- for (int sq = 0; sq < idstring[0].length; sq++)
- {
- if (!((boolean[]) url[1])[sq])
- {
- System.out.println("Seq " + sq + ": " + idstring[0][sq] + "\t: "
- + idstring[1][sq]);
- }
- }
- System.out.println("Sequences that DID match:");
- for (int sq = 0; sq < idstring[0].length; sq++)
- {
- if (((boolean[]) url[1])[sq])
- {
- System.out.println("Seq " + sq + ": " + idstring[0][sq] + "\t: "
- + idstring[1][sq]);
- }
- }
- System.out.println("The generated URL:");
- System.out.println(((String[]) url[3])[0]);
- }
- }
-
- /**
- *
- * @param argv
- * @j2sIgnore
- */
- public static void main(String argv[])
- {
- // note - JAL-1383 - these services are all dead
- String[] links = new String[] {
- "EnVision2|IDS|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=linkInDatasetFromJalview&input=$SEQUENCEIDS$&inputType=0|,",
- "EnVision2|Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=linkInDatasetFromJalview&input=$SEQUENCES$&inputType=1|,",
- "EnVision2|IDS|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=$DATASETID$&input=$SEQUENCEIDS$&inputType=0|,",
- "EnVision2|Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=$DATASETID$&input=$SEQUENCES$&inputType=1|,",
- "EnVision2|IDS|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=$SEQUENCEIDS$&datasetName=linkInDatasetFromJalview&input=$SEQUENCEIDS$&inputType=0|,",
- "EnVision2|Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=$SEQUENCEIDS$&datasetName=$DATASETID$&input=$SEQUENCES$&inputType=1|,",
- "EnVision2 Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Default&datasetName=JalviewSeqs$DATASETID$&input=$SEQUENCES=/([a-zA-Z]+)/=$&inputType=1|,",
- "EnVision2 Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Default&datasetName=JalviewSeqs$DATASETID$&input=$SEQUENCES=/[A-Za-z]+/=$&inputType=1|,"
- /*
- * http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?input=P38389,P38398
- * &inputType=0&workflow=Enfin%20Default%20Workflow&datasetName=
- * linkInDatasetFromPRIDE
- */
- };
-
- SequenceI[] seqs = new SequenceI[] {
- new Sequence("StupidLabel:gi|9234|pdb|102L|A",
- "asdiasdpasdpadpwpadasdpaspdw"), };
- String[][] seqsandids = formStrings(seqs);
- for (int i = 0; i < links.length; i++)
- {
- GroupUrlLink ul = new GroupUrlLink(links[i]);
- if (ul.isValid())
- {
- System.out.println("\n\n\n");
- System.out.println(
- "Link " + i + " " + links[i] + " : " + ul.toString());
- System.out.println(" pref : " + ul.getUrl_prefix());
- System.out.println(" IdReplace : " + ul.getIDRegexReplace());
- System.out.println(" SeqReplace : " + ul.getSeqRegexReplace());
- System.out.println(" Suffixes : " + ul.getUrl_suffix());
-
- System.out.println(
- "<insert input id and sequence strings here> Without onlyIfMatches:");
- Object[] urls;
- try
- {
- urls = ul.makeUrls(seqsandids[0], seqsandids[1], "mydataset",
- false);
- testUrls(ul, seqsandids, urls);
- } catch (UrlStringTooLongException ex)
- {
- System.out.println("too long exception " + ex);
- }
- System.out.println(
- "<insert input id and sequence strings here> With onlyIfMatches set:");
- try
- {
- urls = ul.makeUrls(seqsandids[0], seqsandids[1], "mydataset",
- true);
- testUrls(ul, seqsandids, urls);
- } catch (UrlStringTooLongException ex)
- {
- System.out.println("too long exception " + ex);
- }
- }
- else
- {
- System.err.println("Invalid URLLink : " + links[i] + " : "
- + ul.getInvalidMessage());
- }
- }
- }
-
- /**
- * covenience method to generate the id and sequence string vector from a set
- * of seuqences using each sequence's getName() and getSequenceAsString()
- * method
- *
- * @param seqs
- * @return String[][] {{sequence ids},{sequence strings}}
- */
- public static String[][] formStrings(SequenceI[] seqs)
- {
- String[][] idset = new String[2][seqs.length];
- for (int i = 0; i < seqs.length; i++)
- {
- idset[0][i] = seqs[i].getName();
- idset[1][i] = seqs[i].getSequenceAsString();
- }
- return idset;
- }
-
- public void setLabel(String newlabel)
- {
- this.label = newlabel;
- }
-
}
private static ResourceBundle rb;
- private static Logger log = Logger
+ private final static Logger log = Logger
.getLogger(MessageManager.class.getCanonicalName());
- private static Locale loc;
+ private final static Locale loc;
- private static Set<String> reportedMissing = new HashSet<>();
+ private final static Set<String> reportedMissing = new HashSet<>();
static
{
+ loc = Locale.getDefault();
try
{
- /* Localize Java dialogs */
- loc = Locale.getDefault();
- // Locale.setDefault(loc);
/* Getting messages for GV */
log.info("Getting messages for lang: " + loc);
Control control = Control.getControl(Control.FORMAT_PROPERTIES);
* @param url
* @return true if window has been opened
*/
- public static boolean openURL(String url)
+ public static boolean openURL(String url) throws IOException
{
if (!isJS())
{
+ BrowserLauncher.openURL(url);
return false;
}
/**
}
/**
- * return an ordered list of database sources excluding alignment only databases
+ * return an ordered list of database sources excluding alignment only
+ * databases
*/
public String[] getNonAlignmentSources()
{
String[] srcs = this.getSupportedDb();
List<String> src = new ArrayList<>();
-
- for (int i = 0; i < srcs.length; i++)
+ outer: for (int i = 0; i < srcs.length; i++)
{
- boolean accept = true;
for (DbSourceProxy dbs : getSourceProxy(srcs[i]))
{
// Skip the alignment databases for the moment - they're not useful for
// verifying a single sequence against its reference source
if (dbs.isAlignmentSource())
{
- accept = false;
- break;
+ continue outer;
}
}
- if (accept)
- {
- src.add(srcs[i]);
- }
+ src.add(srcs[i]);
}
Collections.sort(src, String.CASE_INSENSITIVE_ORDER);
return src.toArray(new String[src.size()]);
*/
package jalview.ws;
+import jalview.bin.Jalview;
import jalview.ws.seqfetcher.ASequenceFetcher;
public class SequenceFetcherFactory
{
- private static SequenceFetcher instance;
-
/**
* Returns a new SequenceFetcher object, or a mock object if one has been set
*
*/
public static ASequenceFetcher getSequenceFetcher()
{
- return instance == null ? new SequenceFetcher() : instance;
+ Jalview j = Jalview.getInstance();
+ return (j.sequenceFetcher == null
+ ? j.sequenceFetcher = new SequenceFetcher()
+ : j.sequenceFetcher);
}
/**
*/
public static void setSequenceFetcher(SequenceFetcher sf)
{
- instance = sf;
+ Jalview.getInstance().sequenceFetcher = sf;
}
}
*/
package jalview.ws.jws1;
+import jalview.bin.Jalview;
import jalview.gui.JvOptionPane;
import jalview.util.MessageManager;
public class Discoverer implements Runnable
{
- ext.vamsas.IRegistry registry; // the root registry service.
+
+ public static Discoverer getInstance()
+ {
+ Jalview j = Jalview.getInstance();
+ return (j.discoverer == null ? j.discoverer = new Discoverer()
+ : j.discoverer);
+ }
+
+ private java.net.URL RootServiceURL = null;
+
+ private Vector<URL> ServiceURLList = null;
+
+ private boolean reallyDiscoverServices = true;
+
+ private Hashtable<String, Vector<ServiceHandle>> services = null;
+
+ public Hashtable<String, Vector<ServiceHandle>> getServices()
+ {
+ return services;
+ }
+
+ private Vector<ServiceHandle> serviceList = null;
+
+ // private ext.vamsas.IRegistry registry; // the root registry service.
+
private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
this);
return server;
}
- static private java.net.URL RootServiceURL = null;
-
- static public Vector<URL> ServiceURLList = null;
-
- static private boolean reallyDiscoverServices = true;
-
- public static java.util.Hashtable<String, Vector<ServiceHandle>> services = null;
- // stored by
- // abstractServiceType
- // string
-
- public static java.util.Vector<ServiceHandle> serviceList = null;
-
static private Vector<URL> getDiscoveryURLS()
{
Vector<URL> urls = new Vector<>();
{
jalview.bin.Cache.log
.debug("(Re)-Initialising the discovery URL list.");
+ Discoverer d = getInstance();
try
{
- reallyDiscoverServices = jalview.bin.Cache
+ d.reallyDiscoverServices = jalview.bin.Cache
.getDefault("DISCOVERY_START", false);
- if (reallyDiscoverServices)
+ if (d.reallyDiscoverServices)
{
- ServiceURLList = getDiscoveryURLS();
+ d.ServiceURLList = getDiscoveryURLS();
}
else
{
jalview.bin.Cache.log.debug("Setting default services");
- services = new Hashtable<>();
+ d.services = new Hashtable<>();
// Muscle, Clustal and JPred.
ServiceHandle[] defServices = { new ServiceHandle("MsaWS",
"Edgar, Robert C. (2004), MUSCLE: multiple sequence alignment "
+ "\ndoi://10.1093/nar/gkv332",
"http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred",
"JPred Secondary Structure Prediction") };
- services = new Hashtable<>();
- serviceList = new Vector<>();
- buildServiceLists(defServices, serviceList, services);
+ d.services = new Hashtable<>();
+ d.serviceList = new Vector<>();
+ buildServiceLists(defServices, d.serviceList, d.services);
}
} catch (Exception e)
{
System.err.println(
"jalview.rootRegistry is not a proper url!\nWas set to "
- + RootServiceURL + "\n" + e);
+ + d.RootServiceURL + "\n" + e);
}
}
cat.add(sh[i]);
if (sh[i].getAbstractName().equals("Registry"))
{
- for (int s = 0, sUrls = ServiceURLList.size(); s < sUrls; s++)
+ Vector<URL> list = getInstance().ServiceURLList;
+ for (int s = 0, sUrls = list.size(); s < sUrls; s++)
{
java.net.URL disc_serv = null;
try
{
disc_serv = new java.net.URL(sh[i].getEndpointURL());
- if (!ServiceURLList.contains(disc_serv))
+ if (!list.contains(disc_serv))
{
jalview.bin.Cache.log.debug(
"Adding new discovery service at " + disc_serv);
- ServiceURLList.add(disc_serv);
+ list.add(disc_serv);
seenNewDiscovery = true;
}
} catch (Exception e)
return CALC_ID;
}
- private static String CALC_ID = "jabaws2.AACon";
+ private final static String CALC_ID = "jabaws2.AACon";
public static AlignAnalysisUIText getAlignAnalysisUITest()
{
private static final String RANGE = "RANGE";
- String typeName;
+ private String typeName;
- String methodName;
+ private String methodName;
- String groupName;
+ // private String groupName;
AlignFrame af;
- public AADisorderClient(Jws2Instance sh, AlignFrame alignFrame,
- WsParamSetI thePreset, List<Argument> paramset)
- {
- super(sh, alignFrame, thePreset, paramset);
- af = alignFrame;
- typeName = sh.action;
- methodName = sh.serviceType;
+ private final static Map<String, Map<String, String[]>> featureMap;
- submitGaps = false;
- alignedSeqs = false;
- nucleotidesAllowed = false;
- proteinAllowed = true;
- bySequence = true;
- }
+ private final static Map<String, Map<String, Map<String, Object>>> annotMap;
- @Override
- public String getServiceActionText()
- {
- return "Submitting amino acid sequences for disorder prediction.";
- }
+ private final static String DONTCOMBINE = "DONTCOMBINE";
- @Override
- boolean checkValidInputSeqs(boolean dynamic, List<FastaSequence> seqs)
- {
- return (seqs.size() > 0);
- }
-
- private static Map<String, Map<String, String[]>> featureMap;
+ private final static String INVISIBLE = "INVISIBLE";
- private static Map<String, Map<String, Map<String, Object>>> annotMap;
-
- private static String DONTCOMBINE = "DONTCOMBINE";
-
- private static String INVISIBLE = "INVISIBLE";
static
{
// TODO: turn this into some kind of configuration file that's a bit easier
amap.get("JRonn").put(RANGE, new float[] { 0, 1 });
}
+ public AADisorderClient(Jws2Instance sh, AlignFrame alignFrame,
+ WsParamSetI thePreset, List<Argument> paramset)
+ {
+ super(sh, alignFrame, thePreset, paramset);
+ af = alignFrame;
+ typeName = sh.action;
+ methodName = sh.serviceType;
+
+ submitGaps = false;
+ alignedSeqs = false;
+ nucleotidesAllowed = false;
+ proteinAllowed = true;
+ bySequence = true;
+ }
+
+ @Override
+ public String getServiceActionText()
+ {
+ return "Submitting amino acid sequences for disorder prediction.";
+ }
+
+ @Override
+ boolean checkValidInputSeqs(boolean dynamic, List<FastaSequence> seqs)
+ {
+ return (seqs.size() > 0);
+ }
+
@Override
public void updateResultAnnotation(boolean immediate)
{
if (vals.hasNext())
{
val = vals.next().floatValue();
- sf = new SequenceFeature(type[0], type[1],
- base + rn.from, base + rn.to, val, methodName);
+ sf = new SequenceFeature(type[0], type[1], base + rn.from,
+ base + rn.to, val, methodName);
}
else
{
- sf = new SequenceFeature(type[0], type[1],
- base + rn.from, base + rn.to, methodName);
+ sf = new SequenceFeature(type[0], type[1], base + rn.from,
+ base + rn.to, methodName);
}
dseq.addSequenceFeature(sf);
if (last != val && !Float.isNaN(last))
package jalview.ws.jws2;
import jalview.bin.Cache;
+import jalview.bin.Jalview;
import jalview.gui.AlignFrame;
import jalview.gui.Desktop;
import jalview.gui.JvSwingUtils;
private final static String JWS2HOSTURLS = "JWS2HOSTURLS";
/*
- * Singleton instance
- */
- private static Jws2Discoverer discoverer;
-
- /*
* Override for testing only
*/
private static List<String> testUrls = null;
// preferred url has precedence over others
private String preferredUrl;
- private PropertyChangeSupport changeSupport = new PropertyChangeSupport(
+ protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(
this);
private Vector<String> invalidServiceUrls = null;
oldthread = Thread.currentThread();
try
{
- Class foo = getClass().getClassLoader()
+ getClass().getClassLoader()
.loadClass("compbio.ws.client.Jws2Client");
} catch (ClassNotFoundException e)
{
*/
public static Jws2Discoverer getDiscoverer()
{
- if (discoverer == null)
- {
- discoverer = new Jws2Discoverer();
- }
- return discoverer;
+ Jalview j = Jalview.getInstance();
+ return (j.j2s2discoverer == null
+ ? j.j2s2discoverer = new Jws2Discoverer()
+ : j.j2s2discoverer);
}
public boolean hasServices()
*/
package jalview.ws.jws2.jabaws2;
+import jalview.bin.Jalview;
import jalview.ws.jws2.AAConClient;
import jalview.ws.jws2.RNAalifoldClient;
import jalview.ws.uimodel.AlignAnalysisUIText;
public class Jws2InstanceFactory
{
- private static HashMap<String, AlignAnalysisUIText> aaConGUI;
- private static HashSet<String> ignoreGUI;
+ private HashMap<String, AlignAnalysisUIText> aaConGUI;
+
+ private HashSet<String> ignoreGUI;
+
+ public static Jws2InstanceFactory getInstance()
+ {
+ Jalview j = Jalview.getInstance();
+ return (j.jws2InstanceFactory == null
+ ? j.jws2InstanceFactory = new Jws2InstanceFactory()
+ : j.jws2InstanceFactory);
+ }
private static String category_rewrite(String cat_name)
{
: cat_name;
}
- private static void init()
+ private void init()
{
if (aaConGUI == null)
{
- aaConGUI = new HashMap<String, AlignAnalysisUIText>();
+ aaConGUI = new HashMap<>();
aaConGUI.put(compbio.ws.client.Services.AAConWS.toString(),
AAConClient.getAlignAnalysisUITest());
aaConGUI.put(compbio.ws.client.Services.RNAalifoldWS.toString(),
RNAalifoldClient.getAlignAnalysisUITest());
// ignore list for JABAWS services not supported in jalview ...
- ignoreGUI = new HashSet<String>();
+ ignoreGUI = new HashSet<>();
}
}
*/
public static boolean ignoreService(String serviceType)
{
- init();
- return (ignoreGUI.contains(serviceType.toString()));
+ getInstance().init();
+ return (getInstance().ignoreGUI.contains(serviceType.toString()));
}
/**
String serviceType, String name, String description,
JABAService service)
{
- init();
+ getInstance().init();
Jws2Instance svc = new Jws2Instance(jwsservers, serviceType,
category_rewrite(name), description, service);
- svc.aaui = aaConGUI.get(serviceType.toString());
+ svc.aaui = getInstance().aaConGUI.get(serviceType.toString());
return svc;
}
package jalview.ws.rest;
import jalview.bin.Cache;
+import jalview.bin.Jalview;
import jalview.datamodel.AlignmentView;
import jalview.gui.AlignFrame;
import jalview.gui.AlignViewport;
public class RestClient extends WSClient
implements WSClientI, WSMenuEntryProviderI
{
- RestServiceDescription service;
+ public static final String RSBS_SERVICES = "RSBS_SERVICES";
- public RestClient(RestServiceDescription rsd)
- {
- service = rsd;
- }
+ RestServiceDescription service;
/**
* parent alignframe for this job
*/
AlignViewport av;
+ boolean headless = false;
+
+ protected Vector<String> services = null;
+
/**
* get the alignFrame for the associated input data if it exists.
*
return jalview.gui.Desktop.getAlignFrameFor(av);
}
+ RestClient getInstance()
+ {
+ Jalview j = Jalview.getInstance();
+ return (j.restClient == null ? j.restClient = new RestClient()
+ : j.restClient);
+ }
+
+ private RestClient()
+ {
+
+ }
+
+ public RestClient(RestServiceDescription rsd)
+ {
+ service = rsd;
+ }
+
public RestClient(RestServiceDescription service2, AlignFrame alignFrame)
{
this(service2, alignFrame, false);
}
- boolean headless = false;
-
public RestClient(RestServiceDescription service2, AlignFrame alignFrame,
boolean nogui)
{
String action = "Analysis",
description = "Sequence Harmony and Multi-Relief (Brandt et al. 2010)",
name = MessageManager.getString("label.multiharmony");
- Hashtable<String, InputType> iparams = new Hashtable<String, InputType>();
- jalview.ws.rest.params.JobConstant toolp;
+ Hashtable<String, InputType> iparams = new Hashtable<>();
+ // jalview.ws.rest.params.JobConstant toolp;
// toolp = new jalview.ws.rest.JobConstant("tool","jalview");
// iparams.put(toolp.token, toolp);
// toolp = new jalview.ws.rest.params.JobConstant("mbjob[method]","shmr");
return true;
}
- protected static Vector<String> services = null;
-
- public static final String RSBS_SERVICES = "RSBS_SERVICES";
-
public static RestClient[] getRestClients()
{
- if (services == null)
+ RestClient c = Jalview.getInstance().restClient;
+
+ if (c.services == null)
{
- services = new Vector<String>();
+ c.services = new Vector<>();
try
{
for (RestServiceDescription descr : RestServiceDescription
jalview.bin.Cache.getDefault(RSBS_SERVICES,
makeShmmrRestClient().service.toString())))
{
- services.add(descr.toString());
+ c.services.add(descr.toString());
}
} catch (Exception ex)
{
}
}
- RestClient[] lst = new RestClient[services.size()];
+ RestClient[] lst = new RestClient[c.services.size()];
int i = 0;
- for (String svc : services)
+ for (String svc : c.services)
{
lst[i++] = new RestClient(new RestServiceDescription(svc));
}
public static Vector<String> getRsbsDescriptions()
{
- Vector<String> rsbsDescrs = new Vector<String>();
+ Vector<String> rsbsDescrs = new Vector<>();
for (RestClient rsbs : getRestClients())
{
rsbsDescrs.add(rsbs.getRestDescription().toString());
if (rsbsUrls != null)
{
// TODO: consider validating services ?
- services = new Vector<String>(rsbsUrls);
+ RestClient c = Jalview.getInstance().restClient;
+ c.services = new Vector<>(rsbsUrls);
StringBuffer sprop = new StringBuffer();
- for (String s : services)
+ for (String s : c.services)
{
sprop.append(s);
}
private static final String NOT_OBSERVED = "Not_Observed";
- private static final String SIFTS_FTP_BASE_URL = "http://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/";
+ protected static final String SIFTS_FTP_BASE_URL = "http://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/";
- private final static String NEWLINE = System.lineSeparator();
+ protected final static String NEWLINE = System.lineSeparator();
private String curSourceDBRef;
@Override
public HashSet<String> getAllMappingAccession()
{
- HashSet<String> accessions = new HashSet<String>();
+ HashSet<String> accessions = new HashSet<>();
List<Entity> entities = siftsEntry.getEntity();
for (Entity entity : entities)
{
entity = getEntityById(entityId);
String originalSeq = AlignSeq.extractGaps(
jalview.util.Comparison.GapChars, seq.getSequenceAsString());
- HashMap<Integer, int[]> mapping = new HashMap<Integer, int[]>();
+ HashMap<Integer, int[]> mapping = new HashMap<>();
DBRefEntryI sourceDBRef;
sourceDBRef = getValidSourceDBRef(seq);
// TODO ensure sequence start/end is in the same coordinate system and
seqCoordSys = CoordinateSys.PDB;
}
- HashSet<String> dbRefAccessionIdsString = new HashSet<String>();
+ HashSet<String> dbRefAccessionIdsString = new HashSet<>();
for (DBRefEntry dbref : seq.getDBRefs())
{
dbRefAccessionIdsString.add(dbref.getAccessionId().toLowerCase());
curDBRefAccessionIdsString = dbRefAccessionIdsString;
curSourceDBRef = sourceDBRef.getAccessionId();
- TreeMap<Integer, String> resNumMap = new TreeMap<Integer, String>();
+ TreeMap<Integer, String> resNumMap = new TreeMap<>();
List<Segment> segments = entity.getSegment();
SegmentHelperPojo shp = new SegmentHelperPojo(seq, mapping, resNumMap,
omitNonObserved, nonObservedShiftIndex,pdbeNonObserved);
}
if (!isObserved)
{
- ++pdbeNonObservedCount;
+ ++pdbeNonObservedCount; // TODO this value is never used
}
- if (seqCoordSys == seqCoordSys.PDB) // FIXME: is seqCoordSys ever PDBe
+ if (seqCoordSys == CoordinateSys.PDB) // FIXME: is seqCoordSys ever PDBe
// ???
{
// if the sequence has a primary reference to the PDB, then we are
private Set<String> getResidueAnnotaitons(Residue residue,
ResidueDetailType type)
{
- HashSet<String> foundAnnotations = new HashSet<String>();
+ HashSet<String> foundAnnotations = new HashSet<>();
List<ResidueDetail> resDetails = residue.getResidueDetail();
for (ResidueDetail resDetail : resDetails)
{
public int resCount;
+ protected SiftsEntitySortPojo()
+ {
+ }
+
@Override
public int compareTo(SiftsEntitySortPojo o)
{
{
return pdbeNonObserved;
}
+
public SequenceI getSeq()
{
return seq;
*/
package jalview.ws.sifts;
+import jalview.bin.Jalview;
+
import java.util.Objects;
public class SiftsSettings
{
- private static boolean mapWithSifts = false;
+ private boolean mapWithSifts = false;
+
+ private String siftDownloadDirectory;
- private static String siftDownloadDirectory;
+ private int cacheThresholdInDays;
- private static int cacheThresholdInDays;
+ private int failSafePIDThreshold;
- private static int failSafePIDThreshold;
+ private static SiftsSettings getInstance()
+ {
+ {
+ Jalview j = Jalview.getInstance();
+ return (j.siftsSettings == null
+ ? j.siftsSettings = new SiftsSettings()
+ : j.siftsSettings);
+ }
+ }
public static boolean isMapWithSifts()
{
- return mapWithSifts;
+ return getInstance().mapWithSifts;
}
public static void setMapWithSifts(boolean mapWithSifts)
{
- SiftsSettings.mapWithSifts = mapWithSifts;
+ getInstance().mapWithSifts = mapWithSifts;
}
public static String getSiftDownloadDirectory()
{
- return siftDownloadDirectory;
+ return getInstance().siftDownloadDirectory;
}
public static void setSiftDownloadDirectory(String siftDownloadDirectory)
{
- SiftsSettings.siftDownloadDirectory = siftDownloadDirectory;
+ getInstance().siftDownloadDirectory = siftDownloadDirectory;
}
public static int getCacheThresholdInDays()
{
- return cacheThresholdInDays;
+ return getInstance().cacheThresholdInDays;
}
public static void setCacheThresholdInDays(String cacheThresholdInDays)
{
Objects.requireNonNull(cacheThresholdInDays);
- SiftsSettings.cacheThresholdInDays = Integer
+ getInstance().cacheThresholdInDays = Integer
.valueOf(cacheThresholdInDays);
}
public static int getFailSafePIDThreshold()
{
- return failSafePIDThreshold;
+ return getInstance().failSafePIDThreshold;
}
public static void setFailSafePIDThreshold(String failSafePIDThreshold)
{
Objects.requireNonNull(failSafePIDThreshold);
- SiftsSettings.failSafePIDThreshold = Integer
+ getInstance().failSafePIDThreshold = Integer
.valueOf(failSafePIDThreshold);
}
}
public class PDBfile extends StructureFile
{
- private static String CALC_ID_PREFIX = "JalviewPDB";
+ private final static String CALC_ID_PREFIX = "JalviewPDB";
public PDBfile(boolean addAlignmentAnnotations,
boolean predictSecondaryStructure, boolean externalSecStr)
setId(safeName(getDataName()));
setChains(new Vector<PDBChain>());
- List<SequenceI> rna = new ArrayList<SequenceI>();
- List<SequenceI> prot = new ArrayList<SequenceI>();
+ List<SequenceI> rna = new ArrayList<>();
+ List<SequenceI> prot = new ArrayList<>();
PDBChain tmpchain;
String line = null;
boolean modelFlag = false;
boolean terFlag = false;
String lastID = "";
- int indexx = 0;
+ // int indexx = 0;
String atomnam = null;
try
{