Skip to content

Commit 0941817

Browse files
committed
app: load revel and alphamissense in the collection missense_variation_functional_score, #TASK-8163
1 parent a9b1a69 commit 0941817

2 files changed

Lines changed: 39 additions & 10 deletions

File tree

cellbase-app/src/main/java/org/opencb/cellbase/app/cli/admin/executors/LoadCommandExecutor.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.opencb.cellbase.app.cli.admin.AdminCliOptionsParser;
2323
import org.opencb.cellbase.core.config.SpeciesConfiguration;
2424
import org.opencb.cellbase.core.exception.CellBaseException;
25+
import org.opencb.cellbase.core.models.DataSource;
2526
import org.opencb.cellbase.core.models.Release;
2627
import org.opencb.cellbase.core.result.CellBaseDataResult;
2728
import org.opencb.cellbase.core.utils.DatabaseNameUtils;
@@ -359,17 +360,25 @@ private void loadProteinFunctionalPrediction() throws NoSuchMethodException, Int
359360
}
360361

361362
private void loadRevel() throws CellBaseException {
363+
// Check if REVEL source has already been loaded
364+
checkSourceAlreadyLoaded(REVEL_DATA);
365+
362366
HashMap<String, String> collectionMap = new HashMap<>();
363-
collectionMap.put(PROTEIN_SUBSTITUTION_PREDICTION_DATA, REVEL_DATA + JSON_GZ_EXTENSION);
367+
collectionMap.put(MISSENSE_VARIATION_SCORE_DATA, REVEL_DATA + JSON_GZ_EXTENSION);
364368

365-
loadData(input.resolve(PROTEIN_SUBSTITUTION_PREDICTION_DATA).resolve(REVEL_DATA), collectionMap);
369+
Path revelPath = input.resolve(PROTEIN_SUBSTITUTION_PREDICTION_DATA).resolve(REVEL_DATA);
370+
loadData(revelPath, collectionMap);
366371
}
367372

368373
private void loadAlphaMissense() throws CellBaseException {
374+
// Check if AlphaMissense source has already been loaded
375+
checkSourceAlreadyLoaded(ALPHAMISSENSE_DATA);
376+
369377
HashMap<String, String> collectionMap = new HashMap<>();
370-
collectionMap.put(PROTEIN_SUBSTITUTION_PREDICTION_DATA, ALPHAMISSENSE_DATA + JSON_GZ_EXTENSION);
378+
collectionMap.put(MISSENSE_VARIATION_SCORE_DATA, ALPHAMISSENSE_DATA + JSON_GZ_EXTENSION);
371379

372-
loadData(input.resolve(PROTEIN_SUBSTITUTION_PREDICTION_DATA).resolve(ALPHAMISSENSE_DATA), collectionMap);
380+
Path alphaMissensePath = input.resolve(PROTEIN_SUBSTITUTION_PREDICTION_DATA).resolve(ALPHAMISSENSE_DATA);
381+
loadData(alphaMissensePath, collectionMap);
373382
}
374383

375384
private void loadClinical() throws FileNotFoundException {
@@ -677,4 +686,16 @@ private Release getDataReleaseForLoading(DataReleaseManager dataReleaseManager)
677686
}
678687
return lastDataRelease;
679688
}
689+
690+
private void checkSourceAlreadyLoaded(String sourceId) throws CellBaseException {
691+
Release release = getDataReleaseForLoading(dataReleaseManager);
692+
if (release.getSources() != null) {
693+
for (DataSource source : release.getSources()) {
694+
if (sourceId.equalsIgnoreCase(source.getId())) {
695+
throw new CellBaseException("Loading data '" + sourceId + "' with release " + dataRelease
696+
+ " failed: source '" + sourceId + "' already loaded previously");
697+
}
698+
}
699+
}
700+
}
680701
}

cellbase-lib/src/main/java/org/opencb/cellbase/lib/loader/MongoDBCellBaseLoader.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
import java.util.concurrent.BlockingQueue;
5252
import java.util.stream.Collectors;
5353

54+
import static org.opencb.cellbase.lib.EtlCommons.MISSENSE_VARIATION_SCORE_DATA;
55+
5456
/**
5557
* Created by parce on 18/02/15.
5658
*/
@@ -137,13 +139,19 @@ private String getCollectionName() throws LoaderException {
137139
throw new LoaderException("Invalid data release " + dataRelease + " for database " + database + ". Available releases"
138140
+ " are: " + StringUtils.join(releases, ","));
139141
}
140-
for (Release dr : result.getResults()) {
141-
if (dr.getRelease() == dataRelease) {
142-
if (dr.getCollections().containsKey(data) && dr.getCollections().get(data).equals(collectionName)) {
143-
throw new LoaderException("Loading new data " + data + " with release " + dataRelease
144-
+ " (already populated previously)");
142+
143+
// Sanity check don't populate collections already populated
144+
// Missense variation score data (i.e., revel and alphaMissense) is checked later, since revel and alphamissense are loaded
145+
// in the same collection but independently
146+
if (!data.equalsIgnoreCase(MISSENSE_VARIATION_SCORE_DATA)) {
147+
for (Release dr : result.getResults()) {
148+
if (dr.getRelease() == dataRelease) {
149+
if (dr.getCollections().containsKey(data) && dr.getCollections().get(data).equals(collectionName)) {
150+
throw new LoaderException("Loading new data '" + data + "' with release " + dataRelease
151+
+ " (already populated previously)");
152+
}
153+
break;
145154
}
146-
break;
147155
}
148156
}
149157

0 commit comments

Comments
 (0)