Changeset 20741
- Timestamp:
- 26/02/10 16:54:15 (2 years ago)
- Location:
- trunk/modmine/webapp/src/org/modmine/web
- Files:
-
- 2 edited
-
FeaturesAction.java (modified) (3 diffs)
-
MetadataCache.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modmine/webapp/src/org/modmine/web/FeaturesAction.java
r20522 r20741 11 11 */ 12 12 13 import java.util.List; 14 import java.util.Map; 15 13 16 import javax.servlet.http.HttpServletRequest; 14 17 import javax.servlet.http.HttpServletResponse; 15 18 import javax.servlet.http.HttpSession; 16 19 20 import org.apache.log4j.Logger; 17 21 import org.apache.struts.action.ActionForm; 18 22 import org.apache.struts.action.ActionForward; … … 57 61 * an exception 58 62 */ 63 64 65 66 private static final Logger LOG = Logger.getLogger(MetadataCache.class); 67 68 59 69 public ActionForward execute(ActionMapping mapping, 60 70 ActionForm form, … … 102 112 Submission sub = MetadataCache.getSubmissionByDccId(os, new Integer(dccId)); 103 113 104 q.addView(featureType + ".primaryIdentifier"); 105 q.addView(featureType + ".score"); 106 q.addView(featureType + ".chromosome.primaryIdentifier"); 107 q.addView(featureType + ".chromosomeLocation.start"); 108 q.addView(featureType + ".chromosomeLocation.end"); 109 q.addView(featureType + ".chromosomeLocation.strand"); 110 q.addView(featureType + ".submissions:experimentalFactors.type"); 111 q.addView(featureType + ".submissions:experimentalFactors.name"); 112 q.addConstraint(featureType + ".submissions.DCCid", Constraints.eq(new Integer(dccId))); 113 q.addOrderBy(featureType + ".chromosome.primaryIdentifier"); 114 q.addOrderBy(featureType + ".chromosomeLocation.start"); 115 116 String experimentType = ""; 117 if (sub.getExperimentType() != null) { 118 experimentType = StringUtil.indefiniteArticle(sub.getExperimentType()) 119 + " " + sub.getExperimentType() + " experiment in"; 114 // Map <Integer, String> QQ = MetadataCache.getLocatedFeatureTypes(os); 115 // String locFeature = MetadataCache.getLocatedFeatureTypes(os).get(dccId); 116 // int dccNr = new Integer(dccId).intValue(); 117 // String qq = QQ.get(dccNr); 118 119 List<String> locFeatures = MetadataCache.getLocatedFeatureTypes(os).get(dccId); 120 121 122 123 124 // LOG.info("HERE THEY ARE: " +QQ + "|" +qq + "<-"); 125 126 LOG.info("HERE THEY ARE: " + dccId + "|" +locFeatures + "<-"); 127 128 if (locFeatures.contains(featureType)){ 129 q.addView(featureType + ".primaryIdentifier"); 130 q.addView(featureType + ".score"); 131 q.addView(featureType + ".chromosome.primaryIdentifier"); 132 q.addView(featureType + ".chromosomeLocation.start"); 133 q.addView(featureType + ".chromosomeLocation.end"); 134 q.addView(featureType + ".chromosomeLocation.strand"); 135 q.addView(featureType + ".submissions:experimentalFactors.type"); 136 q.addView(featureType + ".submissions:experimentalFactors.name"); 137 q.addConstraint(featureType + ".submissions.DCCid", Constraints.eq(new Integer(dccId))); 138 q.addOrderBy(featureType + ".chromosome.primaryIdentifier"); 139 q.addOrderBy(featureType + ".chromosomeLocation.start"); 140 141 String experimentType = ""; 142 if (sub.getExperimentType() != null) { 143 experimentType = StringUtil.indefiniteArticle(sub.getExperimentType()) 144 + " " + sub.getExperimentType() + " experiment in"; 145 } 146 147 String efSub = ""; 148 if (SubmissionHelper.getExperimentalFactorString(sub).length() > 1){ 149 efSub = " using " + SubmissionHelper.getExperimentalFactorString(sub); 150 } 151 152 String description = "All " + featureType + " features generated by submission " + dccId 153 + ", " + experimentType + " " 154 + sub.getOrganism().getShortName() + efSub 155 + " (" + sub.getProject().getSurnamePI() + ")."; 156 q.setDescription(description); 157 158 // q.addView(featureType + ".primaryIdentifier"); 159 // q.addView(featureType + ".score"); 160 // q.addView(featureType + ".submissions:experimentalFactors.type"); 161 // q.addView(featureType + ".submissions:experimentalFactors.name"); 162 // q.addConstraint(featureType + ".submissions.DCCid", Constraints.eq(new Integer(dccId))); 163 // 164 // String experimentType = ""; 165 // if (sub.getExperimentType() != null) { 166 // experimentType = StringUtil.indefiniteArticle(sub.getExperimentType()) 167 // + " " + sub.getExperimentType() + " experiment in"; 168 // } 169 // 170 // String efSub = ""; 171 // if (SubmissionHelper.getExperimentalFactorString(sub).length() > 1){ 172 // efSub = " using " + SubmissionHelper.getExperimentalFactorString(sub); 173 // } 174 // 175 // String description = "All " + featureType + " features generated by submission " + dccId 176 // + ", " + experimentType + " " 177 // + sub.getOrganism().getShortName() + efSub 178 // + " (" + sub.getProject().getSurnamePI() + ")."; 179 // q.setDescription(description); 180 181 } else { 182 183 184 q.addView(featureType + ".primaryIdentifier"); 185 q.addView(featureType + ".score"); 186 q.addView(featureType + ".submissions:experimentalFactors.type"); 187 q.addView(featureType + ".submissions:experimentalFactors.name"); 188 q.addConstraint(featureType + ".submissions.DCCid", Constraints.eq(new Integer(dccId))); 189 190 String experimentType = ""; 191 if (sub.getExperimentType() != null) { 192 experimentType = StringUtil.indefiniteArticle(sub.getExperimentType()) 193 + " " + sub.getExperimentType() + " experiment in"; 194 } 195 196 String efSub = ""; 197 if (SubmissionHelper.getExperimentalFactorString(sub).length() > 1){ 198 efSub = " using " + SubmissionHelper.getExperimentalFactorString(sub); 199 } 200 201 String description = "All " + featureType + " features generated by submission " + dccId 202 + ", " + experimentType + " " 203 + sub.getOrganism().getShortName() + efSub 204 + " (" + sub.getProject().getSurnamePI() + ")."; 205 q.setDescription(description); 206 207 // 208 // 209 // 210 // q.addView(featureType + ".primaryIdentifier"); 211 // q.addView(featureType + ".score"); 212 // q.addView(featureType + ".chromosome.primaryIdentifier"); 213 // q.addView(featureType + ".chromosomeLocation.start"); 214 // q.addView(featureType + ".chromosomeLocation.end"); 215 // q.addView(featureType + ".chromosomeLocation.strand"); 216 // q.addView(featureType + ".submissions:experimentalFactors.type"); 217 // q.addView(featureType + ".submissions:experimentalFactors.name"); 218 // q.addConstraint(featureType + ".submissions.DCCid", Constraints.eq(new Integer(dccId))); 219 // q.addOrderBy(featureType + ".chromosome.primaryIdentifier"); 220 // q.addOrderBy(featureType + ".chromosomeLocation.start"); 221 // 222 // String experimentType = ""; 223 // if (sub.getExperimentType() != null) { 224 // experimentType = StringUtil.indefiniteArticle(sub.getExperimentType()) 225 // + " " + sub.getExperimentType() + " experiment in"; 226 // } 227 // 228 // String efSub = ""; 229 // if (SubmissionHelper.getExperimentalFactorString(sub).length() > 1){ 230 // efSub = " using " + SubmissionHelper.getExperimentalFactorString(sub); 231 // } 232 // 233 // String description = "All " + featureType + " features generated by submission " + dccId 234 // + ", " + experimentType + " " 235 // + sub.getOrganism().getShortName() + efSub 236 // + " (" + sub.getProject().getSurnamePI() + ")."; 237 // q.setDescription(description); 238 120 239 } 121 240 122 String efSub = ""; 123 if (SubmissionHelper.getExperimentalFactorString(sub).length() > 1){ 124 efSub = " using " + SubmissionHelper.getExperimentalFactorString(sub); 125 } 126 127 String description = "All " + featureType + " features generated by submission " + dccId 128 + ", " + experimentType + " " 129 + sub.getOrganism().getShortName() + efSub 130 + " (" + sub.getProject().getSurnamePI() + ")."; 131 q.setDescription(description); 241 132 242 } 133 243 -
trunk/modmine/webapp/src/org/modmine/web/MetadataCache.java
r20649 r20741 25 25 import org.intermine.model.bio.Experiment; 26 26 import org.intermine.model.bio.LocatedSequenceFeature; 27 import org.intermine.model.bio.Location; 27 28 import org.intermine.model.bio.Project; 28 29 import org.intermine.model.bio.Submission; … … 94 95 private static Map<Integer, List<String>> submissionFilesCache = null; 95 96 private static Map<Integer, Integer> filesPerSubmissionCache = null; 97 98 // private static Map<Integer, String> submissionLocatedFeatureTypes = null; 99 private static Map<String, List<String>> submissionLocatedFeatureTypes = null; 100 96 101 private static long lastTrackCacheRefresh = 0; 97 102 private static final long ONE_HOUR = 3600000; … … 154 159 } 155 160 return filesPerSubmissionCache; 161 } 162 163 /** 164 * Fetch input/output file names per submission. 165 * @param os the production objectstore 166 * @return map 167 */ 168 // public static synchronized Map<Integer, String> getLocatedFeatureTypes(ObjectStore os) { 169 public static synchronized Map<String, List<String>> getLocatedFeatureTypes(ObjectStore os) { 170 if (submissionLocatedFeatureTypes == null) { 171 readSubmissionLocatedFeature(os); 172 } 173 return submissionLocatedFeatureTypes; 156 174 } 157 175 … … 529 547 530 548 549 550 private static void readSubmissionLocatedFeature(ObjectStore os) { 551 long startTime = System.currentTimeMillis(); 552 553 // submissionLocatedFeatureTypes = new LinkedHashMap<Integer, String>(); 554 submissionLocatedFeatureTypes = new LinkedHashMap<String, List<String>>(); 555 556 Query q = new Query(); 557 q.setDistinct(true); 558 559 QueryClass qcSub = new QueryClass(Submission.class); 560 QueryClass qcLsf = new QueryClass(LocatedSequenceFeature.class); 561 QueryClass qcLoc = new QueryClass(Location.class); 562 563 QueryField qfClass = new QueryField(qcLsf, "class"); 564 565 q.addFrom(qcSub); 566 q.addFrom(qcLsf); 567 q.addFrom(qcLoc); 568 569 q.addToSelect(qcSub); 570 q.addToSelect(qfClass); 571 572 ConstraintSet cs = new ConstraintSet(ConstraintOp.AND); 573 574 QueryCollectionReference features = new QueryCollectionReference(qcSub, "features"); 575 ContainsConstraint ccFeats = new ContainsConstraint(features, ConstraintOp.CONTAINS, qcLsf); 576 cs.addConstraint(ccFeats); 577 578 QueryObjectReference location = new QueryObjectReference(qcLsf, "chromosomeLocation"); 579 ContainsConstraint ccLocs = new ContainsConstraint(location, ConstraintOp.CONTAINS, qcLoc); 580 cs.addConstraint(ccLocs); 581 582 q.setConstraint(cs); 583 584 Results results = os.execute(q); 585 586 // for each classes set the values for jsp 587 for (Iterator<ResultsRow> iter = results.iterator(); iter.hasNext(); ) { 588 ResultsRow row = iter.next(); 589 Submission sub = (Submission) row.get(0); 590 Class feat = (Class) row.get(1); 591 592 addToMap(submissionLocatedFeatureTypes,sub.getdCCid().toString(), 593 feat.getName().replace("org.intermine.model.bio.", "")); 594 595 // submissionLocatedFeatureTypes.put(sub.getdCCid().toString(), 596 // feat.getName().replace("org.intermine.model.bio.", "")); 597 } 598 long timeTaken = System.currentTimeMillis() - startTime; 599 LOG.info("Primed located features cache, took: " + timeTaken + "ms"); 600 601 LOG.info("HERE THEY ARE: " + submissionLocatedFeatureTypes); 602 603 } 604 605 606 607 /** 608 * adds an element to a list which is the value of a map 609 * @param m the map (<String, List<String>>) 610 * @param key the key for the map 611 * @param value the list 612 */ 613 private static void addToMap(Map<String, List<String>> m, String key, String value) { 614 615 List<String> ids = new ArrayList<String>(); 616 617 if (m.containsKey(key)) { 618 ids = m.get(key); 619 } 620 if (!ids.contains(value)) { 621 ids.add(value); 622 m.put(key, ids); 623 } 624 } 625 626 627 628 531 629 /** 532 630 * Method to fill the cached map of submissions (ddcId) to list of
Note: See TracChangeset
for help on using the changeset viewer.
