JAL-3210 Barebones gradle/buildship/eclipse. See README
[jalview.git] / src / jalview / util / GroupUrlLink.java
index e4c4ad0..67309a0 100644 (file)
  */
 package jalview.util;
 
+import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceI;
 
 import java.util.Hashtable;
 
-import com.stevesoft.pat.Regex;
-
-/**
- * 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)
@@ -75,6 +66,11 @@ public class GroupUrlLink
   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;
@@ -83,34 +79,32 @@ public class GroupUrlLink
    * contains tokens in the order they appear in the URL template.
    */
   private String[] mtch;
+  static
+  {
+    if (tokens == null)
+    {
+      tokens = new String[] { "SEQUENCEIDS", "SEQUENCES", "DATASETID" };
+    }
+  }
 
   /**
-   * tokens that can be replaced in the URL.
+   * test for GroupURLType bitfield (with default tokens)
+   */
+  public static final int SEQUENCEIDS = 1;
+
+  /**
+   * test for GroupURLType bitfield (with default tokens)
    */
-  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;
-  //
+  public static final int SEQUENCES = 2;
+
+  /**
+   * test for GroupURLType bitfield (with default tokens)
+   */
+  public 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
@@ -221,7 +215,8 @@ public class GroupUrlLink
         regexReplace[pass] = link.substring(ptok[pass] + mlength, p);
         try
         {
-          Regex rg = Platform.newRegexPerl("/" + regexReplace[pass] + "/");
+          com.stevesoft.pat.Regex rg = com.stevesoft.pat.Regex
+                  .perlCode("/" + regexReplace[pass] + "/");
           if (rg == null)
           {
             invalidMessage = "Invalid Regular Expression : '"
@@ -289,9 +284,6 @@ public class GroupUrlLink
   }
 
   /**
-   * 
-   * called by PopupMenu.addShowLink()
-   * 
    * @return the url_prefix
    */
   public String getUrl_prefix()
@@ -300,8 +292,6 @@ public class GroupUrlLink
   }
 
   /**
-   * called by PopupMenu.buildGroupURLMenu()
-   * 
    * @return the target
    */
   public String getTarget()
@@ -310,9 +300,6 @@ public class GroupUrlLink
   }
 
   /**
-   * 
-   * called by PopupMenu.buildGroupURLMenu()
-   * 
    * @return the label
    */
   public String getLabel()
@@ -321,9 +308,34 @@ public class GroupUrlLink
   }
 
   /**
-   * 
-   * called by PopupMenu.buildGroupURLMenu()
-   * 
+   * @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]);
+  }
+
+  /**
    * @return the invalidMessage
    */
   public String getInvalidMessage()
@@ -332,8 +344,6 @@ public class GroupUrlLink
   }
 
   /**
-   * called by PopupMenu.buildGroupURLMenu()
-   * 
    * Check if URL string was parsed properly.
    * 
    * @return boolean - if false then <code>getInvalidMessage</code> returns an
@@ -345,34 +355,27 @@ public class GroupUrlLink
   }
 
   /**
+   * return one or more URL strings by applying regex to the given idstring
    * 
-   * 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 idstrings
+   *          array of id strings to pass to service
+   * @param seqstrings
+   *          array of seq strings to pass to service
    * @param onlyIfMatches
-   * @return URL stub objects ready to pass to constructFrom in the form of
-   *         Object[] { int[], boolean[], Hashtable&lt;String, String[]&gt;,
-   *         boolean[] }
+   *          - 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
    */
-  public Object[] makeUrlStubs(String[] ids, String[] seqstr, String string,
-          boolean onlyIfMatches) throws UrlStringTooLongException
+  public Object[] makeUrls(String[] idstrings, String[] seqstrings,
+          String dsstring, boolean onlyIfMatches)
+          throws UrlStringTooLongException
   {
-    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[]
+    Hashtable rstrings = replacementArgs(idstrings, seqstrings, dsstring);
+    return makeUrls(rstrings, onlyIfMatches);
   }
 
   /**
@@ -383,10 +386,10 @@ public class GroupUrlLink
    * @param dsstring
    * @return
    */
