GoNoHighLevelTermAnnotationRule extends AbstractAnnotationRule { @Override public Set<AnnotationRuleViolation> getRuleViolations(GeneAnnotation a) { String cls = a.getCls(); if (cls != null) { OWLClass owlClass = go.getOWLClassByIdentifierNoAltIds(cls); if (owlClass != null) { List<String> subsets = go.getSubsets(owlClass); if (subsets != null && !subsets.isEmpty()) { for (String subset : subsets) { if (gocheck_do_not_annotate.equals(subset)) { return createViolation(a, owlClass, subset); } else if (gocheck_do_not_manually_annotate.equals(subset)) { String evidence = a.getShortEvidence(); if (evidence != null && ieaEvidenceCodes.contains(evidence) == false) { return createViolation(a, owlClass, subset); } } } } } } return null; } GoNoHighLevelTermAnnotationRule(OWLGraphWrapper go, 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 GoNoHighLevelTermAnnotationRule(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(2, allViolations.size()); }