package owltools.gaf.rules.go;

import java.util.Collections;
import java.util.List;
import java.util.Set;

import org.semanticweb.owlapi.model.OWLClass;

import owltools.gaf.GeneAnnotation;
import owltools.gaf.rules.AbstractAnnotationRule;
import owltools.gaf.rules.AnnotationRuleViolation;
import owltools.graph.OWLGraphWrapper;

/**
 * GO_AR:0000008
 */
public class GoNoHighLevelTermAnnotationRule extends AbstractAnnotationRule {
	
	/**
	 * The string to identify this class in the annotation_qc.xml and related factories.
	 * This is not supposed to be changed. 
	 */
	public static final String PERMANENT_JAVA_ID = "org.geneontology.rules.GO_AR_0000008";
	
	private final String high_level_subset = "high_level_annotation_qc";
	private final OWLGraphWrapper go;

	/**
	 * @param go
	 */
	public GoNoHighLevelTermAnnotationRule(OWLGraphWrapper go) {
		super();
		this.go = go;
	}

	@Override
	public Set<AnnotationRuleViolation> getRuleViolations(GeneAnnotation a) {
		String cls = a.getCls();
		if (cls != null) {
			OWLClass owlClass = go.getOWLClassByIdentifier(cls);
			if (owlClass != null) {
				List<String> subsets = go.getSubsets(owlClass);
				if (subsets != null && !subsets.isEmpty()) {
					for (String subset : subsets) {
						if (high_level_subset.equals(subset)) {
							String message = "Do not annotate to: "+cls+" The term is considered to high level, as marked via the subset tag: "+high_level_subset;
							return Collections.singleton(new AnnotationRuleViolation(getRuleId(), message , a));
						}
					}
				}
			}
		}
		return null;
	}

}

@@ -281,24 +281,89 @@
 eViolation;%0A
+import owltools.gaf.rules.AnnotationRuleViolation.ViolationType;%0A
 import owlto
@@ -722,16 +722,85 @@
 008%22;%0A%09%0A
+%09private static final ViolationType level = ViolationType.Warning;%0A%09%0A
 %09private
@@ -1645,16 +1645,23 @@
 sage , a
+, level
 ));%0A%09%09%09%09

set level to warning for too high level annotations