2009-10-06 10:45:31 +08:00
|
|
|
package org.broadinstitute.sting.utils.bed;
|
|
|
|
|
|
|
|
|
|
import org.broadinstitute.sting.BaseTest;
|
|
|
|
|
import org.broadinstitute.sting.utils.GenomeLocParser;
|
|
|
|
|
import org.broadinstitute.sting.utils.GenomeLoc;
|
|
|
|
|
import org.junit.BeforeClass;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.junit.Assert;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2010-07-01 12:40:31 +08:00
|
|
|
import net.sf.picard.reference.IndexedFastaSequenceFile;
|
|
|
|
|
|
2009-12-29 15:40:48 +08:00
|
|
|
|
2010-04-08 14:14:15 +08:00
|
|
|
public class BedParserUnitTest extends BaseTest {
|
2009-10-06 10:45:31 +08:00
|
|
|
|
|
|
|
|
private static IndexedFastaSequenceFile seq;
|
|
|
|
|
private File bedFile = new File("testdata/sampleBedFile.bed");
|
|
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
|
public static void beforeTests() {
|
2010-08-05 01:59:37 +08:00
|
|
|
seq = new IndexedFastaSequenceFile(new File(b36KGReference));
|
2009-10-06 10:45:31 +08:00
|
|
|
GenomeLocParser.setupRefContigOrdering(seq);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testLoadBedFile() {
|
|
|
|
|
BedParser parser = new BedParser(bedFile);
|
|
|
|
|
List<GenomeLoc> location = parser.getLocations();
|
|
|
|
|
Assert.assertEquals(4, location.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testBedParsing() {
|
|
|
|
|
BedParser parser = new BedParser(bedFile);
|
|
|
|
|
List<GenomeLoc> location = parser.getLocations();
|
|
|
|
|
Assert.assertEquals(4, location.size());
|
|
|
|
|
Assert.assertTrue(location.get(0).getContig().equals("20"));
|
|
|
|
|
Assert.assertTrue(location.get(1).getContig().equals("20"));
|
|
|
|
|
Assert.assertTrue(location.get(2).getContig().equals("22"));
|
|
|
|
|
Assert.assertTrue(location.get(3).getContig().equals("22"));
|
|
|
|
|
|
|
|
|
|
// now check the the start positions
|
|
|
|
|
Assert.assertEquals(1, location.get(0).getStart());
|
|
|
|
|
Assert.assertEquals(1002, location.get(1).getStart());
|
|
|
|
|
Assert.assertEquals(1001, location.get(2).getStart());
|
|
|
|
|
Assert.assertEquals(2001, location.get(3).getStart());
|
|
|
|
|
|
|
|
|
|
// now check the the stop positions
|
|
|
|
|
Assert.assertEquals(999, location.get(0).getStop());
|
|
|
|
|
Assert.assertEquals(2000, location.get(1).getStop());
|
|
|
|
|
Assert.assertEquals(5000, location.get(2).getStop());
|
|
|
|
|
Assert.assertEquals(6000, location.get(3).getStop());
|
|
|
|
|
}
|
|
|
|
|
}
|