2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
\r
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.util;
\r
21 import jalview.datamodel.Sequence;
\r
22 import jalview.datamodel.SequenceI;
\r
24 import java.util.Hashtable;
\r
25 import java.util.Vector;
\r
27 public class GroupUrlLink
\r
30 * Helper class based on the UrlLink class which enables URLs to be
\r
31 * constructed from sequences or IDs associated with a group of sequences. URL
\r
32 * definitions consist of a pipe separated string containing a <label>|<url
\r
33 * construct>|<separator character>[|<sequence separator character>]. The url
\r
34 * construct includes regex qualified tokens which are replaced with seuqence
\r
35 * IDs ($SEQUENCE_IDS$) and/or seuqence regions ($SEQUENCES$) that are
\r
36 * extracted from the group. See <code>UrlLink</code> for more information
\r
37 * about the approach, and the original implementation.
\r
38 * Documentation to come. Note - groupUrls can be very big!
\r
40 private String url_prefix, target, label;
\r
43 * these are all filled in order of the occurence of each token in the url
\r
46 private String url_suffix[], separators[], regexReplace[];
\r
48 private String invalidMessage = null;
\r
51 * tokens that can be replaced in the URL.
\r
53 private static String[] tokens;
\r
56 * position of each token (which can appear once only) in the url
\r
61 * contains tokens in the order they appear in the URL template.
\r
63 private String[] mtch;
\r
68 tokens = new String[]
\r
69 { "SEQUENCEIDS", "SEQUENCES", "DATASETID" };
\r
73 // private int idseg = -1, seqseg = -1;
\r
76 * parse the given linkString of the form '<label>|<url>|separator
\r
77 * char[|optional sequence separator char]' into parts. url may contain a
\r
78 * string $SEQUENCEIDS<=optional regex=>$ where <=optional regex=> must be of
\r
79 * the form =/<perl style regex>/=$ or $SEQUENCES<=optional regex=>$ or
\r
80 * $SEQUENCES<=optional regex=>$.
\r
84 public GroupUrlLink(String link)
\r
86 int sep = link.indexOf("|");
\r
87 segs = new int[tokens.length];
\r
89 for (int i = 0; i < segs.length; i++)
\r
91 if ((segs[i] = link.indexOf("$" + tokens[i])) > -1)
\r
96 // expect at least one token
\r
99 invalidMessage = "Group URL string must contain at least one of ";
\r
100 for (int i = 0; i < segs.length; i++)
\r
102 invalidMessage += " '$" + tokens[i] + "[=/regex=/]$'";
\r
107 int[] ptok = new int[ntoks + 1];
\r
108 String[] tmtch = new String[ntoks + 1];
\r
109 mtch = new String[ntoks];
\r
110 for (int i = 0, t = 0; i < segs.length; i++)
\r
115 tmtch[t++] = tokens[i];
\r
118 ptok[ntoks] = link.length();
\r
119 tmtch[ntoks] = "$$$$$$$$$";
\r
120 jalview.util.QuickSort.sort(ptok, tmtch);
\r
121 for (int i = 0; i < ntoks; i++)
\r
123 mtch[i] = tmtch[i]; // TODO: check order is ascending
\r
126 * replaces the specific code below {}; if (psqids > -1 && pseqs > -1) { if
\r
127 * (psqids > pseqs) { idseg = 1; seqseg = 0;
\r
129 * ptok = new int[] { pseqs, psqids, link.length() }; mtch = new String[] {
\r
130 * "$SEQUENCES", "$SEQUENCEIDS" }; } else { idseg = 0; seqseg = 1; ptok =
\r
131 * new int[] { psqids, pseqs, link.length() }; mtch = new String[] {
\r
132 * "$SEQUENCEIDS", "$SEQUENCES" }; } } else { if (psqids != -1) { idseg = 0;
\r
133 * ptok = new int[] { psqids, link.length() }; mtch = new String[] {
\r
134 * "$SEQUENCEIDS" }; } else { seqseg = 0; ptok = new int[] { pseqs,
\r
135 * link.length() }; mtch = new String[] { "$SEQUENCES" }; } }
\r
139 // first get the label and target part before the first |
\r
143 p = link.indexOf("|", sep + 1);
\r
144 } while (p > sep && p < ptok[0]);
\r
145 // Assuming that the URL itself does not contain any '|' symbols
\r
146 // sep now contains last pipe symbol position prior to any regex symbols
\r
147 label = link.substring(0, sep);
\r
148 if (label.indexOf("|") > -1)
\r
150 // | terminated database name / www target at start of Label
\r
151 target = label.substring(0, label.indexOf("|"));
\r
153 else if (label.indexOf(" ") > 2)
\r
155 // space separated Label - matches database name
\r
156 target = label.substring(0, label.indexOf(" "));
\r
162 // Now Parse URL : Whole URL string first
\r
163 url_prefix = link.substring(sep + 1, ptok[0]);
\r
164 url_suffix = new String[mtch.length];
\r
165 regexReplace = new String[mtch.length];
\r
166 // and loop through tokens
\r
167 for (int pass = 0; pass < mtch.length; pass++)
\r
169 int mlength = 3 + mtch[pass].length();
\r
170 if (link.indexOf("$" + mtch[pass] + "=/") == ptok[pass]
\r
171 && (p = link.indexOf("/=$", ptok[pass] + mlength)) > ptok[pass]
\r
174 // Extract Regex and suffix
\r
175 if (ptok[pass + 1] < p + 3)
\r
177 // tokens are not allowed inside other tokens - e.g. inserting a
\r
178 // $sequences$ into the regex match for the sequenceid
\r
179 invalidMessage = "Token regexes cannot contain other regexes (did you terminate the $"
\r
180 + mtch[pass] + " regex with a '/=$' ?";
\r
183 url_suffix[pass] = link.substring(p + 3, ptok[pass + 1]);
\r
184 regexReplace[pass] = link.substring(ptok[pass] + mlength, p);
\r
187 com.stevesoft.pat.Regex rg = com.stevesoft.pat.Regex.perlCode("/"
\r
188 + regexReplace[pass] + "/");
\r
191 invalidMessage = "Invalid Regular Expression : '"
\r
192 + regexReplace[pass] + "'\n";
\r
194 } catch (Exception e)
\r
196 invalidMessage = "Invalid Regular Expression : '"
\r
197 + regexReplace[pass] + "'\n";
\r
202 regexReplace[pass] = null;
\r
203 // verify format is really correct.
\r
204 if ((p = link.indexOf("$" + mtch[pass] + "$")) == ptok[pass])
\r
206 url_suffix[pass] = link.substring(p + mtch[pass].length() + 2,
\r
211 invalidMessage = "Warning: invalid regex structure (after '"
\r
212 + mtch[0] + "') for URL link : " + link;
\r
217 separators = new String[url_suffix.length];
\r
218 String suffices = url_suffix[url_suffix.length - 1], lastsep = ",";
\r
219 // have a look in the last suffix for any more separators.
\r
220 while ((p = suffices.indexOf('|')) > -1)
\r
222 separators[pass] = suffices.substring(p + 1);
\r
225 // trim the original suffix string
\r
226 url_suffix[url_suffix.length - 1] = suffices.substring(0, p);
\r
230 lastsep = (separators[pass - 1] = separators[pass - 1].substring(0,
\r
233 suffices = separators[pass];
\r
238 lastsep = separators[pass - 1];
\r
240 // last separator is always used for all the remaining separators
\r
241 while (pass < separators.length)
\r
243 separators[pass++] = lastsep;
\r
248 * @return the url_suffix
\r
250 public String getUrl_suffix()
\r
252 return url_suffix[url_suffix.length - 1];
\r
256 * @return the url_prefix
\r
258 public String getUrl_prefix()
\r
264 * @return the target
\r
266 public String getTarget()
\r
272 * @return the label
\r
274 public String getLabel()
\r
280 * @return the sequence ID regexReplace
\r
282 public String getIDRegexReplace()
\r
284 return _replaceFor(tokens[0]);
\r
287 private String _replaceFor(String token)
\r
289 for (int i = 0; i < mtch.length; i++)
\r
290 if (segs[i] > -1 && mtch[i].equals(token))
\r
292 return regexReplace[i];
\r
298 * @return the sequence ID regexReplace
\r
300 public String getSeqRegexReplace()
\r
302 return _replaceFor(tokens[1]);
\r
306 * @return the invalidMessage
\r
308 public String getInvalidMessage()
\r
310 return invalidMessage;
\r
314 * Check if URL string was parsed properly.
\r
316 * @return boolean - if false then <code>getInvalidMessage</code> returns an
\r
319 public boolean isValid()
\r
321 return invalidMessage == null;
\r
325 * return one or more URL strings by applying regex to the given idstring
\r
328 * array of id strings to pass to service
\r
329 * @param seqstrings
\r
330 * array of seq strings to pass to service
\r
331 * @param onlyIfMatches
\r
332 * - when true url strings are only made if regex is defined and
\r
333 * matches for all qualified tokens in groupURL - TODO: consider if
\r
334 * onlyIfMatches is really a useful parameter!
\r
335 * @return null or Object[] { int[] { number of seqs substituted},boolean[] {
\r
336 * which seqs were substituted }, StringBuffer[] { substituted lists
\r
337 * for each token }, String[] { url } }
\r
339 public Object[] makeUrls(String[] idstrings, String[] seqstrings,
\r
340 String dsstring, boolean onlyIfMatches)
\r
342 Hashtable rstrings = replacementArgs(idstrings, seqstrings, dsstring);
\r
343 return makeUrls(rstrings, onlyIfMatches);
\r
347 * gathers input into a hashtable
\r
349 * @param seqstrings
\r
353 private Hashtable replacementArgs(String[] idstrings,
\r
354 String[] seqstrings, String dsstring)
\r
356 Hashtable rstrings = new Hashtable();
\r
357 rstrings.put(tokens[0], idstrings);
\r
358 rstrings.put(tokens[1], seqstrings);
\r
359 rstrings.put(tokens[2], new String[]
\r
361 if (idstrings.length != seqstrings.length)
\r
364 "idstrings and seqstrings contain one string each per sequence.");
\r
369 public Object[] makeUrls(Hashtable repstrings, boolean onlyIfMatches)
\r
371 return makeUrlsIf(true,repstrings,onlyIfMatches);
\r
379 * @return URL stub objects ready to pass to constructFrom
\r
381 public Object[] makeUrlStubs(String[] ids, String[] seqstr,
\r
382 String string, boolean b)
\r
384 Hashtable rstrings = replacementArgs(ids, seqstr, string);
\r
385 Object[] stubs = makeUrlsIf(false, rstrings, b);
\r
388 return new Object[] { stubs[0], stubs[1], rstrings, new boolean[] { b } };
\r
390 // TODO Auto-generated method stub
\r
395 * generate the URL for the given URL stub object array returned from makeUrlStubs
\r
397 * @return URL string.
\r
399 public String constructFrom(Object[] stubs)
\r
401 Object[] results = makeUrlsIf(true, (Hashtable) stubs[2], ((boolean[])stubs[3])[0]);
\r
402 return ((String[]) results[3])[0];
\r
405 * conditionally generate urls or stubs for a given input.
\r
406 * @param createFullUrl set to false if you only want to test if URLs would be generated.
\r
407 * @param repstrings
\r
408 * @param onlyIfMatches
\r
409 * @return null if no url is generated. 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 })}
\r
411 protected Object[] makeUrlsIf(boolean createFullUrl, Hashtable repstrings, boolean onlyIfMatches)
\r
415 // prepare string arrays in correct order to be assembled into URL input
\r
416 String[][] idseq = new String[mtch.length][]; // indexed by pass
\r
417 int mins = 0, maxs = 0; // allowed two values, 1 or n-sequences.
\r
418 for (int i = 0; i < mtch.length; i++)
\r
420 idseq[i] = (String[]) repstrings.get(mtch[i]);
\r
421 if (idseq[i].length >= 1)
\r
423 if (mins == 0 && idseq[i].length == 1)
\r
429 maxs = idseq[i].length;
\r
433 if (maxs != idseq[i].length)
\r
436 "Cannot have mixed length replacement vectors. Replacement vector for "
\r
437 + (mtch[i]) + " is " + idseq[i].length
\r
438 + " strings long, and have already seen a "
\r
439 + maxs + " length vector.");
\r
446 "Cannot have zero length vector of replacement strings - either 1 value or n values.");
\r
449 // iterate through input, collating segments to be inserted into url
\r
450 StringBuffer matched[] = new StringBuffer[idseq.length];
\r
451 // and precompile regexes
\r
452 com.stevesoft.pat.Regex[] rgxs = new com.stevesoft.pat.Regex[matched.length];
\r
453 for (pass = 0; pass < matched.length; pass++)
\r
455 matched[pass] = new StringBuffer();
\r
456 if (regexReplace[pass] != null)
\r
458 rgxs[pass] = com.stevesoft.pat.Regex.perlCode("/" + regexReplace[pass]
\r
466 // tot up the invariant lengths for this url
\r
467 int urllength = url_prefix.length();
\r
468 for (pass=0;pass<matched.length; pass++)
\r
470 urllength+=url_suffix[pass].length();
\r
473 // flags to record which of the input sequences were actually used to generate the
\r
475 boolean[] thismatched = new boolean[maxs];
\r
476 int seqsmatched = 0;
\r
477 for (int sq = 0; sq < maxs; sq++)
\r
479 // initialise flag for match
\r
480 thismatched[sq] = false;
\r
481 StringBuffer[] thematches = new StringBuffer[rgxs.length];
\r
482 for (pass = 0; pass < rgxs.length; pass++)
\r
484 thematches[pass] = new StringBuffer(); // initialise - in case there are no more
\r
486 // if a regex is provided, then it must match for all sequences in all
\r
487 // tokens for it to be considered.
\r
488 if (idseq[pass].length <= sq)
\r
490 // no more replacement strings to try for this token
\r
493 if (rgxs[pass] != null)
\r
495 com.stevesoft.pat.Regex rg = rgxs[pass];
\r
497 // concatenate all matches of re in the given string!
\r
498 while (rg.searchFrom(idseq[pass][sq], rematchat))
\r
500 rematchat = rg.matchedTo();
\r
501 thismatched[sq] |= true;
\r
502 urllength+=rg.charsMatched(); // count length
\r
503 if (!createFullUrl)
\r
505 continue; // don't bother making the URL replacement text.
\r
507 // do we take the cartesian products of the substituents ?
\r
508 int ns = rg.numSubs();
\r
511 thematches[pass].append(rg.stringMatched());// take whole regex
\r
514 * else if (ns==1) { // take only subgroup match return new String[]
\r
515 * { rg.stringMatched(1), url_prefix+rg.stringMatched(1)+url_suffix
\r
518 // deal with multiple submatch case - for moment we do the simplest
\r
519 // - concatenate the matched regions, instead of creating a complete
\r
520 // list for each alternate match over all sequences.
\r
521 // TODO: specify a 'replace pattern' - next refinement
\r
525 /*for (int s = 0; s <= rg.numSubs(); s++)
\r
527 System.err.println("Sub " + s + " : " + rg.matchedFrom(s)
\r
528 + " : " + rg.matchedTo(s) + " : '"
\r
529 + rg.stringMatched(s) + "'");
\r
531 // try to collate subgroup matches
\r
532 StringBuffer subs = new StringBuffer();
\r
533 // have to loop through submatches, collating them at top level
\r
538 if (s + 1 <= ns && rg.matchedTo(s) > -1
\r
539 && rg.matchedTo(s + 1) > -1
\r
540 && rg.matchedTo(s + 1) < rg.matchedTo(s))
\r
542 // s is top level submatch. search for submatches enclosed by
\r
545 StringBuffer rmtch = new StringBuffer();
\r
546 while (r <= ns && rg.matchedTo(r) <= rg.matchedTo(s))
\r
548 if (rg.matchedFrom(r) > -1)
\r
550 rmtch.append(rg.stringMatched(r));
\r
554 if (rmtch.length() > 0)
\r
556 subs.append(rmtch); // simply concatenate
\r
562 if (rg.matchedFrom(s) > -1)
\r
564 subs.append(rg.stringMatched(s)); // concatenate
\r
569 thematches[pass].append(subs);
\r
575 // are we only supposed to take regex matches ?
\r
576 if (!onlyIfMatches)
\r
578 thismatched[sq] |= true;
\r
579 urllength+=idseq[pass][sq].length(); // tot up length
\r
582 thematches[pass] = new StringBuffer(idseq[pass][sq]); // take whole string -
\r
583 // regardless - probably not a
\r
586 * TODO: do some boilerplate trimming of the fields to make them
\r
587 * sensible e.g. trim off any 'prefix' in the id string (see UrlLink
\r
588 * for the below) - pre 2.4 Jalview behaviour if
\r
589 * (idstring.indexOf("|") > -1) { idstring =
\r
590 * idstring.substring(idstring.lastIndexOf("|") + 1); }
\r
598 // check if we are going to add this sequence's results ? all token
\r
599 // replacements must be valid for this to happen!
\r
600 // (including single value replacements - eg. dataset name)
\r
601 if (thismatched[sq])
\r
603 if (createFullUrl) {
\r
604 for (pass = 0; pass < matched.length; pass++)
\r
606 if (idseq[pass].length > 1 && matched[pass].length() > 0)
\r
608 matched[pass].append(separators[pass]);
\r
610 matched[pass].append(thematches[pass]);
\r
616 // finally, if any sequences matched, then form the URL and return
\r
617 if (seqsmatched==0 || (createFullUrl && matched[0].length() == 0))
\r
619 // no matches - no url generated
\r
622 // check if we are beyond the feasible command line string limit for this platform
\r
623 if ((urllength+32)>Platform.getMaxCommandLineLength())
\r
625 System.err.println("URL estimated to be too long "+urllength);
\r
628 if (!createFullUrl)
\r
630 // just return the essential info about what the URL would be generated from
\r
631 return new Object[]
\r
633 { seqsmatched }, thismatched};
\r
635 // otherwise, create the URL completely.
\r
637 StringBuffer submiturl = new StringBuffer();
\r
638 submiturl.append(url_prefix);
\r
639 for (pass = 0; pass < matched.length; pass++)
\r
641 submiturl.append(matched[pass]);
\r
642 if (url_suffix[pass] != null)
\r
644 submiturl.append(url_suffix[pass]);
\r
648 return new Object[]
\r
650 { seqsmatched }, thismatched, matched, new String[]
\r
651 { submiturl.toString() } };
\r
657 * @return number of distinct sequence (id or seuqence) replacements predicted for this stub
\r
659 public int getNumberInvolved(Object[] urlstub)
\r
661 return ((int[])urlstub[0])[0]; // returns seqsmatched from makeUrlsIf(false,...)
\r
665 * get token types present in this url as a bitfield indicating presence of each token from tokens (LSB->MSB).
\r
666 * @return groupURL class as integer
\r
668 public int getGroupURLType()
\r
671 for (int pass = 0; pass < tokens.length; pass++)
\r
673 for (int i = 0; i < mtch.length; i++)
\r
675 if (mtch[i].equals(tokens[pass]))
\r
684 public String toString()
\r
686 StringBuffer result = new StringBuffer();
\r
687 result.append(label + "|" + url_prefix);
\r
689 for (r = 0; r < url_suffix.length; r++)
\r
691 result.append("$");
\r
692 result.append(mtch[r]);
\r
693 if (regexReplace[r] != null)
\r
695 result.append("=/");
\r
696 result.append(regexReplace[r]);
\r
697 result.append("/=");
\r
699 result.append("$");
\r
700 result.append(url_suffix[r]);
\r
702 for (r = 0; r < separators.length; r++)
\r
704 result.append("|");
\r
705 result.append(separators[r]);
\r
707 return result.toString();
\r
711 * report stats about the generated url string given an input set
\r
717 private static void testUrls(GroupUrlLink ul, String[][] idstring,
\r
723 System.out.println("Created NO urls.");
\r
727 System.out.println("Created a url from " + ((int[]) url[0])[0]
\r
728 + "out of " + idstring[0].length + " sequences.");
\r
729 System.out.println("Sequences that did not match:");
\r
730 for (int sq = 0; sq < idstring[0].length; sq++)
\r
732 if (!((boolean[]) url[1])[sq])
\r
734 System.out.println("Seq " + sq + ": " + idstring[0][sq] + "\t: "
\r
735 + idstring[1][sq]);
\r
738 System.out.println("Sequences that DID match:");
\r
739 for (int sq = 0; sq < idstring[0].length; sq++)
\r
741 if (((boolean[]) url[1])[sq])
\r
743 System.out.println("Seq " + sq + ": " + idstring[0][sq] + "\t: "
\r
744 + idstring[1][sq]);
\r
747 System.out.println("The generated URL:");
\r
748 System.out.println(((String[]) url[3])[0]);
\r
752 public static void main(String argv[])
\r
754 String[] links = new String[]
\r
756 "EnVision2|IDS|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=linkInDatasetFromJalview&input=$SEQUENCEIDS$&inputType=0|,",
\r
757 "EnVision2|Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=linkInDatasetFromJalview&input=$SEQUENCES$&inputType=1|,",
\r
758 "EnVision2|IDS|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=$DATASETID$&input=$SEQUENCEIDS$&inputType=0|,",
\r
759 "EnVision2|Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=Enfin%20Default%20Workflow&datasetName=$DATASETID$&input=$SEQUENCES$&inputType=1|,",
\r
760 "EnVision2|IDS|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=$SEQUENCEIDS$&datasetName=linkInDatasetFromJalview&input=$SEQUENCEIDS$&inputType=0|,",
\r
761 "EnVision2|Seqs|http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?workflow=$SEQUENCEIDS$&datasetName=$DATASETID$&input=$SEQUENCES$&inputType=1|,",
\r
762 "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|,",
\r
763 "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|,"
\r
765 * http://www.ebi.ac.uk/enfin-srv/envision2/pages/linkin.jsf?input=P38389,P38398
\r
766 * &inputType=0&workflow=Enfin%20Default%20Workflow&datasetName=
\r
767 * linkInDatasetFromPRIDE
\r
771 SequenceI[] seqs = new SequenceI[]
\r
772 { new Sequence("StupidLabel:gi|9234|pdb|102L|A",
\r
773 "asdiasdpasdpadpwpadasdpaspdw"), };
\r
774 String[][] seqsandids = formStrings(seqs);
\r
775 for (int i = 0; i < links.length; i++)
\r
777 GroupUrlLink ul = new GroupUrlLink(links[i]);
\r
780 System.out.println("\n\n\n");
\r
781 System.out.println("Link " + i + " " + links[i] + " : "
\r
783 System.out.println(" pref : " + ul.getUrl_prefix());
\r
784 System.out.println(" IdReplace : " + ul.getIDRegexReplace());
\r
785 System.out.println(" SeqReplace : " + ul.getSeqRegexReplace());
\r
786 System.out.println(" Suffixes : " + ul.getUrl_suffix());
\r
789 .println("<insert input id and sequence strings here> Without onlyIfMatches:");
\r
790 Object[] urls = ul.makeUrls(seqsandids[0], seqsandids[1],
\r
791 "mydataset", false);
\r
792 testUrls(ul, seqsandids, urls);
\r
794 .println("<insert input id and sequence strings here> With onlyIfMatches set:");
\r
795 urls = ul.makeUrls(seqsandids[0], seqsandids[1], "mydataset", true);
\r
796 testUrls(ul, seqsandids, urls);
\r
800 System.err.println("Invalid URLLink : " + links[i] + " : "
\r
801 + ul.getInvalidMessage());
\r
807 * covenience method to generate the id and sequence string vector from a set
\r
808 * of seuqences using each sequence's getName() and getSequenceAsString()
\r
812 * @return String[][] {{sequence ids},{sequence strings}}
\r
814 public static String[][] formStrings(SequenceI[] seqs)
\r
816 String[][] idset = new String[2][seqs.length];
\r
817 for (int i = 0; i < seqs.length; i++)
\r
819 idset[0][i] = seqs[i].getName();
\r
820 idset[1][i] = seqs[i].getSequenceAsString();
\r
825 public void setLabel(String newlabel)
\r
827 this.label = newlabel;
\r