Changeset 20768


Ignore:
Timestamp:
02/03/10 16:25:19 (2 years ago)
Author:
contrino
Message:

modmine web: now the check about located features works also for experiments. to be cleaned.

Location:
trunk/modmine/webapp/src/org/modmine/web
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/modmine/webapp/src/org/modmine/web/DisplayExperiment.java

    r20462 r20768  
    133133 
    134134    /** 
     135     * @return the submissions Ids 
     136     */ 
     137    public List<String> getSubmissionsDccId() { 
     138        List<String> subDccIds = new ArrayList<String>(); 
     139        for (Submission sub : submissions) { 
     140            subDccIds.add(sub.getdCCid().toString()); 
     141        } 
     142        return subDccIds; 
     143    } 
     144 
     145    /** 
    135146     * @return submissions and a map of feature type to count 
    136147     */ 
  • trunk/modmine/webapp/src/org/modmine/web/FeaturesAction.java

    r20741 r20768  
    1111 */ 
    1212 
     13import java.util.ArrayList; 
     14import java.util.HashSet; 
    1315import java.util.List; 
    1416import java.util.Map; 
     17import java.util.Set; 
    1518 
    1619import javax.servlet.http.HttpServletRequest; 
     
    8992            DisplayExperiment exp = MetadataCache.getExperimentByName(os, experimentName); 
    9093             
    91             q.addView(featureType + ".primaryIdentifier"); 
    92             q.addView(featureType + ".score"); 
    93             q.addView(featureType + ".chromosome.primaryIdentifier"); 
    94             q.addView(featureType + ".chromosomeLocation.start"); 
    95             q.addView(featureType + ".chromosomeLocation.end"); 
    96             q.addView(featureType + ".chromosomeLocation.strand"); 
    97             q.addView(featureType + ".submissions:experimentalFactors.type"); 
    98             q.addView(featureType + ".submissions:experimentalFactors.name"); 
    99             q.addConstraint(featureType + ".submissions.experiment.name",  
    100                     Constraints.eq(experimentName)); 
    101             q.addOrderBy(featureType + ".chromosome.primaryIdentifier");  
    102             q.addOrderBy(featureType + ".chromosomeLocation.start");  
    103         
    104             String ef = getFactors(exp);             
    105             String description = "All " + featureType + " features generated by experiment '" 
    106             + exp.getName() + "' in " + StringUtil.prettyList(exp.getOrganisms())  
    107             + " (" + exp.getPi() + ")." + ef; 
    108             q.setDescription(description); 
     94            List<String> expSubsIds = exp.getSubmissionsDccId(); 
     95            List<String> notLocated = new ArrayList<String>(); 
     96 
     97            LOG.info("HERE THEY ARE: EXP " + expSubsIds + "<-"); 
     98 
     99            for (String subId : expSubsIds){ 
     100                 
     101                Integer id = Integer.valueOf(subId);  
     102                LOG.info("HERE THEY ARE: FOR " + subId + "<->" + id +"|"); 
     103                 
     104                if (MetadataCache.getUnlocatedFeatureTypes(os).containsKey(new Integer(subId))){ 
     105//                if (MetadataCache.getUnlocatedFeatureTypes(os).get(subId) != null) 
     106                    LOG.info("HERE THEY ARE: LIST " + subId + "<-" ); 
     107                 
     108                    notLocated.addAll(MetadataCache.getUnlocatedFeatureTypes(os).get(new Integer(subId))); 
     109                } 
     110            } 
     111             
     112            Set allUnlocated =  
     113                new HashSet(notLocated); 
     114             
     115            LOG.info("HERE THEY ARE: UNL " + allUnlocated.toString()+ "<-"); 
     116             
     117             
     118//            Set<String> subWithNotLocatedFeats = MetadataCache.getUnlocatedFeatureTypes(os).keySet(); 
     119//             
     120//            Set allExpSubs =  
     121//                new HashSet(expSubsIds); 
     122//             
     123//            Set<String> intersection = new HashSet<String>(allExpSubs); 
     124//            intersection.retainAll(subWithNotLocatedFeats); 
     125// 
     126//            if (!intersection.isEmpty()){ 
     127//             Set unLocatedFTypes =   MetadataCache.getUnlocatedFeatureTypes(os).entrySet()  
     128//            } 
     129             
     130 
     131            if (allUnlocated.contains(featureType)){ 
     132                q.addView(featureType + ".primaryIdentifier"); 
     133                q.addView(featureType + ".score"); 
     134                q.addView(featureType + ".submissions:experimentalFactors.type"); 
     135                q.addView(featureType + ".submissions:experimentalFactors.name"); 
     136                q.addConstraint(featureType + ".submissions.experiment.name",  
     137                        Constraints.eq(experimentName)); 
     138            
     139                String ef = getFactors(exp);             
     140                String description = "All " + featureType + " features generated by experiment '" 
     141                + exp.getName() + "' in " + StringUtil.prettyList(exp.getOrganisms())  
     142                + " (" + exp.getPi() + ")." + ef; 
     143                q.setDescription(description); 
     144                 
     145            } else { 
     146                q.addView(featureType + ".primaryIdentifier"); 
     147                q.addView(featureType + ".score"); 
     148                q.addView(featureType + ".chromosome.primaryIdentifier"); 
     149                q.addView(featureType + ".chromosomeLocation.start"); 
     150                q.addView(featureType + ".chromosomeLocation.end"); 
     151                q.addView(featureType + ".chromosomeLocation.strand"); 
     152                q.addView(featureType + ".submissions:experimentalFactors.type"); 
     153                q.addView(featureType + ".submissions:experimentalFactors.name"); 
     154                q.addConstraint(featureType + ".submissions.experiment.name",  
     155                        Constraints.eq(experimentName)); 
     156                q.addOrderBy(featureType + ".chromosome.primaryIdentifier");  
     157                q.addOrderBy(featureType + ".chromosomeLocation.start");  
     158            
     159                String ef = getFactors(exp);             
     160                String description = "All " + featureType + " features generated by experiment '" 
     161                + exp.getName() + "' in " + StringUtil.prettyList(exp.getOrganisms())  
     162                + " (" + exp.getPi() + ")." + ef; 
     163                q.setDescription(description); 
     164                 
     165            } 
     166             
     167             
     168                         
     169//            q.addView(featureType + ".primaryIdentifier"); 
     170//            q.addView(featureType + ".score"); 
     171//            q.addView(featureType + ".chromosome.primaryIdentifier"); 
     172//            q.addView(featureType + ".chromosomeLocation.start"); 
     173//            q.addView(featureType + ".chromosomeLocation.end"); 
     174//            q.addView(featureType + ".chromosomeLocation.strand"); 
     175//            q.addView(featureType + ".submissions:experimentalFactors.type"); 
     176//            q.addView(featureType + ".submissions:experimentalFactors.name"); 
     177//            q.addConstraint(featureType + ".submissions.experiment.name",  
     178//                    Constraints.eq(experimentName)); 
     179//            q.addOrderBy(featureType + ".chromosome.primaryIdentifier");  
     180//            q.addOrderBy(featureType + ".chromosomeLocation.start");  
     181//        
     182//            String ef = getFactors(exp);             
     183//            String description = "All " + featureType + " features generated by experiment '" 
     184//            + exp.getName() + "' in " + StringUtil.prettyList(exp.getOrganisms())  
     185//            + " (" + exp.getPi() + ")." + ef; 
     186//            q.setDescription(description); 
    109187             
    110188        } else if (type.equals("submission")) { 
     
    117195//            String qq = QQ.get(dccNr); 
    118196 
    119             List<String>  locFeatures = MetadataCache.getLocatedFeatureTypes(os).get(dccId); 
    120              
    121              
    122              
    123              
    124 //            LOG.info("HERE THEY ARE: " +QQ + "|" +qq + "<-"); 
     197            List<String>  locFeatures = MetadataCache.getLocatedFeatureTypes(os).get(new Integer(dccId)); 
     198 
     199//          Map <Integer, String> QQ = MetadataCache.getLocatedFeatureTypes(os); 
     200//          String  locFeature = MetadataCache.getLocatedFeatureTypes(os).get(ddccId); 
     201 
     202            //            LOG.info("HERE THEY ARE: " +QQ + "|" +qq + "<-"); 
    125203             
    126204            LOG.info("HERE THEY ARE: " + dccId + "|" +locFeatures + "<-"); 
     
    156234                q.setDescription(description); 
    157235 
    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                  
    181236            } else { 
    182237 
    183                  
    184238                q.addView(featureType + ".primaryIdentifier"); 
    185239                q.addView(featureType + ".score"); 
     
    204258                    + " (" + sub.getProject().getSurnamePI() + ")."; 
    205259                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              
    239260            } 
    240261             
  • trunk/modmine/webapp/src/org/modmine/web/MetadataCache.java

    r20741 r20768  
    1616import java.util.ArrayList; 
    1717import java.util.HashMap; 
     18import java.util.HashSet; 
    1819import java.util.Iterator; 
    1920import java.util.LinkedHashMap; 
    2021import java.util.List; 
    2122import java.util.Map; 
     23import java.util.Set; 
    2224import java.util.TreeMap; 
    2325 
     
    9597    private static Map<Integer, List<String>> submissionFilesCache = null; 
    9698    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; 
     99    private static Map<Integer, List<String>> submissionLocatedFeatureTypes = null; 
     100    private static Map<Integer, List<String>> submissionUnlocatedFeatureTypes = null; 
    100101 
    101102    private static long lastTrackCacheRefresh = 0; 
     
    134135     * @return map 
    135136     */ 
     137    public static synchronized Map<Integer, List<String>> getUnlocatedFeatureTypes(ObjectStore os) { 
     138        if (submissionUnlocatedFeatureTypes == null) { 
     139            LOG.info("BEFORE readUNL "); 
     140             
     141            readUnlocatedFeatureTypes(os); 
     142            LOG.info("AFTER readUNL "); 
     143        } 
     144        return submissionUnlocatedFeatureTypes; 
     145    } 
     146 
     147    /** 
     148     * Fetch input/output file names per submission. 
     149     * @param os the production objectstore 
     150     * @return map 
     151     */ 
    136152    public static synchronized Map<Integer, List<String>> getSubmissionFiles(ObjectStore os) { 
    137153        if (submissionFilesCache == null) { 
     
    162178 
    163179    /** 
    164      * Fetch input/output file names per submission. 
     180     * Fetch which featureType are located for each sub 
     181     * TODO: the opposite (not located feature types) 
    165182     * @param os the production objectstore 
    166183     * @return map 
    167184     */ 
    168 //    public static synchronized Map<Integer, String> getLocatedFeatureTypes(ObjectStore os) { 
    169         public static synchronized Map<String, List<String>> getLocatedFeatureTypes(ObjectStore os) { 
     185    public static synchronized Map<Integer, List<String>> getLocatedFeatureTypes(ObjectStore os) { 
    170186        if (submissionLocatedFeatureTypes == null) { 
     187            LOG.info("BEFORE readSubmissionLocatedFeature "); 
    171188            readSubmissionLocatedFeature(os); 
     189            LOG.info("AFTER readSubmissionLocatedFeature "); 
     190             
    172191        } 
    173192        return submissionLocatedFeatureTypes; 
     
    399418            q.addToOrderBy(qcName); 
    400419 
    401  
    402420            Results results = os.execute(q); 
    403421 
     
    550568    private static void readSubmissionLocatedFeature(ObjectStore os) { 
    551569        long startTime = System.currentTimeMillis(); 
    552          
    553 //        submissionLocatedFeatureTypes = new LinkedHashMap<Integer, String>(); 
    554         submissionLocatedFeatureTypes = new LinkedHashMap<String, List<String>>(); 
     570        submissionLocatedFeatureTypes = new LinkedHashMap<Integer, List<String>>(); 
    555571         
    556572        Query q = new Query(); 
     
    590606            Class feat = (Class) row.get(1); 
    591607  
    592             addToMap(submissionLocatedFeatureTypes,sub.getdCCid().toString(), 
    593             feat.getName().replace("org.intermine.model.bio.", "")); 
     608//            addToMap(submissionLocatedFeatureTypes,sub.getdCCid(), 
     609//            feat.getName().replace("org.intermine.model.bio.", "")); 
     610   
     611            addToMap(submissionLocatedFeatureTypes,sub.getdCCid(), 
     612                    TypeUtil.unqualifiedName(feat.getName())); 
     613             
    594614             
    595615//            submissionLocatedFeatureTypes.put(sub.getdCCid().toString(),  
     
    606626     
    607627    /** 
     628     * Method to obtain the map of unlocated feature types by submission id 
     629     * 
     630     * @param os the objectStore 
     631     * @return submissionUnlocatedFeatureTypes 
     632     */ 
     633    private static Map<Integer, List<String>> readUnlocatedFeatureTypes(ObjectStore os) { 
     634        try { 
     635 
     636            if (submissionUnlocatedFeatureTypes != null) { 
     637                return submissionUnlocatedFeatureTypes; 
     638            } 
     639 
     640            submissionUnlocatedFeatureTypes = new HashMap<Integer, List<String>>(); 
     641 
     642             
     643            if (submissionLocatedFeatureTypes == null) { 
     644                readSubmissionLocatedFeature(os); 
     645            } 
     646 
     647            if (submissionFeatureCounts == null) { 
     648                readSubmissionFeatureCounts(os); 
     649            } 
     650 
     651            LOG.info("INTO readUNL " + submissionFeatureCounts.keySet()); 
     652 
     653             
     654            for (Integer subId : submissionFeatureCounts.keySet()) { 
     655 
     656                Set<String> allFeatures = submissionFeatureCounts.get(subId).keySet(); 
     657                LOG.info("INTO readUNL SFC keys:" + submissionFeatureCounts.keySet()); 
     658                 
     659                 
     660                LOG.info("INTO readUNL difference 1 " + subId); 
     661                Set<String> difference = new HashSet<String>(allFeatures); 
     662                LOG.info("INTO readUNL difference 2 " + difference); 
     663 
     664                LOG.info("INTO readUNL difference ARG " + submissionLocatedFeatureTypes.get(subId)); 
     665                
     666                difference.removeAll(submissionLocatedFeatureTypes.get(subId)); 
     667                 
     668                LOG.info("INTO readUNL difference 3 " + subId); 
     669                LOG.info("INTO readUNL difference-> " + difference); 
     670 
     671                if (!difference.isEmpty()){ 
     672                    List <String> thisUnlocated = new ArrayList<String>(); 
     673 
     674                    for (String fType : difference){ 
     675                        LOG.info("INTO readUNL ftype: " + subId + "|" + fType); 
     676                         
     677                        thisUnlocated.add(fType); 
     678                    } 
     679                    submissionUnlocatedFeatureTypes.put(subId, thisUnlocated); 
     680                } 
     681            } 
     682        } catch (Exception err) { 
     683            err.printStackTrace(); 
     684        } 
     685        return submissionUnlocatedFeatureTypes; 
     686    } 
     687 
     688     
     689    /** 
    608690     * adds an element to a list which is the value of a map 
    609691     * @param m       the map (<String, List<String>>) 
     
    611693     * @param value   the list 
    612694     */ 
    613     private static void addToMap(Map<String, List<String>> m, String key, String value) { 
     695    private static void addToMap(Map<Integer, List<String>> m, Integer key, String value) { 
    614696 
    615697        List<String> ids = new ArrayList<String>(); 
     
    624706    } 
    625707  
    626      
    627      
    628      
    629708    /** 
    630709     * Method to fill the cached map of submissions (ddcId) to list of 
     
    646725                + submissionTracksCache.size()); 
    647726    } 
    648  
    649727 
    650728    /** 
Note: See TracChangeset for help on using the changeset viewer.