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);
}
Aggregations