Search in sources :

Example 1 with PublicationAuthor

use of org.nextprot.api.core.domain.PublicationAuthor 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)

Example 2 with PublicationAuthor

use of org.nextprot.api.core.domain.PublicationAuthor 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)

Aggregations

PublicationAuthor (org.nextprot.api.core.domain.PublicationAuthor)2 GlobalPublicationStatistics (org.nextprot.api.core.domain.publication.GlobalPublicationStatistics)2 JournalResourceLocator (org.nextprot.api.core.domain.publication.JournalResourceLocator)2 ArrayList (java.util.ArrayList)1 SolrInputDocument (org.apache.solr.common.SolrInputDocument)1 Publication (org.nextprot.api.core.domain.Publication)1 PublicationDbXref (org.nextprot.api.core.domain.PublicationDbXref)1