-
Notifications
You must be signed in to change notification settings - Fork 35
/
duplicate_subjects.py
44 lines (33 loc) · 1.19 KB
/
duplicate_subjects.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
###################################
# Script: Duplicate Subjects
#
# To Use:
# 1) Edit input parameters below:
# destination_subject_set_id = integer ID for destination subject set
# input_subject_ids = list of integer subject IDs
#
# 2) Run from command line: `python duplicate_subjects.py`
from panoptes_client import Panoptes, Subject, SubjectSet
###################################
# Input Parameters
puser = 'USERNAME'
ppswd = 'PASSWORD'
destination_project_id = 99999
destination_subject_set_id = 999999
input_subject_ids = [62834100, 62834101, 62834102, 62834103]
###################################
Panoptes.connect(username=puser, password=ppswd)
print('Processing {} subjects'.format(len(input_subject_ids)))
subjects = []
for sid in input_subject_ids:
print('Working: Existing ID = {}'.format(sid))
sub_in = Subject.find(sid)
sub_out = Subject()
sub_out.locations = sub_in.locations
sub_out.links.project = destination_project_id
sub_out.metadata = sub_in.metadata
sub_out.save()
subjects.append(sub_out)
print('Adding subjects to subject set {}'.format(destination_subject_set_id))
SubjectSet.find(destination_subject_set_id).add(subjects)