package hpoweb.data;

import java.util.HashSet;
import java.util.Set;

import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLClass;

import com.vaadin.server.VaadinService;

import de.charite.phenowl.annotations.AnnotationUtils;
import de.charite.phenowl.hpowl.util.ExtendedOwlOntology;
import de.charite.phenowl.hpowl.util.OwlAxiomClass;

public class HpData {

	private ExtendedOwlOntology extOwlOntology;

	private AnnotationUtils annotationUtils;

	public HpData() {
		String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();

		final String xmlFile = basepath + "/WEB-INF/data/hp/catalog-v001.xml";
		String inputOntologyFile = basepath + "/WEB-INF/data/hp/hp-edit.owl";

		Set<OwlAxiomClass> remove = new HashSet<>();
		remove.add(OwlAxiomClass.EQUIVALENCE);
		extOwlOntology = new ExtendedOwlOntology(inputOntologyFile, xmlFile, remove);

		// debug
		OWLClass cls = extOwlOntology.getOWLClassForIRI(IRI.create("http://purl.obolibrary.org/obo/HP_0100533"));
		System.out.println("ancestors of " + cls);
		for (OWLClass c : extOwlOntology.getAncestorsAsserted(cls)) {
			System.out.println(" - " + extOwlOntology.getLabel(c.getIRI()));
		}

		annotationUtils = new AnnotationUtils(extOwlOntology);
		annotationUtils.setDataPath(basepath + "/WEB-INF/data/biodata/");
		annotationUtils.parseAssociation();

	}

	public ExtendedOwlOntology getExtOwlOntology() {
		return extOwlOntology;
	}

	public AnnotationUtils getAnnotationUtils() {
		return annotationUtils;
	}
}

@@ -248,16 +248,73 @@
 nUtils;%0A
+import de.charite.phenowl.annotations.DiseaseGeneMapper;%0A
 import d
@@ -1312,36 +1312,26 @@
 ;%0A%09%09
-annotationUtils.setDataPath(
+String datapath = 
 base
@@ -1361,16 +1361,103 @@
 iodata/%22
+;%0A%09%09DiseaseGeneMapper.setOrphanetPath(datapath);%0A%09%09annotationUtils.setDataPath(datapath
 );%0A%09%09ann

add orphanet-disease-gene data