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


Java Allele.getBases方法代码示例

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


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

示例1: getMeanAltAlleleLength

import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
/**
 * Refactored out of the AverageAltAlleleLength annotation class
 * @param vc the variant context
 * @return the average length of the alt allele (a double)
 */
public static double getMeanAltAlleleLength(VariantContext vc) {
    double averageLength = 1.0;
    if ( ! vc.isSNP() && ! vc.isSymbolic() ) {
        // adjust for the event length
        int averageLengthNum = 0;
        int averageLengthDenom = 0;
        int refLength = vc.getReference().length();
        for ( final Allele a : vc.getAlternateAlleles() ) {
            int numAllele = vc.getCalledChrCount(a);
            int alleleSize;
            if ( a.length() == refLength ) {
                // SNP or MNP
                byte[] a_bases = a.getBases();
                byte[] ref_bases = vc.getReference().getBases();
                int n_mismatch = 0;
                for ( int idx = 0; idx < a_bases.length; idx++ ) {
                    if ( a_bases[idx] != ref_bases[idx] )
                        n_mismatch++;
                }
                alleleSize = n_mismatch;
            }
            else if ( a.isSymbolic() ) {
                alleleSize = 1;
            } else {
                alleleSize = Math.abs(refLength-a.length());
            }
            averageLengthNum += alleleSize*numAllele;
            averageLengthDenom += numAllele;
        }
        averageLength = ( (double) averageLengthNum )/averageLengthDenom;
    }

    return averageLength;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:40,代码来源:GATKVariantContextUtils.java

示例2: computeReverseClipping

import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
public static int computeReverseClipping(final List<Allele> unclippedAlleles, final byte[] ref) {
    int clipping = 0;
    boolean stillClipping = true;

    while ( stillClipping ) {
        for ( final Allele a : unclippedAlleles ) {
            if ( a.isSymbolic() )
                continue;

            // we need to ensure that we don't reverse clip out all of the bases from an allele because we then will have the wrong
            // position set for the VariantContext (although it's okay to forward clip it all out, because the position will be fine).
            if ( a.length() - clipping == 0 )
                return clipping - 1;

            if ( a.length() - clipping <= 0 || a.length() == 0 ) {
                stillClipping = false;
            }
            else if ( ref.length == clipping ) {
                return -1;
            }
            else if ( a.getBases()[a.length()-clipping-1] != ref[ref.length-clipping-1] ) {
                stillClipping = false;
            }
        }
        if ( stillClipping )
            clipping++;
    }

    return clipping;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:31,代码来源:GATKVariantContextUtils.java

示例3: computeForwardClipping

import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
/**
 * Clip out any unnecessary bases off the front of the alleles
 *
 * The VCF spec represents alleles as block substitutions, replacing AC with A for a
 * 1 bp deletion of the C.  However, it's possible that we'd end up with alleles that
 * contain extra bases on the left, such as GAC/GA to represent the same 1 bp deletion.
 * This routine finds an offset among all alleles that can be safely trimmed
 * off the left of each allele and still represent the same block substitution.
 *
 * A/C => A/C
 * AC/A => AC/A
 * ACC/AC => CC/C
 * AGT/CAT => AGT/CAT
 * <DEL>/C => <DEL>/C
 *
 * @param unclippedAlleles a non-null list of alleles that we want to clip
 * @return the offset into the alleles where we can safely clip, inclusive, or
 *   -1 if no clipping is tolerated.  So, if the result is 0, then we can remove
 *   the first base of every allele.  If the result is 1, we can remove the
 *   second base.
 */
public static int computeForwardClipping(final List<Allele> unclippedAlleles) {
    // cannot clip unless there's at least 1 alt allele
    if ( unclippedAlleles.size() <= 1 )
        return -1;

    // we cannot forward clip any set of alleles containing a symbolic allele
    int minAlleleLength = Integer.MAX_VALUE;
    for ( final Allele a : unclippedAlleles ) {
        if ( a.isSymbolic() )
            return -1;
        minAlleleLength = Math.min(minAlleleLength, a.length());
    }

    final byte[] firstAlleleBases = unclippedAlleles.get(0).getBases();
    int indexOflastSharedBase = -1;

    // the -1 to the stop is that we can never clip off the right most base
    for ( int i = 0; i < minAlleleLength - 1; i++) {
        final byte base = firstAlleleBases[i];

        for ( final Allele allele : unclippedAlleles ) {
            if ( allele.getBases()[i] != base )
                return indexOflastSharedBase;
        }

        indexOflastSharedBase = i;
    }

    return indexOflastSharedBase;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:52,代码来源:GATKVariantContextUtils.java

示例4: remapAlleles

import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
/**
 * This method does a couple of things:
 * <ul><li>
 *     remaps the vc alleles considering the differences between the final reference allele and its own reference,</li>
 * <li>
 *     collects alternative alleles present in variant context and add them to the {@code finalAlleles} set.
 * </li></ul>
 *
 * @param vcAlleles the variant context allele list.
 * @param refAllele final reference allele.
 * @param finalAlleles where to add the final set of non-ref called alleles.
 * @return never {@code null}
 */
//TODO as part of a larger refactoring effort {@link #remapAlleles} can be merged with {@link GATKVariantContextUtils#remapAlleles}.
private static List<Allele> remapAlleles(final List<Allele> vcAlleles, final Allele refAllele, final LinkedHashSet<Allele> finalAlleles) {
    final Allele vcRef = vcAlleles.get(0);
    if (!vcRef.isReference()) throw new IllegalStateException("the first allele of the vc allele list must be reference");
    final byte[] refBases = refAllele.getBases();
    final int extraBaseCount = refBases.length - vcRef.getBases().length;
    if (extraBaseCount < 0) throw new IllegalStateException("the wrong reference was selected");
    final List<Allele> result = new ArrayList<>(vcAlleles.size());

    for (final Allele a : vcAlleles) {
        if (a.isReference()) {
            result.add(refAllele);
        } else if (a.isSymbolic()) {
            result.add(a);
            // we always skip <NON_REF> when adding to finalAlleles this is done outside if applies.
            if (!a.equals(GATKVariantContextUtils.NON_REF_SYMBOLIC_ALLELE))
                finalAlleles.add(a);
        } else if (a.isCalled()) {
            final Allele newAllele;
            if (extraBaseCount > 0) {
                final byte[] oldBases = a.getBases();
                final byte[] newBases = Arrays.copyOf(oldBases,oldBases.length + extraBaseCount);
                System.arraycopy(refBases,refBases.length - extraBaseCount,newBases,oldBases.length,extraBaseCount);
                newAllele = Allele.create(newBases,false);
            } else
                newAllele = a;
            result.add(newAllele);
            finalAlleles.add(newAllele);
        } else { // NO_CALL and strange miscellanea
            result.add(a);
        }
    }
    return result;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:48,代码来源:ReferenceConfidenceVariantContextMerger.java

示例5: pileupElementMatches

import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
public static boolean pileupElementMatches(PileupElement pileupElement, Allele allele, Allele refAllele, byte refBase) {
    if (DEBUG)
        System.out.format("PE: base:%s isNextToDel:%b isNextToIns:%b eventBases:%s eventLength:%d Allele:%s RefAllele:%s\n",
                pileupElement.getBase(), pileupElement.isBeforeDeletionStart(),
                pileupElement.isBeforeInsertion(), pileupElement.getBasesOfImmediatelyFollowingInsertion(), pileupElement.getLengthOfImmediatelyFollowingIndel(), allele.toString(), refAllele.toString());

    //pileupElement.
    // if test allele is ref, any base mismatch, or any insertion/deletion at start of pileup count as mismatch
    if (allele.isReference()) {
        // for a ref allele, any base mismatch or new indel is a mismatch.
        if (allele.getBases().length > 0)
            // todo - can't check vs. allele because allele is not padded so it doesn't include the reference base at this location
            // could clean up/simplify this when unpadding is removed
            return (pileupElement.getBase() == refBase && !pileupElement.isBeforeInsertion() && !pileupElement.isBeforeDeletionStart());
        else
            // either null allele to compare, or ref/alt lengths are different (indel by definition).
            // if we have an indel that we are comparing against a REF allele, any indel presence (of any length/content) is a mismatch
            return (!pileupElement.isBeforeInsertion() && !pileupElement.isBeforeDeletionStart());
    }

    // for non-ref alleles to compare:
    if (refAllele.getBases().length == allele.getBases().length)
        // alleles have the same length (eg snp or mnp)
        return pileupElement.getBase() == allele.getBases()[0];

    // for non-ref alleles,
    byte[] alleleBases = allele.getBases();
    int eventLength = alleleBases.length - refAllele.getBases().length;
    if (eventLength < 0 && pileupElement.isBeforeDeletionStart() && pileupElement.getLengthOfImmediatelyFollowingIndel() == -eventLength)
        return true;

    if (eventLength > 0 && pileupElement.isBeforeInsertion() &&
            Arrays.equals(pileupElement.getBasesOfImmediatelyFollowingInsertion().getBytes(), Arrays.copyOfRange(alleleBases, 1, alleleBases.length))) // allele contains ref byte, but pileupElement's event bases doesn't
        return true;

    return false;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:38,代码来源:ErrorModel.java

示例6: getInitialAlleleList

import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
public static List<Allele> getInitialAlleleList(final RefMetaDataTracker tracker,
                                                final ReferenceContext ref,
                                                final Map<String, AlignmentContext> contexts,
                                                final AlignmentContextUtils.ReadOrientation contextType,
                                                final UnifiedArgumentCollection UAC,
                                                final boolean ignoreSNPAllelesWhenGenotypingIndels) {

    List<Allele> alleles = new ArrayList<Allele>();
    if (UAC.genotypingOutputMode == GenotypingOutputMode.GENOTYPE_GIVEN_ALLELES) {
        VariantContext vc = null;
        for (final VariantContext vc_input : tracker.getValues(UAC.alleles, ref.getLocus())) {
            if (vc_input != null &&
                    allowableTypes.contains(vc_input.getType()) &&
                    ref.getLocus().getStart() == vc_input.getStart()) {
                vc = vc_input;
                break;
            }
        }
        // ignore places where we don't have a variant
        if (vc == null)
            return alleles;

        if (ignoreSNPAllelesWhenGenotypingIndels) {
            // if there's an allele that has same length as the reference (i.e. a SNP or MNP), ignore it and don't genotype it
            for (Allele a : vc.getAlleles())
                if (a.isNonReference() && a.getBases().length == vc.getReference().getBases().length)
                    continue;
                else
                    alleles.add(a);

        } else {
            alleles.addAll(vc.getAlleles());
        }

    } else {
        alleles = computeConsensusAlleles(ref, contexts, contextType, UAC);
    }
    return alleles;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:40,代码来源:IndelGenotypeLikelihoodsCalculationModel.java


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