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());
}
}
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"));
}
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);
}
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"));
}
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));
}
Aggregations