Search in sources :

Example 36 with SAMSequenceDictionary

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

the class SequenceDictionaryUtilsUnitTest method testStandardValidationIgnoresContigOrder.

@Test(dataProvider = "StandardValidationIgnoresContigOrderData")
public void testStandardValidationIgnoresContigOrder(final List<SAMSequenceRecord> firstDictionaryContigs, final List<SAMSequenceRecord> secondDictionaryContigs) {
    final SAMSequenceDictionary firstDictionary = createSequenceDictionary(firstDictionaryContigs);
    final SAMSequenceDictionary secondDictionary = createSequenceDictionary(secondDictionaryContigs);
    // Standard validation (the overload of validateDictionaries() that doesn't take any boolean args)
    // should ignore differences in ordering of common contigs, so we shouldn't get an exception here
    SequenceDictionaryUtils.validateDictionaries("first", firstDictionary, "second", secondDictionary);
}
Also used : SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 37 with SAMSequenceDictionary

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

the class SimpleIntervalUnitTest method expandWithinContigInvalidTestData.

@DataProvider(name = "ExpandWithinContigInvalidData")
public Object[][] expandWithinContigInvalidTestData() {
    final int CONTIG_LENGTH = 10000;
    final SAMSequenceDictionary dictionary = new SAMSequenceDictionary(Arrays.asList(new SAMSequenceRecord("1", CONTIG_LENGTH)));
    final SAMSequenceDictionary badDictionary = new SAMSequenceDictionary(Arrays.asList(new SAMSequenceRecord("2", CONTIG_LENGTH)));
    return new Object[][] { { new SimpleInterval("1", 1, 10), -1, CONTIG_LENGTH, dictionary }, { new SimpleInterval("1", 1, 10), 1, 0, dictionary }, { new SimpleInterval("1", 1, 10), 1, -1, dictionary }, { new SimpleInterval("1", 1, 10), 1, CONTIG_LENGTH, null }, { new SimpleInterval("1", 1, 10), 1, CONTIG_LENGTH, badDictionary } };
}
Also used : SAMSequenceRecord(htsjdk.samtools.SAMSequenceRecord) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) DataProvider(org.testng.annotations.DataProvider)

Example 38 with SAMSequenceDictionary

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

the class IntervalUtilsUnitTest method testParseIntervalWithPeriodInContigName.

@Test
public void testParseIntervalWithPeriodInContigName() {
    // Make sure that we don't interpret contigs with periods in their name as files
    final String contigName = "GL000249.1";
    final SAMSequenceRecord contigRecord = new SAMSequenceRecord(contigName, 100);
    final SAMSequenceDictionary dictionary = new SAMSequenceDictionary(Arrays.asList(contigRecord));
    final GenomeLocParser parser = new GenomeLocParser(dictionary);
    final List<GenomeLoc> result = IntervalUtils.parseIntervalArguments(parser, contigName);
    Assert.assertEquals(result.size(), 1);
    Assert.assertEquals(result.get(0).getContig(), contigName);
    Assert.assertEquals(result.get(0).getStart(), 1);
    Assert.assertEquals(result.get(0).getEnd(), 100);
}
Also used : SAMSequenceRecord(htsjdk.samtools.SAMSequenceRecord) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 39 with SAMSequenceDictionary

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

the class IntervalUtilsUnitTest method testConvertSimpleIntervalToQueryInterval.

@Test
public void testConvertSimpleIntervalToQueryInterval() {
    final SAMSequenceRecord contigRecord = new SAMSequenceRecord("1", 100);
    final SAMSequenceDictionary dictionary = new SAMSequenceDictionary(Arrays.asList(contigRecord));
    final SimpleInterval originalInterval = new SimpleInterval("1", 5, 10);
    final QueryInterval convertedInterval = IntervalUtils.convertSimpleIntervalToQueryInterval(originalInterval, dictionary);
    Assert.assertEquals(convertedInterval.referenceIndex, 0);
    Assert.assertEquals(convertedInterval.start, 5);
    Assert.assertEquals(convertedInterval.end, 10);
}
Also used : SAMSequenceRecord(htsjdk.samtools.SAMSequenceRecord) QueryInterval(htsjdk.samtools.QueryInterval) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 40 with SAMSequenceDictionary

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

the class ReferenceUtilsUnitTest method testLoadFastaDictionaryFromFile.

@Test
public void testLoadFastaDictionaryFromFile() {
    final File referenceDictionaryFile = new File(ReferenceUtils.getFastaDictionaryFileName(hg19MiniReference));
    final SAMSequenceDictionary dictionary = ReferenceUtils.loadFastaDictionary(referenceDictionaryFile);
    Assert.assertNotNull(dictionary, "Sequence dictionary null after loading");
    Assert.assertEquals(dictionary.size(), 4, "Wrong sequence dictionary size after loading");
}
Also used : SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) 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