本文整理汇总了Java中com.google.protobuf.Value类的典型用法代码示例。如果您正苦于以下问题:Java Value类的具体用法?Java Value怎么用?Java Value使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Value类属于com.google.protobuf包,在下文中一共展示了Value类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: doMerge
import com.google.protobuf.Value; //导入依赖的package包/类
@Override
public void doMerge(JsonParser parser, int currentDepth, Message.Builder messageBuilder)
throws IOException {
Value.Builder builder = (Value.Builder) messageBuilder;
JsonToken token = parser.currentToken();
if (token.isBoolean()) {
builder.setBoolValue(ParseSupport.parseBool(parser));
} else if (token.isNumeric()) {
builder.setNumberValue(ParseSupport.parseDouble(parser));
} else if (token == JsonToken.VALUE_NULL) {
builder.setNullValue(NullValue.NULL_VALUE);
} else if (token.isScalarValue()) {
builder.setStringValue(ParseSupport.parseString(parser));
} else if (token == JsonToken.START_OBJECT) {
Struct.Builder structBuilder = builder.getStructValueBuilder();
StructMarshaller.INSTANCE.mergeValue(parser, currentDepth + 1, structBuilder);
} else if (token == JsonToken.START_ARRAY) {
ListValue.Builder listValueBuilder = builder.getListValueBuilder();
ListValueMarshaller.INSTANCE.mergeValue(parser, currentDepth + 1, listValueBuilder);
} else {
throw new IllegalStateException("Unexpected json data: " + parser.getText());
}
}
开发者ID:curioswitch,项目名称:curiostack,代码行数:24,代码来源:WellKnownTypeMarshaller.java
示例2: doWrite
import com.google.protobuf.Value; //导入依赖的package包/类
@Override
public void doWrite(Value message, JsonGenerator gen) throws IOException {
switch (message.getKindCase()) {
case NULL_VALUE:
SerializeSupport.printNull(0, gen);
break;
case NUMBER_VALUE:
SerializeSupport.printDouble(message.getNumberValue(), gen);
break;
case STRING_VALUE:
SerializeSupport.printString(message.getStringValue(), gen);
break;
case BOOL_VALUE:
SerializeSupport.printBool(message.getBoolValue(), gen);
break;
case STRUCT_VALUE:
StructMarshaller.INSTANCE.writeValue(message.getStructValue(), gen);
break;
case LIST_VALUE:
ListValueMarshaller.INSTANCE.writeValue(message.getListValue(), gen);
break;
case KIND_NOT_SET:
SerializeSupport.printNull(0, gen);
break;
}
}
开发者ID:curioswitch,项目名称:curiostack,代码行数:27,代码来源:WellKnownTypeMarshaller.java
示例3: anyInMaps
import com.google.protobuf.Value; //导入依赖的package包/类
@Test
public void anyInMaps() throws Exception {
TestAny.Builder testAny = TestAny.newBuilder();
testAny.putAnyMap("int32_wrapper", Any.pack(Int32Value.newBuilder().setValue(123).build()));
testAny.putAnyMap("int64_wrapper", Any.pack(Int64Value.newBuilder().setValue(456).build()));
testAny.putAnyMap("timestamp", Any.pack(Timestamps.parse("1969-12-31T23:59:59Z")));
testAny.putAnyMap("duration", Any.pack(Durations.parse("12345.1s")));
testAny.putAnyMap("field_mask", Any.pack(FieldMaskUtil.fromString("foo.bar,baz")));
Value numberValue = Value.newBuilder().setNumberValue(1.125).build();
Struct.Builder struct = Struct.newBuilder();
struct.putFields("number", numberValue);
testAny.putAnyMap("struct", Any.pack(struct.build()));
Value nullValue = Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build();
testAny.putAnyMap(
"list_value",
Any.pack(ListValue.newBuilder().addValues(numberValue).addValues(nullValue).build()));
testAny.putAnyMap("number_value", Any.pack(numberValue));
testAny.putAnyMap("any_value_number", Any.pack(Any.pack(numberValue)));
testAny.putAnyMap("any_value_default", Any.pack(Any.getDefaultInstance()));
testAny.putAnyMap("default", Any.getDefaultInstance());
assertMatchesUpstream(testAny.build(), TestAllTypes.getDefaultInstance());
}
开发者ID:curioswitch,项目名称:curiostack,代码行数:24,代码来源:MessageMarshallerTest.java
示例4: newTestLogEntry
import com.google.protobuf.Value; //导入依赖的package包/类
private static LogEntry.Builder newTestLogEntry(String name, int responseCode) {
Value.Builder vb = Value.newBuilder();
Map<String, Value> values = Maps.newHashMap();
values.put("api_key", vb.setStringValue(TEST_API_KEY).build());
values.put("http_method", vb.setStringValue("GET").build());
values.put("timestamp",
vb.setNumberValue(TEST_CLOCK.currentTimeMillis()).build());
values.put("http_response_code", vb.setNumberValue(responseCode).build());
values.put("response_size", vb.setNumberValue(TEST_SIZE).build());
values.put("request_size", vb.setNumberValue(TEST_SIZE).build());
if (responseCode >= 400) {
values.put("error_cause", vb.setStringValue("internal").build());
}
return LogEntry
.newBuilder()
.setStructPayload(Struct.newBuilder().putAllFields(values))
.setName(name)
.setSeverity(responseCode >= 400 ? LogSeverity.ERROR : LogSeverity.INFO)
.setTimestamp(REALLY_EARLY);
}
开发者ID:cloudendpoints,项目名称:endpoints-management-java,代码行数:21,代码来源:ReportRequestInfoTest.java
示例5: createTypedValue
import com.google.protobuf.Value; //导入依赖的package包/类
private static Value createTypedValue(VCFHeaderLineType type, Object value) {
if (type == VCFHeaderLineType.Flag) {
return Value.newBuilder().setBoolValue((Boolean) value).build();
}
// Booleans are given as Boolean objects. Strangely, Floats and Integers
// are given as String objects by HTSJDK.
if (!(value instanceof String)) {
throw new IllegalStateException("Received non-Boolean, non-List type in non-String format. "
+ "This is most likely due to a change in htsjdk's library.");
}
String stringValue = (String) value;
boolean isNumeric = stringValue.matches("[-+]?\\d+(\\.\\d+)?");
if (type == VCFHeaderLineType.Integer && isNumeric) {
return Value.newBuilder().setNumberValue(Integer.parseInt(stringValue)).build();
}
if (type == VCFHeaderLineType.Float && isNumeric) {
return Value.newBuilder().setNumberValue(Double.parseDouble(stringValue)).build();
}
return Value.newBuilder().setStringValue(stringValue).build();
}
开发者ID:verilylifesciences,项目名称:genomewarp,代码行数:27,代码来源:VcfToVariant.java
示例6: parseInlineGenotypeFields
import com.google.protobuf.Value; //导入依赖的package包/类
private static boolean parseInlineGenotypeFields(String field, VariantCall.Builder vcBuilder,
ListValue.Builder lvBuilder, IntGenotypeFieldAccessors.Accessor accessor, Genotype g) {
final int[] intValues = accessor.getValues(g);
if (intValues == null || intValues.length == 0) {
return false;
}
if (field.equals(VCFConstants.GENOTYPE_PL_KEY)) {
// HTSJDK folds GL's into PL's. We only use PL's to store genotype likelihood.
for (int i = 0; i < intValues.length; i++) {
// We add 0.0 to remove the possiblity of getting -0.0.
vcBuilder.addGenotypeLikelihood(-(double) intValues[i] / 10.0 + 0.0);
}
return false;
}
for (int i = 0; i < intValues.length; i++) {
lvBuilder.addValues(Value.newBuilder().setNumberValue(intValues[i]));
}
return true;
}
开发者ID:verilylifesciences,项目名称:genomewarp,代码行数:23,代码来源:VcfToVariant.java
示例7: testGetAlleleFreq
import com.google.protobuf.Value; //导入依赖的package包/类
@Test
public void testGetAlleleFreq() throws Exception {
DoFnTester<Variant, KV<Position, AlleleFreq>> getAlleleFreq = DoFnTester.of(
new GetAlleleFreq());
Position pos = Position.newBuilder()
.setReferenceName("1")
.setPosition(123L)
.build();
Variant.Builder vBuild = Variant.newBuilder()
.setReferenceName("1")
.setStart(123L)
.setReferenceBases("C")
.addAlternateBases("T");
vBuild.getMutableInfo().put("AF", ListValue.newBuilder()
.addValues(Value.newBuilder().setStringValue("0.25").build()).build());
AlleleFreq af = new AlleleFreq();
af.setAltBases(Lists.newArrayList("T"));
af.setRefBases("C");
af.setRefFreq(0.25);
Assert.assertThat(getAlleleFreq.processBundle(vBuild.build()),
CoreMatchers.hasItems(KV.of(pos, af)));
}
开发者ID:googlegenomics,项目名称:dataflow-java,代码行数:23,代码来源:VerifyBamIdTest.java
示例8: onNext
import com.google.protobuf.Value; //导入依赖的package包/类
@Override
public void onNext(T value) {
List<Value> path =
dataFetchingEnvironment
.getFieldTypeInfo()
.getPath()
.toList()
.stream()
.map(
p ->
p instanceof Number
? Value.newBuilder()
.setNumberValue(Double.parseDouble(p.toString()))
.build()
: Value.newBuilder().setStringValue(p.toString()).build())
.collect(ImmutableList.toImmutableList());
ListValue pathListVale =
ListValue.newBuilder()
.addAllValues(path)
.addValues(Value.newBuilder().setNumberValue(pathIndex.incrementAndGet()))
.build();
R graphQlResponse = getData(value, pathListVale);
rejoinerStreamingContext.responseStreamObserver().onNext(graphQlResponse);
try {
System.out.println(
"Streaming response as Json: " + JsonFormat.printer().print(graphQlResponse));
} catch (InvalidProtocolBufferException e) {
throw new RuntimeException(e);
}
}
开发者ID:google,项目名称:rejoiner,代码行数:35,代码来源:GraphQlStreamObserver.java
示例9: struct
import com.google.protobuf.Value; //导入依赖的package包/类
@Test
public void struct() throws Exception {
// Build a struct with all possible values.
TestStruct.Builder builder = TestStruct.newBuilder();
Struct.Builder structBuilder = builder.getStructValueBuilder();
structBuilder.putFields("null_value", Value.newBuilder().setNullValueValue(0).build());
structBuilder.putFields("number_value", Value.newBuilder().setNumberValue(1.25).build());
structBuilder.putFields("string_value", Value.newBuilder().setStringValue("hello").build());
Struct.Builder subStructBuilder = Struct.newBuilder();
subStructBuilder.putFields("number_value", Value.newBuilder().setNumberValue(1234).build());
structBuilder.putFields(
"struct_value", Value.newBuilder().setStructValue(subStructBuilder.build()).build());
ListValue.Builder listBuilder = ListValue.newBuilder();
listBuilder.addValues(Value.newBuilder().setNumberValue(1.125).build());
listBuilder.addValues(Value.newBuilder().setNullValueValue(0).build());
structBuilder.putFields(
"list_value", Value.newBuilder().setListValue(listBuilder.build()).build());
TestStruct message = builder.build();
assertMatchesUpstream(message);
builder = TestStruct.newBuilder();
builder.setValue(Value.newBuilder().setNullValueValue(0).build());
message = builder.build();
assertMatchesUpstream(message);
builder = TestStruct.newBuilder();
listBuilder = builder.getListValueBuilder();
listBuilder.addValues(Value.newBuilder().setNumberValue(31831.125).build());
listBuilder.addValues(Value.newBuilder().setNullValueValue(0).build());
message = builder.build();
assertMatchesUpstream(message);
}
开发者ID:curioswitch,项目名称:curiostack,代码行数:33,代码来源:MessageMarshallerTest.java
示例10: tensorToNDArray
import com.google.protobuf.Value; //导入依赖的package包/类
public static DefaultData tensorToNDArray(DefaultData data){
if (data.getDataOneofCase() == DataOneofCase.TENSOR)
{
List<Double> valuesList = data.getTensor().getValuesList();
List<Integer> shapeList = data.getTensor().getShapeList();
DefaultData.Builder dataBuilder = DefaultData.newBuilder();
int index=0;
for (Iterator<String> i = data.getNamesList().iterator(); i.hasNext();){
dataBuilder.setNames(index, i.next());
index++;
}
ListValue.Builder b1 = ListValue.newBuilder();
for (int i = 0; i < shapeList.get(0); ++i) {
ListValue.Builder b2 = ListValue.newBuilder();
for (int j = 0; j < shapeList.get(1); j++){
b2.addValues(Value.newBuilder().setNumberValue(valuesList.get(i*shapeList.get(1))+j));
}
b1.addValues(Value.newBuilder().setListValue(b2.build()));
}
dataBuilder.setNdarray(b1.build());
return dataBuilder.build();
}
else if (data.getDataOneofCase() == DataOneofCase.NDARRAY)
{
return data;
}
return null;
}
开发者ID:SeldonIO,项目名称:seldon-core,代码行数:34,代码来源:PredictorUtils.java
示例11: updateData
import com.google.protobuf.Value; //导入依赖的package包/类
public static DefaultData updateData(DefaultData oldData, INDArray newData){
DefaultData.Builder dataBuilder = DefaultData.newBuilder();
dataBuilder.addAllNames(oldData.getNamesList());
// int index=0;
// for (Iterator<String> i = oldData.getFeaturesList().iterator(); i.hasNext();){
// dataBuilder.setFeatures(index, i.next());
// index++;
// }
if (oldData.getDataOneofCase() == DataOneofCase.TENSOR){
Tensor.Builder tBuilder = Tensor.newBuilder();
List<Integer> shapeList = Arrays.stream(newData.shape()).boxed().collect(Collectors.toList());
tBuilder.addAllShape(shapeList);
for (int i=0; i<shapeList.get(0); ++i){
for (int j=0; j<shapeList.get(1); ++j){
tBuilder.addValues(newData.getDouble(i,j));
}
}
dataBuilder.setTensor(tBuilder);
return dataBuilder.build();
}
else if (oldData.getDataOneofCase() == DataOneofCase.NDARRAY){
ListValue.Builder b1 = ListValue.newBuilder();
for (int i = 0; i < newData.shape()[0]; ++i) {
ListValue.Builder b2 = ListValue.newBuilder();
for (int j = 0; j < newData.shape()[1]; j++){
b2.addValues(Value.newBuilder().setNumberValue(newData.getDouble(i,j)));
}
b1.addValues(Value.newBuilder().setListValue(b2.build()));
}
dataBuilder.setNdarray(b1.build());
return dataBuilder.build();
}
return null;
}
开发者ID:SeldonIO,项目名称:seldon-core,代码行数:40,代码来源:PredictorUtils.java
示例12: defaultRequest
import com.google.protobuf.Value; //导入依赖的package包/类
@Test
public void defaultRequest() throws InvalidProtocolBufferException
{
String[] features = {"a","b"};
Double[] values = {1.0,2.0,1.5,2.2};
DefaultData.Builder defB = DefaultData.newBuilder();
defB.addAllNames( Arrays.asList(features) );
defB.setTensor(Tensor.newBuilder().addShape(1).addShape(values.length).addAllValues(Arrays.asList(values)).build());
SeldonMessage.Builder b = SeldonMessage.newBuilder();
Value v;
Value v1 = Value.newBuilder().setNumberValue(1.0).build();
b.setData(defB.build()).setMeta(Meta.newBuilder().putTags("key", v1).build());
SeldonMessage request = b.build();
String json = ProtoBufUtils.toJson(request);
System.out.println(json);
SeldonMessage.Builder b2 = SeldonMessage.newBuilder();
ProtoBufUtils.updateMessageBuilderFromJson(b2, json);
SeldonMessage request2 = b2.build();
String json2 = ProtoBufUtils.toJson(request2);
System.out.println(json2);
Assert.assertEquals(json, json2);
}
开发者ID:SeldonIO,项目名称:seldon-core,代码行数:32,代码来源:TestPredictionProto.java
示例13: testSimpleNDArrayCase
import com.google.protobuf.Value; //导入依赖的package包/类
@Test
public void testSimpleNDArrayCase() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException {
List<SeldonMessage> predictorReturns = new ArrayList<>();
String[] names = {"c","d"};
Double[] values1 = {1.0,1.0};
predictorReturns.add(SeldonMessage.newBuilder().setStatus(Status.newBuilder().setStatus(Status.StatusFlag.SUCCESS).build())
.setData(DefaultData.newBuilder().addAllNames(Arrays.asList(names))
.setNdarray(ListValue.newBuilder().addValues(Value.newBuilder().setListValue(ListValue.newBuilder()
.addValues(Value.newBuilder().setNumberValue(values1[0]))
.addValues(Value.newBuilder().setNumberValue(values1[1])).build())).build()).build()).build());
Double[] values2 = {1.0,0.5};
predictorReturns.add(SeldonMessage.newBuilder().setStatus(Status.newBuilder().setStatus(Status.StatusFlag.SUCCESS).build())
.setData(DefaultData.newBuilder().addAllNames(Arrays.asList(names))
.setNdarray(ListValue.newBuilder().addValues(Value.newBuilder().setListValue(ListValue.newBuilder()
.addValues(Value.newBuilder().setNumberValue(values2[0]))
.addValues(Value.newBuilder().setNumberValue(values2[1])).build())).build()).build()).build());
Double[] values3 = {2.2,0.9};
predictorReturns.add(SeldonMessage.newBuilder().setStatus(Status.newBuilder().setStatus(Status.StatusFlag.SUCCESS).build())
.setData(DefaultData.newBuilder().addAllNames(Arrays.asList(names))
.setNdarray(ListValue.newBuilder().addValues(Value.newBuilder().setListValue(ListValue.newBuilder()
.addValues(Value.newBuilder().setNumberValue(values3[0]))
.addValues(Value.newBuilder().setNumberValue(values3[1])).build())).build()).build()).build());
AverageCombinerUnit averageCombinerUnit = new AverageCombinerUnit();
SeldonMessage average = averageCombinerUnit.aggregate(predictorReturns, null);
Assert.assertThat(average.getData().getNamesList().get(0),is(names[0]));
Double[][] expected_values = {{(1.0+1.0+2.2)/3,(1.0+0.5+0.9)/3}};
Assert.assertEquals(expected_values[0][0],average.getData().getNdarray().getValues(0).getListValue().getValues(0).getNumberValue(),1e-7);
}
开发者ID:SeldonIO,项目名称:seldon-core,代码行数:36,代码来源:AverageCombinerTest.java
示例14: createAdditionalServiceTypes
import com.google.protobuf.Value; //导入依赖的package包/类
/**
* Creates additional types (Value, Struct and ListValue) to be added to the Service config.
* TODO (guptasu): Fix this hack. Find a better way to add the predefined types.
* TODO (guptasu): Add them only when required and not in all cases.
*/
static Iterable<Type> createAdditionalServiceTypes() {
Map<String, DescriptorProto> additionalMessages = Maps.newHashMap();
additionalMessages.put(Struct.getDescriptor().getFullName(),
Struct.getDescriptor().toProto());
additionalMessages.put(Value.getDescriptor().getFullName(),
Value.getDescriptor().toProto());
additionalMessages.put(ListValue.getDescriptor().getFullName(),
ListValue.getDescriptor().toProto());
additionalMessages.put(Empty.getDescriptor().getFullName(),
Empty.getDescriptor().toProto());
additionalMessages.put(Int32Value.getDescriptor().getFullName(),
Int32Value.getDescriptor().toProto());
additionalMessages.put(DoubleValue.getDescriptor().getFullName(),
DoubleValue.getDescriptor().toProto());
additionalMessages.put(BoolValue.getDescriptor().getFullName(),
BoolValue.getDescriptor().toProto());
additionalMessages.put(StringValue.getDescriptor().getFullName(),
StringValue.getDescriptor().toProto());
for (Descriptor descriptor : Struct.getDescriptor().getNestedTypes()) {
additionalMessages.put(descriptor.getFullName(), descriptor.toProto());
}
// TODO (guptasu): Remove this hard coding. Without this, creation of Model from Service throws.
// Needs investigation.
String fileName = "struct.proto";
List<Type> additionalTypes = Lists.newArrayList();
for (String typeName : additionalMessages.keySet()) {
additionalTypes.add(TypesBuilderFromDescriptor.createType(typeName,
additionalMessages.get(typeName), fileName));
}
return additionalTypes;
}
开发者ID:googleapis,项目名称:api-compiler,代码行数:40,代码来源:TypesBuilderFromDescriptor.java
示例15: getKind
import com.google.protobuf.Value; //导入依赖的package包/类
private static String getKind(Value.KindCase kind) {
switch (kind) {
case NULL_VALUE: return "NULL_VALUE";
case NUMBER_VALUE: return "NUMBER_VALUE";
case STRING_VALUE: return "STRING_VALUE";
case BOOL_VALUE: return "BOOL_VALUE";
case STRUCT_VALUE: return "STRUCT_VALUE";
case LIST_VALUE: return "LIST_VALUE";
default: return "KIND_NOT_SET";
}
}
开发者ID:verilylifesciences,项目名称:genomewarp,代码行数:12,代码来源:VariantToVcf.java
示例16: parseObject
import com.google.protobuf.Value; //导入依赖的package包/类
private static Object parseObject(String key, Value in, VCFHeaderLineType type) {
// Case on type
switch (in.getKindCase()) {
case NULL_VALUE: throw new IllegalStateException(String.format("field %s contained "
+ "a null value", key));
case NUMBER_VALUE: return getNumberValue(in.getNumberValue(), type);
case STRING_VALUE: return in.getStringValue();
case BOOL_VALUE: return (Boolean) in.getBoolValue();
default: throw new IllegalStateException(String.format("field %s contained a %s type, which"
+ " is not supported by VariantToVcf", key, getKind(in.getKindCase())));
}
}
开发者ID:verilylifesciences,项目名称:genomewarp,代码行数:13,代码来源:VariantToVcf.java
示例17: valueFromObject
import com.google.protobuf.Value; //导入依赖的package包/类
private static Value valueFromObject(Object v) {
if (v instanceof Boolean) {
return Value.newBuilder().setBoolValue((Boolean) v).build();
}
if (v instanceof Integer) {
return Value.newBuilder().setNumberValue((Integer) v).build();
}
if (v instanceof Double) {
return Value.newBuilder().setNumberValue((Double) v).build();
}
return Value.newBuilder().setStringValue((String) v).build();
}
开发者ID:verilylifesciences,项目名称:genomewarp,代码行数:14,代码来源:GenomeWarpTestUtils.java
示例18: testFilterVariantCallsFn_AllCallsRemoved
import com.google.protobuf.Value; //导入依赖的package包/类
@Test
public void testFilterVariantCallsFn_AllCallsRemoved() throws Exception {
Map<String, ListValue> passingFilter = new HashMap<String, ListValue>();
passingFilter.put(
TransformNonVariantSegmentData.FILTER_FIELD,
ListValue.newBuilder()
.addValues(Value.newBuilder().setStringValue(TransformNonVariantSegmentData.PASSING_FILTER).build())
.build());
VariantCall passingCall = VariantCall.newBuilder().putAllInfo(passingFilter).build();
Map<String, ListValue> failingFilter = new HashMap<String, ListValue>();
failingFilter.put(
TransformNonVariantSegmentData.FILTER_FIELD,
ListValue.newBuilder()
.addValues(Value.newBuilder().setStringValue("VQSRTrancheSNP99.90to100.00").build())
.build());
VariantCall failingCall = VariantCall.newBuilder().putAllInfo(failingFilter).build();
DoFnTester<Variant, Variant> filterCallsFn = DoFnTester.of(new FilterCallsFn(true));
List<Variant> filteredVariants = filterCallsFn.processBundle(
Variant.newBuilder().setReferenceBases("T").addAlternateBases("A").addAllCalls(Arrays.asList(failingCall)).build(),
Variant.newBuilder().setReferenceBases("G").addAlternateBases("C").addAllCalls(Arrays.asList(passingCall)).build());
assertEquals(1, filteredVariants.size());
// Non-variant segments are not filtered.
filteredVariants = filterCallsFn.processBundle(
Variant.newBuilder().setReferenceBases("T").addAllCalls(Arrays.asList(failingCall)).build(),
Variant.newBuilder().setReferenceBases("G").addAlternateBases(VariantUtils.GATK_NON_VARIANT_SEGMENT_ALT)
.addAllCalls(Arrays.asList(failingCall)).build());
assertEquals(2, filteredVariants.size());
}
开发者ID:googlegenomics,项目名称:codelabs,代码行数:33,代码来源:TransformNonVariantSegmentDataTest.java
示例19: testFormatCalls
import com.google.protobuf.Value; //导入依赖的package包/类
@Test
public void testFormatCalls() throws Exception {
Map depthInfo = new HashMap<String, List<String>>();
depthInfo.put(
TransformNonVariantSegmentData.DEPTH_FIELD,
ListValue.newBuilder()
.addValues(Value.newBuilder().setStringValue("30").build())
.build());
Map dotDepthInfo = new HashMap<String, List<String>>();
dotDepthInfo.put(
TransformNonVariantSegmentData.DEPTH_FIELD,
ListValue.newBuilder()
.addValues(Value.newBuilder().setStringValue(".").build())
.build());
VariantCall callWithValidDepth = VariantCall.newBuilder()
.setCallSetName("hetAlt").addAllGenotype(Arrays.asList(0, 1))
.putAllInfo(depthInfo)
.build();
VariantCall callWithDotDepth = VariantCall.newBuilder()
.setCallSetName("homAlt").addAllGenotype(Arrays.asList(1, 1))
.putAllInfo(dotDepthInfo)
.build();
Variant variant = Variant.newBuilder()
.putAllInfo(FlagVariantsWithAmbiguousCallsFn.NO_AMBIGUOUS_CALLS_INFO)
.addAllCalls(Arrays.asList(callWithValidDepth, callWithDotDepth))
.build();
DoFnTester<Variant, TableRow> formatVariantsFn = DoFnTester.of(new TransformNonVariantSegmentData.FormatVariantsFn(true, false, cohortMap));
List<TableRow> rows = formatVariantsFn.processBundle(variant);
assertEquals(1, rows.size());
assertEquals("[{call_set_name=hetAlt, phaseset=, genotype=[0, 1], genotype_likelihood=[], FILTER=[], DP=30},"
+ " {call_set_name=homAlt, phaseset=, genotype=[1, 1], genotype_likelihood=[], FILTER=[], DP=null}]",
rows.get(0).get("call").toString());
}
开发者ID:googlegenomics,项目名称:codelabs,代码行数:41,代码来源:TransformNonVariantSegmentDataTest.java
示例20: ValueMarshaller
import com.google.protobuf.Value; //导入依赖的package包/类
ValueMarshaller() {
super(Value.getDefaultInstance());
}
开发者ID:curioswitch,项目名称:curiostack,代码行数:4,代码来源:WellKnownTypeMarshaller.java
注:本文中的com.google.protobuf.Value类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论