use of org.nextprot.api.isoform.mapper.domain.impl.SingleFeatureQuerySuccessImpl.IsoformFeatureResult in project nextprot-api by calipho-sib.
the class StatementTransformationUtil method mapVariationStatementToEntry.
/**
* @param variationStatement
* Can be a variant or mutagenesis
* @param result
* @return
*/
static Statement mapVariationStatementToEntry(Statement variationStatement, FeatureQuerySuccess result) {
String beginPositionOfCanonicalOrIsoSpec = null;
String endPositionOfCanonicalOrIsoSpec = null;
String masterBeginPosition = null;
String masterEndPosition = null;
String isoCanonical = null;
TargetIsoformSet targetIsoforms = new TargetIsoformSet();
for (IsoformFeatureResult isoformFeatureResult : result.getData().values()) {
if (isoformFeatureResult.isMapped()) {
targetIsoforms.add(new TargetIsoformStatementPosition(isoformFeatureResult.getIsoformAccession(), isoformFeatureResult.getBeginIsoformPosition(), // Target
isoformFeatureResult.getEndIsoformPosition(), // Target
IsoTargetSpecificity.UNKNOWN.name(), // propagated)
isoformFeatureResult.getIsoSpecificFeature()));
// canonical
if (beginPositionOfCanonicalOrIsoSpec == null) {
beginPositionOfCanonicalOrIsoSpec = String.valueOf(isoformFeatureResult.getBeginIsoformPosition());
}
if (endPositionOfCanonicalOrIsoSpec == null) {
endPositionOfCanonicalOrIsoSpec = String.valueOf(isoformFeatureResult.getEndIsoformPosition());
}
// If possible use canonical
if (isoformFeatureResult.isCanonical()) {
if (isoCanonical != null) {
throw new NextProtException("Canonical position set already");
}
isoCanonical = isoformFeatureResult.getIsoformAccession();
beginPositionOfCanonicalOrIsoSpec = String.valueOf(isoformFeatureResult.getBeginIsoformPosition());
endPositionOfCanonicalOrIsoSpec = String.valueOf(isoformFeatureResult.getEndIsoformPosition());
}
if (masterBeginPosition == null) {
masterBeginPosition = String.valueOf(isoformFeatureResult.getBeginMasterPosition());
}
if (masterEndPosition == null) {
masterEndPosition = String.valueOf(isoformFeatureResult.getEndMasterPosition());
}
if (masterBeginPosition != null) {
if (!masterBeginPosition.equals(String.valueOf(isoformFeatureResult.getBeginMasterPosition()))) {
throw new NextProtException("Begin master position " + masterBeginPosition + " does not match " + String.valueOf(isoformFeatureResult.getBeginMasterPosition() + " for different isoforms (" + result.getData().values().size() + ") for statement " + variationStatement.getStatementId()));
}
}
if (masterEndPosition != null) {
if (!masterEndPosition.equals(String.valueOf(isoformFeatureResult.getEndMasterPosition()))) {
throw new NextProtException("End master position does not match for different isoforms" + variationStatement.getStatementId());
}
}
}
}
Statement rs = // Keep
StatementBuilder.createNew().addMap(variationStatement).addField(StatementField.RAW_STATEMENT_ID, variationStatement.getStatementId()).addField(StatementField.LOCATION_BEGIN, beginPositionOfCanonicalOrIsoSpec).addField(StatementField.LOCATION_END, endPositionOfCanonicalOrIsoSpec).addField(StatementField.LOCATION_BEGIN_MASTER, masterBeginPosition).addField(StatementField.LOCATION_END_MASTER, masterEndPosition).addField(StatementField.ISOFORM_CANONICAL, isoCanonical).addField(StatementField.TARGET_ISOFORMS, targetIsoforms.serializeToJsonString()).buildWithAnnotationHash(AnnotationType.ENTRY);
return rs;
}
Aggregations