Added the base test case, fixed the rest of the test cases to follow suit. Added more verbose output to ant for junit tests.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@403 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
aaron 2009-04-14 17:11:38 +00:00
parent 961dbbd4ef
commit 4b3578e1de
5 changed files with 37 additions and 33 deletions

View File

@ -199,7 +199,7 @@
<target name="test.compile" depends="compile"> <target name="test.compile" depends="compile">
<echo message="Sting: Compiling test cases!"/> <echo message="Sting: Compiling test cases!"/>
<mkdir dir="${test.classes}"/> <mkdir dir="${test.classes}"/>
<javac destdir="${test.classes}" debug="on" optimize="on"> <javac destdir="${test.classes}" debug="true" optimize="on">
<src path="${test.sources}"/> <src path="${test.sources}"/>
<classpath> <classpath>
<path refid="external.dependencies"/> <path refid="external.dependencies"/>
@ -214,9 +214,8 @@
<target name="test" depends="test.compile" description="Run unit tests"> <target name="test" depends="test.compile" description="Run unit tests">
<mkdir dir="${report}"/> <mkdir dir="${report}"/>
<echo message="Sting: Running test cases!"/> <echo message="Sting: Running test cases!"/>
<junit printsummary="yes" showoutput="yes" clonevm="yes" haltonfailure="yes"> <junit printsummary="yes" showoutput="yes" clonevm="yes" haltonfailure="yes" failureProperty="test.failure">
<formatter type="plain"/> <formatter type="brief" usefile="false" />
<classpath> <classpath>
<path refid="external.dependencies"/> <path refid="external.dependencies"/>
<pathelement location="build"/> <pathelement location="build"/>
@ -227,9 +226,11 @@
<batchtest fork="yes" todir="${report}"> <batchtest fork="yes" todir="${report}">
<fileset dir="${test.classes}"> <fileset dir="${test.classes}">
<include name="**/*.class"/> <include name="**/*.class"/>
<exclude name="**/BaseTest.class"/>
</fileset> </fileset>
</batchtest> </batchtest>
</junit> </junit>
<fail message="test failed" if="test.failure" />
</target> </target>

View File

