Ejemplo n.º 1
0
  public void testAndOptimizeAllNone() {
    optimizeExact(all_and_all, FilterUtils.all());
    optimizeExact(FilterUtils.and(all_and_all, all_and_all), FilterUtils.all());

    optimizeExact(all_and_none, FilterUtils.none());
    optimizeExact(FilterUtils.and(all_and_none, FilterUtils.all()), FilterUtils.none());

    optimizeExact(none_and_none, FilterUtils.none());
  }
Ejemplo n.º 2
0
  public void testAndOrAllNone() {
    optimizeExact(FilterUtils.or(all_and_all, FilterUtils.all()), FilterUtils.all());
    optimizeExact(FilterUtils.or(all_and_none, FilterUtils.all()), FilterUtils.all());

    optimizeExact(FilterUtils.or(all_and_all, FilterUtils.none()), FilterUtils.all());
    optimizeExact(FilterUtils.or(all_and_none, FilterUtils.none()), FilterUtils.none());

    optimizeExact(FilterUtils.and(all_or_all, FilterUtils.all()), FilterUtils.all());
  }
Ejemplo n.º 3
0
  public void testUseCases() {
    // schemas for our database features
    FeatureFilter transcript = FilterUtils.byType("transcript");
    FeatureFilter exon = FilterUtils.byType("exon");
    FeatureFilter repeat = FilterUtils.byType("repeat");

    AnnotationType.Impl tsType = new AnnotationType.Impl();
    tsType.setConstraints(
        "transcript.id", new PropertyConstraint.ByClass(String.class), CardinalityConstraint.ONE);
    tsType.setDefaultConstraints(PropertyConstraint.NONE, CardinalityConstraint.NONE);
    FeatureFilter tsID = FilterUtils.byAnnotationType(tsType);

    AnnotationType.Impl exType = new AnnotationType.Impl();
    exType.setConstraints(
        "id", new PropertyConstraint.ByClass(String.class), CardinalityConstraint.ONE);
    exType.setDefaultConstraints(PropertyConstraint.NONE, CardinalityConstraint.NONE);
    FeatureFilter exID = FilterUtils.byAnnotationType(exType);

    AnnotationType.Impl rpType = new AnnotationType.Impl();
    rpType.setConstraints("id", PropertyConstraint.ANY, CardinalityConstraint.ONE);
    rpType.setDefaultConstraints(PropertyConstraint.NONE, CardinalityConstraint.NONE);
    FeatureFilter repeatID = FilterUtils.byAnnotationType(rpType);

    FeatureFilter tsSchema = FilterUtils.and(transcript, tsID);
    FeatureFilter exSchema = FilterUtils.and(exon, exID);
    FeatureFilter reSchema = FilterUtils.and(repeat, repeatID);

    FeatureFilter dbFilter = FilterUtils.or(new FeatureFilter[] {tsSchema, exSchema, reSchema});

    // pull out a feature by transcript.id
    FeatureFilter aTranscript = FilterUtils.byAnnotation("transcript.id", "ts:42");

    // let the fun commence
    optimizeEquals(
        FilterUtils.and(tsSchema, aTranscript), FilterUtils.and(transcript, aTranscript));
    optimizeExact(FilterUtils.and(exSchema, aTranscript), FilterUtils.none());
    optimizeExact(FilterUtils.and(reSchema, aTranscript), FilterUtils.none());
    optimizeEquals(dbFilter, dbFilter);
    optimizeEquals(
        FilterUtils.and(dbFilter, aTranscript), FilterUtils.and(transcript, aTranscript));
  }
Ejemplo n.º 4
0
  public void testAndOrMethods() {
    checkEquals(
        FilterUtils.and(FilterUtils.and(tf1, tf2), tf3),
        FilterUtils.and(new FeatureFilter[] {tf1, tf2, tf3}));

    checkEquals(
        FilterUtils.and(tf1, FilterUtils.and(tf2, tf3)),
        FilterUtils.and(new FeatureFilter[] {tf1, tf2, tf3}));

    checkEquals(
        FilterUtils.or(FilterUtils.or(tf1, tf2), tf3),
        FilterUtils.or(new FeatureFilter[] {tf1, tf2, tf3}));

    checkEquals(
        FilterUtils.or(tf1, FilterUtils.or(tf2, tf3)),
        FilterUtils.or(new FeatureFilter[] {tf1, tf2, tf3}));
  }