Search in sources :

Example 1 with DbXrefProperty

use of org.nextprot.api.core.domain.DbXref.DbXrefProperty in project nextprot-api by calipho-sib.

the class DbXrefDaoImpl method findDbXrefsProperties.

@Override
public List<DbXrefProperty> findDbXrefsProperties(String entryName, List<Long> resourceIds) {
    List<DbXrefProperty> result = new ArrayList<>();
    // we must split the query into multiple queries otherwise we get an SQL error:
    // the number of parameters (list of resource id) cannot exceed 32767 and miss titin has now 43012 xrefs !
    List<List> paramsList = splitList(resourceIds);
    for (List l : paramsList) {
        Map<String, Object> params = new HashMap<>();
        params.put("resourceIds", l);
        List<DbXrefProperty> someProps = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("dbxref-props-by-resource-ids"), params, new DbXrefPropertyRowMapper());
        result.addAll(someProps);
        params.put("entryName", entryName);
        List<DbXrefProperty> someOtherProps = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("dbxref-entry-link-props-by-entry-and-resource-ids"), params, new DbXrefPropertyRowMapper());
        result.addAll(someOtherProps);
    }
    // System.out.println("AAA final size is " + result.size());
    return result;
}
Also used : NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) DbXrefProperty(org.nextprot.api.core.domain.DbXref.DbXrefProperty)

Example 2 with DbXrefProperty

use of org.nextprot.api.core.domain.DbXref.DbXrefProperty in project nextprot-api by calipho-sib.

the class DbXrefServiceImpl method attachPropertiesToXrefs.

private void attachPropertiesToXrefs(List<DbXref> xrefs, String uniqueName, boolean fetchXrefAnnotationMappingProperties) {
    List<Long> xrefIds = xrefs.stream().map(DbXref::getDbXrefId).collect(Collectors.toList());
    List<DbXrefProperty> shownProperties = dbXRefDao.findDbXrefsProperties(uniqueName, xrefIds).stream().filter(p -> !HIDDEN_PROPERTY_NAME_SET.contains(p.getName())).collect(Collectors.toList());
    Multimap<Long, DbXrefProperty> propsMap = Multimaps.index(shownProperties, DbXrefProperty::getDbXrefId);
    Map<Long, List<DbXrefProperty>> ensemblPropertiesMap = getDbXrefEnsemblInfos(uniqueName, xrefs);
    for (DbXref xref : xrefs) {
        if (!fetchXrefAnnotationMappingProperties)
            xref.setProperties((!Xref2Annotation.hasName(xref.getDatabaseName())) ? new ArrayList<>(propsMap.get(xref.getDbXrefId())) : new ArrayList<>());
        else
            xref.setProperties(new ArrayList<>(propsMap.get(xref.getDbXrefId())));
        if (ensemblPropertiesMap.containsKey(xref.getDbXrefId())) {
            xref.addProperties(ensemblPropertiesMap.get(xref.getDbXrefId()));
        }
    }
    xrefs.addAll(createMissingDbXrefs(xrefs));
}
Also used : java.util(java.util) Cacheable(org.springframework.cache.annotation.Cacheable) PublicationDbXref(org.nextprot.api.core.domain.PublicationDbXref) DbXrefDao(org.nextprot.api.core.dao.DbXrefDao) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Autowired(org.springframework.beans.factory.annotation.Autowired) Multimap(com.google.common.collect.Multimap) Multimaps(com.google.common.collect.Multimaps) AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) ImmutableList(com.google.common.collect.ImmutableList) Service(org.springframework.stereotype.Service) IsoformService(org.nextprot.api.core.service.IsoformService) DbXrefProperty(org.nextprot.api.core.domain.DbXref.DbXrefProperty) DbXrefConverter(org.nextprot.api.core.service.dbxref.conv.DbXrefConverter) DbXref(org.nextprot.api.core.domain.DbXref) EnsemblXrefPropertyConverter(org.nextprot.api.core.service.dbxref.conv.EnsemblXrefPropertyConverter) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) DbXrefService(org.nextprot.api.core.service.DbXrefService) IdentifierOffset(org.nextprot.api.commons.constants.IdentifierOffset) AntibodyResourceIdsService(org.nextprot.api.core.service.AntibodyResourceIdsService) Preconditions(com.google.common.base.Preconditions) PeptideNamesService(org.nextprot.api.core.service.PeptideNamesService) Lazy(org.springframework.context.annotation.Lazy) Xref2Annotation(org.nextprot.api.commons.constants.Xref2Annotation) Isoform(org.nextprot.api.core.domain.Isoform) DbXrefURLResolverSupplier(org.nextprot.api.core.service.dbxref.resolver.DbXrefURLResolverSupplier) PublicationDbXref(org.nextprot.api.core.domain.PublicationDbXref) DbXref(org.nextprot.api.core.domain.DbXref) ImmutableList(com.google.common.collect.ImmutableList) DbXrefProperty(org.nextprot.api.core.domain.DbXref.DbXrefProperty)

Aggregations

DbXrefProperty (org.nextprot.api.core.domain.DbXref.DbXrefProperty)2 Preconditions (com.google.common.base.Preconditions)1 ImmutableList (com.google.common.collect.ImmutableList)1 Multimap (com.google.common.collect.Multimap)1 Multimaps (com.google.common.collect.Multimaps)1 Sets (com.google.common.collect.Sets)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 IdentifierOffset (org.nextprot.api.commons.constants.IdentifierOffset)1 Xref2Annotation (org.nextprot.api.commons.constants.Xref2Annotation)1 DbXrefDao (org.nextprot.api.core.dao.DbXrefDao)1 DbXref (org.nextprot.api.core.domain.DbXref)1 Isoform (org.nextprot.api.core.domain.Isoform)1 PublicationDbXref (org.nextprot.api.core.domain.PublicationDbXref)1 Annotation (org.nextprot.api.core.domain.annotation.Annotation)1 AnnotationEvidence (org.nextprot.api.core.domain.annotation.AnnotationEvidence)1 AnnotationIsoformSpecificity (org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)1 AntibodyResourceIdsService (org.nextprot.api.core.service.AntibodyResourceIdsService)1 DbXrefService (org.nextprot.api.core.service.DbXrefService)1 IsoformService (org.nextprot.api.core.service.IsoformService)1