def sample(ctx, **kwargs): ctx.obj.update(kwargs) sample_set = SampleSet( sample=Sample(alias=ctx.obj['alias'], title=ctx.obj['title'], taxon_id=ctx.obj['taxon_id'], scientific_name=ctx.obj['scientific_name'], common_name=ctx.obj['common_name'], **ast.literal_eval(ctx.obj['attributes']))) sample_set.write_xml(file=ctx.obj['sample_xml']) if ctx.obj['verbose']: print("Sample XML file created in " + ctx.obj['sample_xml']) submission = Submission(**ctx.obj) submission.write_xml(file=ctx.obj['submission_xml']) if ctx.obj['verbose']: print("Submission XML file created in " + ctx.obj['submission_xml']) response = requests.post(ctx.obj['server_address'], files={ 'SUBMISSION': (os.path.basename(ctx.obj['submission_xml']), open(ctx.obj['submission_xml'], 'rb')), 'SAMPLE': (os.path.basename(ctx.obj['sample_xml']), open(ctx.obj['sample_xml'], 'rb')), }, auth=(ctx.obj['user'], ctx.obj['password'])) print(response.content.decode()) return response
def run_set(ctx, **kwargs): ctx.obj.update(kwargs) run_set = RunSet(run=ctx.obj['table'], **kwargs) run_set.write_xml(file=ctx.obj['run_xml']) if ctx.obj['verbose']: print("Run XML file created in " + ctx.obj['run_xml']) submission = Submission(**ctx.obj) submission.write_xml(file=ctx.obj['submission_xml']) if ctx.obj['verbose']: print("Submission XML file created in " + ctx.obj['submission_xml']) response = requests.post(ctx.obj['server_address'], files={ 'SUBMISSION': (os.path.basename(ctx.obj['submission_xml']), open(ctx.obj['submission_xml'], 'rb')), 'RUN': (os.path.basename(ctx.obj['run_xml']), open(ctx.obj['run_xml'], 'rb')), }, auth=(ctx.obj['user'], ctx.obj['password'])) print(response.content.decode()) return response
def experiment(ctx, **kwargs): ctx.obj.update(kwargs) experiment_set = ExperimentSet(experiment=Experiment(**kwargs)) experiment_set.write_xml(file=ctx.obj['experiment_xml']) if ctx.obj['verbose']: print("Experiment XML file created in " + ctx.obj['experiment_xml']) submission = Submission(**ctx.obj) submission.write_xml(file=ctx.obj['submission_xml']) if ctx.obj['verbose']: print("Submission XML file created in " + ctx.obj['submission_xml']) response = requests.post(ctx.obj['server_address'], files={ 'SUBMISSION': (os.path.basename(ctx.obj['submission_xml']), open(ctx.obj['submission_xml'], 'rb')), 'EXPERIMENT': (os.path.basename(ctx.obj['experiment_xml']), open(ctx.obj['experiment_xml'], 'rb')), }, auth=(ctx.obj['user'], ctx.obj['password'])) print(response.content.decode()) return response
def study(ctx, **kwargs): ctx.obj.update(kwargs) project_set = ProjectSet(project=Project(**kwargs)) project_set.write_xml(file=ctx.obj['study_xml']) if ctx.obj['verbose']: print("Project XML file created in " + ctx.obj['study_xml']) submission = Submission(**ctx.obj) submission.write_xml(file=ctx.obj['submission_xml']) if ctx.obj['verbose']: print("Submission XML file created in " + ctx.obj['submission_xml']) response = requests.post(ctx.obj['server_address'], files={ 'SUBMISSION': (os.path.basename(ctx.obj['submission_xml']), open(ctx.obj['submission_xml'], 'rb')), 'PROJECT': (os.path.basename(ctx.obj['study_xml']), open(ctx.obj['study_xml'], 'rb')), }, auth=(ctx.obj['user'], ctx.obj['password'])) print(response.content.decode()) return response