use of org.edamontology.edammap.core.input.json.Tool in project edammap by edamontology.
the class QueryLoader method get.
public static List<Query> get(String queryPath, QueryType type, Map<EdamUri, Concept> concepts, int timeout, String userAgent) throws IOException, ParseException {
if (type == QueryType.server) {
throw new IllegalArgumentException("Query of type \"" + QueryType.server.name() + "\" is not loadable from path, but has to be provided");
}
List<? extends InputType> inputs;
if (type == QueryType.biotools) {
inputs = Json.load(queryPath, type, timeout, userAgent);
} else if (type == QueryType.biotools14) {
inputs = Xml.load(queryPath, type, timeout, userAgent);
} else {
inputs = Csv.load(queryPath, type, timeout, userAgent);
}
Set<Query> queries = new LinkedHashSet<>();
String filename = new File(queryPath).getName();
for (InputType input : inputs) {
switch(type) {
case generic:
queries.add(getGeneric((Generic) input, concepts, filename));
break;
case SEQwiki:
queries.add(getSEQwiki((SEQwiki) input, concepts, filename));
break;
case msutils:
queries.add(getMsutils((Msutils) input, concepts, filename));
break;
case Bioconductor:
queries.add(getBioconductor((Bioconductor) input, concepts));
break;
case biotools14:
queries.add(getBiotools14((Biotools14) input, concepts, filename));
break;
case biotools:
queries.add(getBiotools((Tool) input, concepts, 0, 0, filename));
break;
case server:
break;
}
}
return new ArrayList<>(queries);
}
use of org.edamontology.edammap.core.input.json.Tool in project edammap by edamontology.
the class Json method outputBiotools.
public static void outputBiotools(Writer writer, List<Tool> tools) throws IOException {
ObjectMapper mapper = new ObjectMapper();
JsonGenerator generator = createGenerator(writer, null, mapper);
mapper.setSerializationInclusion(Include.NON_EMPTY);
generator.writeStartObject();
generator.writeNumberField("count", tools.size());
generator.writeFieldName("list");
generator.writeStartArray();
for (Tool tool : tools) {
generator.writeObject(tool);
}
generator.writeEndArray();
generator.writeEndObject();
generator.close();
}
use of org.edamontology.edammap.core.input.json.Tool in project edammap by edamontology.
the class Json method outputBiotools.
public static void outputBiotools(CoreArgs args, String queryPath, Path biotoolsPath, Map<EdamUri, Concept> concepts, Results results) throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.enable(SerializationFeature.CLOSE_CLOSEABLE);
mapper.setSerializationInclusion(Include.NON_EMPTY);
Biotools biotools = null;
try (InputStream is = Input.newInputStream(queryPath, true, args.getFetcherArgs().getTimeout(), args.getFetcherArgs().getPrivateArgs().getUserAgent())) {
biotools = mapper.readValue(is, Biotools.class);
}
if (biotools.getList().size() != results.getMappings().size()) {
throw new RuntimeException("Number of results (" + results.getMappings().size() + ") does not correspond to number of tools (" + biotools.getList().size() + ") from " + queryPath);
}
for (int i = 0; i < biotools.getList().size(); ++i) {
Tool tool = biotools.getList().get(i);
MappingTest mapping = results.getMappings().get(i);
if (tool.getBiotoolsID() != null && !tool.getBiotoolsID().equals(mapping.getId())) {
throw new RuntimeException("Tool ID from " + queryPath + " (" + tool.getBiotoolsID() + ") does not correspond to ID from results (" + mapping.getId() + ")");
}
if (!tool.getName().equals(mapping.getName())) {
throw new RuntimeException("Tool name from " + queryPath + " (" + tool.getName() + ") does not correspond to name from results (" + mapping.getName() + ")");
}
}
for (int i = 0; i < biotools.getList().size(); ++i) {
Tool tool = biotools.getList().get(i);
MappingTest mapping = results.getMappings().get(i);
addAnnotations(args, tool, mapping, concepts);
}
mapper.writeValue(biotoolsPath.toFile(), biotools);
}
Aggregations