Skip to content

Commit

Permalink
Merge pull request #457 from wcmc-its/development
Browse files Browse the repository at this point in the history
Prepare for release of 2.1.0
  • Loading branch information
sarbajitdutta authored Feb 4, 2021
2 parents a3d5d46 + 9a8c27e commit e2b5966
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 75 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:11-jre-slim
FROM adoptopenjdk/openjdk11:alpine-jre

RUN mkdir -p /app
WORKDIR /app
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ Please see the [ReCiter wiki](https://github.com/wcmc-its/ReCiter/wiki) for more
## Technical

### Prerequisites
- Java 1.8
- Java 11
- Latest version of Maven. To install Maven navigate to the directory where ReCiter will be installed, execute `brew install maven` and then `mvn clean install`

If you want to use Java 8 then update `<java.version>1.8</java.version>` in [pom.xml](https://github.com/wcmc-its/ReCiter/blob/a3d5d4665e8692853ca69f2db0caba0eb56f557d/pom.xml#L49)

It is not necessary to install ReCiter in order to use the API.

### Technological stack
Expand Down Expand Up @@ -116,7 +118,7 @@ export SCOPUS_SERVICE=http://localhost:5001
export PUBMED_SERVICE=http://localhost:5002
```
4. Run `mvn spring-boot:run`. You can add additional options if you want like max and min java memory with `export MAVEN_OPTS=-Xmx1024m`
5. Go to `http://localhost:<port-number>/swagger-ui.html` to test and run any API.
5. Go to `http://localhost:<port-number>/swagger-ui/index.html` or `http://localhost:<port-number>/swagger-ui/` (shorthand swagger url) to test and run any API.


### Amazon AWS
Expand Down
4 changes: 2 additions & 2 deletions kubernetes/k8-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ spec:
name: ENVCONFIG
key: AWS_REGION
- name: JAVA_OPTIONS
value: "-Xmx2000m"
value: "-Xmx2400m"
ports:
- containerPort: 5000
name: reciter
resources:
requests:
memory: 2.6G
cpu: 0.8
cpu: 1
limits:
memory: 2.8G
cpu: 1
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
<dependency>
<groupId>edu.cornell.weill.reciter</groupId>
<artifactId>reciter-identity-model</artifactId>
<version>2.0.7</version>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>edu.cornell.weill.reciter</groupId>
Expand All @@ -309,7 +309,7 @@
<dependency>
<groupId>edu.cornell.weill.reciter</groupId>
<artifactId>reciter-dynamodb-model</artifactId>
<version>2.0.6</version>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>com.github.bohnman</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@
*******************************************************************************/
package reciter.algorithm.evidence.targetauthor.articlesize.strategy;

import static org.hamcrest.CoreMatchers.sameInstance;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import reciter.ApplicationContextHolder;
import reciter.algorithm.cluster.article.scorer.ReCiterArticleScorer;
import reciter.algorithm.evidence.targetauthor.AbstractTargetAuthorStrategy;
import reciter.database.dynamodb.model.ESearchPmid;
import reciter.database.dynamodb.model.ESearchPmid.RetrievalRefreshFlag;
import reciter.database.dynamodb.model.ESearchResult;
import reciter.database.dynamodb.model.QueryType;
import reciter.engine.Feature;
Expand All @@ -38,6 +40,10 @@
import reciter.model.identity.Identity;
import reciter.service.ESearchResultService;

/**
* @author Sarbajit Dutta
* @see <a href= "https://github.com/wcmc-its/ReCiter/issues/228">Article Count Strategy</a>
*/
public class ArticleSizeStrategy extends AbstractTargetAuthorStrategy {

private static final Logger slf4jLogger = LoggerFactory.getLogger(ArticleSizeStrategy.class);
Expand Down Expand Up @@ -97,19 +103,37 @@ public double executeStrategy(ReCiterArticle reCiterArticle, Identity identity)

@Override
public double executeStrategy(List<ReCiterArticle> reCiterArticles, Identity identity) {

//Logic was updated to include lookupType in eSearchPmid so as to only count publications when
//ALL_PUBLICATIONS flag is being used and excluding GoldStandard Strategy retrieval type for actual candidate publication count
//https://github.com/wcmc-its/ReCiter/issues/455
ESearchResultService eSearchResultService = ApplicationContextHolder.getContext().getBean(ESearchResultService.class);
ESearchResult eSearchResult = eSearchResultService.findByUid(identity.getUid());
reCiterArticles.forEach(reCiterArticle -> {
ArticleCountEvidence articleCountEvidence = new ArticleCountEvidence();
if(this.numberOfArticles > 0) {
int retrievalArticleCountByLookUpType = 0;
if(eSearchResult != null
&&
eSearchResult.getQueryType() != null
&&
(eSearchResult.getQueryType() == QueryType.LENIENT_LOOKUP || eSearchResult.getQueryType() == QueryType.STRICT_COMPOUND_NAME_LOOKUP)) {
articleCountEvidence.setCountArticlesRetrieved(this.numberOfArticles);
articleCountEvidence.setArticleCountScore(-(this.numberOfArticles - ReCiterArticleScorer.strategyParameters.getArticleCountThresholdScore())/ReCiterArticleScorer.strategyParameters.getArticleCountWeight());
if(eSearchResult.getESearchPmids() != null
&&
!eSearchResult.getESearchPmids().isEmpty()) {
Set<Long> uniqueRetrievalArticle = new HashSet<>();
eSearchResult.getESearchPmids().stream()
.filter(eSearchPmid -> !eSearchPmid.getRetrievalStrategyName().equalsIgnoreCase("GoldStandardRetrievalStrategy") && eSearchPmid.getLookupType() == RetrievalRefreshFlag.ALL_PUBLICATIONS)
.map(ESearchPmid::getPmids)
.forEach(uniqueRetrievalArticle::addAll);
retrievalArticleCountByLookUpType = uniqueRetrievalArticle.size();
if(retrievalArticleCountByLookUpType > 0) {
articleCountEvidence.setCountArticlesRetrieved(retrievalArticleCountByLookUpType);
articleCountEvidence.setArticleCountScore(-(retrievalArticleCountByLookUpType - ReCiterArticleScorer.strategyParameters.getArticleCountThresholdScore())/ReCiterArticleScorer.strategyParameters.getArticleCountWeight());
} else {
articleCountEvidence.setCountArticlesRetrieved(this.numberOfArticles);
articleCountEvidence.setArticleCountScore(-(this.numberOfArticles - ReCiterArticleScorer.strategyParameters.getArticleCountThresholdScore())/ReCiterArticleScorer.strategyParameters.getArticleCountWeight());
}
}
} else if(eSearchResult != null
&&
eSearchResult.getQueryType() != null
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/reciter/pubmed/retriever/PubMedQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public String toString() {
//parts.add(author + " [au]");
parts.add(author);
}
//Switched from [DP] to [EDAT] for better capture of pubs : Date of publication - Date added to Entrez
//Added both [DP] and [EDAT] for better capture of pubs : Date of publication - Date added to Entrez
if (start != null && end != null) {
parts.add(dt.format(start) + ":" + dt.format(end) + "[EDAT]");
parts.add("((" + dt.format(start) + ":" + dt.format(end) + "[EDAT]" + ") OR (" + dt.format(start) + ":" + dt.format(end) + "[DP]))");
}
if (strategyQuery != null && !strategyQuery.isEmpty()) {
parts.add(strategyQuery);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import reciter.api.parameters.RetrievalRefreshFlag;
import reciter.database.dynamodb.model.ESearchPmid;
import reciter.database.dynamodb.model.ESearchResult;
import reciter.database.dynamodb.model.QueryType;
Expand Down Expand Up @@ -96,7 +97,7 @@ public abstract class AbstractReCiterRetrievalEngine implements ReCiterRetrieval
* @param pubMedArticles
* @param uid
*/
protected void savePubMedArticles(Collection<PubMedArticle> pubMedArticles, String uid, String retrievalStrategyName, List<PubMedQueryResult> pubMedQueryResults, QueryType queryType) {
protected void savePubMedArticles(Collection<PubMedArticle> pubMedArticles, String uid, String retrievalStrategyName, List<PubMedQueryResult> pubMedQueryResults, QueryType queryType, RetrievalRefreshFlag refreshFlag) {
// Save the articles.
List<PubMedArticle> pubMedArticleList = new ArrayList<>(pubMedArticles);
pubMedService.save(pubMedArticleList);
Expand All @@ -107,24 +108,32 @@ protected void savePubMedArticles(Collection<PubMedArticle> pubMedArticles, Stri
pmids.add(pubMedArticle.getMedlinecitation().getMedlinecitationpmid().getPmid());
}
ESearchPmid eSearchPmid = null;
if(pmids.size() > 0) {
eSearchPmid = new ESearchPmid(pmids, retrievalStrategyName, new Date());
if(!pmids.isEmpty()){
reciter.database.dynamodb.model.ESearchPmid.RetrievalRefreshFlag eSearchPmidRefreshFlag;
if(refreshFlag == RetrievalRefreshFlag.ALL_PUBLICATIONS) {
eSearchPmidRefreshFlag = reciter.database.dynamodb.model.ESearchPmid.RetrievalRefreshFlag.ALL_PUBLICATIONS;
} else if(refreshFlag == RetrievalRefreshFlag.ONLY_NEWLY_ADDED_PUBLICATIONS) {
eSearchPmidRefreshFlag = reciter.database.dynamodb.model.ESearchPmid.RetrievalRefreshFlag.ONLY_NEWLY_ADDED_PUBLICATIONS;
} else {
eSearchPmidRefreshFlag = reciter.database.dynamodb.model.ESearchPmid.RetrievalRefreshFlag.FALSE;
}
eSearchPmid = new ESearchPmid(pmids, retrievalStrategyName, new Date(), eSearchPmidRefreshFlag);
}
ESearchResult eSearchResultDb = eSearchResultService.findByUid(uid);
if (eSearchResultDb == null) {
List<ESearchPmid> eSearchPmids = new ArrayList<>();
if(eSearchPmid != null) {
eSearchPmids.add(eSearchPmid);
}
if(eSearchPmids.size() > 0) {
if(!eSearchPmids.isEmpty()) {
eSearchResultService.save(new ESearchResult(uid, new Date(), eSearchPmids, queryType));
}
} else {
List<ESearchPmid> eSearchPmids = eSearchResultDb.getESearchPmids();
if(eSearchPmid != null) {
eSearchPmids.add(eSearchPmid);
}
if(eSearchPmids.size() > 0) {
if(!eSearchPmids.isEmpty()) {
eSearchResultService.save(new ESearchResult(uid, new Date(), eSearchPmids, queryType));
} else {
eSearchResultDb.setRetrievalDate(new Date());
Expand Down
Loading

0 comments on commit e2b5966

Please sign in to comment.