use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project goci by EBISPOT.
the class JsonProcessingService method getEfoTraits.
private Map<String, String> getEfoTraits(JsonNode doc) {
Map<String, String> traits = new HashMap<>();
String trait = "";
String uri = "";
if (doc.get("efoLink") != null) {
for (JsonNode efoLink : doc.get("efoLink")) {
String[] data = efoLink.asText().trim().split("\\|");
if (trait == "") {
trait = data[0];
uri = data[2];
} else {
trait = trait.concat(", ").concat(data[0]);
uri = uri.concat(", ").concat(data[2]);
}
}
}
traits.put("trait", trait);
traits.put("uri", uri);
return traits;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project goci by EBISPOT.
the class JsonProcessingService method getRepGene.
private String getRepGene(JsonNode doc) {
String genes = "";
if (doc.get("reportedGene") != null) {
int it = 0;
for (JsonNode gene : doc.get("reportedGene")) {
if (it > 0) {
genes = genes.concat(", ");
}
genes = genes.concat(gene.asText().trim());
it++;
}
}
return genes;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project goci by EBISPOT.
the class JsonProcessingService method processJson.
public String processJson() throws IOException {
String header;
if (type.equals("study") && !includeAncestry) {
header = "DATE ADDED TO CATALOG\tPUBMEDID\tFIRST AUTHOR\tDATE\tJOURNAL\tLINK\tSTUDY\tDISEASE/TRAIT\tINITIAL SAMPLE SIZE\tREPLICATION SAMPLE SIZE\tPLATFORM [SNPS PASSING QC]\tASSOCIATION COUNT";
} else if (includeAncestry) {
header = "STUDY ACCCESSION\tPUBMEDID\tFIRST AUTHOR\tDATE\tINITIAL SAMPLE DESCRIPTION\tREPLICATION SAMPLE DESCRIPTION\tSTAGE\tNUMBER OF INDIVDUALS\tBROAD ANCESTRAL CATEGORY\tCOUNTRY OF ORIGIN\tCOUNTRY OF RECRUITMENT\tADDITONAL ANCESTRY DESCRIPTION";
} else {
header = "DATE ADDED TO CATALOG\tPUBMEDID\tFIRST AUTHOR\tDATE\tJOURNAL\tLINK\tSTUDY\tDISEASE/TRAIT\tINITIAL SAMPLE SIZE\tREPLICATION SAMPLE SIZE\tREGION\tCHR_ID\tCHR_POS\tREPORTED GENE(S)\tMAPPED_GENE\tUPSTREAM_GENE_ID\tDOWNSTREAM_GENE_ID\tSNP_GENE_IDS\tUPSTREAM_GENE_DISTANCE\tDOWNSTREAM_GENE_DISTANCE\tSTRONGEST SNP-RISK ALLELE\tSNPS\tMERGED\tSNP_ID_CURRENT\tCONTEXT\tINTERGENIC\tRISK ALLELE FREQUENCY\tP-VALUE\tPVALUE_MLOG\tP-VALUE (TEXT)\tOR or BETA\t95% CI (TEXT)\tPLATFORM [SNPS PASSING QC]\tCNV";
}
if (includeAnnotations) {
header = header.concat("\tMAPPED_TRAIT\tMAPPED_TRAIT_URI\tSTUDY ACCESSION");
}
header = header.concat("\r\n");
StringBuilder result = new StringBuilder();
result.append(header);
ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.readTree(json);
JsonNode responseNode = node.get("response");
JsonNode docs = responseNode.get("docs");
for (JsonNode doc : docs) {
StringBuilder line = new StringBuilder();
if (type.equals("study") && !includeAncestry) {
processStudyJson(line, doc);
} else if (includeAncestry) {
if (doc.get("ancestryLinks") != null) {
for (JsonNode a : doc.get("ancestryLinks")) {
processAncestryJson(line, doc, a);
}
}
} else {
processAssociationJson(line, doc);
}
result.append(line.toString());
}
return result.toString();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project midpoint by Evolveum.
the class AbstractJsonLexicalProcessor method parseToPrimitive.
private <T> PrimitiveXNode<T> parseToPrimitive(JsonParsingContext ctx) throws IOException, SchemaException {
PrimitiveXNode<T> primitive = new PrimitiveXNode<T>();
Object tid = ctx.parser.getTypeId();
if (tid != null) {
QName typeName = tagToTypeName(tid, ctx);
primitive.setTypeQName(typeName);
primitive.setExplicitTypeDeclaration(true);
} else {
// We don't try to determine XNode type from the implicit JSON/YAML type (integer, number, ...),
// because XNode type prescribes interpretation in midPoint. E.g. YAML string type would be interpreted
// as xsd:string, even if the schema would expect e.g. timestamp.
}
JsonNode jn = ctx.parser.readValueAs(JsonNode.class);
ValueParser<T> vp = new JsonValueParser<T>(ctx.parser, jn);
primitive.setValueParser(vp);
return primitive;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode in project textdb by TextDB.
the class TupleJsonDeserializer method deserialize.
@Override
public Tuple deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
JsonNode node = p.getCodec().readTree(p);
JsonNode schemaNode = node.get(JsonConstants.SCHEMA);
JsonNode fieldsNode = node.get(JsonConstants.FIELDS);
Schema schema = new ObjectMapper().treeToValue(schemaNode, Schema.class);
ArrayList<IField> fields = new ArrayList<>();
for (int i = 0; i < schema.getAttributes().size(); i++) {
AttributeType attributeType = schema.getAttributes().get(i).getAttributeType();
JsonNode fieldNode = fieldsNode.get(i);
IField field = new ObjectMapper().treeToValue(fieldNode, attributeType.getFieldClass());
fields.add(field);
}
return new Tuple(schema, fields);
}
Aggregations