/** * Return the sequence (chromosome/contig) names in this file, if known. * * @return list of strings of the contig names */ public List<String> getSequenceNames() { return !this.hasIndex() ? new ArrayList<String>() : new ArrayList<String>(index.getSequenceNames()); }
/** * Return the sequence (chromosome/contig) names in this file, if known. * * @return list of strings of the contig names */ @Override public List<String> getSequenceNames() { return !this.hasIndex() ? new ArrayList<>() : new ArrayList<>(index.getSequenceNames()); }
/** * Return the sequence (chromosome/contig) names in this file, if known. * * @return list of strings of the contig names */ @Override public List<String> getSequenceNames() { return !this.hasIndex() ? new ArrayList<>() : new ArrayList<>(index.getSequenceNames()); }
/** * create the sequence dictionary with the contig list; a backup approach * @param index the index file to use * @param dict the sequence dictionary to add contigs to * @return the filled-in sequence dictionary */ static SAMSequenceDictionary createSequenceDictionaryFromContigList(final Index index, final SAMSequenceDictionary dict) { final List<String> seqNames = index.getSequenceNames(); if (seqNames == null) { return dict; } for (final String name : seqNames) { SAMSequenceRecord seq = new SAMSequenceRecord(name, 0); dict.addSequence(seq); } return dict; }
@Test(dataProvider = "bedDataProvider") public void testCreateLinearIndexFromBED(final File inputBEDFIle) throws Exception { Index index = IndexFactory.createLinearIndex(inputBEDFIle, new BEDCodec()); String chr = "chr2"; Assert.assertTrue(index.getSequenceNames().contains(chr)); Assert.assertTrue(index.containsChromosome(chr)); Assert.assertEquals(1, index.getSequenceNames().size()); List<Block> blocks = index.getBlocks(chr, 1, 50); Assert.assertEquals(1, blocks.size()); Block block = blocks.get(0); Assert.assertEquals(78, block.getSize()); }
@Test(dataProvider = "writeIndexData") public void testWriteIndex(final File inputFile, final IndexFactory.IndexType type, final FeatureCodec codec) throws Exception { // temp index file for this test final File tempIndex = File.createTempFile("index", (type == IndexFactory.IndexType.TABIX) ? TabixUtils.STANDARD_INDEX_EXTENSION : Tribble.STANDARD_INDEX_EXTENSION); tempIndex.delete(); tempIndex.deleteOnExit(); // create the index final Index index = IndexFactory.createIndex(inputFile, codec, type); Assert.assertFalse(tempIndex.exists()); // write the index to a file index.write(tempIndex); Assert.assertTrue(tempIndex.exists()); // load the generated index final Index loadedIndex = IndexFactory.loadIndex(tempIndex.getAbsolutePath()); //TODO: This is just a smoke test; it can pass even if the generated index is unusable for queries. // test that the sequences and properties are the same Assert.assertEquals(loadedIndex.getSequenceNames(), index.getSequenceNames()); Assert.assertEquals(loadedIndex.getProperties(), index.getProperties()); // test that write to a stream does not blows ip index.write(new LittleEndianOutputStream(nullOutputStrem)); }