Search in sources :

Example 61 with DbXref

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

the class CosmicXrefURLResolverTest method testResolveCosmicBadPrimaryId.

@Test
public void testResolveCosmicBadPrimaryId() throws Exception {
    DbXref xref = DbXrefURLResolverDelegateTest.createDbXref("HCFC1", "Cosmic", "whatever");
    Assert.assertEquals("http://cancer.sanger.ac.uk/cosmic/gene/overview?ln=HCFC1", resolver.resolve(xref));
}
Also used : DbXref(org.nextprot.api.core.domain.DbXref) Test(org.junit.Test)

Example 62 with DbXref

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

the class CosmicXrefURLResolverTest method testResolveCosmicCOSM.

// entry/NX_Q9BXA6/xref.json
@Test
public void testResolveCosmicCOSM() throws Exception {
    DbXref xref = DbXrefURLResolverDelegateTest.createDbXref("COSM1172604", "Cosmic", "whatever");
    Assert.assertEquals("http://cancer.sanger.ac.uk/cosmic/mutation/overview?id=1172604", resolver.resolve(xref));
}
Also used : DbXref(org.nextprot.api.core.domain.DbXref) Test(org.junit.Test)

Example 63 with DbXref

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

the class DbXrefDAOIntegrationTest method mockDbXref.

private static DbXref mockDbXref(long id, String accession, String dbCat, String dbName, String linkUrl, String resolvedUrl, String url) {
    DbXref dbxref = Mockito.mock(DbXref.class);
    Mockito.when(dbxref.getDbXrefId()).thenReturn(id);
    Mockito.when(dbxref.getAccession()).thenReturn(accession);
    Mockito.when(dbxref.getDatabaseCategory()).thenReturn(dbCat);
    Mockito.when(dbxref.getDatabaseName()).thenReturn(dbName);
    Mockito.when(dbxref.getLinkUrl()).thenReturn(linkUrl);
    Mockito.when(dbxref.getResolvedUrl()).thenReturn(resolvedUrl);
    Mockito.when(dbxref.getUrl()).thenReturn(url);
    return dbxref;
}
Also used : DbXref(org.nextprot.api.core.domain.DbXref)

Example 64 with DbXref

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

the class TerminologyUtils method convertXrefsToString.

public static String convertXrefsToString(List<DbXref> xrefs) {
    if (xrefs == null)
        return null;
    // Build a String of xrefs formatted as "dbcat, db:acc" pairs separated by pipes
    StringBuilder sb = new StringBuilder();
    int i = xrefs.size();
    for (DbXref xref : xrefs) {
        sb.append(xref.getDatabaseCategory());
        sb.append(", ");
        sb.append(xref.getDatabaseName());
        sb.append(":");
        sb.append(xref.getAccession());
        if (--i != 0)
            sb.append(" | ");
    }
    return sb.toString();
}
Also used : DbXref(org.nextprot.api.core.domain.DbXref)

Example 65 with DbXref

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

the class TerminologyUtils method convertToXrefs.

public static List<DbXref> convertToXrefs(String xrefsstring) {
    if (xrefsstring == null)
        return null;
    // Builds DbXref list from String of xrefs formatted as "dbcat, db, acc, linkurl" quartetss separated by pipes
    List<DbXref> xrefs = new ArrayList<>();
    List<String> allxrefs = Arrays.asList(xrefsstring.split(" \\| "));
    for (String onexref : allxrefs) {
        List<String> fields = Arrays.asList(onexref.split("\\^ "));
        DbXref dbref = new DbXref();
        dbref.setDatabaseCategory(fields.get(0));
        dbref.setDatabaseName(fields.get(1));
        dbref.setAccession(fields.get(2));
        dbref.setDbXrefId(Long.parseLong(fields.get(3)));
        String url = null;
        String linkurl = null;
        if (fields.size() > 4) {
            url = fields.get(4);
            if (fields.size() > 5)
                linkurl = fields.get(5);
        }
        if (url == null || url.isEmpty() || "none".equalsIgnoreCase(url)) {
            dbref.setUrl("None");
            dbref.setLinkUrl("None");
        } else {
            dbref.setUrl(url);
            dbref.setLinkUrl(linkurl);
        }
        xrefs.add(dbref);
    }
    return xrefs;
}
Also used : DbXref(org.nextprot.api.core.domain.DbXref)

Aggregations

DbXref (org.nextprot.api.core.domain.DbXref)146 Test (org.junit.Test)118 PublicationDbXref (org.nextprot.api.core.domain.PublicationDbXref)12 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)7 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)7 SqlParameterSource (org.springframework.jdbc.core.namedparam.SqlParameterSource)7 DbXrefConverterTest.createDbXref (org.nextprot.api.core.service.dbxref.conv.DbXrefConverterTest.createDbXref)5 Entry (org.nextprot.api.core.domain.Entry)4 Xref2Annotation (org.nextprot.api.commons.constants.Xref2Annotation)3 AnnotationEvidence (org.nextprot.api.core.domain.annotation.AnnotationEvidence)3 DbXrefURLResolverDelegateTest (org.nextprot.api.core.service.dbxref.resolver.DbXrefURLResolverDelegateTest)3 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)3 WebIntegrationBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest)3 ImmutableList (com.google.common.collect.ImmutableList)2 Isoform (org.nextprot.api.core.domain.Isoform)2 Annotation (org.nextprot.api.core.domain.annotation.Annotation)2 PageView (org.nextprot.api.core.domain.ui.page.PageView)2 EnsemblXrefPropertyConverter (org.nextprot.api.core.service.dbxref.conv.EnsemblXrefPropertyConverter)2 Preconditions (com.google.common.base.Preconditions)1 Multimap (com.google.common.collect.Multimap)1