@ -4,6 +4,7 @@ import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.fail; import static junit.framework.Assert.fail;
import net.sf.samtools.SAMSequenceDictionary; import net.sf.samtools.SAMSequenceDictionary;
import net.sf.samtools.SAMSequenceRecord; import net.sf.samtools.SAMSequenceRecord;
import org.broadinstitute.sting.BaseTest;
import org.broadinstitute.sting.utils.FastaSequenceFile2; import org.broadinstitute.sting.utils.FastaSequenceFile2;
import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLoc;
import org.junit.*; import org.junit.*;
@ -37,7 +38,7 @@ import java.util.ArrayList;
* <p/> * <p/>
* A descriptions should go here. Blame aaron if it's missing. * A descriptions should go here. Blame aaron if it's missing.
*/ */
public class ShardStrategyFactoryTest { public class ShardStrategyFactoryTest extends BaseTest {
private static FastaSequenceFile2 seq; private static FastaSequenceFile2 seq;
@ -47,7 +48,7 @@ public class ShardStrategyFactoryTest {
*/ */
@BeforeClass @BeforeClass
public static void doBeforeAnyTests() { public static void doBeforeAnyTests() {
seq = new FastaSequenceFile2(new File("/seq/references/Homo_sapiens_assembly18/v0/Homo_sapiens_assembly18.fasta")); seq = new FastaSequenceFile2(new File(seqLocation + "/references/Homo_sapiens_assembly18/v0/Homo_sapiens_assembly18.fasta"));
} }
/** /**
@ -117,17 +118,17 @@ public class ShardStrategyFactoryTest {
int size = 10000; int size = 10000;
int location = 1; int location = 1;
GenomeLoc.setupRefContigOrdering(dic); GenomeLoc.setupRefContigOrdering(dic);
System.err.println("done to sleep"); logger.debug("done to sleep");
// keep track of the number of genome locs we build // keep track of the number of genome locs we build
int genomeLocs = 0; int genomeLocs = 0;
ArrayList<GenomeLoc> locations = new ArrayList<GenomeLoc>(); ArrayList<GenomeLoc> locations = new ArrayList<GenomeLoc>();
System.err.println("done to sleep2"); logger.debug("done to sleep2");
try { try {
while (location + size < stop) { while (location + size < stop) {
System.err.println("s = " + s.getSequenceName() + " " + location + " " + size); logger.debug("s = " + s.getSequenceName() + " " + location + " " + size);
// lets make up some fake locations // lets make up some fake locations
GenomeLoc gl = new GenomeLoc(s.getSequenceName(), location, location + size - 1); GenomeLoc gl = new GenomeLoc(s.getSequenceName(), location, location + size - 1);
System.err.println("loc = " + location); logger.debug("loc = " + location);
// let's move the location up, with a size space // let's move the location up, with a size space
location += (size * 2); location += (size * 2);
@ -141,18 +142,18 @@ public class ShardStrategyFactoryTest {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
System.err.println("Location count = " + genomeLocs); logger.debug("Location count = " + genomeLocs);
ShardStrategy strategy = ShardStrategyFactory.shatter(ShardStrategyFactory.SHATTER_STRATEGY.LINEAR, seq.getSequenceDictionary(), 5000, locations); ShardStrategy strategy = ShardStrategyFactory.shatter(ShardStrategyFactory.SHATTER_STRATEGY.LINEAR, seq.getSequenceDictionary(), 5000, locations);
int shardCount = 0; int shardCount = 0;
try { try {
for (Shard sh : strategy) { for (Shard sh : strategy) {
GenomeLoc l = sh.getGenomeLoc(); GenomeLoc l = sh.getGenomeLoc();
System.err.println("Shard start: " + l.getStart() + " stop " + l.getStop() + " contig " + l.getContig()); logger.debug("Shard start: " + l.getStart() + " stop " + l.getStop() + " contig " + l.getContig());
shardCount++; shardCount++;
} }
System.err.println("Shard count = " + shardCount); logger.debug("Shard count = " + shardCount);
assertEquals(shardCount, genomeLocs * 2); assertEquals(shardCount, genomeLocs * 2);
} catch (Exception e) { } catch (Exception e) {

View File

@ -2,6 +2,7 @@ package org.broadinstitute.sting.gatk.dataSources.simpleDataSources;
import static junit.framework.Assert.fail; import static junit.framework.Assert.fail;
import net.sf.samtools.SAMRecord; import net.sf.samtools.SAMRecord;
import org.broadinstitute.sting.BaseTest;
import org.broadinstitute.sting.gatk.dataSources.shards.Shard; import org.broadinstitute.sting.gatk.dataSources.shards.Shard;
import org.broadinstitute.sting.gatk.dataSources.shards.ShardStrategy; import org.broadinstitute.sting.gatk.dataSources.shards.ShardStrategy;
import org.broadinstitute.sting.gatk.dataSources.shards.ShardStrategyFactory; import org.broadinstitute.sting.gatk.dataSources.shards.ShardStrategyFactory;
@ -42,7 +43,7 @@ import java.util.List;
* <p/> * <p/>
* A descriptions should go here. Blame aaron if it's missing. * A descriptions should go here. Blame aaron if it's missing.
*/ */
public class SAMBAMDataSourceTest { public class SAMBAMDataSourceTest extends BaseTest {
private List<String> fl; private List<String> fl;
private FastaSequenceFile2 seq; private FastaSequenceFile2 seq;
@ -57,7 +58,7 @@ public class SAMBAMDataSourceTest {
fl = new ArrayList<String>(); fl = new ArrayList<String>();
// sequence // sequence
seq = new FastaSequenceFile2(new File("/seq/references/Homo_sapiens_assembly18/v0/Homo_sapiens_assembly18.fasta")); seq = new FastaSequenceFile2(new File(seqLocation + "/references/Homo_sapiens_assembly18/v0/Homo_sapiens_assembly18.fasta"));
GenomeLoc.setupRefContigOrdering(seq.getSequenceDictionary()); GenomeLoc.setupRefContigOrdering(seq.getSequenceDictionary());
} }
@ -81,7 +82,7 @@ public class SAMBAMDataSourceTest {
int count = 0; int count = 0;
// setup the data // setup the data
fl.add("/humgen/gsa-scr1/aaron/stink/NA12892.bam"); fl.add(oneKGLocation + "/pilot3/sams/NA12892.bam");
try { try {
@ -90,8 +91,8 @@ public class SAMBAMDataSourceTest {
int readCount = 0; int readCount = 0;
count++; count++;
System.out.println("Start : " + sh.getGenomeLoc().getStart() + " stop : " + sh.getGenomeLoc().getStop() + " contig " + sh.getGenomeLoc().getContig()); logger.debug("Start : " + sh.getGenomeLoc().getStart() + " stop : " + sh.getGenomeLoc().getStop() + " contig " + sh.getGenomeLoc().getContig());
System.out.println("count = " + count); logger.debug("count = " + count);
MergingSamRecordIterator2 datum = data.seek(sh.getGenomeLoc()); MergingSamRecordIterator2 datum = data.seek(sh.getGenomeLoc());
// for the first couple of shards make sure we can see the reads // for the first couple of shards make sure we can see the reads
@ -118,7 +119,7 @@ public class SAMBAMDataSourceTest {
// setup the test files // setup the test files
fl.add("/seq/dirseq/analysis/cancer_exome/sams/TCGA-06-0188.aligned.duplicates_marked.bam"); fl.add(seqLocation + "/dirseq/analysis/cancer_exome/sams/TCGA-06-0188.aligned.duplicates_marked.bam");
ArrayList<Integer> readcountPerShard = new ArrayList<Integer>(); ArrayList<Integer> readcountPerShard = new ArrayList<Integer>();
ArrayList<Integer> readcountPerShard2 = new ArrayList<Integer>(); ArrayList<Integer> readcountPerShard2 = new ArrayList<Integer>();
@ -143,7 +144,7 @@ public class SAMBAMDataSourceTest {
} }
readcountPerShard.add(readCount); readcountPerShard.add(readCount);
System.out.println("read count = " + readCount); logger.debug("read count = " + readCount);
datum.close(); datum.close();
} }
} }
@ -155,13 +156,13 @@ public class SAMBAMDataSourceTest {
// setup the data and the counter before our second run // setup the data and the counter before our second run
fl.clear(); fl.clear();
fl.add("/seq/dirseq/analysis/cancer_exome/sams/TCGA-06-0188-01A-01W.aligned.duplicates_marked.bam"); fl.add(seqLocation + "/dirseq/analysis/cancer_exome/sams/TCGA-06-0188-01A-01W.aligned.duplicates_marked.bam");
fl.add("/seq/dirseq/analysis/cancer_exome/sams/TCGA-06-0188-10B-01W.aligned.duplicates_marked.bam"); fl.add(seqLocation + "/dirseq/analysis/cancer_exome/sams/TCGA-06-0188-10B-01W.aligned.duplicates_marked.bam");
count = 0; count = 0;
// the sharding strat. // the sharding strat.
strat = ShardStrategyFactory.shatter(ShardStrategyFactory.SHATTER_STRATEGY.LINEAR, seq.getSequenceDictionary(), 100000); strat = ShardStrategyFactory.shatter(ShardStrategyFactory.SHATTER_STRATEGY.LINEAR, seq.getSequenceDictionary(), 100000);
System.err.println("Pile two:"); logger.debug("Pile two:");
try { try {
SAMBAMDataSource data = new SAMBAMDataSource(fl); SAMBAMDataSource data = new SAMBAMDataSource(fl);
for (Shard sh : strat) { for (Shard sh : strat) {
@ -180,7 +181,7 @@ public class SAMBAMDataSourceTest {
} }
readcountPerShard2.add(readCount); readcountPerShard2.add(readCount);
System.out.println("read count = " + readCount); logger.debug("read count = " + readCount);
datum.close(); datum.close();
} }
} }

View File

@ -1,12 +1,11 @@
package org.broadinstitute.sting.utils; package org.broadinstitute.sting.utils;
import org.junit.*;
import org.apache.log4j.BasicConfigurator;
import java.io.File;
import edu.mit.broad.picard.reference.ReferenceSequence; import edu.mit.broad.picard.reference.ReferenceSequence;
import net.sf.samtools.util.StringUtil; import net.sf.samtools.util.StringUtil;
import org.broadinstitute.sting.BaseTest;
import org.junit.*;
import java.io.File;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
@ -14,9 +13,9 @@ import net.sf.samtools.util.StringUtil;
* Date: Apr 11, 2009 * Date: Apr 11, 2009
* Time: 2:32:52 PM * Time: 2:32:52 PM
*/ */
public class FastaSequenceFile2Test { public class FastaSequenceFile2Test extends BaseTest {
private final String sequenceFileName = "/seq/references/Homo_sapiens_assembly18/v0/Homo_sapiens_assembly18.fasta"; private static String sequenceFileName;
private FastaSequenceFile2 sequenceFile = null; private FastaSequenceFile2 sequenceFile = null;
private final String firstBasesOfChrM = "GATCACAGGTCTATCACCCT"; private final String firstBasesOfChrM = "GATCACAGGTCTATCACCCT";
@ -25,7 +24,7 @@ public class FastaSequenceFile2Test {
@BeforeClass @BeforeClass
public static void initialize() { public static void initialize() {
BasicConfigurator.configure(); sequenceFileName = seqLocation + "/references/Homo_sapiens_assembly18/v0/Homo_sapiens_assembly18.fasta";
} }
@Before @Before
@ -116,6 +115,7 @@ public class FastaSequenceFile2Test {
try { try {
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
boolean success = sequenceFile.seekToContig("absent");
} }
finally { finally {
endTime = System.currentTimeMillis(); endTime = System.currentTimeMillis();

View File

@ -7,6 +7,7 @@ package org.broadinstitute.sting.utils.cmdLine;
import org.junit.*; import org.junit.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.apache.commons.cli.ParseException; import org.apache.commons.cli.ParseException;
import org.broadinstitute.sting.BaseTest;
/** /**
* The ArgumentParserTest test class. In JUnit 4, you don't have to extent the * The ArgumentParserTest test class. In JUnit 4, you don't have to extent the
@ -24,7 +25,7 @@ import org.apache.commons.cli.ParseException;
* <p/> * <p/>
* You should use the methods like * You should use the methods like
*/ */
public class ArgumentParserTest { public class ArgumentParserTest extends BaseTest {
// our argument parser // our argument parser
private ArgumentParser m_parser = null; private ArgumentParser m_parser = null;