-  private Hashtable<String, String[]> replacementArgs(String[] idstrings,
-          String[] seqstrings, String dsstring)
+  private Hashtable replacementArgs(String[] idstrings, String[] seqstrings,
+          String dsstring)
   {
-    Hashtable<String, String[]> rstrings = new Hashtable<>();
+    Hashtable rstrings = new Hashtable();
     rstrings.put(tokens[0], idstrings);
     rstrings.put(tokens[1], seqstrings);
     rstrings.put(tokens[2], new String[] { dsstring });
@@ -398,34 +401,50 @@ public class GroupUrlLink
     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
-   *          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
+   * @return URL string.
    * @throws UrlStringTooLongException
    */
-  @SuppressWarnings("unchecked")
   public String constructFrom(Object[] stubs)
           throws UrlStringTooLongException
   {
-    // 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;
+    Object[] results = makeUrlsIf(true, (Hashtable) stubs[2],
+            ((boolean[]) stubs[3])[0]);
+    return ((String[]) results[3])[0];
   }
 
   /**
@@ -441,8 +460,7 @@ public class GroupUrlLink
    *         }, String[] { url })}
    * @throws UrlStringTooLongException
    */
-  private Object[] makeUrlsIf(boolean createFullUrl,
-          Hashtable<String, String[]> repstrings,
+  protected Object[] makeUrlsIf(boolean createFullUrl, Hashtable repstrings,
           boolean onlyIfMatches) throws UrlStringTooLongException
   {
     int pass = 0;
@@ -452,7 +470,7 @@ public class GroupUrlLink
     int mins = 0, maxs = 0; // allowed two values, 1 or n-sequences.
     for (int i = 0; i < mtch.length; i++)
     {
-      idseq[i] = repstrings.get(mtch[i]);
+      idseq[i] = (String[]) repstrings.get(mtch[i]);
       if (idseq[i].length >= 1)
       {
         if (mins == 0 && idseq[i].length == 1)
@@ -485,13 +503,14 @@ public class GroupUrlLink
     // iterate through input, collating segments to be inserted into url
     StringBuffer matched[] = new StringBuffer[idseq.length];
     // and precompile regexes
-    Regex[] rgxs = new Regex[matched.length];
+    com.stevesoft.pat.Regex[] rgxs = new com.stevesoft.pat.Regex[matched.length];
     for (pass = 0; pass < matched.length; pass++)
     {
       matched[pass] = new StringBuffer();
       if (regexReplace[pass] != null)
       {
-        rgxs[pass] = Platform.newRegexPerl("/" + regexReplace[pass] + "/");
+        rgxs[pass] = com.stevesoft.pat.Regex
+                .perlCode("/" + regexReplace[pass] + "/");
       }
       else
       {
@@ -674,8 +693,7 @@ public class GroupUrlLink
     {
       // just return the essential info about what the URL would be generated
       // from
-      return new Object[] { new int[] { seqsmatched }, thismatched // boolean[]
-      };
+      return new Object[] { new int[] { seqsmatched }, thismatched };
     }
     // otherwise, create the URL completely.
 
@@ -690,17 +708,13 @@ public class GroupUrlLink
       }
     }
 
-    // full return
-    return new Object[] { new int[] { seqsmatched }, thismatched, // boolean[]
-        matched, // StringBuffer[]
+    return new Object[] { new int[] { seqsmatched }, thismatched, matched,
         new String[]
         { submiturl.toString() } };
   }
 
   /**
    * 
-   * Called by PopupMenu.addShowLinks()
-   * 
    * @param urlstub
    * @return number of distinct sequence (id or seuqence) replacements predicted
    *         for this stub
@@ -712,8 +726,6 @@ public class GroupUrlLink
   }
 
   /**
-   * called by PopupMenu.buildGroupURLMenu()
-   * 
    * get token types present in this url as a bitfield indicating presence of
    * each token from tokens (LSB->MSB).
    * 
@@ -735,215 +747,6 @@ public class GroupUrlLink
     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()
   {
@@ -971,4 +774,143 @@ public class GroupUrlLink
     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;
+  }
+
 }