- Timestamp:
- 05/09/11 12:09:58 (13 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 modified
-
org.bridgedb.bio/resources/org/bridgedb/bio/datasources.xml (modified) (1 diff)
-
org.bridgedb.rdb/src/org/bridgedb/rdb/GdbProvider.java (modified) (3 diffs)
-
org.bridgedb.rdb/src/org/bridgedb/rdb/impl (added)
-
org.bridgedb.rdb/src/org/bridgedb/rdb/impl/ConfigFile.java (added)
-
org.bridgedb/src/org/bridgedb/impl/InternalUtils.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/org.bridgedb.bio/resources/org/bridgedb/bio/datasources.xml
r509 r513 1 <datasources> 2 <datasource fullname="Ensembl"> 3 <alias name="ensembl_gene_id"/> 4 </datasource> 5 <datasource fullname="Entrez Gene"> 6 <alias name="entrezgene"/> 7 </datasource> 8 <datasource fullname="Affy"> 9 <alias name="affy_hg_u133a_2"/> 10 </datasource> 11 </datasources> 1 <?xml version="1.0"?> 2 <bridgedb> 3 <datasources> 4 <datasource fullname="Ensembl"> 5 <alias name="ensembl_gene_id"/> 6 </datasource> 7 <datasource fullname="Entrez Gene"> 8 <alias name="entrezgene"/> 9 </datasource> 10 <datasource fullname="Affy"> 11 <alias name="affy_hg_u133a_2"/> 12 </datasource> 13 </datasources> 14 <properties> 15 <property key="org.bridgedb.webservice.synergizer.DefaultUrl" value="http://...."/> 16 </properties> 17 </bridgedb> -
trunk/org.bridgedb.rdb/src/org/bridgedb/rdb/GdbProvider.java
r506 r513 32 32 import org.bridgedb.IDMapperStack; 33 33 import org.bridgedb.bio.Organism; 34 import org.bridgedb.rdb.impl.ConfigFile; 34 35 35 36 /** … … 107 108 } 108 109 109 public static GdbProvider fromConfigFile(File f, boolean transitive) throws IDMapperException, IOException, ClassNotFoundException { 110 System.out.println("Parsing gene database configuration: " + f.getAbsolutePath()); 110 public static GdbProvider fromConfigFile(File f, boolean transitive) throws IDMapperException, IOException, ClassNotFoundException 111 { 112 ConfigFile cf = new ConfigFile(f); 111 113 GdbProvider gdbs = new GdbProvider(transitive); 112 BufferedReader in = new BufferedReader(new FileReader(f)); 113 String line = in.readLine(); 114 Class.forName ("org.bridgedb.rdb.IDMapperRdb"); 115 Class.forName("org.bridgedb.file.IDMapperText"); 116 try 114 List<String> drivers = cf.getDrivers(); 115 116 // add a few defaults that will always be loaded 117 drivers.add("org.bridgedb.rdb.IDMapperRdb"); 118 drivers.add("org.bridgedb.file.IDMapperText"); 119 drivers.add("com.mysql.jdbc.Driver"); 120 121 for (String driver : drivers) 117 122 { 118 Class.forName ("com.mysql.jdbc.Driver"); 123 try 124 { 125 Class.forName (driver); 126 System.out.println ("Loaded driver: " + driver); 127 } 128 catch (ClassNotFoundException ex) 129 { 130 System.out.println ("Warning: driver '" + driver + "' not in classpath, some features may not be available."); 131 } 119 132 } 120 catch (ClassNotFoundException ex) 133 134 for (String key : cf.getMappers().keySet()) 121 135 { 122 System.out.println ("MySQL driver not in classpath, mysql backend unavailable"); 123 } 124 while(line != null) { 125 String[] kv = line.split("\t"); 126 if(kv.length == 2) { 127 String key = kv[0]; 128 String value = kv[1]; 129 130 if (!value.startsWith("idmapper")) value = "idmapper-pgdb:" + value; 136 for (String value : cf.getMappers().get(key)) 137 { 131 138 IDMapper mapper = BridgeDb.connect (value); 132 139 Organism org = Organism.fromLatinName(key); … … 138 145 System.out.println("Unable to parse organism: " + key); 139 146 } 140 } else {141 System.out.println("Invalid key/value pair in gene database configuration: " + line);142 147 } 143 line = in.readLine();144 148 } 145 in.close(); 149 146 150 return gdbs; 147 151 } -
trunk/org.bridgedb/src/org/bridgedb/impl/InternalUtils.java
r509 r513 21 21 import java.net.URL; 22 22 import java.net.URLConnection; 23 import java.util.ArrayList; 23 24 import java.util.Arrays; 24 25 import java.util.Collection; … … 26 27 import java.util.HashMap; 27 28 import java.util.HashSet; 29 import java.util.List; 28 30 import java.util.Map; 29 31 import java.util.Set; … … 229 231 * will not be discared. 230 232 * <p> 233 * This is like multiMapPut, but uses a list instead of a set for each value of the map. 234 * @param <T> key type of multimap 235 * @param <U> value type of multimap 236 * @param map multimap to work on 237 * @param key key of the value to insert 238 * @param val value to insert. 239 */ 240 public static <T, U> void multiMapAdd(Map<T, List<U>> map, T key, U val) 241 { 242 List<U> list; 243 if (map.containsKey (key)) 244 { 245 list = map.get(key); 246 } 247 else 248 { 249 list = new ArrayList<U>(); 250 map.put(key, list); 251 } 252 list.add (val); 253 } 254 255 /** 256 * Generic method for multimaps, a map that can contain multiple values per key. 257 * Unlike a regular map, if you insert a value for a key that already exists, the previous value 258 * will not be discared. 259 * <p> 231 260 * multiMapPutAll let's you insert a collection of items at once. 232 261 * @param <T> key type of multimap
