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


Java Interval.isNegativeStrand方法代码示例

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


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

示例1: doWork

import htsjdk.samtools.util.Interval; //导入方法依赖的package包/类
@Override
protected int doWork() {
    IOUtil.assertFileIsReadable(INPUT);
    IOUtil.assertFileIsWritable(OUTPUT);

    IntervalList intervals = IntervalList.fromFile(INPUT);
    if (SORT) intervals = intervals.sorted();

    try {
        final BufferedWriter out = IOUtil.openFileForBufferedWriting(OUTPUT);
        for (final Interval i : intervals) {
            final String strand = i.isNegativeStrand() ? "-" : "+";
            final List<?> fields = CollectionUtil.makeList(i.getContig(), i.getStart()-1, i.getEnd(), i.getName(), SCORE, strand);
            out.append(fields.stream().map(String::valueOf).collect(Collectors.joining("\t")));
            out.newLine();
        }

        out.close();
    }
    catch (IOException ioe) {
        throw new RuntimeIOException(ioe);
    }

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

示例2: design

import htsjdk.samtools.util.Interval; //导入方法依赖的package包/类
@Override
List<Bait> design(final BaitDesigner designer, final Interval target, final ReferenceSequence reference) {
    final List<Bait> baits = new LinkedList<Bait>();
    final int baitSize = designer.BAIT_SIZE;
    final int baitOffset = designer.BAIT_OFFSET;
    final int lastPossibleBaitStart = Math.min(target.getEnd(), reference.length() - baitSize);
    final int baitCount = 1 + (int) Math.floor((lastPossibleBaitStart - target.getStart()) / (double) baitOffset);

    int i = 0;
    for (int start = target.getStart(); start < lastPossibleBaitStart; start += baitOffset) {
        final Bait bait = new Bait(target.getContig(),
                start,
                CoordMath.getEnd(start, baitSize),
                target.isNegativeStrand(),
                designer.makeBaitName(target.getName(), ++i, baitCount));
        bait.addBases(reference, designer.DESIGN_ON_TARGET_STRAND);
        baits.add(bait);
    }
    return baits;
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:21,代码来源:BaitDesigner.java

示例3: liftVariant

import htsjdk.samtools.util.Interval; //导入方法依赖的package包/类
/**
 * This will take an input VariantContext and lift to the provided interval.
 * If this interval is in the opposite orientation, all alleles and genotypes will be reverse complemented
 * and indels will be left-aligned.  Currently this is only able to invert biallelic indels, and null will be
 * returned for any unsupported VC.
 * @param source The VariantContext to lift
 * @param target The target interval
 * @param refSeq The reference sequence, which should match the target interval
 * @param writeOriginalPosition If true, INFO field annotations will be added to store the original position and contig
 * @return The lifted VariantContext.  This will be null if the input VariantContext could not be lifted.
 */
public static VariantContext liftVariant(final VariantContext source, final Interval target, final ReferenceSequence refSeq, final boolean writeOriginalPosition){
    if (target == null) {
        return null;
    }

    final VariantContextBuilder builder;
    if (target.isNegativeStrand()) {
        builder = reverseComplementVariantContext(source, target, refSeq);
    } else {
        builder = liftSimpleVariantContext(source, target);
    }

    if (builder == null) {
        return null;
    }

    builder.filters(source.getFilters());
    builder.log10PError(source.getLog10PError());
    builder.attributes(source.getAttributes());
    // make sure that the variant isn't mistakenly set as "SwappedAlleles"
    builder.rmAttribute(SWAPPED_ALLELES);
    if (target.isNegativeStrand()) {
        builder.attribute(REV_COMPED_ALLELES, true);
    } else {
        // make sure that the variant isn't mistakenly set as "ReverseComplementedAlleles" (from a previous liftover, say)
        builder.rmAttribute(REV_COMPED_ALLELES);
    }

    builder.id(source.getID());

    if (writeOriginalPosition) {
        builder.attribute(LiftoverVcf.ORIGINAL_CONTIG, source.getContig());
        builder.attribute(LiftoverVcf.ORIGINAL_START, source.getStart());
    }

    return builder.make();
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:49,代码来源:LiftoverUtils.java

示例4: doWork

import htsjdk.samtools.util.Interval; //导入方法依赖的package包/类
@Override
protected int doWork() {
    IOUtil.assertFileIsReadable(INTERVAL_LIST);
    IOUtil.assertFileIsReadable(REFERENCE_SEQUENCE);
    IOUtil.assertFileIsWritable(OUTPUT);

    final IntervalList intervals = IntervalList.fromFile(INTERVAL_LIST);
    final ReferenceSequenceFile ref = ReferenceSequenceFileFactory.getReferenceSequenceFile(REFERENCE_SEQUENCE);
    SequenceUtil.assertSequenceDictionariesEqual(intervals.getHeader().getSequenceDictionary(), ref.getSequenceDictionary());

    final BufferedWriter out = IOUtil.openFileForBufferedWriting(OUTPUT);

    for (final Interval interval : intervals) {
        final ReferenceSequence seq = ref.getSubsequenceAt(interval.getContig(), interval.getStart(), interval.getEnd());
        final byte[] bases = seq.getBases();
        if (interval.isNegativeStrand()) SequenceUtil.reverseComplement(bases);

        try {
            out.write(">");
            out.write(interval.getName());
            out.write("\n");

            for (int i=0; i<bases.length; ++i) {
                if (i > 0 && i % LINE_LENGTH == 0) out.write("\n");
                out.write(bases[i]);
            }

            out.write("\n");
        }
        catch (IOException ioe) {
            throw new PicardException("Error writing to file " + OUTPUT.getAbsolutePath(), ioe);

        }
    }

    CloserUtil.close(out);

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

示例5: testFlipIndel

import htsjdk.samtools.util.Interval; //导入方法依赖的package包/类
@Test(dataProvider = "indelFlipData")
public void testFlipIndel(final VariantContext source, final ReferenceSequence reference, final VariantContext result) {

    final LiftOver liftOver = new LiftOver(CHAIN_FILE);
    final Interval originalLocus = new Interval(source.getContig(), source.getStart(), source.getEnd());
    final Interval target = liftOver.liftOver(originalLocus);
    if (target != null && !target.isNegativeStrand()) {
        throw new RuntimeException("not reversed");
    }

    final VariantContext flipped = LiftoverUtils.liftVariant(source, target, reference, false);

    VcfTestUtils.assertEquals(flipped, result);
}
 
开发者ID:broadinstitute,项目名称:picard,代码行数:15,代码来源:LiftoverVcfTest.java


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