Search in sources :

Example 1 with PublicationDbXref

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

the class PublicationServiceIntegrationTest method testPublicationXrefs.

@Test
@Ignore
public void testPublicationXrefs() {
    Publication publication = publicationService.findPublicationById(690405);
    // check that publication bug NEXTPROT-989 is fixed (pmid 12631268), should have 2 xrefs
    List<PublicationDbXref> xrefs = publication.getDbXrefs();
    // System.err.println(TerminologyUtils.convertXrefsToSolrString(new ArrayList<DbXref>(xrefs)));
    Assert.assertTrue(xrefs.size() > 1);
}
Also used : Publication(org.nextprot.api.core.domain.Publication) PublicationDbXref(org.nextprot.api.core.domain.PublicationDbXref) Ignore(org.junit.Ignore) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 2 with PublicationDbXref

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

the class PublicationServiceImpl method getPublicationsFromDBReferenceIds.

/**
 * Get all publications not found in npPublication from pubmedids
 * @param npPublicationXrefs needed to avoid loading pubmed id publication multiple times
 * @return
 */
private List<Publication> getPublicationsFromDBReferenceIds(List<String> nxflatReferenceIds, String referenceDatabase, Map<Long, List<PublicationDbXref>> npPublicationXrefs) {
    List<Publication> nxflatPublications = new ArrayList<>();
    // Filtering publications which pubmed was not already found in np publications
    List<Long> foundPublicationIds = npPublicationXrefs.keySet().stream().filter(pubid -> npPublicationXrefs.get(pubid).stream().anyMatch(xref -> nxflatReferenceIds.contains(xref.getAccession()))).collect(Collectors.toList());
    nxflatReferenceIds.stream().filter(Objects::nonNull).forEach(pubmed -> {
        Publication pub = this.publicationDao.findPublicationByDatabaseAndAccession(referenceDatabase, pubmed);
        if (pub == null) {
            LOGGER.warn("Pubmed " + pubmed + " cannot be found");
        } else if (!foundPublicationIds.contains(pub.getPublicationId())) {
            nxflatPublications.add(pub);
        }
    });
    return nxflatPublications;
}
Also used : StatementSimpleWhereClauseQueryDSL(org.nextprot.api.core.dao.impl.StatementSimpleWhereClauseQueryDSL) java.util(java.util) StatementDao(org.nextprot.api.core.dao.StatementDao) GlobalPublicationStatistics(org.nextprot.api.core.domain.publication.GlobalPublicationStatistics) Cacheable(org.springframework.cache.annotation.Cacheable) PublicationDao(org.nextprot.api.core.dao.PublicationDao) PublicationDbXref(org.nextprot.api.core.domain.PublicationDbXref) Autowired(org.springframework.beans.factory.annotation.Autowired) StatementField(org.nextprot.commons.statements.StatementField) org.nextprot.api.core.service(org.nextprot.api.core.service) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Logger(org.apache.log4j.Logger) PublicationComparator(org.nextprot.api.core.utils.PublicationComparator) Publication(org.nextprot.api.core.domain.Publication) ImmutableList(com.google.common.collect.ImmutableList) XrefDatabase(org.nextprot.api.core.service.dbxref.XrefDatabase) Service(org.springframework.stereotype.Service) EntryPublication(org.nextprot.api.core.domain.publication.EntryPublication) PublicationAuthor(org.nextprot.api.core.domain.PublicationAuthor) Publication(org.nextprot.api.core.domain.Publication) EntryPublication(org.nextprot.api.core.domain.publication.EntryPublication)

Example 3 with PublicationDbXref

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

the class PublicationSolrindexer method convertToSolrDocument.

