Search in sources :

Example 26 with Publication

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

the class PublicationDaoIntegrationTest method testMissingTitle.

@Test
public void testMissingTitle() {
    Publication publication = publicationDao.findPublicationById(3183815L);
    Assert.assertTrue(!publication.hasTitle());
}
Also used : Publication(org.nextprot.api.core.domain.Publication) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 27 with Publication

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

the class AnnotationBuilderBastUnitTest method init.

@Before
public void init() throws FileNotFoundException, DataSetException {
    MockitoAnnotations.initMocks(this);
    CvTerm cvterm = new CvTerm();
    cvterm.setName("eco-name-1");
    cvterm.setOntology("eco-ontology-cv");
    cvterm.setDescription("some description");
    Mockito.when(terminologyService.findCvTermByAccession(Matchers.anyString())).thenReturn(cvterm);
    Publication pub = new Publication();
    pub.setId(999);
    Mockito.when(publicationService.findPublicationByDatabaseAndAccession("PubMed", "000")).thenReturn(null);
    Mockito.when(publicationService.findPublicationByDatabaseAndAccession("PubMed", "123")).thenReturn(pub);
    // unused in tests yet
    Mockito.when(mainNamesService.findIsoformOrEntryMainName()).thenReturn(null);
}
Also used : CvTerm(org.nextprot.api.core.domain.CvTerm) Publication(org.nextprot.api.core.domain.Publication) Before(org.junit.Before)

Example 28 with Publication

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

the class PublicationsFieldBuilder method init.

@Override
protected void init(Entry entry) {
    // Publications
    // Shouldn't Xrefs to PubMed and DOIs be also indexed here ?
    List<Publication> publications = entry.getPublications();
    int publi_computed_count = 0;
    int publi_curated_count = 0;
    int publi_large_scale_count = 0;
    String Jinfo = "";
    for (Publication currpubli : publications) {
        long pubId = currpubli.getPublicationId();
        logger.debug("looking for stats about pair " + entry.getUniqueName() + " - pubId:" + pubId);
        GlobalPublicationStatistics.PublicationStatistics publiStats = publicationService.getPublicationStatistics(pubId);
        if (publiStats.isComputed())
            publi_computed_count++;
        if (publiStats.isCurated())
            publi_curated_count++;
        if (publiStats.isLargeScale())
            publi_large_scale_count++;
        if (currpubli.isLocatedInScientificJournal()) {
            JournalResourceLocator journalLocator = currpubli.getJournalResourceLocator();
            if (journalLocator.hasJournalId())
                addField(Fields.PUBLICATIONS, journalLocator.getNLMid());
            Jinfo = currpubli.getJournalResourceLocator().getName();
            if (journalLocator.hasJournalId())
                // Index name and abbrev in the same token
                Jinfo += " - " + currpubli.getJournalResourceLocator().getMedAbbrev();
            addField(Fields.PUBLICATIONS, Jinfo);
        }
        String title = currpubli.getTitle();
        if (title.length() > 0)
            addField(Fields.PUBLICATIONS, title);
        SortedSet<PublicationAuthor> authors = currpubli.getAuthors();
        for (PublicationAuthor currauthor : authors) {
            String forename = currauthor.getForeName();
            if (// Submission author
            forename.contains("."))
                addField(Fields.PUBLICATIONS, currauthor.getLastName() + "  " + currauthor.getInitials());
            else if (// trim not to add spaces when forename/initials are empty
            !forename.isEmpty())
                addField(Fields.PUBLICATIONS, (currauthor.getLastName() + " " + forename + " " + currauthor.getInitials()).trim());
            else
                addField(Fields.PUBLICATIONS, (currauthor.getLastName() + " " + currauthor.getInitials()).trim());
        }
    }
    addField(Fields.PUBLI_COMPUTED_COUNT, publi_computed_count);
    addField(Fields.PUBLI_CURATED_COUNT, publi_curated_count);
    addField(Fields.PUBLI_LARGE_SCALE_COUNT, publi_large_scale_count);
    // Based on the publications and the protein existence level we can compute informational score
    int pe_level = entry.getOverview().getProteinExistences().getProteinExistence().getLevel();
    float info_score = 0;
    if (pe_level == 1)
        info_score = 12;
    else if (pe_level == 2)
        info_score = 10;
    else if (pe_level == 3 || pe_level == 4)
        info_score = 8;
    else if (pe_level == 5)
        info_score = 5;
    float coeff = 100 * publi_curated_count + 25 * publi_computed_count + 10 * publi_large_scale_count;
    info_score = coeff * info_score / 10;
    addField(Fields.INFORMATIONAL_SCORE, info_score);
}
Also used : PublicationAuthor(org.nextprot.api.core.domain.PublicationAuthor) Publication(org.nextprot.api.core.domain.Publication) GlobalPublicationStatistics(org.nextprot.api.core.domain.publication.GlobalPublicationStatistics) JournalResourceLocator(org.nextprot.api.core.domain.publication.JournalResourceLocator)

