*/
package jalview.appletgui;
+import static jalview.util.UrlConstants.EMBLEBI_STRING;
+import static jalview.util.UrlConstants.SRS_STRING;
+
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
}
{
// upgrade old SRS link
- int srsPos = links
- .indexOf("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry");
+ int srsPos = links.indexOf(SRS_STRING);
if (srsPos > -1)
{
- links.setElementAt(
- "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$",
- srsPos);
+ links.setElementAt(EMBLEBI_STRING, srsPos);
}
}
if (links.size() < 1)
{
links = new java.util.Vector();
- links.addElement("EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$");
+ links.addElement(EMBLEBI_STRING);
}
}
*/
package jalview.gui;
+import static jalview.util.UrlConstants.EMBLEBI_STRING;
+import static jalview.util.UrlConstants.SEQUENCE_ID;
+import static jalview.util.UrlConstants.SRS_STRING;
+
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.bin.Cache;
import jalview.gui.Help.HelpId;
public static List<String> groupURLLinks;
static
{
- String string = Cache
- .getDefault(
- "SEQUENCE_LINKS",
- "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$");
+ String string = Cache.getDefault("SEQUENCE_LINKS", EMBLEBI_STRING);
sequenceURLLinks = new Vector<String>();
try
String name = st.nextToken();
String url = st.nextToken();
// check for '|' within a regex
- int rxstart = url.indexOf("$SEQUENCE_ID$");
+ int rxstart = url.indexOf("$" + SEQUENCE_ID + "$");
while (rxstart == -1 && url.indexOf("/=$") == -1)
{
url = url + "|" + st.nextToken();
}
{
// upgrade old SRS link
- int srsPos = sequenceURLLinks
- .indexOf("SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry");
+ int srsPos = sequenceURLLinks.indexOf(SRS_STRING);
if (srsPos > -1)
{
- sequenceURLLinks
- .setElementAt(
- "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$",
- srsPos);
+ sequenceURLLinks.setElementAt(EMBLEBI_STRING, srsPos);
}
}
--- /dev/null
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.util;
+
+/**
+ * A class to hold constants relating to Url links used in Jalview
+ */
+public class UrlConstants
+{
+ /*
+ * Default sequence URL link string for EMBL-EBI search
+ */
+ public static final String EMBLEBI_STRING = "EMBL-EBI Search|http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$SEQUENCE_ID$";
+
+ /*
+ * Default sequence URL link string for SRS
+ */
+ public static final String SRS_STRING = "SRS|http://srs.ebi.ac.uk/srsbin/cgi-bin/wgetz?-newId+(([uniprot-all:$SEQUENCE_ID$]))+-view+SwissEntry";
+
+ /*
+ * Sequence ID string
+ */
+ public static final String SEQUENCE_ID = "SEQUENCE_ID";
+
+ /*
+ * Sequence Name string
+ */
+ public static final String SEQUENCE_NAME = "SEQUENCE_NAME";
+
+ /*
+ * not instantiable
+ */
+ private UrlConstants()
+ {
+ }
+}
*/
package jalview.util;
+import static jalview.util.UrlConstants.SEQUENCE_ID;
+
import java.util.Vector;
public class UrlLink
*/
public UrlLink(String link)
{
- int sep = link.indexOf("|"), psqid = link.indexOf("$SEQUENCE_ID");
+ int sep = link.indexOf("|"), psqid = link.indexOf("$" + SEQUENCE_ID);
if (psqid > -1)
{
dynamic = true;
}
// Parse URL : Whole URL string first
url_prefix = link.substring(sep + 1, psqid);
- if (link.indexOf("$SEQUENCE_ID=/") == psqid
+ if (link.indexOf("$" + SEQUENCE_ID + "=/") == psqid
&& (p = link.indexOf("/=$", psqid + 14)) > psqid + 14)
{
// Extract Regex and suffix
{
regexReplace = null;
// verify format is really correct.
- if (link.indexOf("$SEQUENCE_ID$") == psqid)
+ if (link.indexOf("$" + SEQUENCE_ID + "$") == psqid)
{
url_suffix = link.substring(psqid + 13);
regexReplace = null;
}
}
+ @Override
public String toString()
{
return label
+ "|"
+ url_prefix
- + (dynamic ? ("$SEQUENCE_ID" + ((regexReplace != null) ? "="
+ + (dynamic ? ("$" + SEQUENCE_ID + ((regexReplace != null) ? "="
+ regexReplace + "=$" : "$")) : "")
+ ((url_suffix == null) ? "" : url_suffix);
* "PF3|http://us.expasy.org/cgi-bin/niceprot.pl?$SEQUENCE_ID=/PFAM:(.+)/=$"
* , "NOTFER|http://notfer.org/$SEQUENCE_ID=/(?<!\\s)(.+)/=$",
*/
- "NESTED|http://nested/$SEQUENCE_ID=/^(?:Label:)?(?:(?:gi\\|(\\d+))|([^:]+))/=$/nested" };
+ "NESTED|http://nested/$" + SEQUENCE_ID
+ + "=/^(?:Label:)?(?:(?:gi\\|(\\d+))|([^:]+))/=$/nested" };
String[] idstrings = new String[] {
/*
* //"LGUL_human", //"QWIQW_123123", "uniprot|why_do+_12313_foo",