Skip to content

Commit

Permalink
added endpoint to update ena sequence name and md5 checksum for multi…
Browse files Browse the repository at this point in the history
…ple assemblies
  • Loading branch information
nitin-ebi committed Feb 9, 2024
1 parent 5515132 commit 5ff968b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public ResponseEntity<?> fetchAndInsertAssemblyByAccession(
"parallel manner.")
@PutMapping(value = "assemblies")
public ResponseEntity<?> fetchAndInsertAssemblyByAccession(
@RequestBody(required = false) @ApiParam(value = "A JSON array of INSDC or RefSeq assembly accessions. " +
@RequestBody @ApiParam(value = "A JSON array of INSDC or RefSeq assembly accessions. " +
"Eg: [\"GCA_000001405.10\",\"GCA_000001405.11\",\"GCA_000001405.12\"]") List<String> accessions) {
if (accessions == null || accessions.size() <= 0) {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
Expand All @@ -90,7 +90,7 @@ public ResponseEntity<?> fetchAndInsertAssemblyByAccession(
}

@ApiOperation(value = "Given an assembly accession, retrieve MD5 checksum for all chromosomes belonging to assembly and update")
@PutMapping(value = "assemblies/{accession}/md5checksum")
@PutMapping(value = "assemblies/md5checksum/{accession}")
public ResponseEntity<String> retrieveAndInsertMd5ChecksumForAssembly(@PathVariable(name = "accession")
@ApiParam(value = "INSDC or RefSeq assembly accession. Eg: " +
"GCA_000001405.10") String asmAccession) {
Expand All @@ -106,8 +106,20 @@ public ResponseEntity<String> retrieveAndInsertMd5ChecksumForAssembly(@PathVaria
}
}

@ApiOperation(value = "Given a list of assembly accessions, retrieve MD5 checksum for all chromosomes belonging to all the assemblies and update")
@PutMapping(value = "assemblies/md5checksum")
public ResponseEntity<String> retrieveAndInsertMd5ChecksumForAssembly(
@RequestBody @ApiParam(value = "A JSON array of INSDC or RefSeq assembly accessions. " +
"Eg: [\"GCA_000001405.10\",\"GCA_000001405.11\",\"GCA_000001405.12\"]") List<String> accessions) {
handler.retrieveAndInsertMd5ChecksumForAssembly(accessions);
return ResponseEntity.ok("A task has been submitted for updating md5checksum for all chromosomes " +
"in assemblies " + accessions + ". Depending upon the number of chromosomes present in assembly, " +
"and other scheduled jobs, this might take some time to complete");

}

@ApiOperation(value = "Given an assembly accession, retrieve ENA sequence name for all chromosomes belonging to assembly and update")
@PutMapping(value = "assemblies/{accession}/enaSequenceName")
@PutMapping(value = "assemblies/enaSequenceName/{accession}")
public ResponseEntity<String> retrieveAndInsertENASequenceNameForAssembly(@PathVariable(name = "accession")
@ApiParam(value = "INSDC or RefSeq assembly accession. " +
"Eg: GCA_000001405.10") String asmAccession) {
Expand All @@ -123,8 +135,21 @@ public ResponseEntity<String> retrieveAndInsertENASequenceNameForAssembly(@PathV
}
}

@ApiOperation(value = "Given a list of assembly accessions, retrieve ENA sequence name for all chromosomes belonging to all the assemblies and update")
@PutMapping(value = "assemblies/enaSequenceName")
public ResponseEntity<String> retrieveAndInsertENASequenceNameForAssembly(
@RequestBody @ApiParam(value = "A JSON array of INSDC or RefSeq assembly accessions. " +
"Eg: [\"GCA_000001405.10\",\"GCA_000001405.11\",\"GCA_000001405.12\"]") List<String> accessions) {

handler.retrieveAndInsertENASequenceNameForAssembly(accessions);
return ResponseEntity.ok("A task has been submitted for updating ENA Sequence Name for all chromosomes " +
"in assembly " + accessions + ". Depending upon the number of chromosomes present in assembly, " +
"and other scheduled jobs, this might take some time to complete");
}


@ApiOperation(value = "Retrieve list of assemblies for which MD5 Checksum updates are running/going-to-run ")
@GetMapping(value = "assemblies/md5checksum/status")
@GetMapping(value = "assemblies/scheduledJobs")
public ResponseEntity<List<String>> getMD5ChecksumUpdateTaskStatus() {
List<String> scheduledJobStatus = handler.getScheduledJobStatus();
return ResponseEntity.ok(scheduledJobStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,18 @@ public void retrieveAndInsertMd5ChecksumForAssembly(String accession) {
assemblyService.retrieveAndInsertMd5ChecksumForAssembly(accession);
}

public void retrieveAndInsertMd5ChecksumForAssembly(List<String> accessions) {
assemblyService.retrieveAndInsertMd5ChecksumForAssembly(accessions);
}

public void retrieveAndInsertENASequenceNameForAssembly(String accession) {
assemblyService.retrieveAndInsertENASequenceNameForAssembly(accession);
}

public void retrieveAndInsertENASequenceNameForAssembly(List<String> accessions) {
assemblyService.retrieveAndInsertENASequenceNameForAssembly(accessions);
}

public List<String> getScheduledJobStatus() {
return assemblyService.getScheduledJobStatus();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ public void submitJob(Job job) {
ApplicationContextHolder.getApplicationContext().publishEvent(event);
}

public void submitJob(List<Job> jobList) {
jobQueue.addAll(jobList);
jobList.stream().forEach(job -> logger.info("Submitted Job : " + job.getType() + " for assembly " + job.getParameter()));
JobSubmittedEvent event = new JobSubmittedEvent(this);
ApplicationContextHolder.getApplicationContext().publishEvent(event);
}

@Override
public void onApplicationEvent(JobSubmittedEvent event) {
processJobs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,27 @@ public void retrieveAndInsertMd5ChecksumForAssembly(String assembly) {
chromosomeUpdater.submitJob(md5ChecksumupdateJob);
}

public void retrieveAndInsertMd5ChecksumForAssembly(List<String> assemblies) {
List<Job> jobsList = new ArrayList();
for (String assembly : assemblies) {
jobsList.add(new Job(JobType.MD5_CHECKSUM_UPDATE, assembly));
}
chromosomeUpdater.submitJob(jobsList);
}

public void retrieveAndInsertENASequenceNameForAssembly(String assembly) {
Job enaSequenceNameupdateJob = new Job(JobType.ENA_SEQUENCE_NAME_UPDATE, assembly);
chromosomeUpdater.submitJob(enaSequenceNameupdateJob);
}

public void retrieveAndInsertENASequenceNameForAssembly(List<String> assemblies) {
List<Job> jobsList = new ArrayList();
for (String assembly : assemblies) {
jobsList.add(new Job(JobType.ENA_SEQUENCE_NAME_UPDATE, assembly));
}
chromosomeUpdater.submitJob(jobsList);
}

public List<String> getScheduledJobStatus() {
return chromosomeUpdater.getScheduledJobStatus();
}
Expand Down

0 comments on commit 5ff968b

Please sign in to comment.