Exemplo n.º 1
0
 /**
  * If no experiments were specified, inject into statisticsQuery a superset of all experiments for
  * which stats exist across all attributes
  *
  * @param statisticsQuery
  * @param statisticsStorage
  */
 private static void setQueryExperiments(
     StatisticsQueryCondition statisticsQuery, StatisticsStorage statisticsStorage) {
   Set<ExperimentInfo> exps = statisticsQuery.getExperiments();
   if (exps
       .isEmpty()) { // No experiments conditions were specified - assemble a superset of all
                     // experiments for which stats exist across all attributes
     for (EfAttribute attr : statisticsQuery.getAttributes()) {
       Map<ExperimentInfo, ConciseSet> expsToStats =
           getStatisticsForAttribute(statisticsQuery.getStatisticsType(), attr, statisticsStorage);
       if (expsToStats != null) exps.addAll(expsToStats.keySet());
     }
     statisticsQuery.inExperiments(exps);
   }
 }
Exemplo n.º 2
0
  /**
   * @param orAttributes
   * @param statType
   * @param minExperiments minimum experiment count restriction for this clause
   * @param statisticsStorage - used to retrieve orAttributes, needed finding experiment counts in
   *     bit index
   * @return StatisticsQueryOrConditions representing orAttributes
   */
  public static StatisticsQueryOrConditions<StatisticsQueryCondition> getStatisticsOrQuery(
      final List<Attribute> orAttributes,
      final StatisticsType statType,
      int minExperiments,
      final StatisticsStorage statisticsStorage) {

    StatisticsQueryOrConditions<StatisticsQueryCondition> orConditions =
        new StatisticsQueryOrConditions<StatisticsQueryCondition>();

    orConditions.setMinExperiments(minExperiments);

    // LinkedHashMap used to maintain ordering of processing of experiments in multi-Attribute,
    // multi-Experiment bit index queries to
    // retrieve sorted lists of experiments to be plotted on the gene page.
    Map<ExperimentInfo, Set<EfAttribute>> allExpsToAttrs =
        new LinkedHashMap<ExperimentInfo, Set<EfAttribute>>();

    for (Attribute attr : orAttributes) {
      attr.getAttributeToExperimentMappings(statisticsStorage, allExpsToAttrs);
    }

    // Now process allExpsToAttrs - for all efo terms in orAttributes, grouping into one
    // StatisticsQueryCondition
    // attributes from potentially different efoTerms for one experiment. This has the effect of
    // counting a given
    // experiment only once for an OR collection of Attributes.
    for (Map.Entry<ExperimentInfo, Set<EfAttribute>> expToAttr : allExpsToAttrs.entrySet()) {
      StatisticsQueryCondition cond = new StatisticsQueryCondition(statType);
      if (expToAttr.getKey() != EfAttribute.ALL_EXPERIMENTS)
        // For efv Attributes we span all experiments
        cond.inExperiments(Collections.singletonList(expToAttr.getKey()));
      for (EfAttribute attr : expToAttr.getValue()) {
        cond.inAttribute(attr);
      }
      orConditions.orCondition(cond);
    }

    return orConditions;
  }