• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BEDCodec类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中htsjdk.tribble.bed.BEDCodec的典型用法代码示例。如果您正苦于以下问题:Java BEDCodec类的具体用法?Java BEDCodec怎么用?Java BEDCodec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BEDCodec类属于htsjdk.tribble.bed包,在下文中一共展示了BEDCodec类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: reindexBedFile

import htsjdk.tribble.bed.BEDCodec; //导入依赖的package包/类
public BedFile reindexBedFile(long bedFileId) throws FeatureIndexException {
    BedFile bedFile = bedFileManager.loadBedFile(bedFileId);
    Reference reference = referenceGenomeManager.loadReferenceGenome(bedFile.getReferenceId());
    Map<String, Chromosome> chromosomeMap = reference.getChromosomes().stream().collect(
            Collectors.toMap(BaseEntity::getName, chromosome -> chromosome));

    try {
        fileManager.deleteFileFeatureIndex(bedFile);
        try (AbstractFeatureReader<BEDFeature, LineIterator> reader =
                     AbstractFeatureReader.getFeatureReader(bedFile.getPath(), new BEDCodec(), false)) {
            featureIndexManager.makeIndexForBedReader(bedFile, reader, chromosomeMap);
        }
    } catch (IOException e) {
        throw new FeatureIndexException(bedFile, e);
    }

    return bedFile;
}
 
开发者ID:epam,项目名称:NGB,代码行数:19,代码来源:BedManager.java


示例2: getChromosomes

import htsjdk.tribble.bed.BEDCodec; //导入依赖的package包/类
/**
 * Gets the set (no duplicates) of chromosomes from a bed file.
 *
 * @param bedFilePath Path to the bed file.
 *
 * @return The set of chromosomes (no duplicates)
 *
 * @throws FileNotFoundException, IOException
 */
public static Set<String> getChromosomes(String bedFilePath) throws FileNotFoundException, IOException {
    Set<String> chrs = new LinkedHashSet<>();
    File bedFile = FileUtils.getFile(bedFilePath);
    try (InputStream is = new FileInputStream(bedFile);
            AsciiLineReader alr = new AsciiLineReader(is);
            LineIteratorImpl lineIterator = new LineIteratorImpl(alr);) {
        BEDCodec bc = new BEDCodec();
        while (!bc.isDone(lineIterator)) {
            BEDFeature bf = bc.decode(lineIterator);
            if (bf != null) {
                //see https://github.com/samtools/htsjdk/issues/197
                chrs.add(bf.getContig());
            }
        }
    }
    return chrs;
}
 
开发者ID:oicr-gsi,项目名称:gatk3,代码行数:27,代码来源:BEDFileUtils.java


示例3: getDetectCorrectFileFormatTestData

