2011-11-11 22:56:00 +08:00
|
|
|
/*
|
2013-01-11 06:04:08 +08:00
|
|
|
* 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.
|
|
|
|
|
*/
|
2011-11-11 22:56:00 +08:00
|
|
|
|
2012-12-19 03:56:48 +08:00
|
|
|
package org.broadinstitute.variant.variantcontext;
|
2011-11-11 22:56:00 +08:00
|
|
|
|
|
|
|
|
import com.google.caliper.Param;
|
|
|
|
|
import com.google.caliper.SimpleBenchmark;
|
2011-11-17 02:35:16 +08:00
|
|
|
import org.broad.tribble.Feature;
|
|
|
|
|
import org.broad.tribble.FeatureCodec;
|
|
|
|
|
import org.broadinstitute.sting.utils.GenomeLocParser;
|
2012-12-19 03:56:48 +08:00
|
|
|
import org.broadinstitute.variant.vcf.VCFCodec;
|
2011-11-11 22:56:00 +08:00
|
|
|
|
2013-01-08 10:25:44 +08:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Set;
|
2011-11-11 22:56:00 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Caliper microbenchmark of parsing a VCF file
|
|
|
|
|
*/
|
|
|
|
|
public class VariantContextBenchmark extends SimpleBenchmark {
|
|
|
|
|
@Param({"/Users/depristo/Desktop/broadLocal/localData/ALL.chr20.merged_beagle_mach.20101123.snps_indels_svs.genotypes.vcf"})
|
|
|
|
|
String vcfFile;
|
|
|
|
|
|
|
|
|
|
@Param({"1000"})
|
|
|
|
|
int linesToRead; // set automatically by framework
|
|
|
|
|
|
|
|
|
|
@Param({"100"})
|
|
|
|
|
int nSamplesToTake; // set automatically by framework
|
|
|
|
|
|
2011-11-17 02:35:16 +08:00
|
|
|
@Param({"10"})
|
|
|
|
|
int dupsToMerge; // set automatically by framework
|
2011-11-11 23:22:19 +08:00
|
|
|
|
2011-11-17 02:35:16 +08:00
|
|
|
@Param
|
|
|
|
|
Operation operation; // set automatically by framework
|
2011-11-11 23:22:19 +08:00
|
|
|
|
2011-11-11 22:56:00 +08:00
|
|
|
private String INPUT_STRING;
|
|
|
|
|
|
2011-11-11 23:22:19 +08:00
|
|
|
public enum Operation {
|
2011-11-11 22:56:00 +08:00
|
|
|
READ,
|
2011-11-17 02:35:16 +08:00
|
|
|
SUBSET_TO_SAMPLES,
|
|
|
|
|
GET_TYPE,
|
|
|
|
|
GET_ID,
|
|
|
|
|
GET_GENOTYPES,
|
|
|
|
|
GET_ATTRIBUTE_STRING,
|
|
|
|
|
GET_ATTRIBUTE_INT,
|
|
|
|
|
GET_N_SAMPLES,
|
|
|
|
|
GET_GENOTYPES_FOR_SAMPLES,
|
|
|
|
|
GET_GENOTYPES_IN_ORDER_OF_NAME,
|
|
|
|
|
CALC_GENOTYPE_COUNTS,
|
|
|
|
|
MERGE
|
2011-11-11 22:56:00 +08:00
|
|
|
}
|
|
|
|
|
|
2011-11-17 02:35:16 +08:00
|
|
|
private GenomeLocParser b37GenomeLocParser;
|
2011-11-11 23:22:19 +08:00
|
|
|
|
2011-11-11 22:56:00 +08:00
|
|
|
@Override protected void setUp() {
|
Rev Tribble to r97, adding binary feature support
From tribble logs:
Binary feature support in tribble
-- Massive refactoring and cleanup
-- Many bug fixes throughout
-- FeatureCodec is now general, with decode etc. taking a PositionBufferedStream
as an argument not a String
-- See ExampleBinaryCodec for an example binary codec
-- AbstractAsciiFeatureCodec provides to its subclass the same String decode,
readHeader functionality before. Old ASCII codecs should inherit from this base
class, and will work without additional modifications
-- Split AsciiLineReader into a position tracking stream
(PositionalBufferedStream). The new AsciiLineReader takes as an argument a
PositionalBufferedStream and provides the readLine() functionality of before.
Could potentially use optimizations (its a TODO in the code)
-- The Positional interface includes some more functionality that's now
necessary to support the more general decoding of binary features
-- FeatureReaders now work using the general FeatureCodec interface, so they can
index binary features
-- Bugfixes to LinearIndexCreator off by 1 error in setting the end block
position
-- Deleted VariantType, since this wasn't used anywhere and it's a particularly
clean why of thinking about the problem
-- Moved DiploidGenotype, which is specific to Gelitext, to the gelitext package
-- TabixReader requires an AsciiFeatureCodec as it's currently only implemented
to handle line oriented records
-- Renamed AsciiFeatureReader to TribbleIndexedFeatureReader now that it handles
Ascii and binary features
-- Removed unused functions here and there as encountered
-- Fixed build.xml to be truly headless
-- FeatureCodec readHeader returns a FeatureCodecHeader obtain that contains a
value and the position in the file where the header ends (not inclusive).
TribbleReaders now skip the header if the position is set, so its no longer
necessary, if one implements the general readHeader(PositionalBufferedStream)
version to see header lines in the decode functions. Necessary for binary
codecs but a nice side benefit for ascii codecs as well
-- Cleaned up the IndexFactory interface so there's a truly general createIndex
function that takes the enumerated index type. Added a writeIndex() function
that writes an index to disk.
-- Vastly expanded the index unit tests and reader tests to really test linear,
interval, and tabix indexed files. Updated test.bed, and created a tabix
version of it as well.
-- Significant BinaryFeaturesTest suite.
-- Some test files have indent changes
2012-05-03 19:02:28 +08:00
|
|
|
// TODO -- update for new tribble interface
|
|
|
|
|
// try {
|
|
|
|
|
// ReferenceSequenceFile seq = new CachingIndexedFastaSequenceFile(new File(BaseTest.b37KGReference));
|
|
|
|
|
// b37GenomeLocParser = new GenomeLocParser(seq);
|
|
|
|
|
// } catch ( FileNotFoundException e) {
|
|
|
|
|
// throw new RuntimeException(e);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // read it into a String so that we don't try to benchmark IO issues
|
|
|
|
|
// try {
|
|
|
|
|
// FileInputStream s = new FileInputStream(new File(vcfFile));
|
|
|
|
|
// AsciiLineReader lineReader = new AsciiLineReader(s);
|
|
|
|
|
// int counter = 0;
|
|
|
|
|
// StringBuffer sb = new StringBuffer();
|
|
|
|
|
// while (counter++ < linesToRead ) {
|
|
|
|
|
// String line = lineReader.readLine();
|
|
|
|
|
// if ( line == null )
|
|
|
|
|
// break;
|
|
|
|
|
// sb.append(line + "\n");
|
|
|
|
|
// }
|
|
|
|
|
// s.close();
|
|
|
|
|
// INPUT_STRING = sb.toString();
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// throw new RuntimeException(e);
|
|
|
|
|
// }
|
2011-11-11 22:56:00 +08:00
|
|
|
}
|
|
|
|
|
|
2011-11-17 02:35:16 +08:00
|
|
|
private interface FunctionToBenchmark<T extends Feature> {
|
|
|
|
|
public void run(T vc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private <T extends Feature> void runBenchmark(FeatureCodec<T> codec, FunctionToBenchmark<T> func) {
|
Rev Tribble to r97, adding binary feature support
From tribble logs:
Binary feature support in tribble
-- Massive refactoring and cleanup
-- Many bug fixes throughout
-- FeatureCodec is now general, with decode etc. taking a PositionBufferedStream
as an argument not a String
-- See ExampleBinaryCodec for an example binary codec
-- AbstractAsciiFeatureCodec provides to its subclass the same String decode,
readHeader functionality before. Old ASCII codecs should inherit from this base
class, and will work without additional modifications
-- Split AsciiLineReader into a position tracking stream
(PositionalBufferedStream). The new AsciiLineReader takes as an argument a
PositionalBufferedStream and provides the readLine() functionality of before.
Could potentially use optimizations (its a TODO in the code)
-- The Positional interface includes some more functionality that's now
necessary to support the more general decoding of binary features
-- FeatureReaders now work using the general FeatureCodec interface, so they can
index binary features
-- Bugfixes to LinearIndexCreator off by 1 error in setting the end block
position
-- Deleted VariantType, since this wasn't used anywhere and it's a particularly
clean why of thinking about the problem
-- Moved DiploidGenotype, which is specific to Gelitext, to the gelitext package
-- TabixReader requires an AsciiFeatureCodec as it's currently only implemented
to handle line oriented records
-- Renamed AsciiFeatureReader to TribbleIndexedFeatureReader now that it handles
Ascii and binary features
-- Removed unused functions here and there as encountered
-- Fixed build.xml to be truly headless
-- FeatureCodec readHeader returns a FeatureCodecHeader obtain that contains a
value and the position in the file where the header ends (not inclusive).
TribbleReaders now skip the header if the position is set, so its no longer
necessary, if one implements the general readHeader(PositionalBufferedStream)
version to see header lines in the decode functions. Necessary for binary
codecs but a nice side benefit for ascii codecs as well
-- Cleaned up the IndexFactory interface so there's a truly general createIndex
function that takes the enumerated index type. Added a writeIndex() function
that writes an index to disk.
-- Vastly expanded the index unit tests and reader tests to really test linear,
interval, and tabix indexed files. Updated test.bed, and created a tabix
version of it as well.
-- Significant BinaryFeaturesTest suite.
-- Some test files have indent changes
2012-05-03 19:02:28 +08:00
|
|
|
// TODO -- update for new Tribble interface
|
|
|
|
|
// try {
|
|
|
|
|
// InputStream is = new ByteArrayInputStream(INPUT_STRING.getBytes());
|
|
|
|
|
// AsciiLineReader lineReader = new AsciiLineReader(is);
|
|
|
|
|
// codec.readHeader(lineReader);
|
|
|
|
|
//
|
|
|
|
|
// int counter = 0;
|
|
|
|
|
// while (counter++ < linesToRead ) {
|
|
|
|
|
// String line = lineReader.readLine();
|
|
|
|
|
// if ( line == null )
|
|
|
|
|
// break;
|
|
|
|
|
//
|
|
|
|
|
// T vc = codec.decode(line);
|
|
|
|
|
// func.run(vc);
|
|
|
|
|
// }
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// System.out.println("Benchmarking run failure because of " + e.getMessage());
|
|
|
|
|
// }
|
2011-11-11 22:56:00 +08:00
|
|
|
}
|
|
|
|
|
|
2011-11-17 02:35:16 +08:00
|
|
|
public void timeV14(int rep) {
|
|
|
|
|
for ( int i = 0; i < rep; i++ ) {
|
|
|
|
|
FunctionToBenchmark<VariantContext> func = getV14FunctionToBenchmark();
|
|
|
|
|
FeatureCodec<VariantContext> codec = new VCFCodec();
|
|
|
|
|
runBenchmark(codec, func);
|
|
|
|
|
}
|
2011-11-11 22:56:00 +08:00
|
|
|
}
|
|
|
|
|
|
2011-11-17 02:35:16 +08:00
|
|
|
public FunctionToBenchmark<VariantContext> getV14FunctionToBenchmark() {
|
|
|
|
|
switch ( operation ) {
|
|
|
|
|
case READ:
|
|
|
|
|
return new FunctionToBenchmark<VariantContext>() {
|
|
|
|
|
public void run(final VariantContext vc) {
|
|
|
|
|
; // empty operation
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
case SUBSET_TO_SAMPLES:
|
|
|
|
|
return new FunctionToBenchmark<VariantContext>() {
|
|
|
|
|
Set<String> samples;
|
|
|
|
|
public void run(final VariantContext vc) {
|
|
|
|
|
if ( samples == null )
|
|
|
|
|
samples = new HashSet<String>(new ArrayList<String>(vc.getSampleNames()).subList(0, nSamplesToTake));
|
2012-08-01 23:57:16 +08:00
|
|
|
VariantContext sub = vc.subContextFromSamples(samples);
|
2011-11-17 02:35:16 +08:00
|
|
|
sub.getNSamples();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
case GET_TYPE:
|
|
|
|
|
return new FunctionToBenchmark<VariantContext>() {
|
|
|
|
|
public void run(final VariantContext vc) {
|
|
|
|
|
vc.getType();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
case GET_ID:
|
|
|
|
|
return new FunctionToBenchmark<VariantContext>() {
|
|
|
|
|
public void run(final VariantContext vc) {
|
|
|
|
|
vc.getID();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
case GET_GENOTYPES:
|
|
|
|
|
return new FunctionToBenchmark<VariantContext>() {
|
|
|
|
|
public void run(final VariantContext vc) {
|
|
|
|
|
vc.getGenotypes().size();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
case GET_GENOTYPES_FOR_SAMPLES:
|
|
|
|
|
return new FunctionToBenchmark<VariantContext>() {
|
|
|
|
|
Set<String> samples;
|
|
|
|
|
public void run(final VariantContext vc) {
|
|
|
|
|
if ( samples == null )
|
|
|
|
|
samples = new HashSet<String>(new ArrayList<String>(vc.getSampleNames()).subList(0, nSamplesToTake));
|
|
|
|
|
vc.getGenotypes(samples).size();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
case GET_ATTRIBUTE_STRING:
|
|
|
|
|
return new FunctionToBenchmark<VariantContext>() {
|
|
|
|
|
public void run(final VariantContext vc) {
|
|
|
|
|
vc.getAttribute("AN", null);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
case GET_ATTRIBUTE_INT:
|
|
|
|
|
return new FunctionToBenchmark<VariantContext>() {
|
|
|
|
|
public void run(final VariantContext vc) {
|
|
|
|
|
vc.getAttributeAsInt("AC", 0);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
case GET_N_SAMPLES:
|
|
|
|
|
return new FunctionToBenchmark<VariantContext>() {
|
|
|
|
|
public void run(final VariantContext vc) {
|
|
|
|
|
vc.getNSamples();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
case GET_GENOTYPES_IN_ORDER_OF_NAME:
|
|
|
|
|
return new FunctionToBenchmark<VariantContext>() {
|
|
|
|
|
public void run(final VariantContext vc) {
|
|
|
|
|
; // TODO - TEST IS BROKEN
|
|
|
|
|
// int n = 0;
|
2011-11-18 09:37:22 +08:00
|
|
|
// for ( final Genotype g: vc.getGenotypesOrderedByName() ) n++;
|
2011-11-17 02:35:16 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
case CALC_GENOTYPE_COUNTS:
|
|
|
|
|
return new FunctionToBenchmark<VariantContext>() {
|
|
|
|
|
public void run(final VariantContext vc) {
|
|
|
|
|
vc.getHetCount();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
case MERGE:
|
|
|
|
|
return new FunctionToBenchmark<VariantContext>() {
|
|
|
|
|
public void run(final VariantContext vc) {
|
|
|
|
|
List<VariantContext> toMerge = new ArrayList<VariantContext>();
|
|
|
|
|
|
|
|
|
|
for ( int i = 0; i < dupsToMerge; i++ ) {
|
2011-11-17 05:24:05 +08:00
|
|
|
GenotypesContext gc = GenotypesContext.create(vc.getNSamples());
|
2011-11-17 02:35:16 +08:00
|
|
|
for ( final Genotype g : vc.getGenotypes() ) {
|
2012-06-02 07:25:11 +08:00
|
|
|
gc.add(new GenotypeBuilder(g).name(g.getSampleName()+"_"+i).make());
|
2011-11-17 02:35:16 +08:00
|
|
|
}
|
2011-11-19 00:06:15 +08:00
|
|
|
toMerge.add(new VariantContextBuilder(vc).genotypes(gc).make());
|
2011-11-17 02:35:16 +08:00
|
|
|
}
|
|
|
|
|
|
2012-12-19 03:56:48 +08:00
|
|
|
VariantContextUtils.simpleMerge(toMerge, null,
|
2011-11-17 02:35:16 +08:00
|
|
|
VariantContextUtils.FilteredRecordMergeType.KEEP_IF_ANY_UNFILTERED,
|
|
|
|
|
VariantContextUtils.GenotypeMergeType.UNSORTED,
|
|
|
|
|
true, false, "set", false, true);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
default: throw new IllegalArgumentException("Unexpected operation " + operation);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-17 05:08:46 +08:00
|
|
|
// --------------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// V13
|
|
|
|
|
//
|
|
|
|
|
// In order to use this, you must move the v13 version from archive and uncomment
|
|
|
|
|
//
|
|
|
|
|
// git mv private/archive/java/src/org/broadinstitute/sting/utils/variantcontext/v13 public/java/test/org/broadinstitute/sting/utils/variantcontext/v13
|
|
|
|
|
//
|
|
|
|
|
// --------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// public void timeV13(int rep) {
|
|
|
|
|
// for ( int i = 0; i < rep; i++ ) {
|
2012-12-19 03:56:48 +08:00
|
|
|
// FunctionToBenchmark<org.broadinstitute.variant.variantcontext.v13.VariantContext> func = getV13FunctionToBenchmark();
|
|
|
|
|
// FeatureCodec<org.broadinstitute.variant.variantcontext.v13.VariantContext> codec = new org.broadinstitute.variant.variantcontext.v13.VCFCodec();
|
2011-11-17 05:08:46 +08:00
|
|
|
// runBenchmark(codec, func);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
2012-12-19 03:56:48 +08:00
|
|
|
// public FunctionToBenchmark<org.broadinstitute.variant.variantcontext.v13.VariantContext> getV13FunctionToBenchmark() {
|
2011-11-17 05:08:46 +08:00
|
|
|
// switch ( operation ) {
|
|
|
|
|
// case READ:
|
2012-12-19 03:56:48 +08:00
|
|
|
// return new FunctionToBenchmark<org.broadinstitute.variant.variantcontext.v13.VariantContext>() {
|
|
|
|
|
// public void run(final org.broadinstitute.variant.variantcontext.v13.VariantContext vc) {
|
2011-11-17 05:08:46 +08:00
|
|
|
// ; // empty operation
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
// case SUBSET_TO_SAMPLES:
|
2012-12-19 03:56:48 +08:00
|
|
|
// return new FunctionToBenchmark<org.broadinstitute.variant.variantcontext.v13.VariantContext>() {
|
2011-11-17 05:08:46 +08:00
|
|
|
// List<String> samples;
|
2012-12-19 03:56:48 +08:00
|
|
|
// public void run(final org.broadinstitute.variant.variantcontext.v13.VariantContext vc) {
|
2011-11-17 05:08:46 +08:00
|
|
|
// if ( samples == null )
|
|
|
|
|
// samples = new ArrayList<String>(vc.getSampleNames()).subList(0, nSamplesToTake);
|
2012-12-19 03:56:48 +08:00
|
|
|
// org.broadinstitute.variant.variantcontext.v13.VariantContext sub = vc.subContextFromGenotypes(vc.getGenotypes(samples).values());
|
2011-11-17 05:08:46 +08:00
|
|
|
// sub.getNSamples();
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// case GET_TYPE:
|
2012-12-19 03:56:48 +08:00
|
|
|
// return new FunctionToBenchmark<org.broadinstitute.variant.variantcontext.v13.VariantContext>() {
|
|
|
|
|
// public void run(final org.broadinstitute.variant.variantcontext.v13.VariantContext vc) {
|
2011-11-17 05:08:46 +08:00
|
|
|
// vc.getType();
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
// case GET_ID:
|
2012-12-19 03:56:48 +08:00
|
|
|
// return new FunctionToBenchmark<org.broadinstitute.variant.variantcontext.v13.VariantContext>() {
|
|
|
|
|
// public void run(final org.broadinstitute.variant.variantcontext.v13.VariantContext vc) {
|
2011-11-17 05:08:46 +08:00
|
|
|
// vc.getID();
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
// case GET_GENOTYPES:
|
2012-12-19 03:56:48 +08:00
|
|
|
// return new FunctionToBenchmark<org.broadinstitute.variant.variantcontext.v13.VariantContext>() {
|
|
|
|
|
// public void run(final org.broadinstitute.variant.variantcontext.v13.VariantContext vc) {
|
2011-11-17 05:08:46 +08:00
|
|
|
// vc.getGenotypes().size();
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// case GET_GENOTYPES_FOR_SAMPLES:
|
2012-12-19 03:56:48 +08:00
|
|
|
// return new FunctionToBenchmark<org.broadinstitute.variant.variantcontext.v13.VariantContext>() {
|
2011-11-17 05:08:46 +08:00
|
|
|
// Set<String> samples;
|
2012-12-19 03:56:48 +08:00
|
|
|
// public void run(final org.broadinstitute.variant.variantcontext.v13.VariantContext vc) {
|
2011-11-17 05:08:46 +08:00
|
|
|
// if ( samples == null )
|
|
|
|
|
// samples = new HashSet<String>(new ArrayList<String>(vc.getSampleNames()).subList(0, nSamplesToTake));
|
|
|
|
|
// vc.getGenotypes(samples).size();
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// case GET_ATTRIBUTE_STRING:
|
2012-12-19 03:56:48 +08:00
|
|
|
// return new FunctionToBenchmark<org.broadinstitute.variant.variantcontext.v13.VariantContext>() {
|
|
|
|
|
// public void run(final org.broadinstitute.variant.variantcontext.v13.VariantContext vc) {
|
2012-06-14 02:01:35 +08:00
|
|
|
// vc.getExtendedAttribute("AN", null);
|
2011-11-17 05:08:46 +08:00
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// case GET_ATTRIBUTE_INT:
|
2012-12-19 03:56:48 +08:00
|
|
|
// return new FunctionToBenchmark<org.broadinstitute.variant.variantcontext.v13.VariantContext>() {
|
|
|
|
|
// public void run(final org.broadinstitute.variant.variantcontext.v13.VariantContext vc) {
|
2011-11-17 05:08:46 +08:00
|
|
|
// vc.getAttributeAsInt("AC", 0);
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// case GET_N_SAMPLES:
|
2012-12-19 03:56:48 +08:00
|
|
|
// return new FunctionToBenchmark<org.broadinstitute.variant.variantcontext.v13.VariantContext>() {
|
|
|
|
|
// public void run(final org.broadinstitute.variant.variantcontext.v13.VariantContext vc) {
|
2011-11-17 05:08:46 +08:00
|
|
|
// vc.getNSamples();
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// case GET_GENOTYPES_IN_ORDER_OF_NAME:
|
2012-12-19 03:56:48 +08:00
|
|
|
// return new FunctionToBenchmark<org.broadinstitute.variant.variantcontext.v13.VariantContext>() {
|
|
|
|
|
// public void run(final org.broadinstitute.variant.variantcontext.v13.VariantContext vc) {
|
2011-11-17 05:08:46 +08:00
|
|
|
// ; // TODO - TEST IS BROKEN
|
2011-11-18 09:37:22 +08:00
|
|
|
// //vc.getGenotypesOrderedByName();
|
2011-11-17 05:08:46 +08:00
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// case CALC_GENOTYPE_COUNTS:
|
2012-12-19 03:56:48 +08:00
|
|
|
// return new FunctionToBenchmark<org.broadinstitute.variant.variantcontext.v13.VariantContext>() {
|
|
|
|
|
// public void run(final org.broadinstitute.variant.variantcontext.v13.VariantContext vc) {
|
2011-11-17 05:08:46 +08:00
|
|
|
// vc.getHetCount();
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// case MERGE:
|
2012-12-19 03:56:48 +08:00
|
|
|
// return new FunctionToBenchmark<org.broadinstitute.variant.variantcontext.v13.VariantContext>() {
|
|
|
|
|
// public void run(final org.broadinstitute.variant.variantcontext.v13.VariantContext vc) {
|
|
|
|
|
// List<org.broadinstitute.variant.variantcontext.v13.VariantContext> toMerge = new ArrayList<org.broadinstitute.variant.variantcontext.v13.VariantContext>();
|
2011-11-17 05:08:46 +08:00
|
|
|
//
|
|
|
|
|
// for ( int i = 0; i < dupsToMerge; i++ ) {
|
2012-12-19 03:56:48 +08:00
|
|
|
// Map<String, org.broadinstitute.variant.variantcontext.v13.Genotype> gc = new HashMap<String, org.broadinstitute.variant.variantcontext.v13.Genotype>();
|
|
|
|
|
// for ( final org.broadinstitute.variant.variantcontext.v13.Genotype g : vc.getGenotypes().values() ) {
|
2011-11-17 05:08:46 +08:00
|
|
|
// String name = g.getSampleName()+"_"+i;
|
2012-12-19 03:56:48 +08:00
|
|
|
// gc.put(name, new org.broadinstitute.variant.variantcontext.v13.Genotype(name,
|
2011-11-19 10:07:30 +08:00
|
|
|
// g.getAlleles(), g.getLog10PError(), g.getFilters(), g.getAttributes(), g.isPhased(), g.getLikelihoods().getAsVector()));
|
2012-12-19 03:56:48 +08:00
|
|
|
// toMerge.add(org.broadinstitute.variant.variantcontext.v13.VariantContext.modifyGenotypes(vc, gc));
|
2011-11-17 05:08:46 +08:00
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
2012-12-19 03:56:48 +08:00
|
|
|
// org.broadinstitute.variant.variantcontext.v13.VariantContextUtils.simpleMerge(b37GenomeLocParser,
|
2011-11-17 05:08:46 +08:00
|
|
|
// toMerge, null,
|
2012-12-19 03:56:48 +08:00
|
|
|
// org.broadinstitute.variant.variantcontext.v13.VariantContextUtils.FilteredRecordMergeType.KEEP_IF_ANY_UNFILTERED,
|
|
|
|
|
// org.broadinstitute.variant.variantcontext.v13.VariantContextUtils.GenotypeMergeType.UNSORTED,
|
2011-11-17 05:08:46 +08:00
|
|
|
// true, false, "set", false, true);
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
//
|
|
|
|
|
// default: throw new IllegalArgumentException("Unexpected operation " + operation);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2011-11-11 23:22:19 +08:00
|
|
|
|
2011-11-17 02:35:16 +08:00
|
|
|
public static void main(String[] args) {
|
2013-01-08 10:25:44 +08:00
|
|
|
com.google.caliper.Runner.main(VariantContextBenchmark.class, args);
|
2011-11-11 22:56:00 +08:00
|
|
|
}
|
|
|
|
|
}
|