package owltools.gaf.lego;

import static org.junit.Assert.*;

import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Map;
import java.util.Set;

import org.apache.commons.io.FileUtils;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.Test;
import org.semanticweb.elk.owlapi.ElkReasonerFactory;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLNamedIndividual;
import org.semanticweb.owlapi.model.OWLObject;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyStorageException;

import owltools.OWLToolsTestBasics;
import owltools.gaf.GafDocument;
import owltools.gaf.GafObjectsBuilder;
import owltools.graph.OWLGraphWrapper;
import owltools.io.ParserWrapper;
import owltools.util.MinimalModelGeneratorTest;
import owltools.vocab.OBOUpperVocabulary;

public class MolecularModelManagerGeneratorTest extends AbstractLegoModelGeneratorTest {
	private static Logger LOG = Logger.getLogger(MolecularModelManagerGeneratorTest.class);

	MolecularModelManager mmm;

	static{
		Logger.getLogger("org.semanticweb.elk").setLevel(Level.ERROR);
		//Logger.getLogger("org.semanticweb.elk.reasoner.indexing.hierarchy").setLevel(Level.ERROR);
	}

	@Test
	public void testM3() throws Exception {
		ParserWrapper pw = new ParserWrapper();
		//w = new FileWriter(new File("target/lego.out"));

		g = pw.parseToOWLGraph(getResourceIRIString("go-mgi-signaling-test.obo"));
		g.mergeOntology(pw.parseOBO(getResourceIRIString("disease.obo")));
		//g.m

		mmm = new MolecularModelManager(g);
		File gafPath = getResource("mgi-signaling.gaf");
		mmm.loadGaf("mgi", gafPath);

		OWLClass p = g.getOWLClassByIdentifier("GO:0014029"); // neural crest formation
		String modelId = mmm.generateModel(p, "mgi");
		LOG.info("Model: "+modelId);
		LegoModelGenerator model = mmm.getModel(modelId);

		Set<OWLNamedIndividual> inds = mmm.getIndividuals(modelId);
		LOG.info("Individuals: "+inds.size());
		for (OWLNamedIndividual i : inds) {
			LOG.info("I="+i);
		}
		assertTrue(inds.size() == 15);

	
	}




}

@@ -93,191 +93,18 @@
 ava.
-io.FileOutputStream;%0Aimport java.io.FileWriter;%0Aimport java.io.IOException;%0Aimport java.io.Writer;%0Aimport java.util.Map;%0Aimport java.util.Set;%0A%0Aimport org.apache.commons.io.FileUtils;
+util.Set;%0A
 %0Aimp
@@ -190,62 +190,8 @@
 st;%0A
-import org.semanticweb.elk.owlapi.ElkReasonerFactory;%0A
 impo
@@ -292,439 +292,41 @@
 al;%0A
-import org.semanticweb.owlapi.model.OWLObject;%0Aimport org.semanticweb.owlapi.model.OWLOntology;%0Aimport org.semanticweb.owlapi.model.OWLOntologyStorageException;%0A%0Aimport owltools.OWLToolsTestBasics;%0Aimport owltools.gaf.GafDocument;%0Aimport owltools.gaf.GafObjectsBuilder;%0Aimport owltools.graph.OWLGraphWrapper;%0Aimport owltools.io.ParserWrapper;%0Aimport owltools.util.MinimalModelGeneratorTest;%0Aimport owltools.vocab.OBOUpperVocabulary
+%0Aimport owltools.io.ParserWrapper
 ;%0A%0Ap
@@ -998,16 +998,8 @@
 )));
-%0A%09%09//g.m
 %0A%0A%09%09
@@ -1509,13 +1509,81 @@
 sert
-True(
+Equals(%22Expected 15 individuals from the minimal model generation.%22, 15, 
 inds
@@ -1593,14 +1593,8 @@
 ze()
- == 15
 );%0A%0A

make the individual count check more explicit.