GoIEPRestrictionsRule extends AbstractAnnotationRule { @Override public Set<AnnotationRuleViolation> getRuleViolations(GeneAnnotation a) { String evidence = a.getShortEvidence(); if (evidence != null && evidences.contains(evidence)) { String cls = a.getCls(); if (cls != null) { if (!classSubSet.contains(cls)) { AnnotationRuleViolation violation = new AnnotationRuleViolation(getRuleId(), message, a, violationType); return Collections.singleton(violation); } } } return null; } GoIEPRestrictionsRule(OWLGraphWrapper graph, TraversingEcoMapper eco); @Override Set<AnnotationRuleViolation> getRuleViolations(GeneAnnotation a); static final String PERMANENT_JAVA_ID; }
@Test public void test() throws Exception { GafDocument gafdoc = loadGaf("test_gene_association_mgi.gaf"); AnnotationRule rule = new GoIEPRestrictionsRule(graph, eco); List<GeneAnnotation> annotations = gafdoc.getGeneAnnotations(); List<AnnotationRuleViolation> allViolations = new ArrayList<AnnotationRuleViolation>(); for (GeneAnnotation annotation : annotations) { Set<AnnotationRuleViolation> violations = rule.getRuleViolations(annotation); if (violations != null && !violations.isEmpty()) { allViolations.addAll(violations); } } assertEquals(0, allViolations.size()); }