当前位置: 首页>>代码示例>>Java>>正文


Java QueryInterval.optimizeIntervals方法代码示例

本文整理汇总了Java中htsjdk.samtools.QueryInterval.optimizeIntervals方法的典型用法代码示例。如果您正苦于以下问题:Java QueryInterval.optimizeIntervals方法的具体用法?Java QueryInterval.optimizeIntervals怎么用?Java QueryInterval.optimizeIntervals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在htsjdk.samtools.QueryInterval的用法示例。


在下文中一共展示了QueryInterval.optimizeIntervals方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareQueryIntervals

import htsjdk.samtools.QueryInterval; //导入方法依赖的package包/类
/**
 * Converts a List of SimpleIntervals into the format required by the SamReader query API
 * @param rawIntervals SimpleIntervals to be converted
 * @return A sorted, merged list of QueryIntervals suitable for passing to the SamReader query API
 */
static QueryInterval[] prepareQueryIntervals( final List<Interval>
		rawIntervals, final SAMSequenceDictionary sequenceDictionary ) {
	if ( rawIntervals == null || rawIntervals.isEmpty() ) {
		return null;
	}

	// Convert each SimpleInterval to a QueryInterval
	final QueryInterval[] convertedIntervals =
			rawIntervals.stream()
					.map(rawInterval -> convertSimpleIntervalToQueryInterval(rawInterval, sequenceDictionary))
					.toArray(QueryInterval[]::new);

	// Intervals must be optimized (sorted and merged) in order to use the htsjdk query API
	return QueryInterval.optimizeIntervals(convertedIntervals);
}
 
开发者ID:HadoopGenomics,项目名称:Hadoop-BAM,代码行数:21,代码来源:BAMInputFormat.java

示例2: prepareQueryIntervals

import htsjdk.samtools.QueryInterval; //导入方法依赖的package包/类
/**
 * Converts a List of SimpleIntervals into the format required by the SamReader query API
 * @param rawIntervals SimpleIntervals to be converted
 * @return A sorted, merged list of QueryIntervals suitable for passing to the SamReader query API
 */
