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());
}
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);
}
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);
}
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");
}
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;
}
Aggregations