本文整理汇总了Java中htsjdk.variant.variantcontext.StructuralVariantType类的典型用法代码示例。如果您正苦于以下问题:Java StructuralVariantType类的具体用法?Java StructuralVariantType怎么用?Java StructuralVariantType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StructuralVariantType类属于htsjdk.variant.variantcontext包,在下文中一共展示了StructuralVariantType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBreakPointIntervals
import htsjdk.variant.variantcontext.StructuralVariantType; //导入依赖的package包/类
/**
* Returns break point intervals for this structural variant.
* <p>
* Typically the break point interval would be located between two point locations in the reference genome.
* In that case this method will return {@code padding} bases up- and down-stream from that
* inter-base position.
* </p>
* <p>
* In case the padding is set to zero, since the 0-length interval is not valid, this method would
* return an interval including the base just before the break-point.
* </p>
* <p>
* If padForHomology is set, the breakpoint interval will include the region specified as homologous
* sequence in the HOMOLOGY_LENGTH attribute of VariantContext, in addition to the
* normal padding specified in the first parameter.
* </p>
*
* @param padding the padding around the exact location of the break point to be included in the padded interval.
* @param dictionary reference meta-data.
* @param padForHomology Add homologous sequence around the breakpoint to the interval
* @return never {@code null}, potentially 0-length but typically at least one element.
*/
public List<SimpleInterval> getBreakPointIntervals(final int padding,
final SAMSequenceDictionary dictionary,
final boolean padForHomology) {
ParamUtils.isPositiveOrZero(padding, "the input padding must be 0 or greater");
Utils.nonNull(dictionary, "the input dictionary cannot be null");
final String contigName = getContig();
final int contigLength = dictionary.getSequence(contigName).getSequenceLength();
final StructuralVariantType type = getStructuralVariantType();
final int start = getStart();
if (type == StructuralVariantType.INS) {
return Collections.singletonList(
composePaddedInterval(contigName, contigLength, start, start, padding));
} else if (type == StructuralVariantType.DEL) {
final int end = getEnd();
final int homologyPadding = (padForHomology ? getAttributeAsInt(GATKSVVCFConstants.HOMOLOGY_LENGTH, 0) : 0);
return Arrays.asList(
composePaddedInterval(contigName, contigLength, start + 1,
start + 1 + homologyPadding, padding),
composePaddedInterval(contigName, contigLength, end,
end + homologyPadding, padding));
} else {
// Please, add more types as needed!
throw new UnsupportedOperationException("currently only supported for INS and DELs");
}
}
示例2: getPairedStrandedIntervals
import htsjdk.variant.variantcontext.StructuralVariantType; //导入依赖的package包/类
public PairedStrandedIntervals getPairedStrandedIntervals(final ReadMetadata metadata, final SAMSequenceDictionary referenceSequenceDictionary, final int padding) {
final StructuralVariantType type = getStructuralVariantType();
if (type == StructuralVariantType.DEL) {
final List<SimpleInterval> breakPointIntervals = getBreakPointIntervals(padding, referenceSequenceDictionary, true);
final SimpleInterval leftBreakpointSimpleInterval = breakPointIntervals.get(0);
final SVInterval leftBreakpointInterval = new SVInterval(
metadata.getContigID(leftBreakpointSimpleInterval.getContig()),
leftBreakpointSimpleInterval.getStart(),
leftBreakpointSimpleInterval.getEnd() + 1);
final SimpleInterval rightBreakpointSimpleInterval = breakPointIntervals.get(1);
final SVInterval rightBreakpointInterval = new SVInterval(
metadata.getContigID(rightBreakpointSimpleInterval.getContig()),
rightBreakpointSimpleInterval.getStart(),
rightBreakpointSimpleInterval.getEnd() + 1);
return new PairedStrandedIntervals(new StrandedInterval(leftBreakpointInterval, true),
new StrandedInterval(rightBreakpointInterval, false));
} else {
throw new UnsupportedOperationException("currently only supported for DELs");
}
}
示例3: testGetBreakPoints
import htsjdk.variant.variantcontext.StructuralVariantType; //导入依赖的package包/类
private void testGetBreakPoints(final VariantContext vc, final ReferenceMultiSource reference, final int paddingSize) throws IOException {
final SVContext svc = SVContext.of(vc);
if (svc.getStructuralVariantType() != StructuralVariantType.INS && svc.getStructuralVariantType() != StructuralVariantType.DEL) {
throw new SkipException("unsupported type; skipped for now");
}
final List<SimpleInterval> breakPoints = svc.getBreakPointIntervals(paddingSize, reference.getReferenceSequenceDictionary(null), false);
final int contigLength = reference.getReferenceSequenceDictionary(null).getSequence(vc.getContig()).getSequenceLength();
final List<Integer> expectedOffsets = new ArrayList<>();
if (svc.getStructuralVariantType() == StructuralVariantType.INS) {
expectedOffsets.add(vc.getStart());
} else if (svc.getStructuralVariantType() == StructuralVariantType.DEL) {
expectedOffsets.add(vc.getStart() + 1);
expectedOffsets.add(vc.getEnd());
}
final List<SimpleInterval> expectedBreakPoints = expectedOffsets.stream()
.map(i -> new SimpleInterval(vc.getContig(), Math.max(1, paddingSize > 0 ? (i - paddingSize + 1) : i),
Math.min(contigLength, i + paddingSize)))
.collect(Collectors.toList());
Assert.assertEquals(breakPoints, expectedBreakPoints);
}
示例4: entryToObject
import htsjdk.variant.variantcontext.StructuralVariantType; //导入依赖的package包/类
@Override
public KeySorter entryToObject(final TupleInput in) {
final KeySorter ks= new KeySorter();
ks.st = this.sttypes[(int)in.readByte()];
ks.contig1= in.readString();
if(ks.st.equals(StructuralVariantType.BND)) {
ks.contig2= in.readString();
}
else
{
ks.contig2= ks.contig1;
}
ks.start = in.readInt();
ks.end = in.readInt();
ks.id = in.readLong();
return ks;
}
示例5: getSortKey
import htsjdk.variant.variantcontext.StructuralVariantType; //导入依赖的package包/类
private KeySorter getSortKey() {
if(_sortKey==null) {
final Function<String,String> normalize=C->C.startsWith("chr")?C.substring(3):C;
final Interval rgn = getInterval() ;
_sortKey = new KeySorter();
_sortKey.st = this.ctx.getStructuralVariantType();
_sortKey.contig1 = normalize.apply(rgn.getContig());
if(_sortKey.st.equals(StructuralVariantType.BND)) {
_sortKey.contig2 = normalize.apply(LumpyConstants.getBnDContig(this.ctx.getAlternateAllele(0).getDisplayString()));
}
else
{
_sortKey.contig2 = _sortKey.contig1;
}
_sortKey.start = rgn.getStart();
_sortKey.end = rgn.getEnd();
_sortKey.id=this.id;
}
return _sortKey;
}
示例6: canMerge
import htsjdk.variant.variantcontext.StructuralVariantType; //导入依赖的package包/类
boolean canMerge(final LumpyVar o)
{
// we cannot have common available variants between two ctx
final Set<String> commonSamples= new HashSet<String>(this.getGenotypedSamples());
commonSamples.retainAll(o.getGenotypedSamples());
if(!commonSamples.isEmpty()) {
return false;
}
Interval L1 = this.getInterval();
Interval L2 = o.getInterval();
if(!LumpySort.this.overlap(L1,L2)) return false;
if(this.ctx.getStructuralVariantType()==StructuralVariantType.BND) {
L1 = this.getBndInterval();
L2 = o.getBndInterval();
if(!LumpySort.this.overlap(L1,L2)) return false;
}
return true;
}
示例7: annotateWithImpreciseEvidenceLinks
import htsjdk.variant.variantcontext.StructuralVariantType; //导入依赖的package包/类
private static VariantContext annotateWithImpreciseEvidenceLinks(final VariantContext variant,
final PairedStrandedIntervalTree<EvidenceTargetLink> evidenceTargetLinks,
final SAMSequenceDictionary referenceSequenceDictionary,
final ReadMetadata metadata,
final int defaultUncertainty) {
if (variant.getStructuralVariantType() == StructuralVariantType.DEL) {
SVContext svc = SVContext.of(variant);
final int padding = (metadata == null) ? defaultUncertainty : (metadata.getMaxMedianFragmentSize() / 2);
PairedStrandedIntervals svcIntervals = svc.getPairedStrandedIntervals(metadata, referenceSequenceDictionary, padding);
final Iterator<Tuple2<PairedStrandedIntervals, EvidenceTargetLink>> overlappers = evidenceTargetLinks.overlappers(svcIntervals);
int readPairs = 0;
int splitReads = 0;
while (overlappers.hasNext()) {
final Tuple2<PairedStrandedIntervals, EvidenceTargetLink> next = overlappers.next();
readPairs += next._2.getReadPairs();
splitReads += next._2.getSplitReads();
overlappers.remove();
}
final VariantContextBuilder variantContextBuilder = new VariantContextBuilder(variant);
if (readPairs > 0) {
variantContextBuilder.attribute(GATKSVVCFConstants.READ_PAIR_SUPPORT, readPairs);
}
if (splitReads > 0) {
variantContextBuilder.attribute(GATKSVVCFConstants.SPLIT_READ_SUPPORT, splitReads);
}
return variantContextBuilder.make();
} else {
return variant;
}
}
示例8: getEnd
import htsjdk.variant.variantcontext.StructuralVariantType; //导入依赖的package包/类
/**
* The end position of this variant context.
* This end position is determined in this order:
* <ul>
* <li>the value of the annotation {@value VCFConstants#END_KEY} if present, otherwise</li>
* <li>the value that results from applying the length annotated under {@value GATKSVVCFConstants#SVLEN} based on the structural type if such annotation is present, otherwise</li>
* <li>the variant context start position + the length of the reference allele - 1 as per {@link VariantContext#getEnd()}.</li>
* </ul>
* @return whatever is returned by {@link #getStart()} or greater.
*/
@Override
public int getEnd() {
if (end == MISSING_END) {
end = getAttributeAsInt(VCFConstants.END_KEY, MISSING_END);
if (end == MISSING_END) { // need to test a second time as "END=." would result in still a missing-end.
if (getStructuralVariantType() == StructuralVariantType.DEL) {
end = getStart() + getStructuralVariantLength();
} else {
end = super.getEnd();
}
}
}
return end;
}
示例9: readBreakpointsFromTruthVCF
import htsjdk.variant.variantcontext.StructuralVariantType; //导入依赖的package包/类
public static SVIntervalTree<String> readBreakpointsFromTruthVCF(final String truthVCF,
final SAMSequenceDictionary dictionary,
final int padding ) {
SVIntervalTree<String> breakpoints = new SVIntervalTree<>();
try ( final FeatureDataSource<VariantContext> dataSource =
new FeatureDataSource<>(truthVCF, null, 0, VariantContext.class) ) {
for ( final VariantContext vc : dataSource ) {
final StructuralVariantType svType = vc.getStructuralVariantType();
if ( svType == null ) continue;
final String eventName = vc.getID();
final int contigID = dictionary.getSequenceIndex(vc.getContig());
if ( contigID < 0 ) {
throw new UserException("VCF contig " + vc.getContig() + " does not appear in dictionary.");
}
final int start = vc.getStart();
switch ( svType ) {
case DEL:
case INV:
case CNV:
final int end = vc.getEnd();
breakpoints.put(new SVInterval(contigID,start-padding, end+padding), eventName);
break;
case INS:
case DUP:
case BND:
breakpoints.put(new SVInterval(contigID,start-padding, start+padding), eventName);
break;
}
}
}
return breakpoints;
}
示例10: testType
import htsjdk.variant.variantcontext.StructuralVariantType; //导入依赖的package包/类
/**
* Tests {@link SVContext#getStructuralVariantType()}.
* @param vc input variant context.
*/
@Test(dataProvider="validVariantContexts", dependsOnMethods = {"testCreate"}, groups = "sv")
public void testType(final VariantContext vc, @SuppressWarnings("unused") final ReferenceMultiSource reference) {
final SVContext svc = SVContext.of(vc);
final StructuralVariantType type = svc.getStructuralVariantType();
Assert.assertNotNull(type);
final Allele alternativeAllele = svc.getAlternateAllele(0);
final String alternativeAlleleName = alternativeAllele.getDisplayString();
Assert.assertEquals("<" + type.name() + ">" , alternativeAlleleName);
}
示例11: testComposeAlternativeHaplotype
import htsjdk.variant.variantcontext.StructuralVariantType; //导入依赖的package包/类
/**
* Tests {@link SVContext#composeHaplotypeBasedOnReference(int, int, ReferenceMultiSource)}} when used
* to obtain the reference alternative haplotype.
* @param vc input variant context.
*/
@Test(dataProvider="validVariantContexts", dependsOnMethods = {"testCreate", "testType", "testLength"}, groups = "sv")
public void testComposeAlternativeHaplotype(final VariantContext vc, @SuppressWarnings("unused") final ReferenceMultiSource reference) throws IOException {
final SVContext svc = SVContext.of(vc);
if (svc.getStructuralVariantType() != StructuralVariantType.INS && svc.getStructuralVariantType() != StructuralVariantType.DEL) {
throw new SkipException("unsupported type; skipped for now");
}
final int paddingSize = 10;
final Haplotype altHaplotype = svc.composeHaplotypeBasedOnReference(1, paddingSize, reference);
Assert.assertNotNull(altHaplotype);
Assert.assertFalse(altHaplotype.isReference());
final SimpleInterval expectedInterval = new SimpleInterval(vc.getContig(), vc.getStart() + 1 - paddingSize, vc.getEnd() + paddingSize);
Assert.assertEquals(new SimpleInterval(altHaplotype.getGenomeLocation()), expectedInterval, svc.getContig() + ":" + svc.getStart() + " " + svc.getStructuralVariantType() + " " + svc.getStructuralVariantLength());
final byte[] expectedBases;
final Cigar expectedCigar;
if (svc.getStructuralVariantType() == StructuralVariantType.INS) {
expectedBases = Utils.concat(reference.getReferenceBases(
new SimpleInterval(vc.getContig(), vc.getStart() + 1 - paddingSize, vc.getStart())).getBases(),
svc.getInsertedSequence(),
reference.getReferenceBases(new SimpleInterval(vc.getContig(), vc.getStart() + 1, vc.getStart() + paddingSize)).getBases());
expectedCigar = new Cigar(Arrays.asList(new CigarElement(paddingSize, CigarOperator.M), new CigarElement(svc.getStructuralVariantLength(), CigarOperator.I), new CigarElement(paddingSize, CigarOperator.M)));
} else { // must be DEL.
expectedBases = Utils.concat(reference.getReferenceBases(
new SimpleInterval(vc.getContig(), vc.getStart() + 1 - paddingSize, vc.getStart())).getBases(),
reference.getReferenceBases(
new SimpleInterval(vc.getContig(), vc.getStart() + svc.getStructuralVariantLength() + 1, vc.getStart() + svc.getStructuralVariantLength() + paddingSize)).getBases());
expectedCigar = new Cigar(Arrays.asList(new CigarElement(paddingSize, CigarOperator.M), new CigarElement(svc.getStructuralVariantLength(), CigarOperator.D), new CigarElement(paddingSize, CigarOperator.M)));
}
Assert.assertEquals(altHaplotype.getCigar(), expectedCigar);
Assert.assertEquals(altHaplotype.getBases(), expectedBases, svc.getStructuralVariantType().name() + " " + new String(altHaplotype.getBases()) + " vs " + new String(expectedBases));
}
示例12: compare1
import htsjdk.variant.variantcontext.StructuralVariantType; //导入依赖的package包/类
public int compare1(final KeySorter o) {
int i= st.compareTo(o.st);
if(i!=0) return i;
//
i = this.contig1.compareTo(o.contig1);
if(i!=0) return i;
//
if(st.equals(StructuralVariantType.BND)) {
i = this.contig2.compareTo(o.contig2);
if(i!=0) return i;
}
return 0;
}
示例13: objectToEntry
import htsjdk.variant.variantcontext.StructuralVariantType; //导入依赖的package包/类
@Override
public void objectToEntry(final KeySorter key, final TupleOutput out) {
out.writeByte((byte)key.st.ordinal());
out.writeString(key.contig1);
if(key.st.equals(StructuralVariantType.BND)) {
out.writeString(key.contig2);
}
out.writeInt(key.start);
out.writeInt(key.end);
out.writeLong(key.id);
}
示例14: getBndInterval
import htsjdk.variant.variantcontext.StructuralVariantType; //导入依赖的package包/类
private Interval getBndInterval() {
if(this._bndinterval==null) {
if(!ctx.hasAttribute("CIPOS")) throw new IllegalArgumentException("No CIPOS in "+ctx);
final List<Integer> ciposL= ctx.getAttributeAsIntList("CIPOS",0);
if(ciposL.size()!=2) throw new IllegalArgumentException("len(CIPOS)!=2 in "+ctx);
if(!ctx.hasAttribute("CIEND")) throw new IllegalArgumentException("No CIEND in "+ctx);
final List<Integer> ciendL= ctx.getAttributeAsIntList("CIEND",0);
if(ciendL.size()!=2) throw new IllegalArgumentException("len(CIEND)!=2 in "+ctx);
String cL;
int pL;
if(ctx.getStructuralVariantType()==StructuralVariantType.BND) {
final Map.Entry<String,Integer> entry = LumpyConstants.getBnDContigAndPos(ctx.getAlternateAllele(0).getDisplayString());
cL = entry.getKey();
pL = entry.getValue();
}
else
{
cL = ctx.getContig();
pL = ctx.getEnd();
}
this._bndinterval = new Interval(
cL,
Math.max(0,pL+ciposL.get(0) - LumpySort.this.slop_size),
pL+ciendL.get(1) + LumpySort.this.slop_size
);
}
return this._bndinterval;
}
示例15: visit
import htsjdk.variant.variantcontext.StructuralVariantType; //导入依赖的package包/类
public void visit(final VariantContext ctx,final List<KnownGene> knownGenes) {
final Genotype genotype = ctx.getGenotype(this.sampleName);
if(genotype==null) return;
this.countTypes.incr(genotype.getType());
if(ctx.isVariant() && genotype.isCalled() && !genotype.isHomRef())
{
this.variantsPerContigs.incr(ctx.getContig());
this.countBins.incr(new ContigBin(ctx.getContig(),ctx.getStart()));
}
if( this.pedireePerson !=null &&
this.pedireePerson.hasAtLeastOneParent() &&
VariantStats.this.vcfTools.isMendelianIncompatibility(ctx, this.pedireePerson))
{
for(final SequenceOntologyTree.Term t:VariantStats.this.sequenceOntologyTermsToObserve)
{
if(vcfTools.hasSequenceOntologyTerm(ctx, t))
{
this.countMendelianViolations.incr(t.getLabel());
}
}
}
final StructuralVariantType structuralVariantType= ctx.getStructuralVariantType();
if(structuralVariantType!=null)
{
if(
(genotype.isCalled() && !genotype.isHomRef()) ||
(LumpyConstants.isLumpyVariant(ctx) && genotype.hasExtendedAttribute("SU") && genotype.getAttributeAsInt("SU", 0)>0)
)
{
this.countStructuralVariations.incr(structuralVariantType);
}
}
if(genotype.hasDP())
{
final int dp = genotype.getDP();
if(dp>=0)
{
this.countDepth.incr(VcfStats.this.depthTranches.getRange(dp));
}
}
if(genotype.isHomVar() || genotype.isHet())
{
visitForDistance(ctx);
visitForGeneLocation(ctx,knownGenes);
visitForConsequences(ctx,
VariantStats.this.sequenceOntologyTermsToObserve,
VariantStats.this.vcfTools
);
}
}