Changeset 20762
- Timestamp:
- 02/03/10 12:47:01 (2 years ago)
- Location:
- trunk/bio
- Files:
-
- 3 edited
-
tools/main/.classpath (modified) (1 diff)
-
tools/main/src/org/intermine/bio/logic/OrthologueLinkManager.java (modified) (8 diffs)
-
webapp/src/org/intermine/bio/web/OrthologueLinkController.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bio/tools/main/.classpath
r16977 r20762 8 8 <classpathentry combineaccessrules="false" kind="src" path="/intermine-web"/> 9 9 <classpathentry kind="lib" path="/intermine-web/lib/struts.jar"/> 10 <classpathentry combineaccessrules="false" kind="src" path="/intermine-api-main"/> 10 11 <classpathentry kind="output" path="bin"/> 11 12 </classpath> -
trunk/bio/tools/main/src/org/intermine/bio/logic/OrthologueLinkManager.java
r20728 r20762 26 26 import org.apache.commons.lang.StringUtils; 27 27 import org.apache.log4j.Logger; 28 import org.intermine.api.InterMineAPI; 29 import org.intermine.model.bio.DataSet; 30 import org.intermine.model.bio.Gene; 31 import org.intermine.model.bio.Homologue; 32 import org.intermine.model.bio.Organism; 33 import org.intermine.objectstore.query.ConstraintOp; 34 import org.intermine.objectstore.query.ConstraintSet; 35 import org.intermine.objectstore.query.ContainsConstraint; 36 import org.intermine.objectstore.query.Query; 37 import org.intermine.objectstore.query.QueryClass; 38 import org.intermine.objectstore.query.QueryCollectionReference; 39 import org.intermine.objectstore.query.QueryField; 40 import org.intermine.objectstore.query.QueryObjectReference; 41 import org.intermine.objectstore.query.Results; 42 import org.intermine.objectstore.query.ResultsRow; 28 43 import org.intermine.util.PropertiesUtil; 29 44 … … 56 71 private static final String WEB_SERVICE_CONSTRAINT = 57 72 "constraint1=Gene.primaryIdentifier&op1=eq&value1=*"; 73 private static InterMineAPI im = null; 58 74 59 75 /** 60 76 * @param webProperties the web properties 61 77 */ 62 public OrthologueLinkManager( Properties webProperties) {63 78 public OrthologueLinkManager(InterMineAPI im, Properties webProperties) { 79 this.im = im; 64 80 String localMineName = webProperties.getProperty("project.title"); 65 81 … … 74 90 * @return OrthologueLinkManager the link manager 75 91 */ 76 public static synchronized OrthologueLinkManager getInstance(Properties webProperties) { 92 public static synchronized OrthologueLinkManager getInstance(InterMineAPI im, 93 Properties webProperties) { 77 94 if (orthologueLinkManager == null) { 78 orthologueLinkManager = new OrthologueLinkManager( webProperties);95 orthologueLinkManager = new OrthologueLinkManager(im, webProperties); 79 96 } 80 97 primeCache(); … … 87 104 public static synchronized void primeCache() { 88 105 long timeSinceLastRefresh = System.currentTimeMillis() - lastCacheRefresh; 89 // TODO hardcoded for testing. 106 // FIXME hardcoded for testing. 107 // if release version is different, update homologue mappings in cache 90 108 if (timeSinceLastRefresh > ONE_HOUR || DEBUG) { 91 // if release version is different, update homologue mappings in cache109 lastCacheRefresh = System.currentTimeMillis(); 92 110 updateMaps(); 93 lastCacheRefresh = System.currentTimeMillis();94 111 } 95 112 } … … 175 192 // check if local mine has orthologues for genes in this remote mine 176 193 // has to be done last so we know which genes to check for 177 checkLocalOrthologues(mine);194 getLocalOrthologues(mine); 178 195 } 179 196 … … 217 234 localMine.setUrl(url); 218 235 localMine.setLogo(logo); 219 // setOrganisms(localMine); 220 setOrthologues(localMine); 236 setLocalOrthologues(); 221 237 // skip, this is the local intermine. 222 238 continue; … … 265 281 mine.setOrganisms(names); 266 282 return !names.isEmpty(); 283 } 284 285 private static void setLocalOrthologues() { 286 287 Map<String, Map<String, Set[]>> orthologues = null; 288 289 Query q = new Query(); 290 291 QueryClass qcGene = new QueryClass(Gene.class); 292 QueryClass qcOrganism = new QueryClass(Organism.class); 293 QueryClass qcHomologue = new QueryClass(Homologue.class); 294 QueryClass qcHomologueOrganism = new QueryClass(Organism.class); 295 QueryClass qcDataset = new QueryClass(DataSet.class); 296 297 QueryField qfGeneOrganismName = new QueryField(qcOrganism, "shortName"); 298 QueryField qfDataset = new QueryField(qcDataset, "title"); 299 QueryField qfHomologueOrganismName = new QueryField(qcHomologueOrganism, "shortName"); 300 301 q.setDistinct(true); 302 303 q.addToSelect(qfGeneOrganismName); 304 q.addToSelect(qfDataset); 305 q.addToOrderBy(qfHomologueOrganismName); 306 307 q.addFrom(qcGene); 308 q.addFrom(qcHomologue); 309 q.addFrom(qcOrganism); 310 q.addFrom(qcHomologueOrganism); 311 q.addFrom(qcDataset); 312 313 ConstraintSet cs = new ConstraintSet(ConstraintOp.AND); 314 315 // gene.organism.name 316 QueryObjectReference c1 = new QueryObjectReference(qcGene, "organism"); 317 cs.addConstraint(new ContainsConstraint(c1, ConstraintOp.CONTAINS, qcOrganism)); 318 319 // gene.homologues.homologue 320 QueryCollectionReference c2 = new QueryCollectionReference(qcGene, "homologues"); 321 cs.addConstraint(new ContainsConstraint(c2, ConstraintOp.CONTAINS, qcHomologue)); 322 323 // gene.homologues.homologue.datasets.title 324 QueryCollectionReference c3 = new QueryCollectionReference(qcHomologue, "dataSets"); 325 cs.addConstraint(new ContainsConstraint(c3, ConstraintOp.CONTAINS, qcDataset)); 326 327 // gene.homologues.homologue.organism.shortName 328 QueryObjectReference c4 = new QueryObjectReference(qcHomologue, "organism"); 329 cs.addConstraint(new ContainsConstraint(c4, ConstraintOp.CONTAINS, 330 qcHomologueOrganism)); 331 332 q.setConstraint(cs); 333 334 Results results = im.getObjectStore().execute(q); 335 Iterator it = results.iterator(); 336 while (it.hasNext()) { 337 338 ResultsRow row = (ResultsRow) it.next(); 339 340 String geneOrganismName = (String) row.get(0); 341 String dataset = (String) row.get(1); 342 String homologueOrganismName = (String) row.get(1); 343 344 /** 345 * gene --> homologue --> datasets 346 * 347 * D. rerio | H. sapiens | treefam 348 * | | inparanoid 349 * | C. elegans | treefam 350 */ 351 352 // gene --> homologue|dataset 353 Map<String, Set[]> homologueMapping = orthologues.get(geneOrganismName); 354 if (homologueMapping == null) { 355 homologueMapping = new HashMap(); 356 orthologues.put(geneOrganismName, homologueMapping); 357 } 358 359 // homologue --> datasets 360 Set[] datasets = homologueMapping.get(homologueOrganismName); 361 if (datasets == null) { 362 datasets = new HashSet[2]; 363 datasets[1] = new HashSet(); 364 homologueMapping.put(homologueOrganismName, datasets); 365 } 366 datasets[1].add(dataset); 367 } 368 localMine.setOrthologues(orthologues); 267 369 } 268 370 … … 415 517 * NB this assumes the remote mine has its orthologues populated already 416 518 */ 417 private static void checkLocalOrthologues(Mine mine) {519 private static void getLocalOrthologues(Mine mine) { 418 520 419 521 // list of organisms for which this mine has genes. -
trunk/bio/webapp/src/org/intermine/bio/web/OrthologueLinkController.java
r20698 r20762 61 61 62 62 OrthologueLinkManager orthologueLinkManager 63 = OrthologueLinkManager.getInstance( webProperties);63 = OrthologueLinkManager.getInstance(im, webProperties); 64 64 Collection<String> organismNamesInBag = BioUtil.getOrganisms(im.getObjectStore(), bag, 65 65 false, "shortName");
Note: See TracChangeset
for help on using the changeset viewer.
