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


Java Allele.isSymbolic方法代码示例

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


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

示例1: typeOfBiallelicVariant

import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
private static VariantContext.Type typeOfBiallelicVariant(Allele ref, Allele allele) {
    if (ref.isSymbolic()) {
        throw new IllegalStateException("Unexpected error: encountered a record with a symbolic reference allele");
    }
    if (allele.isSymbolic()) {
        return VariantContext.Type.SYMBOLIC;
    }
    if (ref.length() == allele.length()) {
        if (allele.length() == 1) {
            return VariantContext.Type.SNP;
        } else {
            return VariantContext.Type.MNP;
        }
    }

    return VariantContext.Type.INDEL;
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:18,代码来源:VcfGa4ghReader.java

示例2: 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

示例3: trimAlleles

import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
/**
 * Trim up alleles in inputVC, cutting out all bases up to fwdTrimEnd inclusive and
 * the last revTrim bases from the end
 *
 * @param inputVC a non-null input VC
 * @param fwdTrimEnd bases up to this index (can be -1) will be removed from the start of all alleles
 * @param revTrim the last revTrim bases of each allele will be clipped off as well
 * @return a non-null VariantContext (may be == to inputVC) with trimmed up alleles
 */
protected static VariantContext trimAlleles(final VariantContext inputVC,
                                            final int fwdTrimEnd,
                                            final int revTrim) {
    if( fwdTrimEnd == -1 && revTrim == 0 ) // nothing to do, so just return inputVC unmodified
        return inputVC;

    final List<Allele> alleles = new LinkedList<>();
    final Map<Allele, Allele> originalToTrimmedAlleleMap = new HashMap<>();

    for (final Allele a : inputVC.getAlleles()) {
        if (a.isSymbolic()) {
            alleles.add(a);
            originalToTrimmedAlleleMap.put(a, a);
        } else {
            // get bases for current allele and create a new one with trimmed bases
            final byte[] newBases = Arrays.copyOfRange(a.getBases(), fwdTrimEnd+1, a.length()-revTrim);
            final Allele trimmedAllele = Allele.create(newBases, a.isReference());
            alleles.add(trimmedAllele);
            originalToTrimmedAlleleMap.put(a, trimmedAllele);
        }
    }

    // now we can recreate new genotypes with trimmed alleles
    final AlleleMapper alleleMapper = new AlleleMapper(originalToTrimmedAlleleMap);
    final GenotypesContext genotypes = updateGenotypesWithMappedAlleles(inputVC.getGenotypes(), alleleMapper);

    final int start = inputVC.getStart() + (fwdTrimEnd + 1);
    final VariantContextBuilder builder = new VariantContextBuilder(inputVC);
    builder.start(start);
    builder.stop(start + alleles.get(0).length() - 1);
    builder.alleles(alleles);
    builder.genotypes(genotypes);
    return builder.make();
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:44,代码来源:GATKVariantContextUtils.java

示例4: 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

示例5: 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

示例6: 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

示例7: isUsableAlternateAllele

import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
static private boolean isUsableAlternateAllele(final Allele allele) {
    return ! (allele.isReference() || allele.isSymbolic() );
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:4,代码来源:GATKVariantContextUtils.java


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