Skip to content

Commit

Permalink
add sample coordinates creation jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
emiliorighi committed Dec 12, 2023
1 parent 862aa15 commit 234dc01
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 16 additions & 0 deletions server/rest/cronjob/cronjob_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,19 @@ def add_blob_link():
if len(response) and 'names' in response[0].keys() and len(response[0]['names']):
ass.blobtoolkit_id = response[0]['names'][0]
ass.save()

def create_biosample_coordinates():
biosamples = BioSample.objects()
existing_coordinates = SampleCoordinates.objects().scalar('sample_accession')
for biosample in biosamples:
if biosample.accession in existing_coordinates:
continue
sample_locations_service.save_coordinates(biosample)

def create_local_sample_coordinates():
local_samples = LocalSample.objects()
existing_coordinates = SampleCoordinates.objects().scalar('sample_accession')
for local_sample in local_samples:
if local_sample.local_id in existing_coordinates:
continue
sample_locations_service.save_coordinates(local_sample,id_field='local_id')
4 changes: 3 additions & 1 deletion server/rest/cronjob/cronjobs_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
'update_sample_locations': cronjob_service.update_sample_locations,
'get_samples_collection_date':cronjob_service.get_samples_collection_date,
'add_blob_link':cronjob_service.add_blob_link,
'remove_orphan_local_samples':cronjob_service.remove_orphan_local_samples
'remove_orphan_local_samples':cronjob_service.remove_orphan_local_samples,
'create_biosample_coordinates':cronjob_service.create_biosample_coordinates,
'create_local_sample_coordinates':cronjob_service.create_local_sample_coordinates
}
## persist cronjob status
class CronJobApi(Resource):
Expand Down

0 comments on commit 234dc01

Please sign in to comment.