use of org.edamontology.edammap.core.input.csv.Bioconductor 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.csv.Bioconductor in project edammap by edamontology.
the class Csv method load.
public static List<InputType> load(String queryPath, QueryType type, int timeout, String userAgent) throws IOException, ParseException {
List<InputType> inputs = new ArrayList<>();
BeanListProcessor<? extends InputType> rowProcessor;
switch(type) {
case SEQwiki:
rowProcessor = new BeanListProcessor<SEQwiki>(SEQwiki.class);
break;
case msutils:
rowProcessor = new BeanListProcessor<Msutils>(Msutils.class);
break;
case Bioconductor:
rowProcessor = new BeanListProcessor<Bioconductor>(Bioconductor.class);
break;
default:
rowProcessor = new BeanListProcessor<Generic>(Generic.class);
break;
}
rowProcessor.setStrictHeaderValidationEnabled(false);
CsvParserSettings settings = new CsvParserSettings();
settings.setProcessor(rowProcessor);
settings.setHeaderExtractionEnabled(true);
settings.setAutoConfigurationEnabled(true);
// disabling is (slightly) more efficient if your input is small
settings.setReadInputOnSeparateThread(false);
settings.setSkipEmptyLines(true);
settings.trimValues(true);
settings.setMaxCharsPerColumn(100000);
settings.getFormat().setDelimiter(',');
settings.getFormat().setQuote('"');
settings.getFormat().setQuoteEscape('"');
settings.getFormat().setCharToEscapeQuoteEscaping('"');
settings.getFormat().setLineSeparator("\n");
settings.getFormat().setComment('#');
try (InputStreamReader reader = new InputStreamReader(Input.newInputStream(queryPath, true, timeout, userAgent), StandardCharsets.UTF_8)) {
CsvParser parser = new CsvParser(settings);
parser.parse(reader);
}
int i = 0;
for (InputType inputType : rowProcessor.getBeans()) {
inputType.check(++i);
inputs.add(inputType);
}
logger.debug("Loaded {} CSV entries from {} of type {}", inputs.size(), queryPath, type);
return inputs;
}
Aggregations