diff --git a/test/build-test.xml b/test/build-test.xml new file mode 100644 index 0000000000000000000000000000000000000000..d6301f6b7c001e254c1967f819ba581bd87b1a13 --- /dev/null +++ b/test/build-test.xml @@ -0,0 +1,97 @@ +<?xml version="1.0"?> + +<!-- + + Ant build file for Artemis Test Suite + +--> + +<project default="test" basedir="."> + + <target name="init"> + <tstamp /> + <property name="name" value="artemis test suite" /> + <property name="version" value="live" /> + <property name="build.compiler" value="modern" /> + <property name="classpath" value="." /> + <property name="src.tests.dir" value="." /> + <property name="src.lib.dir" value="lib" /> + + <property name="build.dir" value="./ant-build" /> + + <!-- Subdirectories for tests source and classes --> + <property name="build.src.tests" value="${build.dir}/src/tests" /> + <property name="build.dest.tests" value="${build.dir}/classes/tests" /> + + <!-- Compile classpath --> + <path id="compile.classpath"> + <!-- Main classes from build --> + <pathelement path="${classpath}" /> + <pathelement path="../ant-build/classes/main/" /> + <pathelement path="${build.dest.tests}" /> + <!-- Dependency classes --> + <fileset dir="${src.lib.dir}"> + <include name="**/*.jar" /> + </fileset> + </path> + </target> + + <!-- Prepares the build directory --> + <target name="prepare" depends="init"> + <mkdir dir="${build.dir}" /> + </target> + + <!-- Prepares the source code --> + <target name="prepare-core" depends="init,prepare"> + <!-- Creates directories --> + <mkdir dir="${build.src.tests}" /> + <mkdir dir="${build.dest.tests}" /> + + <!-- Copies src files --> + <copy todir="${build.src.tests}"> + <fileset dir="${src.tests.dir}"> + <exclude name="**/CVS/**" /> + <exclude name="**/data/**" /> + <exclude name="**/lib/**" /> + </fileset> + </copy> + + <!-- Copies jars --> + <copy todir="${build.dir}"> + <fileset dir="${src.lib.dir}"> + <include name="*.jar" /> + </fileset> + </copy> + </target> + + <!-- Compiles the source directory --> + <target name="compile" depends="init,prepare-core"> + <javac + fork="true" + srcdir="${build.src.tests}" + destdir="${build.dest.tests}" + deprecation="false" + depend="no" + debug="true"> + <classpath refid="compile.classpath"/> + </javac> + </target> + + <target name="test" depends="compile"> + <junit description="alltests" fork="yes"> + <jvmarg value="-DEMBOSS_ROOT=/Users/tjc/EMBOSS/emboss/"/> + <batchtest todir="${build.dest.tests}"> + <fileset dir="${build.src.tests}"> + <include name="uk/ac/sanger/artemis/circular/digest/**Test.java"/> + </fileset> + </batchtest> + <formatter type="plain" usefile="false"/> + <classpath refid="compile.classpath"/> + </junit> + </target> + + <!-- Cleans everything --> + <target name="clean" depends="init"> + <delete dir="${build.dir}" /> + </target> +</project> diff --git a/test/data/foo.restrict b/test/data/foo.restrict new file mode 100644 index 0000000000000000000000000000000000000000..e34c84216a680590925e1730b2bd8707a4dcbab0 --- /dev/null +++ b/test/data/foo.restrict @@ -0,0 +1,41 @@ +######################################## +# Program: restrict +# Rundate: Wed 18 Feb 2009 11:01:39 +# Commandline: restrict +# [-sequence] /Users/tjc/foo.embl +# -auto +# -limit y +# -enzymes HincII,hinfI,ppiI,hindiii +# -outfile /private/tmp/circular_genome57650.txt +# Report_format: table +# Report_file: /private/tmp/circular_genome57650.txt +######################################## + +#======================================= +# +# Sequence: from: 1 to: 41243 +# HitCount: 158 +# +# Minimum cuts per enzyme: 1 +# Maximum cuts per enzyme: 2000000000 +# Minimum length of recognition site: 4 +# Blunt ends allowed +# Sticky ends allowed +# DNA is linear +# Ambiguities allowed +# +#======================================= + + Start End Strand Enzyme_name Restriction_site 5prime 3prime 5primerev 3primerev + 81 86 + HindIII AAGCTT 81 85 . . + 140 144 + HinfI GANTC 140 143 . . + 40956 40960 + HinfI GANTC 40956 40959 . . + 41036 41041 + HindII GTYRAC 41038 41038 . . + +#--------------------------------------- +#--------------------------------------- + +#--------------------------------------- +# Total_sequences: 1 +# Total_hitcount: 158 +#--------------------------------------- diff --git a/test/lib/junit-4.5.jar b/test/lib/junit-4.5.jar new file mode 100644 index 0000000000000000000000000000000000000000..733921623d4a71ae2ae1432228e6eba5e508ae4c Binary files /dev/null and b/test/lib/junit-4.5.jar differ diff --git a/test/uk/ac/sanger/artemis/circular/digest/CircularGenomeControllerTest.java b/test/uk/ac/sanger/artemis/circular/digest/CircularGenomeControllerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e31985198a10db730c28f67a7c19e736feff2c93 --- /dev/null +++ b/test/uk/ac/sanger/artemis/circular/digest/CircularGenomeControllerTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2009 Genome Research Limited + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ +package uk.ac.sanger.artemis.circular.digest; + +import static org.junit.Assert.*; + +import java.io.File; +import org.junit.Test; + +public class CircularGenomeControllerTest +{ + /** + * Test that EMBOSS_ROOT is set + */ + @Test + public void testEmbossRoot() + { + assertNotNull("EMBOSS_ROOT not set", System.getProperty("EMBOSS_ROOT")); + } + + /** + * Test that restrict can be found + */ + @Test + public void testEmbossInstalled() + { + String restrictPath = System.getProperty("EMBOSS_ROOT") + "/bin/restrict"; + File restrict = new File(restrictPath); + assertTrue("restrict not found at: " + restrictPath, restrict.exists()); + } +} \ No newline at end of file diff --git a/test/uk/ac/sanger/artemis/circular/digest/EmbossTableParserTest.java b/test/uk/ac/sanger/artemis/circular/digest/EmbossTableParserTest.java new file mode 100644 index 0000000000000000000000000000000000000000..791afb9cfd74ad347341695d5d0639a4f5a1c451 --- /dev/null +++ b/test/uk/ac/sanger/artemis/circular/digest/EmbossTableParserTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2009 Genome Research Limited + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ +package uk.ac.sanger.artemis.circular.digest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.BufferedReader; +import java.io.IOException; +import java.util.List; + +import org.junit.Test; + +import uk.ac.sanger.artemis.circular.digest.CutSite; +import uk.ac.sanger.artemis.circular.digest.EmbossTableParser; + +public class EmbossTableParserTest +{ + /** + * Test that restrict output is parsed + */ + @Test + public void testParser() throws IOException + { + final InputStream inputStream = + EmbossTableParserTest.class.getResourceAsStream("/data/foo.restrict"); + + InputStreamReader reader = new InputStreamReader(inputStream); + EmbossTableParser etp = new EmbossTableParser(); + + etp.parse(new BufferedReader(reader)); + } +} diff --git a/test/uk/ac/sanger/artemis/circular/digest/UtilsTest.java b/test/uk/ac/sanger/artemis/circular/digest/UtilsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..33be3fdc4265c16068bd50f6fc2758046e82c2af --- /dev/null +++ b/test/uk/ac/sanger/artemis/circular/digest/UtilsTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2009 Genome Research Limited + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ +package uk.ac.sanger.artemis.circular.digest; + +import static org.junit.Assert.*; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.List; +import org.junit.Test; + +import uk.ac.sanger.artemis.circular.digest.CutSite; + +public class UtilsTest +{ + /** + * Test that restrict output is parsed + */ + @Test + public void testFindCutSitesFromEmbossReport() + { + final InputStream inputStream = + UtilsTest.class.getResourceAsStream("/data/foo.restrict"); + + InputStreamReader reader = new InputStreamReader(inputStream); + ReportDetails report = Utils.findCutSitesFromEmbossReport(reader); + + assertNotNull("ReportDetails null",report); + assertEquals("Sequence length",report.length, 41243); + + List<CutSite> cutSites = report.cutSites; + CutSite firstCutSite = cutSites.get(0); + + assertEquals("Number of cut sites", cutSites.size(), 4); + assertEquals("Enzyme name", firstCutSite.getEnzymeName(), "HindIII"); + assertEquals("3prime", firstCutSite.getThreePrime(), 85); + assertEquals("5prime", firstCutSite.getFivePrime(), 81); + assertEquals("3prime-rev", firstCutSite.getThreePrimeRev(), 0); + assertEquals("5prime-rev", firstCutSite.getFivePrimeRev(), 0); + assertTrue("Cut site strand", firstCutSite.isForward()); + } + +}