Search in sources :

Example 1 with MultipleFeatureQuery

use of org.nextprot.api.isoform.mapper.domain.MultipleFeatureQuery in project nextprot-api by calipho-sib.

the class IsoformMappingService method handleMultipleQueries.

/**
 * Execute the given single feature query function to each feature query
 * @param multipleFeatureQuery multiple feature query
 * @param function the function that process a FeatureQuery and produces FeatureQueryResult
 * @return a map of results
 */
default Map<String, FeatureQueryResult> handleMultipleQueries(MultipleFeatureQuery multipleFeatureQuery, Function<SingleFeatureQuery, FeatureQueryResult> function) {
    Map<String, FeatureQueryResult> results = new HashMap<>(multipleFeatureQuery.getFeatureList().size() + multipleFeatureQuery.getFeatureMaps().size());
    multipleFeatureQuery.getFeatureList().stream().filter(feature -> !results.containsKey(feature)).forEach(feature -> results.put(feature, function.apply(new SingleFeatureQuery(feature, multipleFeatureQuery.getFeatureType(), multipleFeatureQuery.getAccession()))));
    multipleFeatureQuery.getFeatureMaps().stream().filter(featureQuery -> !results.containsKey(featureQuery.get("feature"))).forEach(featureQuery -> results.put(featureQuery.get("feature"), function.apply(new SingleFeatureQuery(featureQuery.get("feature"), multipleFeatureQuery.getFeatureType(), featureQuery.get("accession")))));
    return results;
}
Also used : FeatureQueryResult(org.nextprot.api.isoform.mapper.domain.FeatureQueryResult) Map(java.util.Map) HashMap(java.util.HashMap) Function(java.util.function.Function) MultipleFeatureQuery(org.nextprot.api.isoform.mapper.domain.MultipleFeatureQuery) SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) FeatureQueryResult(org.nextprot.api.isoform.mapper.domain.FeatureQueryResult) SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 Function (java.util.function.Function)1 FeatureQueryResult (org.nextprot.api.isoform.mapper.domain.FeatureQueryResult)1 MultipleFeatureQuery (org.nextprot.api.isoform.mapper.domain.MultipleFeatureQuery)1 SingleFeatureQuery (org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery)1