Search in sources :

Example 1 with Entry

use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.

the class IsoformSequencePositionMapperTest method positionOnIso1ShouldNotMapToIso2.

@Test
public void positionOnIso1ShouldNotMapToIso2() throws Exception {
    Entry entry = entryBuilderService.build(EntryConfig.newConfig("NX_P38398").withTargetIsoforms());
    Integer position = IsoformSequencePositionMapper.getProjectedPosition(IsoformUtils.getIsoformByName(entry, "NX_P38398-1"), 1812, IsoformUtils.getIsoformByName(entry, "NX_P38398-2"));
    Assert.assertNull(position);
}
Also used : Entry(org.nextprot.api.core.domain.Entry) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 2 with Entry

use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.

the class IsoformSequencePositionMapperIntegrationTest method testSingleVariantPositionOnMaster.

@Test
public void testSingleVariantPositionOnMaster() throws Exception {
    // just to be aware of difference between db info and api info
    String entry_ac = "NX_P01308";
    String iso_ac = "NX_P01308-1";
    String variant_ac = "AN_P01308_001747";
    int expectedBeginPosOnMaster = 502;
    Entry entry = entryBuilderService.build(EntryConfig.newConfig(entry_ac).withTargetIsoforms().withAnnotations());
    for (Annotation a : entry.getAnnotations()) {
        if (a.getUniqueName().equals(variant_ac)) {
            int pos = a.getTargetingIsoformsMap().get(iso_ac).getFirstPosition();
            Isoform iso = IsoformUtils.getIsoformByName(entry, iso_ac);
            GeneMasterCodonPosition nuPos = IsoformSequencePositionMapper.getCodonPositionsOnMaster(pos, iso);
            if (sout) {
                System.out.println("isoform position                                               : " + pos);
                System.out.println("nuPos is valid                                                 : " + nuPos.isValid());
                System.out.println("master position according to iso mapper service                : " + nuPos.getNucleotidePosition(0));
                System.out.println("master position according to table identifier_feature_position : " + expectedBeginPosOnMaster);
                System.out.println("master first_position for Anne                                 : " + (nuPos.getNucleotidePosition(0) - 1));
            }
            // we then have to gie the last_positon to Anne, there are 2 cases:
            // case 1: original AAs = single AA
            // => master last_positon fo Anne = first_position for Anne + 3
            // case 2: original AAs length has more than one AAs
            // compute position on master of last AA (same process as above), return nuPos(0)-1 found for iso pos)
            // we expect a difference of 1 between what we have in db and what we have from api
            Assert.assertEquals(new Integer(expectedBeginPosOnMaster + 1), new Integer(nuPos.getNucleotidePosition(0)));
            return;
        }
    }
    Assert.assertTrue(false);
/*
		 * SQL to get master position for this variant
		 * 
		select a.unique_name, a.cv_annotation_type_id, pfp.first_pos,pfp.last_pos,ifp.first_pos as master_frist_pos, ifp.last_pos as master_last_pos from sequence_identifiers si
		inner join annotations a on (a.identifier_id=si.identifier_id)
		inner join annotation_protein_assoc apa on (a.annotation_id=apa.annotation_id)
		inner join protein_feature_positions pfp on (apa.assoc_id=pfp.annotation_protein_id)
		inner join identifier_feature_positions ifp on (ifp.annotation_id=a.annotation_id)
		where si.unique_name='NX_P01308' 
		and pfp.first_pos=20;
		
		SQL result:
		unique_name	        cv_annotation_type_id	first_pos	last_pos	master_frist_pos	master_last_pos
        AN_P01308_001839    1027                    20          21          430                 433
		(1 row)
		
		 */
}
Also used : Entry(org.nextprot.api.core.domain.Entry) Isoform(org.nextprot.api.core.domain.Isoform) Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 3 with Entry

use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.

the class IsoformSequencePositionMapperIntegrationTest method testSingleVariantWithInvalidNucleotideIndice.

