+ public static Hashtable CanonicalSourceNameLookup=null;
+ /**
+ * look up source in an internal list of database reference sources
+ * and return the canonical jalview name for the source, or the original
+ * string if it has no canonical form.
+ * @param source
+ * @return canonical jalview source (one of jalview.datamodel.DBRefSource.*) or original source
+ */
+ public static String getCanonicalName(String source)
+ {
+ if (CanonicalSourceNameLookup==null) {
+ CanonicalSourceNameLookup = new Hashtable();
+ CanonicalSourceNameLookup.put("uniprotkb/swiss-prot", jalview.datamodel.DBRefSource.UNIPROT);
+ CanonicalSourceNameLookup.put("uniprotkb/trembl", jalview.datamodel.DBRefSource.UNIPROT);
+ CanonicalSourceNameLookup.put("pdb", jalview.datamodel.DBRefSource.PDB);
+ }
+ String canonical = (String) CanonicalSourceNameLookup.get(source.
+ toLowerCase());
+ if (canonical==null)
+ {
+ return source;
+ }
+ return canonical;
+ }
+ /**
+ * find RefEntry corresponding to a particular pattern
+ * the equals method of each entry is used, from String attributes right down to Mapping attributes.
+ * @param ref Set of references to search
+ * @param entry pattern to collect - null any entry for wildcard match
+ * @return
+ */
+ public static DBRefEntry[] searchRefs(DBRefEntry[] ref, DBRefEntry entry)
+ {
+ if (ref==null || entry==null)
+ return null;
+ Vector rfs = new Vector();
+ for (int i=0; i<ref.length;i++)
+ {
+ if (entry.getSource()==null || ref[i].getSource().equals(entry.getSource()))
+ {
+ if (entry.getVersion()==null || ref[i].getVersion().equals(entry.getVersion()))
+ {
+ if (entry.getAccessionId()==null || ref[i].getAccessionId().equals(entry.getAccessionId()))
+ {
+ if (entry.getMap()==null || (ref[i].getMap()!=null && ref[i].getMap().equals(entry.getMap())))
+ {
+ rfs.addElement(ref[i]);
+ }
+ }
+ }
+ }
+ }
+ // TODO Auto-generated method stub
+ if (rfs.size()>0)
+ {
+ DBRefEntry[] rf = new DBRefEntry[rfs.size()];
+ rfs.copyInto(rf);
+ return rf;
+ }
+ return null;
+ }