Search in sources :

Example 6 with Statement

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());
}
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 7 with Statement

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()));
    }
}
Also used : TargetIsoformSet(org.nextprot.commons.statements.TargetIsoformSet) Set(java.util.Set) HashSet(java.util.HashSet) Statement(org.nextprot.commons.statements.Statement) HashSet(java.util.HashSet) Test(org.junit.Test) StatementETLBaseUnitTest(org.nextprot.api.etl.statement.StatementETLBaseUnitTest)

Example 8 with Statement

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);
}
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 9 with Statement

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);
}
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 10 with Statement

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"));
}
Also used : Statement(org.nextprot.commons.statements.Statement) TargetIsoformStatementPosition(org.nextprot.commons.statements.TargetIsoformStatementPosition) HashSet(java.util.HashSet) Test(org.junit.Test) StatementETLBaseUnitTest(org.nextprot.api.etl.statement.StatementETLBaseUnitTest)

Aggregations

Statement (org.nextprot.commons.statements.Statement)16 Test (org.junit.Test)11 StatementETLBaseUnitTest (org.nextprot.api.etl.statement.StatementETLBaseUnitTest)6 Annotation (org.nextprot.api.core.domain.annotation.Annotation)4 ReportBuilder (org.nextprot.api.etl.service.impl.StatementETLServiceImpl.ReportBuilder)4 StatementField (org.nextprot.commons.statements.StatementField)4 TargetIsoformSet (org.nextprot.commons.statements.TargetIsoformSet)4 Collectors (java.util.stream.Collectors)3 NextProtException (org.nextprot.api.commons.exception.NextProtException)3 Supplier (com.google.common.base.Supplier)2 java.util (java.util)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 Logger (org.apache.log4j.Logger)2 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)2 IdentifierOffset (org.nextprot.api.commons.constants.IdentifierOffset)2 StringUtils (org.nextprot.api.commons.utils.StringUtils)2 BioObject (org.nextprot.api.core.domain.BioObject)2 BioType (org.nextprot.api.core.domain.BioObject.BioType)2