use of org.nextprot.commons.statements.Statement in project nextprot-api by calipho-sib.
the class StatementLoadAndRetrievedStatementsOnUnitDBTest method shouldExtractLoadAndRetriveStatements.
@Test
public void shouldExtractLoadAndRetriveStatements() {
StatementExtractorService extractor = new StatementsExtractorLocalMockImpl();
Set<Statement> rawStatements = extractor.getStatementsForSourceForGeneNameAndEnvironment(null, "2017-01-13", "msh6-variant-on-iso1-but-not-on-iso2");
statementETLService.setStatementExtractorService(extractor);
statementETLService.setStatementTransformerService(transformerMockedService);
Set<Statement> mappedStatements = ((StatementETLServiceImpl) statementETLService).transformStatements(rawStatements, new ReportBuilder());
((StatementETLServiceImpl) statementETLService).loadStatements(rawStatements, mappedStatements, true, new ReportBuilder());
List<Statement> dbStatements = statementDao.findNormalStatements(AnnotationType.ENTRY, "NX_P52701");
dbStatements.addAll(statementDao.findProteoformStatements(AnnotationType.ENTRY, "NX_P52701"));
Assert.assertEquals(dbStatements.size(), mappedStatements.size());
}
use of org.nextprot.commons.statements.Statement in project nextprot-api by calipho-sib.
the class StatementETLServiceUnitTest method shouldComputeCorrectTargetIsoformsForProteoformAnnotations.
@Test
public void shouldComputeCorrectTargetIsoformsForProteoformAnnotations() throws Exception {
Set<Statement> rawSubjectStatements = new HashSet<>(Arrays.asList(StatementBuilder.createNew().addField(StatementField.ENTRY_ACCESSION, "NX_Q15858").addField(StatementField.ANNOTATION_NAME, "SCN9A-iso3-p.Met932Leu").build(), StatementBuilder.createNew().addField(StatementField.ENTRY_ACCESSION, "NX_Q15858").addField(StatementField.ANNOTATION_NAME, "SCN9A-iso3-p.Val991Leu").build()));
List<Statement> subjectStatements = StatementTransformationUtil.getPropagatedStatementsForEntry(isoformMappingServiceMocked, rawSubjectStatements, "NX_Q15858");
Statement proteoformStatement = StatementBuilder.createNew().addField(StatementField.ENTRY_ACCESSION, "NX_Q15858").build();
{
Set<TargetIsoformStatementPosition> result = StatementTransformationUtil.computeTargetIsoformsForProteoformAnnotation(proteoformStatement, isoformMappingServiceMocked, subjectStatements, true, "NX_Q15858-3", Arrays.asList("NX_Q15858-1", "NX_Q15858-2", "NX_Q15858-3", "NX_Q15858-4"));
Assert.assertTrue(result.size() == 1);
Assert.assertTrue(result.iterator().next().getName().equals("SCN9A-iso3-p.Met932Leu + SCN9A-iso3-p.Val991Leu"));
Assert.assertTrue(result.iterator().next().getSpecificity().equals(IsoTargetSpecificity.SPECIFIC.name()));
}
{
Set<TargetIsoformStatementPosition> result = StatementTransformationUtil.computeTargetIsoformsForProteoformAnnotation(proteoformStatement, isoformMappingServiceMocked, subjectStatements, false, null, Arrays.asList("NX_Q15858-1", "NX_Q15858-2", "NX_Q15858-3", "NX_Q15858-4"));
System.err.println(result.size());
// Because SCN9A-iso1-p.Val991Leu can only be propagated on 1 and 3
Assert.assertEquals(result.size(), 2);
Assert.assertTrue(result.iterator().next().getName().equals("SCN9A-iso1-p.Met943Leu + SCN9A-iso1-p.Val1002Leu"));
Assert.assertTrue(result.iterator().next().getSpecificity().equals(IsoTargetSpecificity.UNKNOWN.name()));
}
}
use of org.nextprot.commons.statements.Statement in project nextprot-api by calipho-sib.
the class StatementTransformBDDTest method shouldPropagateVariantsOnlyToMappableIsoforms.
/**
* Specification: A variant should always be propagated to all possible isoforms.
* If a variant can not be propagated to an isoform, then the 'phenotypic variation' should not exist for that isoform neiher.
* However the object annotation should be propagate to all isoforms (if not positional)
*
* In this test we check if the propagation of the variant MSH6-p.Thr1219Asp is not propagated to the isoform 2, because the Isoform 2 can not contain this exons.
* Additionally we check that the phenotypic variation annotation is well propagated according to the variant.
* Finally we check that the object is propagate to all isoforms.
*/
@Test
public void shouldPropagateVariantsOnlyToMappableIsoforms() {
StatementsExtractorLocalMockImpl sle = new StatementsExtractorLocalMockImpl();
Set<Statement> rawStatements = sle.getStatementsForSourceForGeneNameAndEnvironment(null, null, "msh6-variant-on-iso1-but-not-on-iso2");
// Variant
Set<Statement> mappedStatements = statementETLServiceMocked.transformStatements(rawStatements, new ReportBuilder());
Statement variantMappedStatement = mappedStatements.stream().filter(new AnnotationCategoryPredicate(VARIANT)).findFirst().orElseThrow(RuntimeException::new);
String variantMappedStatementIsoformsJson = variantMappedStatement.getValue(StatementField.TARGET_ISOFORMS);
String isoPropagationsWithoutIsoform2 = "[{\"isoformAccession\":\"NX_P52701-1\",\"specificity\":\"UNKNOWN\",\"begin\":1219,\"end\":1219,\"name\":\"MSH6-isoGTBP-N-p.Thr1219Asp\"},{\"isoformAccession\":\"NX_P52701-3\",\"specificity\":\"UNKNOWN\",\"begin\":1089,\"end\":1089,\"name\":\"MSH6-iso3-p.Thr1089Asp\"},{\"isoformAccession\":\"NX_P52701-4\",\"specificity\":\"UNKNOWN\",\"begin\":917,\"end\":917,\"name\":\"MSH6-iso4-p.Thr917Asp\"}]";
Assert.assertEquals(variantMappedStatementIsoformsJson, isoPropagationsWithoutIsoform2);
// Phenotypic variation
Statement phentypicMappedStatement = mappedStatements.stream().filter(new AnnotationCategoryPredicate(AnnotationCategory.PHENOTYPIC_VARIATION)).findFirst().orElseThrow(RuntimeException::new);
String phenotypicMappedStatementIsoformJson = phentypicMappedStatement.getValue(StatementField.TARGET_ISOFORMS);
Assert.assertEquals(TargetIsoformSet.deSerializeFromJsonString(phenotypicMappedStatementIsoformJson).size(), 3);
String phenotypicWithoutIsoform2 = "[{\"isoformAccession\":\"NX_P52701-1\",\"specificity\":\"UNKNOWN\",\"name\":\"MSH6-isoGTBP-N-p.Thr1219Asp\"},{\"isoformAccession\":\"NX_P52701-3\",\"specificity\":\"UNKNOWN\",\"name\":\"MSH6-iso3-p.Thr1089Asp\"},{\"isoformAccession\":\"NX_P52701-4\",\"specificity\":\"UNKNOWN\",\"name\":\"MSH6-iso4-p.Thr917Asp\"}]";
Assert.assertEquals(TargetIsoformSet.deSerializeFromJsonString(phenotypicWithoutIsoform2).size(), 3);
Assert.assertEquals(phenotypicMappedStatementIsoformJson, phenotypicWithoutIsoform2);
// Object
Statement objectStatement = mappedStatements.stream().filter(new AnnotationCategoryPredicate(AnnotationCategory.GO_MOLECULAR_FUNCTION)).findFirst().orElseThrow(RuntimeException::new);
String objectMappedStatementIsoformJson = phentypicMappedStatement.getValue(StatementField.TARGET_ISOFORMS);
// TODO what to do??? System.err.println(objectMappedStatementIsoformJson);
}
use of org.nextprot.commons.statements.Statement in project nextprot-api by calipho-sib.
the class StatementTransformBDDTest method shouldPropagateVariantButNotPhenotypicVariationOnIsoSpecificVPAnnotations.
/**
* When one receive a phenotypic variation whereby the subject is specific,
*/
@Test
public void shouldPropagateVariantButNotPhenotypicVariationOnIsoSpecificVPAnnotations() {
StatementsExtractorLocalMockImpl sle = new StatementsExtractorLocalMockImpl();
Set<Statement> rawStatements = sle.getStatementsForSourceForGeneNameAndEnvironment(null, null, "scn9a-variant-iso-spec");
// Variant
Set<Statement> mappedStatements = statementETLServiceMocked.transformStatements(rawStatements, new ReportBuilder());
Statement variantMappedStatement = mappedStatements.stream().filter(new AnnotationCategoryPredicate(AnnotationCategory.VARIANT)).findFirst().orElseThrow(RuntimeException::new);
String variantMappedStatementIsoformJson = variantMappedStatement.getValue(StatementField.TARGET_ISOFORMS);
Assert.assertEquals(TargetIsoformSet.deSerializeFromJsonString(variantMappedStatementIsoformJson).size(), 4);
Assert.assertEquals("[{\"isoformAccession\":\"NX_Q15858-1\",\"specificity\":\"UNKNOWN\",\"begin\":1460,\"end\":1460,\"name\":\"SCN9A-iso1-p.Phe1460Val\"},{\"isoformAccession\":\"NX_Q15858-2\",\"specificity\":\"UNKNOWN\",\"begin\":1460,\"end\":1460,\"name\":\"SCN9A-iso2-p.Phe1460Val\"},{\"isoformAccession\":\"NX_Q15858-3\",\"specificity\":\"UNKNOWN\",\"begin\":1449,\"end\":1449,\"name\":\"SCN9A-iso3-p.Phe1449Val\"},{\"isoformAccession\":\"NX_Q15858-4\",\"specificity\":\"UNKNOWN\",\"begin\":1449,\"end\":1449,\"name\":\"SCN9A-iso4-p.Phe1449Val\"}]", variantMappedStatementIsoformJson);
// Phenotypic variation
Statement phentypicMappedStatement = mappedStatements.stream().filter(new AnnotationCategoryPredicate(AnnotationCategory.PHENOTYPIC_VARIATION)).findFirst().orElseThrow(RuntimeException::new);
String phenotypicMappedStatementIsoformJson = phentypicMappedStatement.getValue(StatementField.TARGET_ISOFORMS);
Assert.assertEquals(TargetIsoformSet.deSerializeFromJsonString(phenotypicMappedStatementIsoformJson).size(), 1);
Assert.assertEquals("[{\"isoformAccession\":\"NX_Q15858-3\",\"specificity\":\"SPECIFIC\",\"name\":\"SCN9A-iso3-p.Phe1449Val\"}]", phenotypicMappedStatementIsoformJson);
}
use of org.nextprot.commons.statements.Statement in project nextprot-api by calipho-sib.
the class StatementETLServiceUnitTest method shouldComputeCorrectTargetIsoformsForVariants.
@Test
public void shouldComputeCorrectTargetIsoformsForVariants() throws Exception {
Set<Statement> subjectStatements = new HashSet<>(Arrays.asList(StatementBuilder.createNew().addField(StatementField.ENTRY_ACCESSION, "NX_Q15858").addField(StatementField.ANNOTATION_NAME, "SCN9A-iso3-p.Ile848Thr").build()));
List<Statement> variantOnEntry = StatementTransformationUtil.getPropagatedStatementsForEntry(isoformMappingServiceMocked, subjectStatements, "NX_Q15858");
// It should return only one statement with target isoforms
Assert.assertTrue(variantOnEntry.size() == 1);
String targetIsoformsString = variantOnEntry.iterator().next().getValue(StatementField.TARGET_ISOFORMS);
Set<TargetIsoformStatementPosition> targetIsoforms = TargetIsoformSet.deSerializeFromJsonString(targetIsoformsString);
Assert.assertEquals(targetIsoforms.size(), 4);
TargetIsoformStatementPosition pos1 = targetIsoforms.stream().filter(ti -> ti.getIsoformAccession().equals("NX_Q15858-1")).collect(Collectors.toList()).get(0);
Assert.assertTrue(pos1.getBegin().equals(859));
Assert.assertTrue(pos1.getName().equals("SCN9A-iso1-p.Ile859Thr"));
}
Aggregations