Search in sources :

Example 6 with SAMSequenceDictionary

use of htsjdk.samtools.SAMSequenceDictionary in project gatk by broadinstitute.

the class GenomeLocParserUnitTest method testcreateGenomeLocOnContig.

@Test
public void testcreateGenomeLocOnContig() throws FileNotFoundException {
    final CachingIndexedFastaSequenceFile seq = new CachingIndexedFastaSequenceFile(new File(exampleReference));
    final SAMSequenceDictionary dict = seq.getSequenceDictionary();
    final GenomeLocParser genomeLocParser = new GenomeLocParser(dict);
    for (final SAMSequenceRecord rec : dict.getSequences()) {
        final GenomeLoc loc = genomeLocParser.createOverEntireContig(rec.getSequenceName());
        Assert.assertEquals(loc.getContig(), rec.getSequenceName());
        Assert.assertEquals(loc.getStart(), 1);
        Assert.assertEquals(loc.getStop(), rec.getSequenceLength());
    }
}
Also used : CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) SAMSequenceRecord(htsjdk.samtools.SAMSequenceRecord) CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) File(java.io.File) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 7 with SAMSequenceDictionary

use of htsjdk.samtools.SAMSequenceDictionary in project gatk by broadinstitute.

the class IndexUtilsUnitTest method testCreateSequenceDictionaryFromTabixIndex.

@Test
public void testCreateSequenceDictionaryFromTabixIndex() throws Exception {
    final SAMSequenceDictionary dict = IndexUtils.createSequenceDictionaryFromFeatureIndex(new File(getToolTestDataDir(), "test_variants_for_index.vcf.bgz"));
    final Set<String> contigs = dict.getSequences().stream().map(s -> s.getSequenceName()).collect(Collectors.toSet());
    Assert.assertEquals(contigs, Sets.newHashSet("1", "2", "3", "4"));
}
Also used : DataProvider(org.testng.annotations.DataProvider) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Files(java.nio.file.Files) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) Set(java.util.Set) Test(org.testng.annotations.Test) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) File(java.io.File) IndexFactory(htsjdk.tribble.index.IndexFactory) Assert(org.testng.Assert) SAMSequenceRecord(htsjdk.samtools.SAMSequenceRecord) Index(htsjdk.tribble.index.Index) Path(java.nio.file.Path) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) File(java.io.File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 8 with SAMSequenceDictionary

use of htsjdk.samtools.SAMSequenceDictionary in project gatk by broadinstitute.

the class GenomeLocParserUnitTest method testContigHasColon.

@Test
public void testContigHasColon() {
    SAMFileHeader header = new SAMFileHeader();
    header.setSortOrder(htsjdk.samtools.SAMFileHeader.SortOrder.coordinate);
    SAMSequenceDictionary dict = new SAMSequenceDictionary();
    SAMSequenceRecord rec = new SAMSequenceRecord("c:h:r1", 10);
    rec.setSequenceLength(10);
    dict.addSequence(rec);
    header.setSequenceDictionary(dict);
    final GenomeLocParser myGenomeLocParser = new GenomeLocParser(header.getSequenceDictionary());
    GenomeLoc loc = myGenomeLocParser.parseGenomeLoc("c:h:r1:4-5");
    assertEquals(0, loc.getContigIndex());
    assertEquals(loc.getStart(), 4);
    assertEquals(loc.getStop(), 5);
}
Also used : SAMSequenceRecord(htsjdk.samtools.SAMSequenceRecord) SAMFileHeader(htsjdk.samtools.SAMFileHeader) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 9 with SAMSequenceDictionary

use of htsjdk.samtools.SAMSequenceDictionary in project gatk by broadinstitute.

the class IndexUtilsUnitTest method testCreateSequenceDictionaryFromTribbleIndex.

@Test
public void testCreateSequenceDictionaryFromTribbleIndex() throws Exception {
    final SAMSequenceDictionary dict = IndexUtils.createSequenceDictionaryFromFeatureIndex(new File(getToolTestDataDir(), "test_variants_for_index.vcf"));
    final Set<String> contigs = dict.getSequences().stream().map(s -> s.getSequenceName()).collect(Collectors.toSet());
    Assert.assertEquals(contigs, Sets.newHashSet("1", "2", "3", "4"));
}
Also used : DataProvider(org.testng.annotations.DataProvider) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Files(java.nio.file.Files) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) Set(java.util.Set) Test(org.testng.annotations.Test) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) File(java.io.File) IndexFactory(htsjdk.tribble.index.IndexFactory) Assert(org.testng.Assert) SAMSequenceRecord(htsjdk.samtools.SAMSequenceRecord) Index(htsjdk.tribble.index.Index) Path(java.nio.file.Path) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) File(java.io.File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 10 with SAMSequenceDictionary

use of htsjdk.samtools.SAMSequenceDictionary in project gatk by broadinstitute.

the class IndexUtilsUnitTest method testIsSequenceDictionaryFromIndexPositive.

@Test
public void testIsSequenceDictionaryFromIndexPositive() throws Exception {
    final SAMSequenceDictionary dict = IndexUtils.createSequenceDictionaryFromFeatureIndex(new File(getToolTestDataDir(), "test_variants_for_index.vcf"));
    Assert.assertTrue(IndexUtils.isSequenceDictionaryFromIndex(dict));
}
Also used : SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) File(java.io.File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Aggregations

SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)110 Test (org.testng.annotations.Test)41 SAMSequenceRecord (htsjdk.samtools.SAMSequenceRecord)37 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)37 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)35 File (java.io.File)31 UserException (org.broadinstitute.hellbender.exceptions.UserException)24 VariantContext (htsjdk.variant.variantcontext.VariantContext)23 Argument (org.broadinstitute.barclay.argparser.Argument)21 Collectors (java.util.stream.Collectors)20 ReferenceMultiSource (org.broadinstitute.hellbender.engine.datasources.ReferenceMultiSource)20 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)18 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)17 VCFHeader (htsjdk.variant.vcf.VCFHeader)16 IntervalUtils (org.broadinstitute.hellbender.utils.IntervalUtils)16 SAMFileHeader (htsjdk.samtools.SAMFileHeader)14 List (java.util.List)14 JavaRDD (org.apache.spark.api.java.JavaRDD)14 Broadcast (org.apache.spark.broadcast.Broadcast)12 StreamSupport (java.util.stream.StreamSupport)11