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

View File

@ -4,6 +4,7 @@ import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.fail;
import net.sf.samtools.SAMSequenceDictionary;
import net.sf.samtools.SAMSequenceRecord;
import org.broadinstitute.sting.BaseTest;
import org.broadinstitute.sting.utils.FastaSequenceFile2;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.junit.*;
@ -37,7 +38,7 @@ import java.util.ArrayList;
* <p/>
* A descriptions should go here. Blame aaron if it's missing.
*/
public class ShardStrategyFactoryTest {
public class ShardStrategyFactoryTest extends BaseTest {
private static FastaSequenceFile2 seq;
@ -47,7 +48,7 @@ public class ShardStrategyFactoryTest {
*/
@BeforeClass
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 location = 1;
GenomeLoc.setupRefContigOrdering(dic);
System.err.println("done to sleep");
logger.debug("done to sleep");
// keep track of the number of genome locs we build
int genomeLocs = 0;
ArrayList<GenomeLoc> locations = new ArrayList<GenomeLoc>();
System.err.println("done to sleep2");
logger.debug("done to sleep2");
try {
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
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
location += (size * 2);
@ -141,18 +142,18 @@ public class ShardStrategyFactoryTest {
} catch (Exception e) {
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);
int shardCount = 0;
try {
for (Shard sh : strategy) {
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++;
}
System.err.println("Shard count = " + shardCount);
logger.debug("Shard count = " + shardCount);
assertEquals(shardCount, genomeLocs * 2);
} catch (Exception e) {

View File

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

View File

@ -1,12 +1,11 @@
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 net.sf.samtools.util.StringUtil;
import org.broadinstitute.sting.BaseTest;
import org.junit.*;
import java.io.File;
/**
* Created by IntelliJ IDEA.
@ -14,9 +13,9 @@ import net.sf.samtools.util.StringUtil;
* Date: Apr 11, 2009
* 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 final String firstBasesOfChrM = "GATCACAGGTCTATCACCCT";
@ -25,7 +24,7 @@ public class FastaSequenceFile2Test {
@BeforeClass
public static void initialize() {
BasicConfigurator.configure();
sequenceFileName = seqLocation + "/references/Homo_sapiens_assembly18/v0/Homo_sapiens_assembly18.fasta";
}
@Before
@ -116,6 +115,7 @@ public class FastaSequenceFile2Test {
try {
startTime = System.currentTimeMillis();
boolean success = sequenceFile.seekToContig("absent");
}
finally {
endTime = System.currentTimeMillis();

View File

@ -7,6 +7,7 @@ package org.broadinstitute.sting.utils.cmdLine;
import org.junit.*;
import static org.junit.Assert.*;
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
@ -24,7 +25,7 @@ import org.apache.commons.cli.ParseException;
* <p/>
* You should use the methods like
*/
public class ArgumentParserTest {
public class ArgumentParserTest extends BaseTest {
// our argument parser
private ArgumentParser m_parser = null;