@Test
public void testSingleVariantWithInvalidNucleotideIndice() throws Exception {
    String entry_ac = "NX_O00115";
    String iso_ac = "NX_O00115-1";
    String variant_ac = "AN_O00115_000472";
    Entry entry = entryBuilderService.build(EntryConfig.newConfig(entry_ac).withTargetIsoforms().withAnnotations());
    for (Annotation a : entry.getAnnotations()) {
        if (a.getUniqueName().equals(variant_ac)) {
            int pos = a.getTargetingIsoformsMap().get(iso_ac).getFirstPosition();
            Isoform iso = IsoformUtils.getIsoformByName(entry, iso_ac);
            GeneMasterCodonPosition nuPos = IsoformSequencePositionMapper.getCodonPositionsOnMaster(pos, iso);
            for (Isoform iso2 : entry.getIsoforms()) {
                if (!iso2.equals(iso)) {
                    CodonNucleotideIndices nuIdx = IsoformSequencePositionMapper.getCodonNucleotideIndices(nuPos, iso2);
                    // cannot be projected to iso2
                    Assert.assertEquals(false, nuIdx.has3Nucleotides());
                    Assert.assertEquals(false, nuIdx.areConsecutive());
                    Assert.assertEquals(false, nuIdx.areInFrame());
                    Assert.assertNull(nuIdx.getAminoAcidPosition());
                }
            }
            return;
        }
    }
    Assert.assertTrue(false);
}
Also used : Entry(org.nextprot.api.core.domain.Entry) Isoform(org.nextprot.api.core.domain.Isoform) Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 4 with Entry

use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.

the class EntryPartExporterImplTest method testPartialSortOrderForExpressionProfile.

@Test
public void testPartialSortOrderForExpressionProfile() throws Exception {
    // the sort order defined fro expression-profile is :
    // alpha(term name), alpha(eco_name), alpha(expression level), temporal(stage accession)
    // here we test that the 3 first criteria are correct
    String subpart = "expression-profile";
    EntryPartExporter exporter = EntryPartExporterImpl.fromSubPart(subpart);
    Entry entry = entryBuilderService.build(EntryConfig.newConfig("NX_P01308").with(subpart));
    List<Row> rows = exporter.exportRows(entry);
    String lastSortKey = "";
    for (Row r : rows) {
        String termName = r.getValue(exporter.getColumnIndex(Header.TERM_NAME));
        String ecoName = r.getValue(exporter.getColumnIndex(Header.ECO_NAME));
        String exprLevel = r.getValue(exporter.getColumnIndex(Header.EXPRESSION_LEVEL));
        String sortKey = termName + "\t" + ecoName + "\t" + exprLevel;
        int result = lastSortKey.compareTo(sortKey);
        // System.out.println("result:"+ result + "for: " + sortKey); //  + " " +  stage + " -" + stageAc);
        Assert.assertTrue(result <= 0);
        lastSortKey = sortKey;
    }
}
Also used : Entry(org.nextprot.api.core.domain.Entry) Row(org.nextprot.api.core.export.EntryPartExporter.Row) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 5 with Entry

use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.

the class EntryPageServiceTest method proteomicPageShouldFilterPhosphoSitePlusDb.

@Test
public void proteomicPageShouldFilterPhosphoSitePlusDb() {
    String entryAC = "NX_P52701";
    Entry filteredEntry = entryPageService.filterXrefInPageView(entryAC, "proteomics");
    Assert.assertTrue(filteredEntry.getXrefs().stream().anyMatch(x -> x.getDatabaseName().equals("PhosphoSitePlus")));
}
Also used : Entry(org.nextprot.api.core.domain.Entry) WebIntegrationBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest) EntryConfig(org.nextprot.api.core.service.fluent.EntryConfig) Map(java.util.Map) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) Assert(org.junit.Assert) EntryBuilderService(org.nextprot.api.core.service.EntryBuilderService) Entry(org.nextprot.api.core.domain.Entry) WebIntegrationBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest) Test(org.junit.Test)

Aggregations

Entry (org.nextprot.api.core.domain.Entry)60 Test (org.junit.Test)38 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)16 Annotation (org.nextprot.api.core.domain.annotation.Annotation)9 Isoform (org.nextprot.api.core.domain.Isoform)8 EntryConfig (org.nextprot.api.core.service.fluent.EntryConfig)8 WebIntegrationBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest)8 EntryBuilderService (org.nextprot.api.core.service.EntryBuilderService)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 Assert (org.junit.Assert)4 Ignore (org.junit.Ignore)4 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)4 DbXref (org.nextprot.api.core.domain.DbXref)4 ArrayList (java.util.ArrayList)3 PropertyApiModel (org.nextprot.api.commons.constants.PropertyApiModel)3 SolrDiffTest (org.nextprot.api.tasks.solr.indexer.entry.SolrDiffTest)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 PrintWriter (java.io.PrintWriter)2 java.util (java.util)2