import htsjdk.tribble.bed.BEDCodec; //导入依赖的package包/类
@DataProvider(name = "DetectCorrectFileFormatTestData")
public Object[][] getDetectCorrectFileFormatTestData() {
    return new Object[][] {
            { new File(FEATURE_MANAGER_TEST_DIRECTORY + "minimal_vcf4_file.vcf"), VCFCodec.class },
            { new File(FEATURE_MANAGER_TEST_DIRECTORY + "minimal_vcf3_file.vcf"), VCF3Codec.class },
            { new File(FEATURE_MANAGER_TEST_DIRECTORY + "minimal_bcf_file.bcf"), BCF2Codec.class },
            { new File(FEATURE_MANAGER_TEST_DIRECTORY + "minimal_bed_file.bed"), BEDCodec.class},
            { new File(FEATURE_MANAGER_TEST_DIRECTORY + "minimal_table_file.table"), TableCodec.class}
    };
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:11,代码来源:FeatureManagerUnitTest.java


示例4: LongISLNDReadAlignmentMap

import htsjdk.tribble.bed.BEDCodec; //导入依赖的package包/类
public LongISLNDReadAlignmentMap(final Collection<String> readAlignmentMapFiles) throws IOException {
    for (final String readAlignmentMapFileName : readAlignmentMapFiles) {
        log.info("Reading in read map from " + readAlignmentMapFileName);
        final AbstractFeatureReader<BEDFeature, LineIterator> featureReader = AbstractFeatureReader.getFeatureReader(readAlignmentMapFileName, new BEDCodec(), false);
        try {
            final CloseableTribbleIterator<BEDFeature> featureIterator = featureReader.iterator();
            while (featureIterator.hasNext()) {
                final BEDFeature feature = featureIterator.next();
                readAlignmentMap.put(feature.getName(), new LongISLNDReadMapRecord(feature).toReadMapRecord());
            }
        } finally {
            featureReader.close();
        }
    }
}
 
开发者ID:bioinform,项目名称:varsim,代码行数:16,代码来源:LongISLNDReadAlignmentMap.java


示例5: getNumNonNBases

import htsjdk.tribble.bed.BEDCodec; //导入依赖的package包/类
public long getNumNonNBases(final File regions) throws IOException {
    long count = 0;

    final FeatureCodec<BEDFeature, LineIterator> bedCodec = new BEDCodec(BEDCodec.StartOffset.ONE);
    final LineIterator lineIterator = new AsciiLineReaderIterator(new AsciiLineReader(new FileInputStream(regions)));

    while (lineIterator.hasNext()) {
        final BEDFeature bedFeature = bedCodec.decode(lineIterator);
        count += data.get(new ChrString(bedFeature.getContig())).getNumNonNBases(bedFeature.getStart(), bedFeature.getEnd());
    }
    return count;
}
 
开发者ID:bioinform,项目名称:varsim,代码行数:13,代码来源:SimpleReference.java


示例6: BedFileAnnotator

import htsjdk.tribble.bed.BEDCodec; //导入依赖的package包/类
public BedFileAnnotator(BedAnnotationOptions options) {
	this.options = options;
	this.featureFile = new File(options.getPathBed());

	try {
		this.reader = new TabixFeatureReader<>(featureFile.getAbsolutePath().toString(),
				featureFile.getAbsolutePath().toString() + ".tbi", new BEDCodec());
	} catch (IOException e) {
		throw new RuntimeException("Problem opening indexed BED file", e);
	}
}
 
开发者ID:charite,项目名称:jannovar,代码行数:12,代码来源:BedFileAnnotator.java


示例7: testSortBed

import htsjdk.tribble.bed.BEDCodec; //导入依赖的package包/类
@Test
public void testSortBed() throws Exception {
    testSort(getTemplate("invalid/unsorted.bed"), new BEDCodec(), UNSORTED_BED_EXPECTED_LINES);
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:5,代码来源:SortTest.java


示例8: testSortBedCompressed

import htsjdk.tribble.bed.BEDCodec; //导入依赖的package包/类
@Test
public void testSortBedCompressed() throws Exception {
    testSort(getTemplate("genes_sorted.bed.gz"), new BEDCodec(), GENE_SORTED_BED_EXPECTED_LINES);
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:5,代码来源:SortTest.java


示例9: testSortBedCompressedOutOfMemory

import htsjdk.tribble.bed.BEDCodec; //导入依赖的package包/类
@Test
public void testSortBedCompressedOutOfMemory() throws Exception {
    testSort(getTemplate("big.bed.gz"), new BEDCodec(), BIG_BED_EXPECTED_LINES, 1);
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:5,代码来源:SortTest.java


示例10: BEDFileLookupFileImpl

import htsjdk.tribble.bed.BEDCodec; //导入依赖的package包/类
public BEDFileLookupFileImpl(final String bedFile) {
    reader = getFeatureReader(bedFile, new BEDCodec(), true);
}
 
开发者ID:hartwigmedical,项目名称:hmftools,代码行数:4,代码来源:BEDFileLookupFileImpl.java


示例11: doWork

import htsjdk.tribble.bed.BEDCodec; //导入依赖的package包/类
@Override
protected int doWork() {
    IOUtil.assertFileIsReadable(INPUT);
    IOUtil.assertFileIsReadable(SEQUENCE_DICTIONARY);
    IOUtil.assertFileIsWritable(OUTPUT);
    try {
        // create a new header that we will assign the dictionary provided by the SAMSequenceDictionaryExtractor to.
        final SAMFileHeader header = new SAMFileHeader();
        final SAMSequenceDictionary samSequenceDictionary = SAMSequenceDictionaryExtractor.extractDictionary(SEQUENCE_DICTIONARY.toPath());
        header.setSequenceDictionary(samSequenceDictionary);
        // set the sort order to be sorted by coordinate, which is actually done below
        // by getting the .uniqued() intervals list before we write out the file
        header.setSortOrder(SAMFileHeader.SortOrder.coordinate);
        final IntervalList intervalList = new IntervalList(header);

        /**
         * NB: BED is zero-based, but a BEDCodec by default (since it is returns tribble Features) has an offset of one,
         * so it returns 1-based starts.  Ugh.  Set to zero.
         */
        final FeatureReader<BEDFeature> bedReader = AbstractFeatureReader.getFeatureReader(INPUT.getAbsolutePath(), new BEDCodec(BEDCodec.StartOffset.ZERO), false);
        final CloseableTribbleIterator<BEDFeature> iterator = bedReader.iterator();
        final ProgressLogger progressLogger = new ProgressLogger(LOG, (int) 1e6);

        while (iterator.hasNext()) {
            final BEDFeature bedFeature = iterator.next();
            final String sequenceName = bedFeature.getContig();
            /**
             * NB: BED is zero-based, so we need to add one here to make it one-based.  Please observe we set the start
             * offset to zero when creating the BEDCodec.
             */
            final int start = bedFeature.getStart() + 1;
            /**
             * NB: BED is 0-based OPEN (which, for the end is equivalent to 1-based closed).
             */
            final int end = bedFeature.getEnd();
            // NB: do not use an empty name within an interval
            String name = bedFeature.getName();
            if (name.isEmpty()) name = null;

            final SAMSequenceRecord sequenceRecord = header.getSequenceDictionary().getSequence(sequenceName);

            // Do some validation
            if (null == sequenceRecord) {
                throw new PicardException(String.format("Sequence '%s' was not found in the sequence dictionary", sequenceName));
            } else if (start < 1) {
                throw new PicardException(String.format("Start on sequence '%s' was less than one: %d", sequenceName, start));
            } else if (sequenceRecord.getSequenceLength() < start) {
                throw new PicardException(String.format("Start on sequence '%s' was past the end: %d < %d", sequenceName, sequenceRecord.getSequenceLength(), start));
            } else if (end < 1) {
                throw new PicardException(String.format("End on sequence '%s' was less than one: %d", sequenceName, end));
            } else if (sequenceRecord.getSequenceLength() < end) {
                throw new PicardException(String.format("End on sequence '%s' was past the end: %d < %d", sequenceName, sequenceRecord.getSequenceLength(), end));
            } else if (end < start - 1) {
                throw new PicardException(String.format("On sequence '%s', end < start-1: %d <= %d", sequenceName, end, start));
            }

            final boolean isNegativeStrand = bedFeature.getStrand() == Strand.NEGATIVE;
            final Interval interval = new Interval(sequenceName, start, end, isNegativeStrand, name);
            intervalList.add(interval);

            progressLogger.record(sequenceName, start);
        }
        CloserUtil.close(bedReader);

        // Sort and write the output
        IntervalList out = intervalList;
        if (SORT) out = out.sorted();
        if (UNIQUE) out = out.uniqued();
        out.write(OUTPUT);

    } catch (final IOException e) {
        throw new RuntimeException(e);
    }

    return 0;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:77,代码来源:BedToIntervalList.java



注:本文中的htsjdk.tribble.bed.BEDCodec类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HieroSettings类代码示例发布时间:2022-05-22
下一篇:
Java ImageWriteException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap