package owltools.cli;

import org.junit.Test;

/**
 * Tests for {@link CommandRunner}.
 * 
 * these are somewhat ad-hoc at the moment - output is written to stdout;
 * no attempt made to check results
 * 
 */
public class GafCommandRunnerTest extends AbstractCommandRunnerTest {
	
	protected void init() {
		runner = new GafCommandRunner();
	}

	@Test
	public void testRunner() throws Exception {
		init();
		load("go_sample_mf_subset.obo");
		String gafpath = getResource("test_gene_association_mgi.gaf").getAbsolutePath();
		run("--gaf "+gafpath);
		
		run("--extract-ontology-subset-by-gaf -u http://x.org/foo -o -f obo /tmp/foo.obo");
		
		//run("-o -f obo /tmp/foo.obo");
		
	}
	
	@Test
	public void testRemoveRedundant() throws Exception {
		init();
		load("go_sample_mf_subset.obo");
		String gafpath = getResource("test_gene_association_mgi.gaf").getAbsolutePath();
		run("--gaf "+gafpath);
		
		run("--gaf-remove-redundant --write-gaf target/nr.gaf");
		
		//run("-o -f obo /tmp/foo.obo");
		
	}

	
	@Test
	public void testFolder() throws Exception {
		init();
		load("go_sample_mf_subset.obo");
		String gafpath = getResource("test_gene_association_mgi.gaf").getAbsolutePath();
		run("--gaf "+gafpath);
		
		run("--gaf-fold-extensions");
		String opath = "target/tmp.gaf";
		run("--write-gaf "+opath);
		run("-o -f obo target/foo.obo");
		run("-o file:///tmp//foo.owl");
		
		//run("-o -f obo /tmp/foo.obo");
		
	}
	
	@Test
	public void testQuery() throws Exception {
		init();
		load("gaf/mgi-exttest-go-subset.obo");
		String gafpath = getResource("gaf/mgi-exttest.gaf").getAbsolutePath();
		run("--gaf "+gafpath);
		
		run("--gaf-query GO:0008152");
		String opath = "target/gafq-output.gaf";
		run("--write-gaf "+opath);
		
		
	}


	@Test
	public void testMap2Slim() throws Exception {
		init();
		load("gaf/mgi-exttest-go-subset.obo");
		String gafpath = getResource("gaf/mgi-exttest.gaf").getAbsolutePath();
		run("--gaf "+gafpath);
		
		run("--map2slim -s goslim_plant");
		String opath = "target/map2slim-output.gaf";
		run("--write-gaf "+opath);
		
		
	}
	
	@Test
	public void testMap2SlimIds() throws Exception {
		init();
		load("gaf/mgi-exttest-go-subset.obo");
		String gafpath = getResource("gaf/mgi-exttest.gaf").getAbsolutePath();
		run("--gaf "+gafpath);
		
		String slimpath = getResource("gaf/goslim_plant.terms").getAbsolutePath();
		run("--map2slim --idfile "+slimpath);
		String opath = "target/map2slim-output-ids.gaf";
		run("--write-gaf "+opath);
		
		
	}
	
	@Test
	public void testAddLabels() throws Exception {
		init();
		load("gaf/mgi-exttest-go-subset.obo");
		String gafpath = getResource("gaf/mgi-exttest.gaf").getAbsolutePath();
		run("--add-labels -c 1,5 "+gafpath);

		
	}


	
	
}

@@ -2712,15 +2712,272 @@
 %0A%09%09%0A%09%7D%0A%0A
+%09@Test%0A%09public void testGafSpecificity() throws Exception %7B%0A%09%09init();%0A%09%09load(%22gaf/mgi-exttest-go-subset.obo%22);%0A%09%09String gafpath = getResource(%22gaf/mgi-exttest.gaf%22).getAbsolutePath();%0A%09%09run(%22--gaf %22+gafpath);%0A%09%09%0A%09%09run(%22--gaf-calculate-specificity%22);%0A%0A%09%09%0A%09%7D%0A
 %0A%09%0A%09%0A%7D%0A

test for gaf specificity