5 import jalview.datamodel.*;
8 public class DBRefUtils
11 * Utilities for handling DBRef objects and their collections.
15 * @param dbrefs Vector of DBRef objects to search
16 * @param sources String[] array of source DBRef IDs to retrieve
19 public static DBRefEntry [] selectRefs(DBRefEntry [] dbrefs, String[] sources) {
24 Hashtable srcs = new Hashtable();
25 Vector res=new Vector();
27 for (int i=0; i<sources.length; i++)
28 srcs.put(new String(sources[i]), new Integer(i));
29 for (int i = 0, j = dbrefs.length; i < j; i++)
31 if (srcs.containsKey(dbrefs[i].getSource()))
37 DBRefEntry [] reply = new DBRefEntry[res.size()];
38 for(int i=0; i<res.size(); i++)
39 reply[i] = (DBRefEntry)res.elementAt(i);
43 // there are probable memory leaks in the hashtable!
48 * isDasCoordinateSystem
50 * @param string String
51 * @param dBRefEntry DBRefEntry
52 * @return boolean true if Source DBRefEntry is compatible with DAS CoordinateSystem name
54 public static Hashtable DasCoordinateSystemsLookup = null;
55 public static boolean isDasCoordinateSystem(String string,
56 DBRefEntry dBRefEntry)
58 if (DasCoordinateSystemsLookup==null)
60 DasCoordinateSystemsLookup = new Hashtable();
61 DasCoordinateSystemsLookup.put("pdbresnum",
62 jalview.datamodel.DBRefSource.PDB);
63 DasCoordinateSystemsLookup.put("uniprot",
64 jalview.datamodel.DBRefSource.UNIPROT);
67 String coordsys = (String) DasCoordinateSystemsLookup.get(string.toLowerCase());
69 return coordsys.equals(dBRefEntry.getSource());