Search in sources :

Example 1 with IsoformMappingService

use of org.nextprot.api.isoform.mapper.service.IsoformMappingService in project nextprot-api by calipho-sib.

the class StatementTransformationUtil method computeTargetIsoformsForProteoformAnnotation.

public static TargetIsoformSet computeTargetIsoformsForProteoformAnnotation(Statement proteoformStatement, IsoformMappingService isoformMappingService, List<Statement> subjectsForThisProteoform, boolean isIsoSpecific, String isoSpecificAccession, List<String> isoformAccessions) {
    List<String> isoformsToBeConsidered = new ArrayList<>();
    if (isIsoSpecific) {
        isoformsToBeConsidered.add(isoSpecificAccession);
    } else {
        isoformsToBeConsidered.addAll(isoformAccessions);
    }
    Set<TargetIsoformStatementPosition> result = new TreeSet<>();
    for (String isoformAccession : isoformsToBeConsidered) {
        String name = null;
        boolean allOk = true;
        for (Statement s : subjectsForThisProteoform) {
            TargetIsoformSet targetIsoforms = TargetIsoformSet.deSerializeFromJsonString(s.getValue(StatementField.TARGET_ISOFORMS));
            List<TargetIsoformStatementPosition> targetIsoformsFiltered = targetIsoforms.stream().filter(ti -> ti.getIsoformAccession().equals(isoformAccession)).collect(Collectors.toList());
            if (targetIsoformsFiltered.isEmpty()) {
                LOGGER.debug("(skip) Could not map to isoform " + isoformAccession);
                allOk = false;
                break;
            } else if (targetIsoformsFiltered.size() > 1) {
                throw new NextProtException("Something got wrong. Found more than one target isoform for same accession" + isoformAccession);
            }
            TargetIsoformStatementPosition tisp = targetIsoformsFiltered.iterator().next();
            if (name == null) {
                name = tisp.getName();
            } else {
                name += (" + " + tisp.getName());
            }
        }
        if (name != null && allOk) {
            if (isIsoSpecific) {
                result.add(new TargetIsoformStatementPosition(isoformAccession, IsoTargetSpecificity.SPECIFIC.name(), name));
            } else {
                result.add(new TargetIsoformStatementPosition(isoformAccession, IsoTargetSpecificity.UNKNOWN.name(), name));
            }
        }
    }
    return new TargetIsoformSet(result);
}
Also used : NPreconditions(org.nextprot.api.commons.exception.NPreconditions) java.util(java.util) FeatureQueryResult(org.nextprot.api.isoform.mapper.domain.FeatureQueryResult) IsoTargetSpecificity(org.nextprot.commons.constants.IsoTargetSpecificity) org.nextprot.commons.statements(org.nextprot.commons.statements) NextProtException(org.nextprot.api.commons.exception.NextProtException) IsoformFeatureResult(org.nextprot.api.isoform.mapper.domain.impl.SingleFeatureQuerySuccessImpl.IsoformFeatureResult) IsoformMappingService(org.nextprot.api.isoform.mapper.service.IsoformMappingService) Collectors(java.util.stream.Collectors) FeatureQuerySuccess(org.nextprot.api.isoform.mapper.domain.FeatureQuerySuccess) SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) Logger(org.apache.log4j.Logger) AnnotationType(org.nextprot.commons.statements.constants.AnnotationType) IsoformService(org.nextprot.api.core.service.IsoformService) FeatureQueryFailure(org.nextprot.api.isoform.mapper.domain.FeatureQueryFailure) Isoform(org.nextprot.api.core.domain.Isoform) NextProtException(org.nextprot.api.commons.exception.NextProtException)

Aggregations

java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Logger (org.apache.log4j.Logger)1 NPreconditions (org.nextprot.api.commons.exception.NPreconditions)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 Isoform (org.nextprot.api.core.domain.Isoform)1 IsoformService (org.nextprot.api.core.service.IsoformService)1 FeatureQueryFailure (org.nextprot.api.isoform.mapper.domain.FeatureQueryFailure)1 FeatureQueryResult (org.nextprot.api.isoform.mapper.domain.FeatureQueryResult)1 FeatureQuerySuccess (org.nextprot.api.isoform.mapper.domain.FeatureQuerySuccess)1 SingleFeatureQuery (org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery)1 IsoformFeatureResult (org.nextprot.api.isoform.mapper.domain.impl.SingleFeatureQuerySuccessImpl.IsoformFeatureResult)1 IsoformMappingService (org.nextprot.api.isoform.mapper.service.IsoformMappingService)1 IsoTargetSpecificity (org.nextprot.commons.constants.IsoTargetSpecificity)1 org.nextprot.commons.statements (org.nextprot.commons.statements)1 AnnotationType (org.nextprot.commons.statements.constants.AnnotationType)1