本文整理汇总了Java中htsjdk.variant.variantcontext.Allele.length方法的典型用法代码示例。如果您正苦于以下问题:Java Allele.length方法的具体用法?Java Allele.length怎么用?Java Allele.length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.variant.variantcontext.Allele
的用法示例。
在下文中一共展示了Allele.length方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: determineReferenceAllele
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
/**
* Determines the common reference allele
*
* @param VCs the list of VariantContexts
* @param loc if not null, ignore records that do not begin at this start location
* @return possibly null Allele
*/
public static Allele determineReferenceAllele(final List<VariantContext> VCs, final GenomeLoc loc) {
Allele ref = null;
for ( final VariantContext vc : VCs ) {
if ( contextMatchesLoc(vc, loc) ) {
final Allele myRef = vc.getReference();
if ( ref == null || ref.length() < myRef.length() )
ref = myRef;
else if ( ref.length() == myRef.length() && ! ref.equals(myRef) )
throw new TribbleException(String.format("The provided variant file(s) have inconsistent references for the same position(s) at %s:%d, %s vs. %s", vc.getChr(), vc.getStart(), ref, myRef));
}
}
return ref;
}
示例2: createAlleleMapping
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
/**
* Create an allele mapping for the given context where its reference allele must (potentially) be extended to the given allele
*
* The refAllele is the longest reference allele seen at this start site.
* So imagine it is:
* refAllele: ACGTGA
* myRef: ACGT
* myAlt: A
*
* We need to remap all of the alleles in vc to include the extra GA so that
* myRef => refAllele and myAlt => AGA
*
* @param refAllele the new (extended) reference allele
* @param oneVC the Variant Context to extend
* @param currentAlleles the list of alleles already created
* @return a non-null mapping of original alleles to new (extended) ones
*/
private static Map<Allele, Allele> createAlleleMapping(final Allele refAllele,
final VariantContext oneVC,
final Collection<Allele> currentAlleles) {
final Allele myRef = oneVC.getReference();
if ( refAllele.length() <= myRef.length() ) throw new IllegalStateException("BUG: myRef="+myRef+" is longer than refAllele="+refAllele);
final byte[] extraBases = Arrays.copyOfRange(refAllele.getBases(), myRef.length(), refAllele.length());
final Map<Allele, Allele> map = new HashMap<>();
for ( final Allele a : oneVC.getAlternateAlleles() ) {
if ( isUsableAlternateAllele(a) ) {
Allele extended = Allele.extend(a, extraBases);
for ( final Allele b : currentAlleles )
if ( extended.equals(b) )
extended = b;
map.put(a, extended);
}
}
return map;
}
示例3: 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;
}
示例4: getVariationTypeForSimpleInDels
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
@NotNull private static VariationType getVariationTypeForSimpleInDels(VariantContext context,
Genotype genotype) {
Allele firstAllele = genotype.getAllele(0);
Allele secondAllele = genotype.getAllele(1);
VariationType type;
if (firstAllele.isNonReference() && secondAllele.isNonReference()) {
// if both are alt
if (firstAllele.length() > context.getReference().length()
&& secondAllele.length() > context.getReference().length()) {
type = VariationType.INS;
} else if (firstAllele.length() < context.getReference().length() &&
secondAllele.length() < context.getReference().length()) {
type = VariationType.DEL;
} else {
type = VariationType.MIXED;
}
} else {
// if both are ref
type = VariationType.MIXED;
}
return type;
}
示例5: getVariationTypeForComplexInDels
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
@NotNull private static VariationType getVariationTypeForComplexInDels(Genotype genotype) {
Allele firstAllele = genotype.getAllele(0);
Allele secondAllele = genotype.getAllele(1);
if (firstAllele.length() == secondAllele.length()) { // if it is a change
return firstAllele.length() == 1 ? VariationType.SNV : VariationType.MNP;
}
VariationType type;
if (firstAllele.isReference()) { // if it is an insertion/deletion
type = genotype.getAlleles().get(0).length() > genotype.getAlleles().get(1).length() ?
VariationType.DEL : VariationType.INS;
} else if (secondAllele.isReference()) {
type = genotype.getAlleles().get(1).length() > genotype.getAlleles().get(0).length() ?
VariationType.DEL : VariationType.INS;
} else {
type = VariationType.MIXED;
}
return type;
}
示例6: 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;
}
示例7: isRepeatAllele
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
/**
* Helper function for isTandemRepeat that checks that allele matches somewhere on the reference
* @param ref
* @param alt
* @param refBasesStartingAtVCWithoutPad
* @return
*/
protected static boolean isRepeatAllele(final Allele ref, final Allele alt, final String refBasesStartingAtVCWithoutPad) {
if ( ! Allele.oneIsPrefixOfOther(ref, alt) )
return false; // we require one allele be a prefix of another
if ( ref.length() > alt.length() ) { // we are a deletion
return basesAreRepeated(ref.getBaseString(), alt.getBaseString(), refBasesStartingAtVCWithoutPad, 2);
} else { // we are an insertion
return basesAreRepeated(alt.getBaseString(), ref.getBaseString(), refBasesStartingAtVCWithoutPad, 1);
}
}
示例8: 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;
}
示例9: insertAllele
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
public Haplotype insertAllele(final Allele refAllele, final Allele altAllele, final int refInsertLocation, final int genomicInsertLocation) {
// refInsertLocation is in ref haplotype offset coordinates NOT genomic coordinates
final int haplotypeInsertLocation = ReadUtils.getReadCoordinateForReferenceCoordinate(alignmentStartHapwrtRef, cigar, refInsertLocation, ReadUtils.ClippingTail.RIGHT_TAIL, true);
final byte[] myBases = this.getBases();
if (haplotypeInsertLocation == -1 || haplotypeInsertLocation + refAllele.length() >= myBases.length) { // desired change falls inside deletion so don't bother creating a new haplotype
return null;
}
byte[] newHaplotypeBases = new byte[]{};
newHaplotypeBases = ArrayUtils.addAll(newHaplotypeBases, ArrayUtils.subarray(myBases, 0, haplotypeInsertLocation)); // bases before the variant
newHaplotypeBases = ArrayUtils.addAll(newHaplotypeBases, altAllele.getBases()); // the alt allele of the variant
newHaplotypeBases = ArrayUtils.addAll(newHaplotypeBases, ArrayUtils.subarray(myBases, haplotypeInsertLocation + refAllele.length(), myBases.length)); // bases after the variant
return new Haplotype(newHaplotypeBases);
}
示例10: findMaxAlleleLength
import htsjdk.variant.variantcontext.Allele; //导入方法依赖的package包/类
private int findMaxAlleleLength(final List<? extends Allele> alleles) {
int max = 0;
for (final Allele allele : alleles) {
final int alleleLength = allele.length();
if (max < alleleLength)
max = alleleLength;
}
return max;
}