Search in sources :

Example 1 with ReportBuilder

use of org.nextprot.api.etl.service.impl.StatementETLServiceImpl.ReportBuilder 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());
}
Also used : ReportBuilder(org.nextprot.api.etl.service.impl.StatementETLServiceImpl.ReportBuilder) Statement(org.nextprot.commons.statements.Statement) StatementExtractorService(org.nextprot.api.etl.service.StatementExtractorService) Test(org.junit.Test) StatementETLBaseUnitTest(org.nextprot.api.etl.statement.StatementETLBaseUnitTest)

Example 2 with ReportBuilder

use of org.nextprot.api.etl.service.impl.StatementETLServiceImpl.ReportBuilder 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);
}
Also used : ReportBuilder(org.nextprot.api.etl.service.impl.StatementETLServiceImpl.ReportBuilder) Statement(org.nextprot.commons.statements.Statement) Test(org.junit.Test) StatementETLBaseUnitTest(org.nextprot.api.etl.statement.StatementETLBaseUnitTest)

Example 3 with ReportBuilder

use of org.nextprot.api.etl.service.impl.StatementETLServiceImpl.ReportBuilder 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);
}
Also used : ReportBuilder(org.nextprot.api.etl.service.impl.StatementETLServiceImpl.ReportBuilder) Statement(org.nextprot.commons.statements.Statement) Test(org.junit.Test) StatementETLBaseUnitTest(org.nextprot.api.etl.statement.StatementETLBaseUnitTest)

Example 4 with ReportBuilder

use of org.nextprot.api.etl.service.impl.StatementETLServiceImpl.ReportBuilder in project nextprot-api by calipho-sib.

the class StatementTransformUnitTest method rawStatementsShouldBeWellConvertedToMappedStatements.

@Test
public void rawStatementsShouldBeWellConvertedToMappedStatements() {
    StatementsExtractorLocalMockImpl sle = new StatementsExtractorLocalMockImpl();
    Set<Statement> rawStatements = sle.getStatementsForSourceForGeneNameAndEnvironment(null, null, "msh2-multiple-mutant");
    Set<Statement> mappedStatements = statementETLServiceMocked.transformStatements(rawStatements, new ReportBuilder());
    int statementsCount = rawStatements.stream().map(s -> s.getValue(StatementField.STATEMENT_ID)).distinct().collect(Collectors.toList()).size();
    int annotationsCount = mappedStatements.stream().map(s -> s.getValue(StatementField.ANNOTATION_ID)).distinct().collect(Collectors.toList()).size();
    assertEquals(5, statementsCount);
    assertEquals(4, annotationsCount);
    Statement phenotypicVariationStatement = filterStatementsBy(mappedStatements, StatementField.ANNOTATION_CATEGORY, "phenotypic-variation").get(0);
    String[] subjectAnnotations = phenotypicVariationStatement.getValue(StatementField.SUBJECT_ANNOTATION_IDS).split(",");
    String referenceVarAnnotation1 = subjectAnnotations[0];
    String referenceVarAnnotation2 = subjectAnnotations[1];
    String variantAnnotA = filterStatementsBy(mappedStatements, StatementField.ANNOTATION_CATEGORY, "variant").get(0).getValue(StatementField.ANNOTATION_ID);
    String variantAnnotB = filterStatementsBy(mappedStatements, StatementField.ANNOTATION_CATEGORY, "variant").get(1).getValue(StatementField.ANNOTATION_ID);
    Set<String> refAnnots = new TreeSet<>(Arrays.asList(referenceVarAnnotation1, referenceVarAnnotation2));
    Set<String> varAnnots = new TreeSet<>(Arrays.asList(variantAnnotA, variantAnnotB));
    assertEquals(refAnnots.size(), 2);
    assertEquals(refAnnots, varAnnots);
}
Also used : ReportBuilder(org.nextprot.api.etl.service.impl.StatementETLServiceImpl.ReportBuilder) Arrays(java.util.Arrays) List(java.util.List) StatementETLBaseUnitTest(org.nextprot.api.etl.statement.StatementETLBaseUnitTest) Set(java.util.Set) Test(org.junit.Test) StatementField(org.nextprot.commons.statements.StatementField) Collectors(java.util.stream.Collectors) Statement(org.nextprot.commons.statements.Statement) TreeSet(java.util.TreeSet) Assert.assertEquals(org.junit.Assert.assertEquals) ReportBuilder(org.nextprot.api.etl.service.impl.StatementETLServiceImpl.ReportBuilder) Statement(org.nextprot.commons.statements.Statement) TreeSet(java.util.TreeSet) StatementETLBaseUnitTest(org.nextprot.api.etl.statement.StatementETLBaseUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 ReportBuilder (org.nextprot.api.etl.service.impl.StatementETLServiceImpl.ReportBuilder)4 StatementETLBaseUnitTest (org.nextprot.api.etl.statement.StatementETLBaseUnitTest)4 Statement (org.nextprot.commons.statements.Statement)4 Arrays (java.util.Arrays)1 List (java.util.List)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 Collectors (java.util.stream.Collectors)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 StatementExtractorService (org.nextprot.api.etl.service.StatementExtractorService)1 StatementField (org.nextprot.commons.statements.StatementField)1