Merge branch 'master' of github.com:broadinstitute/gsa-unstable
This commit is contained in:
commit
07fe3dd1ef
|
|
@ -54,7 +54,7 @@ import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotatorCompa
|
|||
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.ExperimentalAnnotation;
|
||||
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
|
||||
import org.broadinstitute.sting.utils.genotyper.PerReadAlleleLikelihoodMap;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.variant.vcf.VCFHeaderLineType;
|
||||
import org.broadinstitute.variant.vcf.VCFInfoHeaderLine;
|
||||
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotatorCompa
|
|||
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
|
||||
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.StandardAnnotation;
|
||||
import org.broadinstitute.sting.utils.genotyper.PerReadAlleleLikelihoodMap;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.MathUtils;
|
||||
import org.broadinstitute.sting.utils.QualityUtils;
|
||||
import org.broadinstitute.variant.vcf.VCFHeaderLineType;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ import org.broadinstitute.sting.gatk.iterators.ReadTransformer;
|
|||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.walkers.*;
|
||||
import org.broadinstitute.sting.utils.MathUtils;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.baq.BAQ;
|
||||
import org.broadinstitute.sting.utils.clipping.ReadClipper;
|
||||
import org.broadinstitute.sting.utils.collections.Pair;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
package org.broadinstitute.sting.gatk.walkers.compression.reducereads;
|
||||
|
||||
import org.broadinstitute.sting.utils.GenomeLocComparator;
|
||||
import org.broadinstitute.sting.utils.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.TreeSet;
|
||||
|
|
@ -61,22 +61,22 @@ import java.util.TreeSet;
|
|||
* Date: 10/15/12
|
||||
* Time: 4:08 PM
|
||||
*/
|
||||
public class CompressionStash extends TreeSet<SimpleGenomeLoc> {
|
||||
public class CompressionStash extends TreeSet<FinishedGenomeLoc> {
|
||||
public CompressionStash() {
|
||||
super(new GenomeLocComparator());
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a SimpleGenomeLoc to the stash and merges it with any overlapping (and contiguous) existing loc
|
||||
* Adds a UnvalidatingGenomeLoc to the stash and merges it with any overlapping (and contiguous) existing loc
|
||||
* in the stash.
|
||||
*
|
||||
* @param insertLoc the new loc to be inserted
|
||||
* @return true if the loc, or it's merged version, wasn't present in the list before.
|
||||
*/
|
||||
@Override
|
||||
public boolean add(SimpleGenomeLoc insertLoc) {
|
||||
TreeSet<SimpleGenomeLoc> removedLocs = new TreeSet<SimpleGenomeLoc>();
|
||||
for (SimpleGenomeLoc existingLoc : this) {
|
||||
public boolean add(FinishedGenomeLoc insertLoc) {
|
||||
TreeSet<FinishedGenomeLoc> removedLocs = new TreeSet<FinishedGenomeLoc>();
|
||||
for (FinishedGenomeLoc existingLoc : this) {
|
||||
if (existingLoc.isPast(insertLoc)) {
|
||||
break; // if we're past the loc we're done looking for overlaps.
|
||||
}
|
||||
|
|
@ -87,17 +87,17 @@ public class CompressionStash extends TreeSet<SimpleGenomeLoc> {
|
|||
removedLocs.add(existingLoc); // list the original loc for merging
|
||||
}
|
||||
}
|
||||
for (SimpleGenomeLoc loc : removedLocs) {
|
||||
for (GenomeLoc loc : removedLocs) {
|
||||
this.remove(loc); // remove all locs that will be merged
|
||||
}
|
||||
removedLocs.add(insertLoc); // add the new loc to the list of locs that will be merged
|
||||
return super.add(SimpleGenomeLoc.merge(removedLocs)); // merge them all into one loc and add to the stash
|
||||
return super.add(new FinishedGenomeLoc(GenomeLoc.merge(removedLocs), insertLoc.isFinished()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends SimpleGenomeLoc> locs) {
|
||||
public boolean addAll(Collection<? extends FinishedGenomeLoc> locs) {
|
||||
boolean result = false;
|
||||
for (SimpleGenomeLoc loc : locs) {
|
||||
for (final FinishedGenomeLoc loc : locs) {
|
||||
result |= this.add(loc);
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -46,11 +46,8 @@
|
|||
|
||||
package org.broadinstitute.sting.gatk.walkers.compression.reducereads;
|
||||
|
||||
import com.google.java.contract.Requires;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import org.broadinstitute.sting.utils.UnvalidatingGenomeLoc;
|
||||
|
||||
/**
|
||||
* GenomeLocs are very useful objects to keep track of genomic locations and perform set operations
|
||||
|
|
@ -59,70 +56,27 @@ import java.util.SortedSet;
|
|||
* However, GenomeLocs are bound to strict validation through the GenomeLocParser and cannot
|
||||
* be created easily for small tasks that do not require the rigors of the GenomeLocParser validation
|
||||
*
|
||||
* SimpleGenomeLoc is a simple utility to create GenomeLocs without going through the parser. Should
|
||||
* UnvalidatingGenomeLoc is a simple utility to create GenomeLocs without going through the parser. Should
|
||||
* only be used outside of the engine.
|
||||
*
|
||||
* User: carneiro
|
||||
* Date: 10/16/12
|
||||
* Time: 2:07 PM
|
||||
*/
|
||||
public class SimpleGenomeLoc extends GenomeLoc {
|
||||
public class FinishedGenomeLoc extends UnvalidatingGenomeLoc {
|
||||
private boolean finished;
|
||||
|
||||
public SimpleGenomeLoc(String contigName, int contigIndex, int start, int stop, boolean finished) {
|
||||
super(contigName, contigIndex, start, stop);
|
||||
public FinishedGenomeLoc(final String contigName, final int contigIndex, final int start, final int stop, final boolean finished) {
|
||||
super(contigName, contigIndex, start, stop);
|
||||
this.finished = finished;
|
||||
}
|
||||
|
||||
public FinishedGenomeLoc(final GenomeLoc loc, final boolean finished) {
|
||||
super(loc.getContig(), loc.getContigIndex(), loc.getStart(), loc.getStop());
|
||||
this.finished = finished;
|
||||
}
|
||||
|
||||
public boolean isFinished() {
|
||||
return finished;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges 2 *contiguous* locs into 1
|
||||
*
|
||||
* @param a SimpleGenomeLoc #1
|
||||
* @param b SimpleGenomeLoc #2
|
||||
* @return one merged loc
|
||||
*/
|
||||
@Requires("a != null && b != null")
|
||||
public static SimpleGenomeLoc merge(SimpleGenomeLoc a, SimpleGenomeLoc b) throws ReviewedStingException {
|
||||
if(GenomeLoc.isUnmapped(a) || GenomeLoc.isUnmapped(b)) {
|
||||
throw new ReviewedStingException("Tried to merge unmapped genome locs");
|
||||
}
|
||||
|
||||
if (!(a.contiguousP(b))) {
|
||||
throw new ReviewedStingException("The two genome locs need to be contiguous");
|
||||
}
|
||||
|
||||
return new SimpleGenomeLoc(a.getContig(), a.contigIndex,
|
||||
Math.min(a.getStart(), b.getStart()),
|
||||
Math.max(a.getStop(), b.getStop()),
|
||||
a.isFinished());
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges a list of *sorted* *contiguous* locs into one
|
||||
*
|
||||
* @param sortedLocs a sorted list of contiguous locs
|
||||
* @return one merged loc
|
||||
*/
|
||||
@Requires("sortedLocs != null")
|
||||
public static SimpleGenomeLoc merge(SortedSet<SimpleGenomeLoc> sortedLocs) {
|
||||
SimpleGenomeLoc result = null;
|
||||
|
||||
for ( SimpleGenomeLoc loc : sortedLocs ) {
|
||||
if ( loc.isUnmapped() )
|
||||
throw new ReviewedStingException("Tried to merge unmapped genome locs");
|
||||
|
||||
if ( result == null )
|
||||
result = loc;
|
||||
else if ( !result.contiguousP(loc) )
|
||||
throw new ReviewedStingException("The genome locs need to be contiguous");
|
||||
else
|
||||
result = merge(result, loc);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -64,7 +64,6 @@ import org.broadinstitute.sting.gatk.walkers.PartitionType;
|
|||
import org.broadinstitute.sting.gatk.walkers.ReadFilters;
|
||||
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.GenomeLocComparator;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.clipping.ReadClipper;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
|
|
@ -267,8 +266,8 @@ public class ReduceReads extends ReadWalker<LinkedList<GATKSAMRecord>, ReduceRea
|
|||
public void initialize() {
|
||||
super.initialize();
|
||||
GenomeAnalysisEngine toolkit = getToolkit();
|
||||
readNameHash = new HashMap<String, Long>(); // prepare the read name hash to keep track of what reads have had their read names compressed
|
||||
intervalList = new TreeSet<GenomeLoc>(new GenomeLocComparator()); // get the interval list from the engine. If no interval list was provided, the walker will work in WGS mode
|
||||
readNameHash = new HashMap<String, Long>(); // prepare the read name hash to keep track of what reads have had their read names compressed
|
||||
intervalList = new TreeSet<GenomeLoc>(); // get the interval list from the engine. If no interval list was provided, the walker will work in WGS mode
|
||||
|
||||
if (toolkit.getIntervals() != null)
|
||||
intervalList.addAll(toolkit.getIntervals());
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import net.sf.samtools.CigarElement;
|
|||
import net.sf.samtools.CigarOperator;
|
||||
import net.sf.samtools.SAMFileHeader;
|
||||
import org.broadinstitute.sting.gatk.downsampling.ReservoirDownsampler;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.collections.Pair;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.recalibration.EventType;
|
||||
|
|
@ -213,7 +214,7 @@ public class SlidingWindow {
|
|||
* @return null if nothing is variant, start/stop if there is a complete variant region, start/-1 if there is an incomplete variant region. All coordinates returned are global.
|
||||
*/
|
||||
@Requires({"from >= 0", "from <= to", "to <= variantSite.length"})
|
||||
private SimpleGenomeLoc findNextVariantRegion(int from, int to, boolean[] variantSite, boolean closeLastRegion) {
|
||||
private FinishedGenomeLoc findNextVariantRegion(int from, int to, boolean[] variantSite, boolean closeLastRegion) {
|
||||
boolean foundStart = false;
|
||||
final int windowHeaderStart = getStartLocation(windowHeader);
|
||||
int variantRegionStartIndex = 0;
|
||||
|
|
@ -223,12 +224,12 @@ public class SlidingWindow {
|
|||
foundStart = true;
|
||||
}
|
||||
else if(!variantSite[i] && foundStart) {
|
||||
return(new SimpleGenomeLoc(contig, contigIndex, windowHeaderStart + variantRegionStartIndex, windowHeaderStart + i - 1, true));
|
||||
return(new FinishedGenomeLoc(contig, contigIndex, windowHeaderStart + variantRegionStartIndex, windowHeaderStart + i - 1, true));
|
||||
}
|
||||
}
|
||||
final int refStart = windowHeaderStart + variantRegionStartIndex;
|
||||
final int refStop = windowHeaderStart + to - 1;
|
||||
return (foundStart && closeLastRegion) ? new SimpleGenomeLoc(contig, contigIndex, refStart, refStop, true) : null;
|
||||
return (foundStart && closeLastRegion) ? new FinishedGenomeLoc(contig, contigIndex, refStart, refStop, true) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -248,7 +249,7 @@ public class SlidingWindow {
|
|||
int index = from;
|
||||
while(index < to) {
|
||||
// returns results in global coordinates
|
||||
SimpleGenomeLoc result = findNextVariantRegion(index, to, variantSite, closeLastRegion);
|
||||
FinishedGenomeLoc result = findNextVariantRegion(index, to, variantSite, closeLastRegion);
|
||||
if (result == null)
|
||||
break;
|
||||
|
||||
|
|
@ -699,8 +700,8 @@ public class SlidingWindow {
|
|||
int lastStop = -1;
|
||||
int windowHeaderStart = getStartLocation(windowHeader);
|
||||
|
||||
for (SimpleGenomeLoc region : regions) {
|
||||
if (region.isFinished() && region.getContig() == contig && region.getStart() >= windowHeaderStart && region.getStop() < windowHeaderStart + windowHeader.size()) {
|
||||
for (GenomeLoc region : regions) {
|
||||
if (((FinishedGenomeLoc)region).isFinished() && region.getContig() == contig && region.getStart() >= windowHeaderStart && region.getStop() < windowHeaderStart + windowHeader.size()) {
|
||||
int start = region.getStart() - windowHeaderStart;
|
||||
int stop = region.getStop() - windowHeaderStart;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
package org.broadinstitute.sting.gatk.walkers.genotyper;
|
||||
|
||||
import net.sf.samtools.SAMUtils;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.MathUtils;
|
||||
import org.broadinstitute.sting.utils.QualityUtils;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
|
|
|
|||
|
|
@ -49,9 +49,8 @@ package org.broadinstitute.sting.gatk.walkers.genotyper;
|
|||
|
||||
import net.sf.samtools.SAMUtils;
|
||||
import org.broadinstitute.sting.gatk.walkers.genotyper.afcalc.ExactACset;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.MathUtils;
|
||||
import org.broadinstitute.sting.utils.baq.BAQ;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.pileup.PileupElement;
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContextUtils;
|
|||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.utils.*;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.variant.variantcontext.*;
|
||||
|
||||
import java.util.*;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
|||
import org.broadinstitute.sting.gatk.contexts.AlignmentContextUtils;
|
||||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.pileup.PileupElement;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContextUtils;
|
|||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.walkers.indels.PairHMMIndelErrorModel;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||
import org.broadinstitute.sting.utils.Haplotype;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
|||
import org.broadinstitute.sting.gatk.contexts.AlignmentContextUtils;
|
||||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||
import org.broadinstitute.sting.utils.MathUtils;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ import org.broadinstitute.sting.utils.*;
|
|||
import org.broadinstitute.sting.utils.baq.BAQ;
|
||||
import org.broadinstitute.sting.utils.classloader.PluginManager;
|
||||
import org.broadinstitute.sting.utils.variant.GATKVariantContextUtils;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.variant.vcf.VCFConstants;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.pileup.PileupElement;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
|||
import org.broadinstitute.sting.utils.genotyper.PerReadAlleleLikelihoodMap;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
import org.broadinstitute.sting.utils.variant.GATKVariantContextUtils;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.variant.variantcontext.*;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ import org.broadinstitute.sting.utils.sam.NWaySAMFileWriter;
|
|||
import org.broadinstitute.sting.utils.sam.ReadUtils;
|
||||
import org.broadinstitute.sting.utils.text.TextFormattingUtils;
|
||||
import org.broadinstitute.sting.utils.text.XReadLines;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContext;
|
||||
|
||||
import java.io.File;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
package org.broadinstitute.sting.gatk.walkers.phasing;
|
||||
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
package org.broadinstitute.sting.gatk.walkers.phasing;
|
||||
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.QualityUtils;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
|||
import org.broadinstitute.sting.gatk.walkers.*;
|
||||
import org.broadinstitute.sting.utils.variant.GATKVCFUtils;
|
||||
import org.broadinstitute.sting.utils.variant.GATKVariantContextUtils;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.HasGenomeLocation;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
package org.broadinstitute.sting.gatk.walkers.phasing;
|
||||
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.variant.variantcontext.Allele;
|
||||
import org.broadinstitute.variant.variantcontext.Genotype;
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ import org.broadinstitute.sting.utils.MathUtils;
|
|||
import org.broadinstitute.sting.utils.QualityUtils;
|
||||
import org.broadinstitute.sting.utils.R.RScriptExecutor;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.variant.GATKVariantContextUtils;
|
||||
import org.broadinstitute.variant.vcf.VCFHeader;
|
||||
import org.broadinstitute.variant.vcf.VCFHeaderLine;
|
||||
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
|
||||
|
|
@ -66,7 +67,6 @@ import org.broadinstitute.sting.utils.exceptions.UserException;
|
|||
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
|
||||
import org.broadinstitute.sting.utils.io.Resource;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContext;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContextUtils;
|
||||
import org.broadinstitute.variant.variantcontext.writer.VariantContextWriter;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -274,7 +274,7 @@ public class VariantRecalibrator extends RodWalker<ExpandingArrayList<VariantDat
|
|||
datum.loc = getToolkit().getGenomeLocParser().createGenomeLoc(vc);
|
||||
datum.originalQual = vc.getPhredScaledQual();
|
||||
datum.isSNP = vc.isSNP() && vc.isBiallelic();
|
||||
datum.isTransition = datum.isSNP && VariantContextUtils.isTransition(vc);
|
||||
datum.isTransition = datum.isSNP && GATKVariantContextUtils.isTransition(vc);
|
||||
|
||||
// Loop through the training data sets and if they overlap this loci then update the prior and training status appropriately
|
||||
dataManager.parseTrainingSets( tracker, context.getLocation(), vc, datum, TRUST_ALL_POLYMORPHIC );
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ import org.broadinstitute.sting.gatk.report.GATKReportTable;
|
|||
import org.broadinstitute.sting.gatk.walkers.bqsr.RecalibrationArgumentCollection;
|
||||
import org.broadinstitute.sting.utils.classloader.JVMUtils;
|
||||
import org.broadinstitute.sting.utils.recalibration.covariates.*;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.R.RScriptExecutor;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.classloader.PluginManager;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ package org.broadinstitute.sting.utils.recalibration.covariates;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.broadinstitute.sting.gatk.walkers.bqsr.RecalibrationArgumentCollection;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.clipping.ClippingRepresentation;
|
||||
import org.broadinstitute.sting.utils.clipping.ReadClipper;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ package org.broadinstitute.sting.utils.recalibration.covariates;
|
|||
|
||||
import org.broadinstitute.sting.utils.recalibration.ReadCovariates;
|
||||
import org.broadinstitute.sting.gatk.walkers.bqsr.RecalibrationArgumentCollection;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.NGSPlatform;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ import org.broadinstitute.sting.gatk.walkers.bqsr.RecalibrationArgumentCollectio
|
|||
import org.broadinstitute.sting.utils.recalibration.ReadCovariates;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
import org.broadinstitute.sting.utils.variant.GATKVariantContextUtils;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.collections.Pair;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
|
|||
|
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
* By downloading the PROGRAM you agree to the following terms of use:
|
||||
*
|
||||
* BROAD INSTITUTE - SOFTWARE LICENSE AGREEMENT - FOR ACADEMIC NON-COMMERCIAL RESEARCH PURPOSES ONLY
|
||||
*
|
||||
* This Agreement is made between the Broad Institute, Inc. with a principal address at 7 Cambridge Center, Cambridge, MA 02142 (BROAD) and the LICENSEE and is effective at the date the downloading is completed (EFFECTIVE DATE).
|
||||
*
|
||||
* WHEREAS, LICENSEE desires to license the PROGRAM, as defined hereinafter, and BROAD wishes to have this PROGRAM utilized in the public interest, subject only to the royalty-free, nonexclusive, nontransferable license rights of the United States Government pursuant to 48 CFR 52.227-14; and
|
||||
* WHEREAS, LICENSEE desires to license the PROGRAM and BROAD desires to grant a license on the following terms and conditions.
|
||||
* NOW, THEREFORE, in consideration of the promises and covenants made herein, the parties hereto agree as follows:
|
||||
*
|
||||
* 1. DEFINITIONS
|
||||
* 1.1 PROGRAM shall mean copyright in the object code and source code known as GATK2 and related documentation, if any, as they exist on the EFFECTIVE DATE and can be downloaded from http://www.broadinstitute/GATK on the EFFECTIVE DATE.
|
||||
*
|
||||
* 2. LICENSE
|
||||
* 2.1 Grant. Subject to the terms of this Agreement, BROAD hereby grants to LICENSEE, solely for academic non-commercial research purposes, a non-exclusive, non-transferable license to: (a) download, execute and display the PROGRAM and (b) create bug fixes and modify the PROGRAM.
|
||||
* The LICENSEE may apply the PROGRAM in a pipeline to data owned by users other than the LICENSEE and provide these users the results of the PROGRAM provided LICENSEE does so for academic non-commercial purposes only. For clarification purposes, academic sponsored research is not a commercial use under the terms of this Agreement.
|
||||
* 2.2 No Sublicensing or Additional Rights. LICENSEE shall not sublicense or distribute the PROGRAM, in whole or in part, without prior written permission from BROAD. LICENSEE shall ensure that all of its users agree to the terms of this Agreement. LICENSEE further agrees that it shall not put the PROGRAM on a network, server, or other similar technology that may be accessed by anyone other than the LICENSEE and its employees and users who have agreed to the terms of this agreement.
|
||||
* 2.3 License Limitations. Nothing in this Agreement shall be construed to confer any rights upon LICENSEE by implication, estoppel, or otherwise to any computer software, trademark, intellectual property, or patent rights of BROAD, or of any other entity, except as expressly granted herein. LICENSEE agrees that the PROGRAM, in whole or part, shall not be used for any commercial purpose, including without limitation, as the basis of a commercial software or hardware product or to provide services. LICENSEE further agrees that the PROGRAM shall not be copied or otherwise adapted in order to circumvent the need for obtaining a license for use of the PROGRAM.
|
||||
*
|
||||
* 3. OWNERSHIP OF INTELLECTUAL PROPERTY
|
||||
* LICENSEE acknowledges that title to the PROGRAM shall remain with BROAD. The PROGRAM is marked with the following BROAD copyright notice and notice of attribution to contributors. LICENSEE shall retain such notice on all copies. LICENSEE agrees to include appropriate attribution if any results obtained from use of the PROGRAM are included in any publication.
|
||||
* Copyright 2012 Broad Institute, Inc.
|
||||
* Notice of attribution: The GATK2 program was made available through the generosity of Medical and Population Genetics program at the Broad Institute, Inc.
|
||||
* LICENSEE shall not use any trademark or trade name of BROAD, or any variation, adaptation, or abbreviation, of such marks or trade names, or any names of officers, faculty, students, employees, or agents of BROAD except as states above for attribution purposes.
|
||||
*
|
||||
* 4. INDEMNIFICATION
|
||||
* LICENSEE shall indemnify, defend, and hold harmless BROAD, and their respective officers, faculty, students, employees, associated investigators and agents, and their respective successors, heirs and assigns, (Indemnitees), against any liability, damage, loss, or expense (including reasonable attorneys fees and expenses) incurred by or imposed upon any of the Indemnitees in connection with any claims, suits, actions, demands or judgments arising out of any theory of liability (including, without limitation, actions in the form of tort, warranty, or strict liability and regardless of whether such action has any factual basis) pursuant to any right or license granted under this Agreement.
|
||||
*
|
||||
* 5. NO REPRESENTATIONS OR WARRANTIES
|
||||
* THE PROGRAM IS DELIVERED AS IS. BROAD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE PROGRAM OR THE COPYRIGHT, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. BROAD EXTENDS NO WARRANTIES OF ANY KIND AS TO PROGRAM CONFORMITY WITH WHATEVER USER MANUALS OR OTHER LITERATURE MAY BE ISSUED FROM TIME TO TIME.
|
||||
* IN NO EVENT SHALL BROAD OR ITS RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AFFILIATED INVESTIGATORS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER BROAD SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING.
|
||||
*
|
||||
* 6. ASSIGNMENT
|
||||
* This Agreement is personal to LICENSEE and any rights or obligations assigned by LICENSEE without the prior written consent of BROAD shall be null and void.
|
||||
*
|
||||
* 7. MISCELLANEOUS
|
||||
* 7.1 Export Control. LICENSEE gives assurance that it will comply with all United States export control laws and regulations controlling the export of the PROGRAM, including, without limitation, all Export Administration Regulations of the United States Department of Commerce. Among other things, these laws and regulations prohibit, or require a license for, the export of certain types of software to specified countries.
|
||||
* 7.2 Termination. LICENSEE shall have the right to terminate this Agreement for any reason upon prior written notice to BROAD. If LICENSEE breaches any provision hereunder, and fails to cure such breach within thirty (30) days, BROAD may terminate this Agreement immediately. Upon termination, LICENSEE shall provide BROAD with written assurance that the original and all copies of the PROGRAM have been destroyed, except that, upon prior written authorization from BROAD, LICENSEE may retain a copy for archive purposes.
|
||||
* 7.3 Survival. The following provisions shall survive the expiration or termination of this Agreement: Articles 1, 3, 4, 5 and Sections 2.2, 2.3, 7.3, and 7.4.
|
||||
* 7.4 Notice. Any notices under this Agreement shall be in writing, shall specifically refer to this Agreement, and shall be sent by hand, recognized national overnight courier, confirmed facsimile transmission, confirmed electronic mail, or registered or certified mail, postage prepaid, return receipt requested. All notices under this Agreement shall be deemed effective upon receipt.
|
||||
* 7.5 Amendment and Waiver; Entire Agreement. This Agreement may be amended, supplemented, or otherwise modified only by means of a written instrument signed by all parties. Any waiver of any rights or failure to act in a specific instance shall relate only to such instance and shall not be construed as an agreement to waive any rights or fail to act in any other instance, whether or not similar. This Agreement constitutes the entire agreement among the parties with respect to its subject matter and supersedes prior agreements or understandings between the parties relating to its subject matter.
|
||||
* 7.6 Binding Effect; Headings. This Agreement shall be binding upon and inure to the benefit of the parties and their respective permitted successors and assigns. All headings are for convenience only and shall not affect the meaning of any provision of this Agreement.
|
||||
* 7.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.gatk.walkers.compression.reducereads;
|
||||
|
||||
|
||||
import org.broadinstitute.sting.BaseTest;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SimpleGenomeLocUnitTest extends BaseTest {
|
||||
|
||||
private static final SimpleGenomeLoc loc1 = new SimpleGenomeLoc("1", 0, 10, 20, false);
|
||||
private static final SimpleGenomeLoc loc2 = new SimpleGenomeLoc("1", 0, 21, 30, false);
|
||||
private static final SimpleGenomeLoc loc3 = new SimpleGenomeLoc("1", 0, 31, 40, false);
|
||||
|
||||
private class SGLTest {
|
||||
public List<SimpleGenomeLoc> locs;
|
||||
|
||||
private SGLTest(final List<SimpleGenomeLoc> locs) {
|
||||
this.locs = locs;
|
||||
}
|
||||
}
|
||||
|
||||
@DataProvider(name = "SGLtest")
|
||||
public Object[][] createFindVariantRegionsData() {
|
||||
List<Object[]> tests = new ArrayList<Object[]>();
|
||||
|
||||
tests.add(new Object[]{new SGLTest(Arrays.<SimpleGenomeLoc>asList(loc1))});
|
||||
tests.add(new Object[]{new SGLTest(Arrays.<SimpleGenomeLoc>asList(loc1, loc2))});
|
||||
tests.add(new Object[]{new SGLTest(Arrays.<SimpleGenomeLoc>asList(loc1, loc2, loc3))});
|
||||
|
||||
return tests.toArray(new Object[][]{});
|
||||
}
|
||||
|
||||
@Test(dataProvider = "SGLtest", enabled = true)
|
||||
public void testSimpleGenomeLoc(SGLTest test) {
|
||||
testMerge(test.locs);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ReviewedStingException.class)
|
||||
public void testNotContiguousLocs() {
|
||||
final List<SimpleGenomeLoc> locs = new ArrayList<SimpleGenomeLoc>(1);
|
||||
locs.add(loc1);
|
||||
locs.add(loc3);
|
||||
testMerge(locs);
|
||||
}
|
||||
|
||||
private void testMerge(final List<SimpleGenomeLoc> locs) {
|
||||
SimpleGenomeLoc result1 = locs.get(0);
|
||||
for ( int i = 1; i < locs.size(); i++ )
|
||||
result1 = SimpleGenomeLoc.merge(result1, locs.get(i));
|
||||
|
||||
SimpleGenomeLoc result2 = SimpleGenomeLoc.merge(new TreeSet<SimpleGenomeLoc>(locs));
|
||||
Assert.assertEquals(result1, result2);
|
||||
Assert.assertEquals(result1.getStart(), locs.get(0).getStart());
|
||||
Assert.assertEquals(result1.getStop(), locs.get(locs.size() - 1).getStop());
|
||||
}
|
||||
}
|
||||
|
|
@ -46,14 +46,7 @@
|
|||
|
||||
package org.broadinstitute.sting.gatk.walkers.compression.reducereads;
|
||||
|
||||
import net.sf.samtools.SAMFileHeader;
|
||||
import net.sf.samtools.SAMReadGroupRecord;
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.BaseTest;
|
||||
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
||||
import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils;
|
||||
import org.broadinstitute.sting.utils.sam.ArtificialSingleSampleReadStream;
|
||||
import org.broadinstitute.sting.utils.sam.ArtificialSingleSampleReadStreamAnalyzer;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
|
@ -70,31 +63,31 @@ public class SlidingWindowUnitTest extends BaseTest {
|
|||
|
||||
private static final int variantRegionLength = 1000;
|
||||
private static final int globalStartPosition = 1000000;
|
||||
private static final SimpleGenomeLoc loc90to95 = new SimpleGenomeLoc("1", 0, 1000090, 1000095, false);
|
||||
private static final SimpleGenomeLoc loc96to99 = new SimpleGenomeLoc("1", 0, 1000096, 1000099, false);
|
||||
private static final SimpleGenomeLoc loc100to110 = new SimpleGenomeLoc("1", 0, 1000100, 1000110, false);
|
||||
private static final SimpleGenomeLoc loc999 = new SimpleGenomeLoc("1", 0, 1000999, 1000999, false);
|
||||
private static final FinishedGenomeLoc loc90to95 = new FinishedGenomeLoc("1", 0, 1000090, 1000095, false);
|
||||
private static final FinishedGenomeLoc loc96to99 = new FinishedGenomeLoc("1", 0, 1000096, 1000099, false);
|
||||
private static final FinishedGenomeLoc loc100to110 = new FinishedGenomeLoc("1", 0, 1000100, 1000110, false);
|
||||
private static final FinishedGenomeLoc loc999 = new FinishedGenomeLoc("1", 0, 1000999, 1000999, false);
|
||||
|
||||
private class FindVariantRegionsTest {
|
||||
public List<SimpleGenomeLoc> locs, expectedResult;
|
||||
public List<FinishedGenomeLoc> locs, expectedResult;
|
||||
public boolean[] variantRegionBitset;
|
||||
|
||||
private FindVariantRegionsTest(final List<SimpleGenomeLoc> locs) {
|
||||
private FindVariantRegionsTest(final List<FinishedGenomeLoc> locs) {
|
||||
this.locs = locs;
|
||||
this.expectedResult = locs;
|
||||
variantRegionBitset = createBitset(locs);
|
||||
}
|
||||
|
||||
private FindVariantRegionsTest(final List<SimpleGenomeLoc> locs, final List<SimpleGenomeLoc> expectedResult) {
|
||||
private FindVariantRegionsTest(final List<FinishedGenomeLoc> locs, final List<FinishedGenomeLoc> expectedResult) {
|
||||
this.locs = locs;
|
||||
this.expectedResult = expectedResult;
|
||||
variantRegionBitset = createBitset(locs);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean[] createBitset(final List<SimpleGenomeLoc> locs) {
|
||||
private static boolean[] createBitset(final List<FinishedGenomeLoc> locs) {
|
||||
boolean[] variantRegionBitset = new boolean[variantRegionLength];
|
||||
for ( SimpleGenomeLoc loc : locs ) {
|
||||
for ( FinishedGenomeLoc loc : locs ) {
|
||||
final int stop = loc.getStop() - globalStartPosition;
|
||||
for ( int i = loc.getStart() - globalStartPosition; i <= stop; i++ )
|
||||
variantRegionBitset[i] = true;
|
||||
|
|
@ -106,11 +99,11 @@ public class SlidingWindowUnitTest extends BaseTest {
|
|||
public Object[][] createFindVariantRegionsData() {
|
||||
List<Object[]> tests = new ArrayList<Object[]>();
|
||||
|
||||
tests.add(new Object[]{new FindVariantRegionsTest(Arrays.<SimpleGenomeLoc>asList(loc90to95))});
|
||||
tests.add(new Object[]{new FindVariantRegionsTest(Arrays.<SimpleGenomeLoc>asList(loc90to95, loc100to110))});
|
||||
tests.add(new Object[]{new FindVariantRegionsTest(Arrays.<SimpleGenomeLoc>asList(loc90to95, loc96to99, loc100to110), Arrays.<SimpleGenomeLoc>asList(new SimpleGenomeLoc("1", 0, 1000090, 1000110, false)))});
|
||||
tests.add(new Object[]{new FindVariantRegionsTest(Arrays.<SimpleGenomeLoc>asList(loc90to95, loc999))});
|
||||
tests.add(new Object[]{new FindVariantRegionsTest(Arrays.<SimpleGenomeLoc>asList(loc999))});
|
||||
tests.add(new Object[]{new FindVariantRegionsTest(Arrays.<FinishedGenomeLoc>asList(loc90to95))});
|
||||
tests.add(new Object[]{new FindVariantRegionsTest(Arrays.<FinishedGenomeLoc>asList(loc90to95, loc100to110))});
|
||||
tests.add(new Object[]{new FindVariantRegionsTest(Arrays.<FinishedGenomeLoc>asList(loc90to95, loc96to99, loc100to110), Arrays.<FinishedGenomeLoc>asList(new FinishedGenomeLoc("1", 0, 1000090, 1000110, false)))});
|
||||
tests.add(new Object[]{new FindVariantRegionsTest(Arrays.<FinishedGenomeLoc>asList(loc90to95, loc999))});
|
||||
tests.add(new Object[]{new FindVariantRegionsTest(Arrays.<FinishedGenomeLoc>asList(loc999))});
|
||||
|
||||
return tests.toArray(new Object[][]{});
|
||||
}
|
||||
|
|
@ -120,7 +113,7 @@ public class SlidingWindowUnitTest extends BaseTest {
|
|||
final SlidingWindow slidingWindow = new SlidingWindow("1", 0, globalStartPosition);
|
||||
final CompressionStash locs = slidingWindow.findVariantRegions(0, variantRegionLength, test.variantRegionBitset, true);
|
||||
int index = 0;
|
||||
for ( final SimpleGenomeLoc loc : locs ) {
|
||||
for ( final FinishedGenomeLoc loc : locs ) {
|
||||
Assert.assertTrue(loc.equals(test.expectedResult.get(index++)));
|
||||
}
|
||||
}
|
||||
|
|
@ -128,7 +121,7 @@ public class SlidingWindowUnitTest extends BaseTest {
|
|||
@Test(enabled = true)
|
||||
public void testNoClosingRegions() {
|
||||
final SlidingWindow slidingWindow = new SlidingWindow("1", 0, globalStartPosition);
|
||||
final CompressionStash locs = slidingWindow.findVariantRegions(0, variantRegionLength, createBitset(Arrays.<SimpleGenomeLoc>asList(loc90to95, loc999)), false);
|
||||
final CompressionStash locs = slidingWindow.findVariantRegions(0, variantRegionLength, createBitset(Arrays.<FinishedGenomeLoc>asList(loc90to95, loc999)), false);
|
||||
Assert.assertEquals(locs.size(), 1);
|
||||
Assert.assertEquals(locs.iterator().next(), loc90to95);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
|||
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
||||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.utils.locusiterator.LocusIteratorByState;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||
import org.broadinstitute.sting.utils.QualityUtils;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ import net.sf.samtools.SAMUtils;
|
|||
import org.apache.log4j.Logger;
|
||||
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
||||
import org.broadinstitute.sting.gatk.walkers.Walker;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.MathUtils;
|
||||
import org.broadinstitute.sting.utils.collections.Pair;
|
||||
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ import org.broadinstitute.sting.utils.GenomeLocParser;
|
|||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.collections.Pair;
|
||||
import org.broadinstitute.sting.utils.fasta.CachingIndexedFastaSequenceFile;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.variant.variantcontext.Allele;
|
||||
import org.broadinstitute.variant.variantcontext.Genotype;
|
||||
import org.broadinstitute.variant.variantcontext.GenotypeBuilder;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ package org.broadinstitute.sting.utils.pairhmm;
|
|||
// the imports for unit testing.
|
||||
|
||||
import org.broadinstitute.sting.BaseTest;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ import org.broadinstitute.sting.utils.recalibration.covariates.*;
|
|||
import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
import org.broadinstitute.sting.utils.variant.GATKVariantContextUtils;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.collections.Pair;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
package org.broadinstitute.sting.alignment;
|
||||
|
||||
import net.sf.samtools.*;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import org.broadinstitute.sting.gatk.CommandLineGATK;
|
|||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import net.sf.picard.reference.IndexedFastaSequenceFile;
|
|||
import net.sf.samtools.*;
|
||||
import org.broadinstitute.sting.alignment.Aligner;
|
||||
import org.broadinstitute.sting.alignment.Alignment;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
|
||||
import java.io.File;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import org.broadinstitute.sting.alignment.Alignment;
|
|||
import org.broadinstitute.sting.alignment.bwa.BWAAligner;
|
||||
import org.broadinstitute.sting.alignment.bwa.BWAConfiguration;
|
||||
import org.broadinstitute.sting.alignment.reference.bwt.*;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ package org.broadinstitute.sting.gatk.contexts;
|
|||
|
||||
import com.google.java.contract.Ensures;
|
||||
import com.google.java.contract.Requires;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import net.sf.samtools.SAMReadGroupRecord;
|
|||
import org.broadinstitute.sting.utils.*;
|
||||
import org.broadinstitute.sting.utils.pileup.*;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.variant.variantcontext.Allele;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
|||
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotatorCompatible;
|
||||
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
|
||||
import org.broadinstitute.sting.utils.genotyper.PerReadAlleleLikelihoodMap;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.variant.vcf.VCFHeaderLineType;
|
||||
import org.broadinstitute.variant.vcf.VCFInfoHeaderLine;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContext;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
|||
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotatorCompatible;
|
||||
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation;
|
||||
import org.broadinstitute.sting.utils.genotyper.PerReadAlleleLikelihoodMap;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.variant.vcf.VCFHeaderLineType;
|
||||
import org.broadinstitute.variant.vcf.VCFInfoHeaderLine;
|
||||
import org.broadinstitute.sting.utils.pileup.PileupElement;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
|||
import org.broadinstitute.sting.gatk.walkers.*;
|
||||
import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.*;
|
||||
import org.broadinstitute.sting.utils.variant.GATKVCFUtils;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.classloader.PluginManager;
|
||||
import org.broadinstitute.variant.vcf.*;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import org.broadinstitute.sting.utils.*;
|
|||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
|
||||
import org.broadinstitute.sting.utils.pileup.PileupElement;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ package org.broadinstitute.sting.gatk.walkers.coverage;
|
|||
import net.sf.samtools.SAMReadGroupRecord;
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.fragments.FragmentCollection;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
|
|||
import org.broadinstitute.sting.gatk.refdata.utils.LocationAwareSeekableRODIterator;
|
||||
import org.broadinstitute.sting.gatk.refdata.utils.RODRecordList;
|
||||
import org.broadinstitute.sting.gatk.walkers.*;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.refseq.RefSeqCodec;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.broadinstitute.sting.gatk.walkers.coverage;
|
||||
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
|||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.walkers.*;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.collections.Pair;
|
||||
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
|||
import org.broadinstitute.sting.gatk.report.GATKReport;
|
||||
import org.broadinstitute.sting.gatk.report.GATKReportTable;
|
||||
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.QualityUtils;
|
||||
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
|
||||
import org.broadinstitute.sting.utils.pileup.PileupElement;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
|||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.walkers.RefWalker;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
|||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.walkers.RefWalker;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.exceptions.StingException;
|
||||
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
|||
import org.broadinstitute.sting.gatk.walkers.DataSource;
|
||||
import org.broadinstitute.sting.gatk.walkers.ReadWalker;
|
||||
import org.broadinstitute.sting.gatk.walkers.Requires;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.clipping.ClippingOp;
|
||||
import org.broadinstitute.sting.utils.clipping.ClippingRepresentation;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import org.broadinstitute.sting.utils.codecs.table.TableFeature;
|
|||
import org.broadinstitute.sting.gatk.walkers.DataSource;
|
||||
import org.broadinstitute.sting.gatk.walkers.Requires;
|
||||
import org.broadinstitute.sting.gatk.walkers.RodWalker;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
|||
import org.broadinstitute.sting.gatk.walkers.varianteval.util.Analysis;
|
||||
import org.broadinstitute.sting.gatk.walkers.varianteval.util.DataPoint;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.variant.GATKVariantContextUtils;
|
||||
import org.broadinstitute.variant.variantcontext.Allele;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContext;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContextUtils;
|
||||
|
||||
@Analysis(description = "Evaluation summary for multi-allelic variants")
|
||||
public class MultiallelicSummary extends VariantEvaluator implements StandardEval {
|
||||
|
|
@ -122,7 +122,7 @@ public class MultiallelicSummary extends VariantEvaluator implements StandardEva
|
|||
|
||||
private void calculatePairwiseTiTv(VariantContext vc) {
|
||||
for ( Allele alt : vc.getAlternateAlleles() ) {
|
||||
if ( VariantContextUtils.isTransition(vc.getReference(), alt) )
|
||||
if ( GATKVariantContextUtils.isTransition(vc.getReference(), alt) )
|
||||
nTi++;
|
||||
else
|
||||
nTv++;
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
|||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.walkers.varianteval.util.Analysis;
|
||||
import org.broadinstitute.sting.gatk.walkers.varianteval.util.DataPoint;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.variant.GATKVariantContextUtils;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContext;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContextUtils;
|
||||
|
||||
@Analysis(description = "Ti/Tv Variant Evaluator")
|
||||
public class TiTvVariantEvaluator extends VariantEvaluator implements StandardEval {
|
||||
|
|
@ -61,7 +61,7 @@ public class TiTvVariantEvaluator extends VariantEvaluator implements StandardEv
|
|||
|
||||
public void updateTiTv(VariantContext vc, boolean updateStandard) {
|
||||
if (vc != null && vc.isSNP() && vc.isBiallelic() && vc.isPolymorphicInSamples()) {
|
||||
if (VariantContextUtils.isTransition(vc)) {
|
||||
if ( GATKVariantContextUtils.isTransition(vc)) {
|
||||
if (updateStandard) nTiInComp++;
|
||||
else nTi++;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ import org.broadinstitute.sting.gatk.walkers.varianteval.util.Analysis;
|
|||
import org.broadinstitute.sting.gatk.walkers.varianteval.util.DataPoint;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.variant.GATKVariantContextUtils;
|
||||
import org.broadinstitute.variant.vcf.VCFConstants;
|
||||
import org.broadinstitute.sting.utils.interval.IntervalUtils;
|
||||
import org.broadinstitute.variant.variantcontext.Genotype;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContext;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContextUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ public class VariantSummary extends VariantEvaluator implements StandardEval {
|
|||
|
||||
// type specific calculations
|
||||
if ( type == Type.SNP && eval.isBiallelic() ) {
|
||||
titvTable = VariantContextUtils.isTransition(eval) ? transitionsPerSample : transversionsPerSample;
|
||||
titvTable = GATKVariantContextUtils.isTransition(eval) ? transitionsPerSample : transversionsPerSample;
|
||||
titvTable.inc(type, ALL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
|||
import org.broadinstitute.sting.gatk.walkers.RodWalker;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.variant.GATKVCFUtils;
|
||||
import org.broadinstitute.sting.utils.variant.GATKVariantContextUtils;
|
||||
import org.broadinstitute.variant.vcf.*;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContext;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContextBuilder;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContextUtils;
|
||||
import org.broadinstitute.variant.variantcontext.writer.VariantContextWriter;
|
||||
import org.broadinstitute.variant.variantcontext.writer.VariantContextWriterFactory;
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ public class LiftoverVariants extends RodWalker<Integer, Integer> {
|
|||
if ( toInterval != null ) {
|
||||
// check whether the strand flips, and if so reverse complement everything
|
||||
if ( fromInterval.isPositiveStrand() != toInterval.isPositiveStrand() && vc.isPointEvent() ) {
|
||||
vc = VariantContextUtils.reverseComplement(vc);
|
||||
vc = GATKVariantContextUtils.reverseComplement(vc);
|
||||
}
|
||||
|
||||
vc = new VariantContextBuilder(vc).loc(toInterval.getSequence(), toInterval.getStart(), toInterval.getStart() + length).make();
|
||||
|
|
@ -133,7 +133,7 @@ public class LiftoverVariants extends RodWalker<Integer, Integer> {
|
|||
.attribute("OriginalStart", fromInterval.getStart()).make();
|
||||
}
|
||||
|
||||
if ( originalVC.isSNP() && originalVC.isBiallelic() && VariantContextUtils.getSNPSubstitutionType(originalVC) != VariantContextUtils.getSNPSubstitutionType(vc) ) {
|
||||
if ( originalVC.isSNP() && originalVC.isBiallelic() && GATKVariantContextUtils.getSNPSubstitutionType(originalVC) != GATKVariantContextUtils.getSNPSubstitutionType(vc) ) {
|
||||
logger.warn(String.format("VCF at %s / %d => %s / %d is switching substitution type %s/%s to %s/%s",
|
||||
originalVC.getChr(), originalVC.getStart(), vc.getChr(), vc.getStart(),
|
||||
originalVC.getReference(), originalVC.getAlternateAllele(0), vc.getReference(), vc.getAlternateAllele(0)));
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
|||
import org.broadinstitute.sting.gatk.walkers.RodWalker;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContextUtils;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.lang.reflect.Array;
|
||||
|
|
@ -432,7 +431,7 @@ public class VariantsToTable extends RodWalker<Integer, Integer> {
|
|||
getters.put("QUAL", new Getter() { public String get(VariantContext vc) { return Double.toString(vc.getPhredScaledQual()); } });
|
||||
getters.put("TRANSITION", new Getter() { public String get(VariantContext vc) {
|
||||
if ( vc.isSNP() && vc.isBiallelic() )
|
||||
return VariantContextUtils.isTransition(vc) ? "1" : "0";
|
||||
return GATKVariantContextUtils.isTransition(vc) ? "1" : "0";
|
||||
else
|
||||
return "-1";
|
||||
}});
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
|
|||
import org.broadinstitute.sting.gatk.walkers.Reference;
|
||||
import org.broadinstitute.sting.gatk.walkers.RodWalker;
|
||||
import org.broadinstitute.sting.gatk.walkers.Window;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.hapmap.RawHapMapFeature;
|
||||
|
|
|
|||
|
|
@ -23,12 +23,14 @@
|
|||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.variant.utils;
|
||||
package org.broadinstitute.sting.utils;
|
||||
|
||||
import net.sf.samtools.util.StringUtil;
|
||||
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* BaseUtils contains some basic utilities for manipulating nucleotides.
|
||||
|
|
@ -95,9 +97,6 @@ public class BaseUtils {
|
|||
baseIndexWithIupacMap['v'] = Base.N.ordinal();
|
||||
}
|
||||
|
||||
// Use a fixed random seed to allow for deterministic results when using random bases
|
||||
private static final Random randomNumberGen = new Random(47382911L);
|
||||
|
||||
/// In genetics, a transition is a mutation changing a purine to another purine nucleotide (A <-> G) or
|
||||
// a pyrimidine to another pyrimidine nucleotide (C <-> T).
|
||||
// Approximately two out of every three single nucleotide polymorphisms (SNPs) are transitions.
|
||||
|
|
@ -174,7 +173,7 @@ public class BaseUtils {
|
|||
if ( baseIndex == Base.N.ordinal() ) {
|
||||
bases[i] = 'N';
|
||||
} else if ( errorOnBadReferenceBase && baseIndex == -1 ) {
|
||||
throw new IllegalStateException("We encountered a non-standard non-IUPAC base in the provided reference: '" + bases[i] + "'");
|
||||
throw new UserException.BadInput("We encountered a non-standard non-IUPAC base in the provided reference: '" + bases[i] + "'");
|
||||
}
|
||||
}
|
||||
return bases;
|
||||
|
|
@ -251,7 +250,7 @@ public class BaseUtils {
|
|||
*/
|
||||
static public int simpleBaseToBaseIndex(final byte base) {
|
||||
if ( base < 0 || base >= 256 )
|
||||
throw new IllegalArgumentException("Non-standard bases were encountered in either the input reference or BAM file(s)");
|
||||
throw new UserException.BadInput("Non-standard bases were encountered in either the input reference or BAM file(s)");
|
||||
return baseIndexMap[base];
|
||||
}
|
||||
|
||||
|
|
@ -491,7 +490,7 @@ public class BaseUtils {
|
|||
int randomBaseIndex = excludeBaseIndex;
|
||||
|
||||
while (randomBaseIndex == excludeBaseIndex) {
|
||||
randomBaseIndex = randomNumberGen.nextInt(4);
|
||||
randomBaseIndex = GenomeAnalysisEngine.getRandomGenerator().nextInt(4);
|
||||
}
|
||||
|
||||
return randomBaseIndex;
|
||||
|
|
@ -515,7 +514,7 @@ public class BaseUtils {
|
|||
case 'N':
|
||||
return 'N';
|
||||
default:
|
||||
throw new IllegalArgumentException("base must be A, C, G or T. " + (char) base + " is not a valid base.");
|
||||
throw new ReviewedStingException("base must be A, C, G or T. " + (char) base + " is not a valid base.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -30,10 +30,7 @@ import com.google.java.contract.Requires;
|
|||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
|
|
@ -581,4 +578,49 @@ public class GenomeLoc implements Comparable<GenomeLoc>, Serializable, HasGenome
|
|||
public GenomeLoc incPos(GenomeLoc loc, int by) {
|
||||
return new GenomeLoc(loc.getContig(), loc.getContigIndex(), loc.start + by, loc.stop + by);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges 2 *contiguous* locs into 1
|
||||
*
|
||||
* @param a GenomeLoc #1
|
||||
* @param b GenomeLoc #2
|
||||
* @return one merged loc
|
||||
*/
|
||||
@Requires("a != null && b != null")
|
||||
public static <T extends GenomeLoc> GenomeLoc merge(final T a, final T b) {
|
||||
if ( isUnmapped(a) || isUnmapped(b) ) {
|
||||
throw new ReviewedStingException("Tried to merge unmapped genome locs");
|
||||
}
|
||||
|
||||
if ( !(a.contiguousP(b)) ) {
|
||||
throw new ReviewedStingException("The two genome locs need to be contiguous");
|
||||
}
|
||||
|
||||
return new GenomeLoc(a.getContig(), a.contigIndex, Math.min(a.getStart(), b.getStart()), Math.max(a.getStop(), b.getStop()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges a list of *sorted* *contiguous* locs into 1
|
||||
*
|
||||
* @param sortedLocs a sorted list of contiguous locs
|
||||
* @return one merged loc
|
||||
*/
|
||||
@Requires("sortedLocs != null")
|
||||
public static <T extends GenomeLoc> GenomeLoc merge(final SortedSet<T> sortedLocs) {
|
||||
GenomeLoc result = null;
|
||||
|
||||
for ( GenomeLoc loc : sortedLocs ) {
|
||||
if ( loc.isUnmapped() )
|
||||
throw new ReviewedStingException("Tried to merge unmapped genome locs");
|
||||
|
||||
if ( result == null )
|
||||
result = loc;
|
||||
else if ( !result.contiguousP(loc) )
|
||||
throw new ReviewedStingException("The genome locs need to be contiguous");
|
||||
else
|
||||
result = merge(result, loc);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2012 The Broad Institute
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.utils;
|
||||
|
||||
import com.google.java.contract.Ensures;
|
||||
import com.google.java.contract.Requires;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Mauricio Carneiro
|
||||
* @since 9/28/11
|
||||
*/
|
||||
public class GenomeLocComparator implements Comparator<GenomeLoc> {
|
||||
/**
|
||||
* compares genomeLoc's contigs
|
||||
*
|
||||
* @param gl1 the genome loc to compare contigs
|
||||
* @param gl2 the genome loc to compare contigs
|
||||
* @return 0 if equal, -1 if gl2.contig is greater, 1 if gl1.contig is greater
|
||||
*/
|
||||
@Requires("gl2 != null")
|
||||
@Ensures("result == 0 || result == 1 || result == -1")
|
||||
public final int compareContigs( GenomeLoc gl1, GenomeLoc gl2 ) {
|
||||
if (gl1.contigIndex == gl2.contigIndex)
|
||||
return 0;
|
||||
else if (gl1.contigIndex > gl2.contigIndex)
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Requires("gl2 != null")
|
||||
@Ensures("result == 0 || result == 1 || result == -1")
|
||||
public int compare ( GenomeLoc gl1, GenomeLoc gl2 ) {
|
||||
int result = 0;
|
||||
|
||||
if ( gl1 == gl2 ) {
|
||||
result = 0;
|
||||
}
|
||||
else if(GenomeLoc.isUnmapped(gl1))
|
||||
result = 1;
|
||||
else if(GenomeLoc.isUnmapped(gl2))
|
||||
result = -1;
|
||||
else {
|
||||
final int cmpContig = compareContigs(gl1, gl2);
|
||||
|
||||
if ( cmpContig != 0 ) {
|
||||
result = cmpContig;
|
||||
} else {
|
||||
if ( gl1.getStart() < gl2.getStart() ) result = -1;
|
||||
if ( gl1.getStart() > gl2.getStart() ) result = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2012 The Broad Institute
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.utils;
|
||||
|
||||
import com.google.java.contract.Requires;
|
||||
|
||||
/**
|
||||
* GenomeLocs are very useful objects to keep track of genomic locations and perform set operations
|
||||
* with them.
|
||||
*
|
||||
* However, GenomeLocs are bound to strict validation through the GenomeLocParser and cannot
|
||||
* be created easily for small tasks that do not require the rigors of the GenomeLocParser validation
|
||||
*
|
||||
* UnvalidatingGenomeLoc is a simple utility to create GenomeLocs without going through the parser.
|
||||
*
|
||||
* WARNING: SHOULD BE USED ONLY BY EXPERT USERS WHO KNOW WHAT THEY ARE DOING!
|
||||
*
|
||||
* User: carneiro
|
||||
* Date: 10/16/12
|
||||
* Time: 2:07 PM
|
||||
*/
|
||||
public class UnvalidatingGenomeLoc extends GenomeLoc {
|
||||
|
||||
public UnvalidatingGenomeLoc(String contigName, int contigIndex, int start, int stop) {
|
||||
super(contigName, contigIndex, start, stop);
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.broadinstitute.sting.utils.duplicates;
|
||||
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||
import org.broadinstitute.sting.utils.QualityUtils;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import net.sf.samtools.SAMSequenceRecord;
|
|||
import net.sf.samtools.util.StringUtil;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.broadinstitute.sting.utils.genotyper;
|
||||
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
|
||||
public enum DiploidGenotype {
|
||||
AA ('A', 'A'),
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import com.google.java.contract.Ensures;
|
|||
import com.google.java.contract.Requires;
|
||||
import net.sf.samtools.CigarElement;
|
||||
import net.sf.samtools.CigarOperator;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.MathUtils;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import org.broadinstitute.sting.utils.fragments.FragmentCollection;
|
|||
import org.broadinstitute.sting.utils.fragments.FragmentUtils;
|
||||
import org.broadinstitute.sting.utils.locusiterator.LocusIteratorByState;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import net.sf.samtools.CigarElement;
|
|||
import net.sf.samtools.CigarOperator;
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.pileup.PileupElement;
|
||||
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import org.broadinstitute.sting.utils.MathUtils;
|
|||
import org.broadinstitute.sting.utils.NGSPlatform;
|
||||
import org.broadinstitute.sting.utils.collections.Pair;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
|
|
|||
|
|
@ -30,10 +30,7 @@ import org.apache.commons.lang.ArrayUtils;
|
|||
import org.apache.log4j.Logger;
|
||||
import org.broad.tribble.TribbleException;
|
||||
import org.broad.tribble.util.popgen.HardyWeinbergCalculation;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||
import org.broadinstitute.sting.utils.MathUtils;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.*;
|
||||
import org.broadinstitute.sting.utils.collections.Pair;
|
||||
import org.broadinstitute.variant.variantcontext.*;
|
||||
import org.broadinstitute.variant.vcf.VCFConstants;
|
||||
|
|
@ -108,6 +105,68 @@ public class GATKVariantContextUtils {
|
|||
return genomeLocParser.createGenomeLoc(vc.getChr(), vc.getStart(), vc.getEnd(), true);
|
||||
}
|
||||
|
||||
public static BaseUtils.BaseSubstitutionType getSNPSubstitutionType(VariantContext context) {
|
||||
if (!context.isSNP() || !context.isBiallelic())
|
||||
throw new IllegalStateException("Requested SNP substitution type for bialleic non-SNP " + context);
|
||||
return BaseUtils.SNPSubstitutionType(context.getReference().getBases()[0], context.getAlternateAllele(0).getBases()[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is a BiAlleic SNP, is it a transition?
|
||||
*/
|
||||
public static boolean isTransition(VariantContext context) {
|
||||
return getSNPSubstitutionType(context) == BaseUtils.BaseSubstitutionType.TRANSITION;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is a BiAlleic SNP, is it a transversion?
|
||||
*/
|
||||
public static boolean isTransversion(VariantContext context) {
|
||||
return getSNPSubstitutionType(context) == BaseUtils.BaseSubstitutionType.TRANSVERSION;
|
||||
}
|
||||
|
||||
public static boolean isTransition(Allele ref, Allele alt) {
|
||||
return BaseUtils.SNPSubstitutionType(ref.getBases()[0], alt.getBases()[0]) == BaseUtils.BaseSubstitutionType.TRANSITION;
|
||||
}
|
||||
|
||||
public static boolean isTransversion(Allele ref, Allele alt) {
|
||||
return BaseUtils.SNPSubstitutionType(ref.getBases()[0], alt.getBases()[0]) == BaseUtils.BaseSubstitutionType.TRANSVERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a context identical to this with the REF and ALT alleles reverse complemented.
|
||||
*
|
||||
* @param vc variant context
|
||||
* @return new vc
|
||||
*/
|
||||
public static VariantContext reverseComplement(VariantContext vc) {
|
||||
// create a mapping from original allele to reverse complemented allele
|
||||
HashMap<Allele, Allele> alleleMap = new HashMap<Allele, Allele>(vc.getAlleles().size());
|
||||
for ( Allele originalAllele : vc.getAlleles() ) {
|
||||
Allele newAllele;
|
||||
if ( originalAllele.isNoCall() )
|
||||
newAllele = originalAllele;
|
||||
else
|
||||
newAllele = Allele.create(BaseUtils.simpleReverseComplement(originalAllele.getBases()), originalAllele.isReference());
|
||||
alleleMap.put(originalAllele, newAllele);
|
||||
}
|
||||
|
||||
// create new Genotype objects
|
||||
GenotypesContext newGenotypes = GenotypesContext.create(vc.getNSamples());
|
||||
for ( final Genotype genotype : vc.getGenotypes() ) {
|
||||
List<Allele> newAlleles = new ArrayList<Allele>();
|
||||
for ( Allele allele : genotype.getAlleles() ) {
|
||||
Allele newAllele = alleleMap.get(allele);
|
||||
if ( newAllele == null )
|
||||
newAllele = Allele.NO_CALL;
|
||||
newAlleles.add(newAllele);
|
||||
}
|
||||
newGenotypes.add(new GenotypeBuilder(genotype).alleles(newAlleles).make());
|
||||
}
|
||||
|
||||
return new VariantContextBuilder(vc).alleles(alleleMap.values()).genotypes(newGenotypes).make();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true iff VC is an non-complex indel where every allele represents an expansion or
|
||||
* contraction of a series of identical bases in the reference.
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.broadinstitute.variant.variantcontext;
|
||||
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import net.sf.samtools.util.StringUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
|
@ -130,7 +130,7 @@ public class Allele implements Comparable<Allele> {
|
|||
if ( isRef ) throw new IllegalArgumentException("Cannot tag a symbolic allele as the reference allele");
|
||||
}
|
||||
else {
|
||||
BaseUtils.convertToUpperCase(bases);
|
||||
StringUtil.toUpperCase(bases);
|
||||
}
|
||||
|
||||
this.isRef = isRef;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import com.google.java.contract.Requires;
|
|||
import org.apache.commons.jexl2.Expression;
|
||||
import org.apache.commons.jexl2.JexlEngine;
|
||||
import org.broad.tribble.TribbleException;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.variant.utils.GeneralUtils;
|
||||
import org.broadinstitute.variant.vcf.*;
|
||||
|
||||
|
|
@ -432,40 +431,6 @@ public class VariantContextUtils {
|
|||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Returns a context identical to this with the REF and ALT alleles reverse complemented.
|
||||
*
|
||||
* @param vc variant context
|
||||
* @return new vc
|
||||
*/
|
||||
public static VariantContext reverseComplement(VariantContext vc) {
|
||||
// create a mapping from original allele to reverse complemented allele
|
||||
HashMap<Allele, Allele> alleleMap = new HashMap<Allele, Allele>(vc.getAlleles().size());
|
||||
for ( Allele originalAllele : vc.getAlleles() ) {
|
||||
Allele newAllele;
|
||||
if ( originalAllele.isNoCall() )
|
||||
newAllele = originalAllele;
|
||||
else
|
||||
newAllele = Allele.create(BaseUtils.simpleReverseComplement(originalAllele.getBases()), originalAllele.isReference());
|
||||
alleleMap.put(originalAllele, newAllele);
|
||||
}
|
||||
|
||||
// create new Genotype objects
|
||||
GenotypesContext newGenotypes = GenotypesContext.create(vc.getNSamples());
|
||||
for ( final Genotype genotype : vc.getGenotypes() ) {
|
||||
List<Allele> newAlleles = new ArrayList<Allele>();
|
||||
for ( Allele allele : genotype.getAlleles() ) {
|
||||
Allele newAllele = alleleMap.get(allele);
|
||||
if ( newAllele == null )
|
||||
newAllele = Allele.NO_CALL;
|
||||
newAlleles.add(newAllele);
|
||||
}
|
||||
newGenotypes.add(new GenotypeBuilder(genotype).alleles(newAlleles).make());
|
||||
}
|
||||
|
||||
return new VariantContextBuilder(vc).alleles(alleleMap.values()).genotypes(newGenotypes).make();
|
||||
}
|
||||
|
||||
public static VariantContext purgeUnallowedGenotypeAttributes(VariantContext vc, Set<String> allowedAttributes) {
|
||||
if ( allowedAttributes == null )
|
||||
return vc;
|
||||
|
|
@ -483,34 +448,6 @@ public class VariantContextUtils {
|
|||
return new VariantContextBuilder(vc).genotypes(newGenotypes).make();
|
||||
}
|
||||
|
||||
public static BaseUtils.BaseSubstitutionType getSNPSubstitutionType(VariantContext context) {
|
||||
if (!context.isSNP() || !context.isBiallelic())
|
||||
throw new IllegalStateException("Requested SNP substitution type for bialleic non-SNP " + context);
|
||||
return BaseUtils.SNPSubstitutionType(context.getReference().getBases()[0], context.getAlternateAllele(0).getBases()[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is a BiAlleic SNP, is it a transition?
|
||||
*/
|
||||
public static boolean isTransition(VariantContext context) {
|
||||
return getSNPSubstitutionType(context) == BaseUtils.BaseSubstitutionType.TRANSITION;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is a BiAlleic SNP, is it a transversion?
|
||||
*/
|
||||
public static boolean isTransversion(VariantContext context) {
|
||||
return getSNPSubstitutionType(context) == BaseUtils.BaseSubstitutionType.TRANSVERSION;
|
||||
}
|
||||
|
||||
public static boolean isTransition(Allele ref, Allele alt) {
|
||||
return BaseUtils.SNPSubstitutionType(ref.getBases()[0], alt.getBases()[0]) == BaseUtils.BaseSubstitutionType.TRANSITION;
|
||||
}
|
||||
|
||||
public static boolean isTransversion(Allele ref, Allele alt) {
|
||||
return BaseUtils.SNPSubstitutionType(ref.getBases()[0], alt.getBases()[0]) == BaseUtils.BaseSubstitutionType.TRANSVERSION;
|
||||
}
|
||||
|
||||
public static int getSize( VariantContext vc ) {
|
||||
return vc.getEnd() - vc.getStart() + 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
* Copyright (c) 2012 The Broad Institute
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting;
|
||||
|
||||
|
||||
// the imports for unit testing.
|
||||
|
||||
|
||||
import net.sf.picard.reference.IndexedFastaSequenceFile;
|
||||
import net.sf.samtools.SAMFileHeader;
|
||||
import net.sf.samtools.SAMFileReader;
|
||||
import net.sf.samtools.SAMRecord;
|
||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.activeregion.ActiveRegion;
|
||||
import org.broadinstitute.sting.utils.activeregion.ActivityProfileState;
|
||||
import org.broadinstitute.sting.utils.fasta.CachingIndexedFastaSequenceFile;
|
||||
import org.broadinstitute.sting.utils.pileup.PileupElement;
|
||||
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
|
||||
import org.broadinstitute.sting.utils.pileup.ReadBackedPileupImpl;
|
||||
import org.broadinstitute.sting.utils.sam.ArtificialBAMBuilder;
|
||||
import org.broadinstitute.sting.utils.sam.ArtificialSAMUtils;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||
import org.broadinstitute.sting.utils.sam.GATKSamRecordFactory;
|
||||
import org.broadinstitute.variant.variantcontext.Allele;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContext;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContextBuilder;
|
||||
import org.broadinstitute.variant.variantcontext.VariantContextTestProvider;
|
||||
import org.broadinstitute.variant.vcf.VCFCodec;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.*;
|
||||
|
||||
public class ExampleToCopyUnitTest extends BaseTest {
|
||||
// example genome loc parser for this test, can be deleted if you don't use the reference
|
||||
private GenomeLocParser genomeLocParser;
|
||||
|
||||
// example fasta index file, can be deleted if you don't use the reference
|
||||
private IndexedFastaSequenceFile seq;
|
||||
|
||||
@BeforeClass
|
||||
public void setup() throws FileNotFoundException {
|
||||
// sequence
|
||||
seq = new CachingIndexedFastaSequenceFile(new File(b37KGReference));
|
||||
genomeLocParser = new GenomeLocParser(seq);
|
||||
}
|
||||
|
||||
/**
|
||||
* Combinatorial unit test data provider example.
|
||||
*
|
||||
* Creates data for testMyData test function, containing two arguments, start and size at each value
|
||||
*
|
||||
* @return Object[][] for testng DataProvider
|
||||
*/
|
||||
@DataProvider(name = "MyDataProvider")
|
||||
public Object[][] makeMyDataProvider() {
|
||||
List<Object[]> tests = new ArrayList<Object[]>();
|
||||
|
||||
// this functionality can be adapted to provide input data for whatever you might want in your data
|
||||
for ( final int start : Arrays.asList(1, 10, 100) ) {
|
||||
for ( final int size : Arrays.asList(1, 10, 100, 1000) ) {
|
||||
tests.add(new Object[]{start, size});
|
||||
}
|
||||
}
|
||||
|
||||
return tests.toArray(new Object[][]{});
|
||||
}
|
||||
|
||||
/**
|
||||
* Example testng test using MyDataProvider
|
||||
*/
|
||||
@Test(dataProvider = "MyDataProvider")
|
||||
public void testMyData(final int start, final int size) {
|
||||
// adaptor this code to do whatever testing you want given the arguments start and size
|
||||
Assert.assertTrue(start >= 0);
|
||||
Assert.assertTrue(size >= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* A unit test that creates an artificial read for testing some code that uses reads
|
||||
*/
|
||||
@Test()
|
||||
public void testWithARead() {
|
||||
final SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(seq.getSequenceDictionary());
|
||||
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "myRead", 0, 1, 10);
|
||||
Assert.assertEquals(read.getReadLength(), 10);
|
||||
// TODO -- add some tests here using read
|
||||
}
|
||||
|
||||
/**
|
||||
* A unit test that creates a GenomeLoc for testing
|
||||
*/
|
||||
@Test()
|
||||
public void testWithAGenomeLoc() {
|
||||
final GenomeLoc loc = genomeLocParser.createGenomeLoc("1", 1, 10);
|
||||
Assert.assertEquals(loc.size(), 10);
|
||||
// TODO -- add some tests here using the loc
|
||||
}
|
||||
|
||||
/**
|
||||
* A unit test that creates an artificial read for testing some code that uses reads
|
||||
*
|
||||
* Note that effective creation of RBPs isn't so good. If you need pileups of specific properties, you shoud
|
||||
* look into building them yourself as in the example below
|
||||
*/
|
||||
@Test()
|
||||
public void testWithAPileup() {
|
||||
final SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(seq.getSequenceDictionary());
|
||||
final GenomeLoc myLocation = genomeLocParser.createGenomeLoc("1", 10);
|
||||
final ReadBackedPileup pileup = ArtificialSAMUtils.createReadBackedPileup(header, myLocation, 10, 400, 10);
|
||||
Assert.assertFalse(pileup.isEmpty());
|
||||
// TODO -- add some tests here using pileup
|
||||
}
|
||||
|
||||
/**
|
||||
* A unit test that creates an artificial read for testing some code that uses reads
|
||||
*
|
||||
* Builds the pileup from scratch to have specific properties
|
||||
*/
|
||||
@Test()
|
||||
public void testBuildingAPileupWithSpecificProperties() {
|
||||
final SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(seq.getSequenceDictionary());
|
||||
final GenomeLoc myLocation = genomeLocParser.createGenomeLoc("1", 10);
|
||||
|
||||
final int pileupSize = 100;
|
||||
final int readLength = 10;
|
||||
final List<GATKSAMRecord> reads = new LinkedList<GATKSAMRecord>();
|
||||
for ( int i = 0; i < pileupSize; i++ ) {
|
||||
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "myRead" + i, 0, 1, readLength);
|
||||
final byte[] bases = Utils.dupBytes((byte)'A', readLength);
|
||||
bases[0] = (byte)(i % 2 == 0 ? 'A' : 'C'); // every other base is a C
|
||||
|
||||
// set the read's bases and quals
|
||||
read.setReadBases(bases);
|
||||
read.setBaseQualities(Utils.dupBytes((byte)30, readLength));
|
||||
reads.add(read);
|
||||
}
|
||||
|
||||
// create a pileup with all reads having offset 0
|
||||
final ReadBackedPileup pileup = new ReadBackedPileupImpl(myLocation, reads, 0);
|
||||
// TODO -- add some tests here using pileup
|
||||
|
||||
// this code ensures that the pileup example is correct. Can be deleted
|
||||
Assert.assertEquals(pileup.getNumberOfElements(), pileupSize);
|
||||
int nA = 0, nC = 0;
|
||||
for ( final PileupElement p : pileup ) {
|
||||
if ( p.getBase() == 'A' ) nA++;
|
||||
if ( p.getBase() == 'C' ) nC++;
|
||||
}
|
||||
Assert.assertEquals(nA, pileupSize / 2);
|
||||
Assert.assertEquals(nC, pileupSize / 2);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A unit test that creates an artificial read for testing some code that uses reads
|
||||
*/
|
||||
@Test()
|
||||
public void testWithBAMFile() {
|
||||
// create a fake BAM file, and iterate through it
|
||||
final ArtificialBAMBuilder bamBuilder = new ArtificialBAMBuilder(seq, 20, 10);
|
||||
final File bam = bamBuilder.makeTemporarilyBAMFile();
|
||||
final SAMFileReader reader = new SAMFileReader(bam);
|
||||
reader.setSAMRecordFactory(new GATKSamRecordFactory());
|
||||
|
||||
final Iterator<SAMRecord> bamIt = reader.iterator();
|
||||
while ( bamIt.hasNext() ) {
|
||||
final GATKSAMRecord read = (GATKSAMRecord)bamIt.next(); // all reads are actually GATKSAMRecords
|
||||
// TODO -- add some tests that use reads from a BAM
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test code that creates VariantContexts
|
||||
*/
|
||||
@Test()
|
||||
public void testWithVariantContext() throws Exception {
|
||||
final List<Allele> alleles = Arrays.asList(Allele.create("A", true), Allele.create("C"));
|
||||
final VariantContext vc = new VariantContextBuilder("test", "1", 10, 10, alleles).make();
|
||||
Assert.assertTrue(vc.getAlleles().size() >= 0);
|
||||
// TODO -- add some tests that use VariantContext
|
||||
}
|
||||
}
|
||||
|
|
@ -23,20 +23,22 @@
|
|||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.variant.utils;
|
||||
package org.broadinstitute.sting.utils;
|
||||
|
||||
import org.broadinstitute.variant.VariantBaseTest;
|
||||
import org.broadinstitute.sting.BaseTest;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
|
||||
|
||||
public class BaseUtilsUnitTest extends VariantBaseTest {
|
||||
public class BaseUtilsUnitTest extends BaseTest {
|
||||
@BeforeClass
|
||||
public void init() { }
|
||||
|
||||
@Test
|
||||
public void testMostFrequentBaseFraction() {
|
||||
logger.warn("Executing testMostFrequentBaseFraction");
|
||||
|
||||
compareFrequentBaseFractionToExpected("AAAAA", 1.0);
|
||||
compareFrequentBaseFractionToExpected("ACCG", 0.5);
|
||||
compareFrequentBaseFractionToExpected("ACCCCTTTTG", 4.0/10.0);
|
||||
|
|
@ -44,7 +46,7 @@ public class BaseUtilsUnitTest extends VariantBaseTest {
|
|||
|
||||
private void compareFrequentBaseFractionToExpected(String sequence, double expected) {
|
||||
double fraction = BaseUtils.mostFrequentBaseFraction(sequence.getBytes());
|
||||
Assert.assertTrue(GeneralUtils.compareDoubles(fraction, expected) == 0);
|
||||
Assert.assertTrue(MathUtils.compareDoubles(fraction, expected) == 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -64,6 +66,8 @@ public class BaseUtilsUnitTest extends VariantBaseTest {
|
|||
|
||||
@Test
|
||||
public void testTransitionTransversion() {
|
||||
logger.warn("Executing testTransitionTransversion");
|
||||
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( (byte)'A', (byte)'T' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( (byte)'A', (byte)'C' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( (byte)'A', (byte)'G' ) == BaseUtils.BaseSubstitutionType.TRANSITION );
|
||||
|
|
@ -89,6 +93,8 @@ public class BaseUtilsUnitTest extends VariantBaseTest {
|
|||
|
||||
@Test
|
||||
public void testReverseComplementString() {
|
||||
logger.warn("Executing testReverseComplementString");
|
||||
|
||||
compareRCStringToExpected("ACGGT", "ACCGT");
|
||||
compareRCStringToExpected("TCGTATATCTCGCTATATATATATAGCTCTAGTATA", "TATACTAGAGCTATATATATATAGCGAGATATACGA");
|
||||
compareRCStringToExpected("AAAN", "NTTT");
|
||||
|
|
@ -29,6 +29,7 @@ package org.broadinstitute.sting.utils;
|
|||
// the imports for unit testing.
|
||||
|
||||
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.interval.IntervalMergingRule;
|
||||
import org.broadinstitute.sting.utils.interval.IntervalUtils;
|
||||
import org.testng.Assert;
|
||||
|
|
@ -40,10 +41,7 @@ import org.broadinstitute.sting.utils.fasta.CachingIndexedFastaSequenceFile;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import net.sf.picard.reference.ReferenceSequenceFile;
|
||||
import net.sf.picard.reference.IndexedFastaSequenceFile;
|
||||
|
|
@ -291,4 +289,58 @@ public class GenomeLocUnitTest extends BaseTest {
|
|||
if ( expected == ComparisonResult.EQUALS )
|
||||
Assert.assertEquals(g1.hashCode(), g2.hashCode(), "Equal genome locs don't have the same hash code");
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
//
|
||||
// testing merging functionality
|
||||
//
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
private static final GenomeLoc loc1 = new GenomeLoc("1", 0, 10, 20);
|
||||
private static final GenomeLoc loc2 = new GenomeLoc("1", 0, 21, 30);
|
||||
private static final GenomeLoc loc3 = new GenomeLoc("1", 0, 31, 40);
|
||||
|
||||
private class MergeTest {
|
||||
public List<GenomeLoc> locs;
|
||||
|
||||
private MergeTest(final List<GenomeLoc> locs) {
|
||||
this.locs = locs;
|
||||
}
|
||||
}
|
||||
|
||||
@DataProvider(name = "SGLtest")
|
||||
public Object[][] createFindVariantRegionsData() {
|
||||
List<Object[]> tests = new ArrayList<Object[]>();
|
||||
|
||||
tests.add(new Object[]{new MergeTest(Arrays.<GenomeLoc>asList(loc1))});
|
||||
tests.add(new Object[]{new MergeTest(Arrays.<GenomeLoc>asList(loc1, loc2))});
|
||||
tests.add(new Object[]{new MergeTest(Arrays.<GenomeLoc>asList(loc1, loc2, loc3))});
|
||||
|
||||
return tests.toArray(new Object[][]{});
|
||||
}
|
||||
|
||||
@Test(dataProvider = "SGLtest", enabled = true)
|
||||
public void testSimpleGenomeLoc(MergeTest test) {
|
||||
testMerge(test.locs);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ReviewedStingException.class)
|
||||
public void testNotContiguousLocs() {
|
||||
final List<GenomeLoc> locs = new ArrayList<GenomeLoc>(1);
|
||||
locs.add(loc1);
|
||||
locs.add(loc3);
|
||||
testMerge(locs);
|
||||
}
|
||||
|
||||
private void testMerge(final List<GenomeLoc> locs) {
|
||||
GenomeLoc result1 = locs.get(0);
|
||||
for ( int i = 1; i < locs.size(); i++ )
|
||||
result1 = GenomeLoc.merge(result1, locs.get(i));
|
||||
|
||||
GenomeLoc result2 = GenomeLoc.merge(new TreeSet<GenomeLoc>(locs));
|
||||
Assert.assertEquals(result1, result2);
|
||||
Assert.assertEquals(result1.getStart(), locs.get(0).getStart());
|
||||
Assert.assertEquals(result1.getStop(), locs.get(locs.size() - 1).getStop());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ public class CachingIndexedFastaSequenceFileUnitTest extends BaseTest {
|
|||
Assert.assertEquals(changingNs, preservingNs + 4);
|
||||
}
|
||||
|
||||
@Test(enabled = true, expectedExceptions = {IllegalStateException.class})
|
||||
@Test(enabled = true, expectedExceptions = {UserException.class})
|
||||
public void testFailOnBadBase() throws FileNotFoundException, InterruptedException {
|
||||
final String testFasta = privateTestDir + "problematicFASTA.fasta";
|
||||
final CachingIndexedFastaSequenceFile fasta = new CachingIndexedFastaSequenceFile(new File(testFasta));
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ package org.broadinstitute.sting.utils.sam;
|
|||
|
||||
import org.broadinstitute.sting.BaseTest;
|
||||
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.sting.utils.BaseUtils;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ package org.broadinstitute.variant.variantcontext;
|
|||
|
||||
import org.broad.tribble.TribbleException;
|
||||
import org.broadinstitute.variant.VariantBaseTest;
|
||||
import org.broadinstitute.variant.utils.BaseUtils;
|
||||
import org.broadinstitute.variant.utils.GeneralUtils;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
|
@ -154,9 +153,9 @@ public class GenotypeLikelihoodsUnitTest extends VariantBaseTest {
|
|||
|
||||
public void testGetQualFromLikelihoodsMultiAllelic() {
|
||||
GenotypeLikelihoods gl = GenotypeLikelihoods.fromLog10Likelihoods(triAllelic);
|
||||
Allele ref = Allele.create(BaseUtils.Base.A.base,true);
|
||||
Allele alt1 = Allele.create(BaseUtils.Base.C.base);
|
||||
Allele alt2 = Allele.create(BaseUtils.Base.T.base);
|
||||
Allele ref = Allele.create((byte)'A',true);
|
||||
Allele alt1 = Allele.create((byte)'C');
|
||||
Allele alt2 = Allele.create((byte)'T');
|
||||
List<Allele> allAlleles = Arrays.asList(ref,alt1,alt2);
|
||||
List<Allele> gtAlleles = Arrays.asList(alt1,alt2);
|
||||
GenotypeBuilder gtBuilder = new GenotypeBuilder();
|
||||
|
|
|
|||
Loading…
Reference in New Issue