Beispiel #1
0
  public static Feature createDefaultFeature(String name, CvTerm featureType, Range range) {

    Feature feature = new DefaultFeature(name, null, featureType);
    if (range != null) {
      feature.getRanges().add(range);
    }
    return feature;
  }
Beispiel #2
0
  public static Feature createDefaultFeature(
      String name, CvTerm featureType, Collection<Range> ranges) {

    Feature feature = new DefaultFeature(name, null, featureType);
    if (ranges != null) {
      feature.getRanges().addAll(ranges);
    }
    return feature;
  }
  /**
   * Use DefaultFeatureBaseComparator to know if two features are equals.
   *
   * @param feature1
   * @param feature2
   * @return true if the two features are equal
   */
  public static boolean areEquals(Feature feature1, Feature feature2) {
    if (feature1 == feature2) {
      return true;
    } else if (feature1 == null || feature2 == null) {
      return false;
    } else {
      // first compare shortnames
      String name1 = feature1.getShortName();
      String name2 = feature2.getShortName();
      if (name1 != null && name2 != null) {
        if (!name1.equalsIgnoreCase(name2)) {
          return false;
        }
      }

      // then compares feature types
      CvTerm type1 = feature1.getType();
      CvTerm type2 = feature2.getType();

      if (!DefaultCvTermComparator.areEquals(type1, type2)) {
        return false;
      }

      // then compares feature role
      CvTerm interactionEffect1 = feature1.getRole();
      CvTerm interactionEffect2 = feature2.getRole();

      if (!DefaultCvTermComparator.areEquals(interactionEffect1, interactionEffect2)) {
        return false;
      }

      // then compares interpro
      String interpro1 = feature1.getInterpro();
      String interpro2 = feature2.getInterpro();

      if (interpro1 != null && interpro2 != null) {
        if (!interpro1.equals(interpro2)) {
          return false;
        }
      }
      // or compare identifiers
      else if (!feature1.getIdentifiers().isEmpty() && !feature2.getIdentifiers().isEmpty()) {
        if (!ComparatorUtils.findAtLeastOneMatchingIdentifier(
            feature1.getIdentifiers(), feature2.getIdentifiers())) {
          return false;
        }
      }

      // then compares the ranges
      Collection<Range> ranges1 = feature1.getRanges();
      Collection<Range> ranges2 = feature2.getRanges();

      return ComparatorUtils.areRangesEqual(ranges1, ranges2);
    }
  }