@Override
public SolrInputDocument convertToSolrDocument(Publication publi) {
    GlobalPublicationStatistics.PublicationStatistics publicationStats = publicationService.getPublicationStatistics(publi.getPublicationId());
    SolrInputDocument doc = new SolrInputDocument();
    doc.addField("id", publi.getPublicationId());
    List<PublicationDbXref> xrefs = publi.getDbXrefs();
    // TODO: this 'ac' field should be renamed 'xrefs'
    if (xrefs != null) // The format is slightly different in current publication indexes vs terminology indexes, check if justified
    // if yes create an adhoc Publication.convertXrefsToSolrString method
    {
        doc.addField("ac", TerminologyUtils.convertXrefsToSolrString(new ArrayList<>(xrefs)));
    }
    String filters = "";
    filters += ((publicationStats.isComputed()) ? " computed" : "");
    // Change getIsCurated or set here to 'curated' if computed is false
    filters += ((publicationStats.isCurated()) ? " curated" : "");
    filters += ((publicationStats.isLargeScale()) ? " largescale" : "");
    doc.addField("filters", filters);
    doc.addField("title", publi.getTitle());
    doc.addField("title_s", publi.getTitle());
    if (publi.getPublicationDate() != null) {
        doc.addField("date", publi.getPublicationDate());
        doc.addField("year", publi.getPublicationYear());
    }
    doc.addField("first_page", publi.getFirstPage());
    doc.addField("last_page", publi.getLastPage());
    doc.addField("volume", publi.getVolume());
    doc.addField("volume_s", publi.getVolume());
    doc.addField("abstract", publi.getAbstractText());
    doc.addField("type", publi.getPublicationType().name());
    if (publi.isLocatedInScientificJournal()) {
        JournalResourceLocator journal = publi.getJournalResourceLocator();
        String jfield = journal.getName();
        if (journal.hasJournalId()) {
            String jabbrev = journal.getAbbrev();
            jfield += " " + jabbrev;
            // TODO: rename "pretty_journal" to "abbrev_journal"
            doc.addField("pretty_journal", jabbrev);
        }
        doc.addField("journal", jfield);
    }
    // no need the following anymore as journal name is now accessible from journal
    // else if(publi.getJournal_from_properties() != null)
    // doc.addField("journal", publi.getJournal_from_properties());
    SortedSet<PublicationAuthor> authorset = publi.getAuthors();
    if (authorset != null) {
        String toIndex = "";
        String inidotted = "";
        int i = authorset.size();
        StringBuilder sb = new StringBuilder();
        for (PublicationAuthor author : authorset) {
            // replace each character by itself plus a dot
            inidotted = author.getInitials().replaceAll("(.)", "$1\\.");
            // System.err.println("LastName: " + author.getLastName() + " ForeName: " + author.getForeName() + " Initials: " + author.getInitials() + " inidotted: " + inidotted);
            toIndex = author.getLastName() + " " + author.getForeName() + " " + inidotted;
            doc.addField("authors", toIndex.trim().replaceAll("  ", " "));
            sb.append(author.getLastName() + " " + inidotted.replaceAll("\\.\\.\\.", "."));
            if (--i != 0)
                sb.append(" | ");
        }
        // for display only
        doc.addField("pretty_authors", sb.toString());
    }
    return doc;
}
Also used : SolrInputDocument(org.apache.solr.common.SolrInputDocument) PublicationAuthor(org.nextprot.api.core.domain.PublicationAuthor) ArrayList(java.util.ArrayList) PublicationDbXref(org.nextprot.api.core.domain.PublicationDbXref) GlobalPublicationStatistics(org.nextprot.api.core.domain.publication.GlobalPublicationStatistics) JournalResourceLocator(org.nextprot.api.core.domain.publication.JournalResourceLocator)

Aggregations

PublicationDbXref (org.nextprot.api.core.domain.PublicationDbXref)3 Publication (org.nextprot.api.core.domain.Publication)2 PublicationAuthor (org.nextprot.api.core.domain.PublicationAuthor)2 GlobalPublicationStatistics (org.nextprot.api.core.domain.publication.GlobalPublicationStatistics)2 ImmutableList (com.google.common.collect.ImmutableList)1 Sets (com.google.common.collect.Sets)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 Collectors (java.util.stream.Collectors)1 Logger (org.apache.log4j.Logger)1 SolrInputDocument (org.apache.solr.common.SolrInputDocument)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 PublicationDao (org.nextprot.api.core.dao.PublicationDao)1 StatementDao (org.nextprot.api.core.dao.StatementDao)1 StatementSimpleWhereClauseQueryDSL (org.nextprot.api.core.dao.impl.StatementSimpleWhereClauseQueryDSL)1 EntryPublication (org.nextprot.api.core.domain.publication.EntryPublication)1 JournalResourceLocator (org.nextprot.api.core.domain.publication.JournalResourceLocator)1 org.nextprot.api.core.service (org.nextprot.api.core.service)1 XrefDatabase (org.nextprot.api.core.service.dbxref.XrefDatabase)1