Skip to content

Commit

Permalink
lib: improve protein downloader by checking if data is already downlo…
Browse files Browse the repository at this point in the history
…aded, #TASK-5575, #TASK-5564
  • Loading branch information
jtarraga committed Jul 24, 2024
1 parent 4ba788d commit 6fc7129
Showing 1 changed file with 33 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,49 @@ public List<DownloadFile> download() throws IOException, InterruptedException, C

// Check if the species is supported
if (SpeciesUtils.hasData(configuration, speciesConfiguration.getScientificName(), PROTEIN_DATA)) {
logger.info(DOWNLOADING_LOG_MESSAGE, getDataName(PROTEIN_DATA));
Path proteinFolder = downloadFolder.resolve(PROTEIN_DATA);
Files.createDirectories(proteinFolder);

Path uniProtFolder = Files.createDirectories(proteinFolder.resolve(UNIPROT_DATA));
Path interProFolder = Files.createDirectories(proteinFolder.resolve(INTERPRO_DATA));
Path intactFolder = Files.createDirectories(proteinFolder.resolve(INTACT_DATA));

// Already downloaded ?
boolean downloadUniProt = !isAlreadyDownloaded(uniProtFolder.resolve(getDataVersionFilename(UNIPROT_DATA)),
getDataName(UNIPROT_DATA));
boolean downloadInterPro = !isAlreadyDownloaded(interProFolder.resolve(getDataVersionFilename(INTERPRO_DATA)),
getDataName(INTERPRO_DATA));
boolean downloadIntact = !isAlreadyDownloaded(intactFolder.resolve(getDataVersionFilename(INTACT_DATA)),
getDataName(INTACT_DATA));

if (!downloadUniProt && !downloadInterPro && !downloadIntact) {
return new ArrayList<>();
}

logger.info(DOWNLOADING_LOG_MESSAGE, getDataName(PROTEIN_DATA));

DownloadFile downloadFile;

// Uniprot
downloadFile = downloadAndSaveDataSource(configuration.getDownload().getUniprot(),
UNIPROT_FILE_ID, UNIPROT_DATA, proteinFolder);
downloadFiles.add(downloadFile);
if (downloadUniProt) {
downloadFile = downloadAndSaveDataSource(configuration.getDownload().getUniprot(), UNIPROT_FILE_ID, UNIPROT_DATA,
uniProtFolder);
downloadFiles.add(downloadFile);
}

// InterPro
downloadFile = downloadAndSaveDataSource(configuration.getDownload().getInterpro(),
INTERPRO_FILE_ID, INTERPRO_DATA, proteinFolder);
downloadFiles.add(downloadFile);
if (downloadInterPro) {
downloadFile = downloadAndSaveDataSource(configuration.getDownload().getInterpro(), INTERPRO_FILE_ID, INTERPRO_DATA,
interProFolder);
downloadFiles.add(downloadFile);
}

// Intact
downloadFile = downloadAndSaveDataSource(configuration.getDownload().getIntact(),
INTACT_FILE_ID, INTACT_DATA, proteinFolder);
downloadFiles.add(downloadFile);
if (downloadIntact) {
downloadFile = downloadAndSaveDataSource(configuration.getDownload().getIntact(), INTACT_FILE_ID, INTACT_DATA,
intactFolder);
downloadFiles.add(downloadFile);
}

logger.info(DOWNLOADING_DONE_LOG_MESSAGE, getDataName(PROTEIN_DATA));
}
Expand Down

0 comments on commit 6fc7129

Please sign in to comment.