private QueryInterval[] prepareQueryIntervals( final List<SimpleInterval> rawIntervals ) {
    if ( rawIntervals == null || rawIntervals.isEmpty() ) {
        return null;
    }

    // This might take a while with large interval lists, so log a status message
    logger.debug("Preparing intervals for traversal");

    // Convert each SimpleInterval to a QueryInterval
    final QueryInterval[] convertedIntervals =
            rawIntervals.stream()
            .map(rawInterval -> IntervalUtils.convertSimpleIntervalToQueryInterval(rawInterval, reader.getFileHeader().getSequenceDictionary()))
            .toArray(QueryInterval[]::new);

    // Intervals must be optimized (sorted and merged) in order to use the htsjdk query API
    return QueryInterval.optimizeIntervals(convertedIntervals);
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:23,代码来源:SamReaderQueryingIterator.java

示例3: extractSupportingReads

import htsjdk.samtools.QueryInterval; //导入方法依赖的package包/类
private List<SAMRecord> extractSupportingReads(
	final VariantContext ctx,
	final String sample,
	final SamReader reader,
	QueryInterval intervals[]
	) {
intervals = QueryInterval.optimizeIntervals(intervals);
final List<SAMRecord> L = new ArrayList<>();
final CloseableIterator<SAMRecord> iter= reader.query(intervals,false);
while(iter.hasNext())
	{
	final SAMRecord rec=iter.next();
	if(rec.getReadUnmappedFlag()) continue;
	if(rec.getDuplicateReadFlag()) continue;
	if(rec.getCigar()==null || rec.getCigar().isEmpty()) continue;
	final SAMReadGroupRecord rg = rec.getReadGroup();
	if(rg==null) continue;
	if(!sample.equals(rg.getSample())) continue;
	L.add(rec);
	}
iter.close();
return L;
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:24,代码来源:LumpyMoreSamples.java

示例4: getIntervalsFromBED

import htsjdk.samtools.QueryInterval; //导入方法依赖的package包/类
@NotNull
private static QueryInterval[] getIntervalsFromBED(@NotNull final String bedPath, @NotNull final SAMFileHeader header)
        throws IOException, EmptyFileException {
    final Slicer bedSlicer = SlicerFactory.fromBedFile(bedPath);
    final List<QueryInterval> queryIntervals = Lists.newArrayList();
    for (final GenomeRegion region : bedSlicer.regions()) {
        queryIntervals.add(new QueryInterval(header.getSequenceIndex(region.chromosome()), (int) region.start(), (int) region.end()));
    }
    return QueryInterval.optimizeIntervals(queryIntervals.toArray(new QueryInterval[queryIntervals.size()]));
}
 
开发者ID:hartwigmedical,项目名称:hmftools,代码行数:11,代码来源:BamSlicerApplication.java

示例5: processStructuralVariant

import htsjdk.samtools.QueryInterval; //导入方法依赖的package包/类
StructuralVariantResult processStructuralVariant(final HMFVariantContext ctx) throws IOException {

        final QueryInterval[] intervals = QueryInterval.optimizeIntervals(new QueryInterval[] {
                new QueryInterval(ctx.MantaBP1.ReferenceIndex, Math.max(0, ctx.MantaBP1.Position + ctx.Uncertainty1.Start - range),
                        ctx.MantaBP1.Position + ctx.Uncertainty1.End + range),
                new QueryInterval(ctx.MantaBP2.ReferenceIndex, Math.max(0, ctx.MantaBP2.Position + ctx.Uncertainty2.Start - range),
                        ctx.MantaBP2.Position + ctx.Uncertainty2.End + range) });

        final File TEMP_REF_BAM = queryNameSortedBAM(refReader, intervals, "ref");
        final File TEMP_TUMOR_BAM = queryNameSortedBAM(tumorReader, intervals, "tumor");

        final SamReader SORTED_REF_READER = SamReaderFactory.makeDefault().open(TEMP_REF_BAM);
        final SamReader SORTED_TUMOR_READER = SamReaderFactory.makeDefault().open(TEMP_TUMOR_BAM);

        final BreakpointResult breakpoints = determineBreakpoints(ctx, SORTED_TUMOR_READER);

        final StructuralVariantResult result = new StructuralVariantResult();
        result.Breakpoints = breakpoints.Breakpoints;
        result.QueryIntervals = intervals;

        if (breakpoints.Error != BreakpointError.NONE) {
            result.Filters = Filter.getErrorFilter();
        } else {
            result.TumorStats = collectEvidence(ctx, SORTED_TUMOR_READER, result.Breakpoints);
            result.RefStats = collectEvidence(ctx, SORTED_REF_READER, result.Breakpoints);
            result.AlleleFrequency = AlleleFrequency.calculate(result.TumorStats);

            // load sample clipping
            SORTED_TUMOR_READER.forEach(r -> Clipping.getClips(r).forEach(c -> result.TumorStats.Sample_Clipping.add(c)));
            SORTED_REF_READER.forEach(r -> Clipping.getClips(r).forEach(c -> result.RefStats.Sample_Clipping.add(c)));

            result.Filters = Filter.getFilters(ctx, result.TumorStats, result.RefStats, result.Breakpoints, contamination);

            // adjust for homology
            final Location bp1 = result.Breakpoints.getLeft().add(ctx.OrientationBP1 > 0 ? 0 : -1);
            final Location bp2;
            if (!ctx.isInsert() && ctx.InsertSequence.isEmpty()) {
                bp2 = result.Breakpoints.getRight()
                        .add(-ctx.OrientationBP2 * ctx.HomologySequence.length())
                        .add(ctx.OrientationBP2 > 0 ? 0 : -1);
            } else {
                bp2 = result.Breakpoints.getRight().add(ctx.OrientationBP2 > 0 ? 0 : -1);
            }
            result.Breakpoints = Pair.of(bp1, bp2);
        }

        result.FilterString = result.Filters.isEmpty() ? "PASS" : String.join(";", result.Filters);

        // clean up
        SORTED_REF_READER.close();
        SORTED_TUMOR_READER.close();

        if (!TEMP_REF_BAM.delete()) {
            LOGGER.error("couldn't delete {}", TEMP_REF_BAM);
        }
        if (!TEMP_TUMOR_BAM.delete()) {
            LOGGER.error("couldn't delete {}", TEMP_TUMOR_BAM);
        }

        return result;
    }
 
开发者ID:hartwigmedical,项目名称:hmftools,代码行数:62,代码来源:Analysis.java


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