+ /**
+ * 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