import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.io.gff.GffConstants;
-import jalview.util.DBRefUtils;
+ import jalview.util.MessageManager;
import jalview.util.UrlLink;
--import java.util.ArrayList;
+ import java.util.Arrays;
+import java.util.Collection;
+ import java.util.Comparator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
System.err.println(urlLink.getInvalidMessage());
return null;
}
- final String target = urlLink.getTarget(); // link.substring(0,
- // link.indexOf("|"));
- final String label = urlLink.getLabel();
- if (seq != null && urlLink.isDynamic())
- {
- urlSets.addAll(createDynamicLinks(seq, urlLink, uniques));
- }
- else
- {
- String unq = label + "|" + urlLink.getUrl_prefix();
- if (!uniques.contains(unq))
- {
- uniques.add(unq);
- urlSets.add(new String[] { target, label, null,
- urlLink.getUrl_prefix() });
- }
- }
-
- return urlSets.toArray(new String[][] {});
- }
- /**
- * Formats and returns a list of dynamic href links
- *
- * @param seq
- * @param urlLink
- * @param uniques
- */
- List<String[]> createDynamicLinks(SequenceI seq, UrlLink urlLink,
- List<String> uniques)
- {
- List<String[]> result = new ArrayList<String[]>();
- final String target = urlLink.getTarget();
- final String label = urlLink.getLabel();
+ urlLink.createLinksFromSeq(seq, urlSets);
- // collect matching db-refs
- DBRefEntry[] dbr = DBRefUtils.selectRefs(seq.getDBRefs(),
- new String[] { target });
- // collect id string too
- String id = seq.getName();
- String descr = seq.getDescription();
- if (descr != null && descr.length() < 1)
- {
- descr = null;
- }
- if (dbr != null)
- {
- for (int r = 0; r < dbr.length; r++)
- {
- if (id != null && dbr[r].getAccessionId().equals(id))
- {
- // suppress duplicate link creation for the bare sequence ID
- // string with this link
- id = null;
- }
- // create Bare ID link for this URL
- String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(), true);
- if (urls != null)
- {
- for (int u = 0; u < urls.length; u += 2)
- {
- String unq = urls[u] + "|" + urls[u + 1];
- if (!uniques.contains(unq))
- {
- result.add(new String[] { target, label, urls[u], urls[u + 1] });
- uniques.add(unq);
- }
- }
- }
- }
- }
- if (id != null)
- {
- // create Bare ID link for this URL
- String[] urls = urlLink.makeUrls(id, true);
- if (urls != null)
- {
- for (int u = 0; u < urls.length; u += 2)
- {
- String unq = urls[u] + "|" + urls[u + 1];
- if (!uniques.contains(unq))
- {
- result.add(new String[] { target, label, urls[u], urls[u + 1] });
- uniques.add(unq);
- }
- }
- }
- }
- if (descr != null && urlLink.getRegexReplace() != null)
- {
- // create link for this URL from description only if regex matches
- String[] urls = urlLink.makeUrls(descr, true);
- if (urls != null)
- {
- for (int u = 0; u < urls.length; u += 2)
- {
- String unq = urls[u] + "|" + urls[u + 1];
- if (!uniques.contains(unq))
- {
- result.add(new String[] { target, label, urls[u], urls[u + 1] });
- uniques.add(unq);
- }
- }
- }
- }
- return result;
+ return urlSets.values();
}
- public void createSequenceAnnotationReport(final StringBuffer tip,
+ public void createSequenceAnnotationReport(final StringBuilder tip,
SequenceI sequence, boolean showDbRefs, boolean showNpFeats,
Map<String, float[][]> minmax)
{