-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #436 from alliance-genome/SCRUM-1371-SCRUM-1396-ge…
…ne-and-agm-removal SCRUM-1371 + SCRUM-1396: non-loaded gene and agm removal
- Loading branch information
Showing
55 changed files
with
603 additions
and
446 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
docker run -d --net curation -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" --name elasticsearch docker.elastic.co/elasticsearch/elasticsearch:7.10.2 | ||
docker run -d --net curation -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xmx4g -Xms4g" --name elasticsearch docker.elastic.co/elasticsearch/elasticsearch:7.10.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 44 additions & 7 deletions
51
src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneFmsExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,103 @@ | ||
package org.alliancegenome.curation_api.jobs.executors; | ||
|
||
import java.io.FileInputStream; | ||
import java.util.*; | ||
import java.util.stream.Collectors; | ||
import java.util.zip.GZIPInputStream; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
|
||
import org.alliancegenome.curation_api.dao.GeneDAO; | ||
import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; | ||
import org.alliancegenome.curation_api.exceptions.ObjectUpdateException.ObjectUpdateExceptionData; | ||
import org.alliancegenome.curation_api.model.entities.Gene; | ||
import org.alliancegenome.curation_api.model.entities.bulkloads.*; | ||
import org.alliancegenome.curation_api.model.ingest.fms.dto.*; | ||
import org.alliancegenome.curation_api.response.*; | ||
import org.alliancegenome.curation_api.services.GeneService; | ||
import org.alliancegenome.curation_api.util.ProcessDisplayHelper; | ||
import org.apache.commons.collections4.ListUtils; | ||
|
||
import lombok.extern.jbosslog.JBossLog; | ||
|
||
@JBossLog | ||
@ApplicationScoped | ||
public class GeneFmsExecutor extends LoadFileExecutor { | ||
|
||
@Inject GeneDAO geneDAO; | ||
|
||
@Inject GeneService geneService; | ||
|
||
|
||
public void runLoad(BulkLoadFile bulkLoadFile) { | ||
|
||
try { | ||
GeneMetaDataFmsDTO geneData = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), GeneMetaDataFmsDTO.class); | ||
bulkLoadFile.setRecordCount(geneData.getData().size()); | ||
bulkLoadFileDAO.merge(bulkLoadFile); | ||
|
||
trackHistory(runLoad(geneData), bulkLoadFile); | ||
|
||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
// Gets called from the API directly | ||
public APIResponse runLoad(GeneMetaDataFmsDTO geneData) { | ||
List<String> taxonIDs = geneData.getData().stream() | ||
.map( geneDTO -> geneDTO.getBasicGeneticEntity().getTaxonId() ).distinct().collect( Collectors.toList() ); | ||
|
||
List<String> annotationsIdsBefore = new ArrayList<String>(); | ||
for(String taxonID: taxonIDs) { | ||
List<String> annotationIds = geneDAO.findAllAnnotationIds(taxonID); | ||
log.debug("runLoad: Before: taxonID " + taxonID + " " + annotationIds.size()); | ||
annotationsIdsBefore.addAll(annotationIds); | ||
} | ||
|
||
log.debug("runLoad: Before: total " + annotationsIdsBefore.size()); | ||
List<String> annotationsIdsLoaded = new ArrayList<>(); | ||
|
||
BulkLoadFileHistory history = new BulkLoadFileHistory(geneData.getData().size()); | ||
|
||
ProcessDisplayHelper ph = new ProcessDisplayHelper(10000); | ||
|
||
ph.startProcess("Gene FMS DTO Update", geneData.getData().size()); | ||
|
||
for(GeneFmsDTO gene: geneData.getData()) { | ||
for(GeneFmsDTO geneDTO: geneData.getData()) { | ||
|
||
try { | ||
geneService.processUpdate(gene); | ||
Gene annotation = geneService.processUpdate(geneDTO); | ||
history.incrementCompleted(); | ||
annotationsIdsLoaded.add(annotation.getCurie()); | ||
} catch (ObjectUpdateException e) { | ||
addException(history, e.getData()); | ||
} catch (Exception e) { | ||
addException(history, new ObjectUpdateExceptionData(gene, e.getMessage())); | ||
addException(history, new ObjectUpdateExceptionData(geneDTO, e.getMessage())); | ||
} | ||
|
||
ph.progressProcess(); | ||
} | ||
ph.finishProcess(); | ||
|
||
|
||
log.debug("runLoad: Loaded: " + taxonIDs.toString() + " " + annotationsIdsLoaded.size()); | ||
|
||
List<String> distinctLoaded = annotationsIdsLoaded.stream().distinct().collect(Collectors.toList()); | ||
log.debug("runLoad: Distinct loaded: " + taxonIDs.toString() + " " + distinctLoaded.size()); | ||
|
||
List<String> curiesToRemove = ListUtils.subtract(annotationsIdsBefore, distinctLoaded); | ||
log.debug("runLoad: Remove: " + taxonIDs.toString() + " " + curiesToRemove.size()); | ||
|
||
for (String curie : curiesToRemove) { | ||
SearchResponse<Gene> gene = geneDAO.findByField("curie", curie); | ||
if (gene != null && gene.getTotalResults() == 1) { | ||
geneDAO.remove(gene.getResults().get(0).getCurie()); | ||
} else { | ||
log.error("Failed getting annotation: " + curie); | ||
} | ||
} | ||
|
||
return new LoadHistoryResponce(history); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/resources/db/migration/v0.4.0.1__agr_curation_api.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- Need to drop index to allow hibernate to recreate it with new definition (as hibernate doesn't replace constraints by itself) | ||
-- This change does require the application to be restarted after initial start-up (so hibernate would create the new constraint)! | ||
ALTER TABLE "genediseaseannotation" | ||
DROP CONSTRAINT "fk8xs26m9hfc38nmy7gvu3cec3t"; | ||
ALTER TABLE "agmdiseaseannotation" | ||
DROP CONSTRAINT "fklvr4o1waqclvbktjmyg6x25ls"; |
Oops, something went wrong.