Example 29 with Publication

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

the class GenerateSolrPublicationIndex method start.

@Override
public void start(String[] args) {
    PublicationService publicationService = getBean(PublicationService.class);
    int pubcnt = 0;
    String solrServer = System.getProperty("solr.server");
    NPreconditions.checkNotNull(solrServer, "Please set solr.server variable. For example: java -Dsolr.server=http://localhost:8983/solr/nppublications1");
    logger.info("Solr server: " + solrServer);
    SolrIndexer<Publication> indexer = new PublicationSolrindexer(solrServer, publicationService);
    // Remove previous indexes
    logger.info("removing all solr publication records");
    indexer.clearDatabase("");
    List<Long> allpubids;
    logger.info("getting all publications from API");
    long start = System.currentTimeMillis();
    allpubids = publicationService.findAllPublicationIds();
    logger.info("indexing " + allpubids.size() + " publications...");
    for (Long id : allpubids) {
        Publication currpub = publicationService.findPublicationById(id);
        if (currpub.getPublicationType().equals(PublicationType.ARTICLE)) {
            indexer.add(currpub);
            pubcnt++;
        }
        if ((pubcnt % 5000) == 0)
            logger.info(pubcnt + "/" + allpubids.size() + " publications done");
    }
    indexer.addRemaing();
    logger.info("comitting");
    indexer.commit();
    logger.info(pubcnt + " publications indexed in " + (System.currentTimeMillis() - start) / 1000 + " seconds...END");
}
Also used : PublicationSolrindexer(org.nextprot.api.tasks.solr.indexer.PublicationSolrindexer) PublicationService(org.nextprot.api.core.service.PublicationService) Publication(org.nextprot.api.core.domain.Publication)

Example 30 with Publication

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

the class PublicationServiceImpl method updateMissingPublicationFields.

private Map<Long, List<PublicationDbXref>> updateMissingPublicationFields(List<Publication> publications) {
    List<Long> publicationIds = publications.stream().map(Publication::getPublicationId).collect(Collectors.toList());
    Map<Long, List<PublicationAuthor>> authorMap = authorService.findAuthorsByPublicationIds(publicationIds).stream().collect(Collectors.groupingBy(PublicationAuthor::getPublicationId));
    Map<Long, List<PublicationDbXref>> xrefMap = dbXrefService.findDbXRefByPublicationIds(publicationIds).stream().collect(Collectors.groupingBy(PublicationDbXref::getPublicationId));
    for (Publication publication : publications) {
        setAuthorsAndEditors(publication, authorMap.get(publication.getPublicationId()));
        setXrefs(publication, xrefMap.get(publication.getPublicationId()));
    }
    return xrefMap;
}
Also used : Publication(org.nextprot.api.core.domain.Publication) EntryPublication(org.nextprot.api.core.domain.publication.EntryPublication) ImmutableList(com.google.common.collect.ImmutableList)

Aggregations

Publication (org.nextprot.api.core.domain.Publication)33 Test (org.junit.Test)17 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)13 EntryPublication (org.nextprot.api.core.domain.publication.EntryPublication)6 Ignore (org.junit.Ignore)4 StatementSimpleWhereClauseQueryDSL (org.nextprot.api.core.dao.impl.StatementSimpleWhereClauseQueryDSL)4 ImmutableList (com.google.common.collect.ImmutableList)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Cacheable (org.springframework.cache.annotation.Cacheable)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 PublicationAuthor (org.nextprot.api.core.domain.PublicationAuthor)2 PublicationDbXref (org.nextprot.api.core.domain.PublicationDbXref)2 GlobalPublicationStatistics (org.nextprot.api.core.domain.publication.GlobalPublicationStatistics)2 Service (org.springframework.stereotype.Service)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Sets (com.google.common.collect.Sets)1 Argument (graphql.language.Argument)1 Field (graphql.language.Field)1