本文整理汇总了Python中ngi_pipeline.database.classes.CharonSession.project_update方法的典型用法代码示例。如果您正苦于以下问题:Python CharonSession.project_update方法的具体用法?Python CharonSession.project_update怎么用?Python CharonSession.project_update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ngi_pipeline.database.classes.CharonSession
的用法示例。
在下文中一共展示了CharonSession.project_update方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from ngi_pipeline.database.classes import CharonSession [as 别名]
# 或者: from ngi_pipeline.database.classes.CharonSession import project_update [as 别名]
def main():
args = cli_args()
cs = CharonSession()
cs.project_update(args.project_id,best_practice_analysis="hello_engine")
# it is actually picking up stdout and stderr as well
output = subprocess.check_output(["./nextflow", "run", "hello-ga.nf"])
print "The output is:"
print output
print "done"
示例2: add_supr_name_delivery_in_charon
# 需要导入模块: from ngi_pipeline.database.classes import CharonSession [as 别名]
# 或者: from ngi_pipeline.database.classes.CharonSession import project_update [as 别名]
def add_supr_name_delivery_in_charon(self, supr_name_of_delivery):
'''Updates delivery_projects in Charon at project level
'''
charon_session = CharonSession()
try:
#fetch the project
project_charon = charon_session.project_get(self.projectid)
delivery_projects = project_charon['delivery_projects']
if supr_name_of_delivery not in delivery_projects:
delivery_projects.append(supr_name_of_delivery)
charon_session.project_update(self.projectid, delivery_projects=delivery_projects)
logger.info('Charon delivery_projects for project {} updated with value {}'.format(self.projectid, supr_name_of_delivery))
else:
logger.warn('Charon delivery_projects for project {} not updated with value {} because the value was already present'.format(self.projectid, supr_name_of_delivery))
except Exception, e:
logger.error('Failed to update delivery_projects in charon while delivering {}. Error says: {}'.format(self.projectid, e))
logger.exception(e)
示例3: write_status_to_charon
# 需要导入模块: from ngi_pipeline.database.classes import CharonSession [as 别名]
# 或者: from ngi_pipeline.database.classes.CharonSession import project_update [as 别名]
def write_status_to_charon(project_id, return_code):
"""Update the status of a workflow for a project in the Charon database.
:param NGIProject project_id: The name of the project
:param int return_code: The return code of the workflow process
:raises RuntimeError: If the Charon database could not be updated
"""
## Consider keeping on CharonSession open. What's the time savings?
charon_session = CharonSession()
## Is "CLOSED" correct here?
status = "CLOSED" if return_code is 0 else "FAILED"
try:
charon_session.project_update(project_id, status=status)
except CharonError as e:
error_msg = ('Failed to update project status to "{}" for "{}" '
'in Charon database: {}'.format(status, project_id, e))
raise RuntimeError(error_msg)
示例4: DbConnections
# 需要导入模块: from ngi_pipeline.database.classes import CharonSession [as 别名]
# 或者: from ngi_pipeline.database.classes.CharonSession import project_update [as 别名]
class DbConnections():
def __init__(self):
with open(os.getenv('STATUS_DB_CONFIG'), 'r') as db_cred_file:
db_conf = yaml.load(db_cred_file)['statusdb']
self.statusdbSess = sdb(db_conf, db="projects")
self.CharonSess = CharonSession()
def add_delivery_proj_in_charon(self, delivery_proj, projectid):
'''Updates delivery_projects in Charon at project level
'''
try:
#fetch the project
project_charon = self.CharonSess.project_get(projectid)
delivery_projects = project_charon['delivery_projects']
if delivery_proj not in delivery_projects:
delivery_projects.append(delivery_proj)
self.CharonSess.project_update(projectid, delivery_projects=delivery_projects)
logger.info('Charon delivery_projects for project {} updated with value {}'.format(projectid, delivery_proj))
else:
logger.warn('Charon delivery_projects for project {} not updated with value {} because the value was already present'.format(projectid, delivery_proj))
except Exception, e:
logger.error('Failed to update delivery_projects in charon for {}. Error says: {}'.format(projectid, e))
logger.exception(e)
示例5: analyze
# 需要导入模块: from ngi_pipeline.database.classes import CharonSession [as 别名]
# 或者: from ngi_pipeline.database.classes.CharonSession import project_update [as 别名]
def analyze(project, sample,
exec_mode="local",
restart_finished_jobs=False,
restart_running_jobs=False,
keep_existing_data=False,
level="sample",
genotype_file=None,
config=None, config_file_path=None,
generate_bqsr_bam=False):
"""Analyze data at the sample level.
:param NGIProject project: the project to analyze
:param NGISample sample: the sample to analyzed
:param str exec_mode: "sbatch" or "local" (local not implemented)
:param bool restart_finished_jobs: Restart jobs that are already done (have a .done file)
:param bool restart_running_jobs: Kill and restart currently-running jobs
:param str level: The level on which to perform the analysis ("sample" or "genotype")
:param str genotype_file: The path to the genotype file (only relevant for genotype analysis)
:param dict config: The parsed configuration file (optional)
:param str config_file_path: The path to the configuration file (optional)
:raises ValueError: If exec_mode is an unsupported value
"""
#TODO add trace_tracking_path somehow
dir_prefix = project.base_path + "/DATA/" + project.project_id + "/"
LOG.info("Processing "+project.project_id + " at " + dir_prefix)
# in the debugger you can have something like
# import pdb
# pdb.set_trace()
# ...
# print project.samples['P697_001'].libpreps['A'].seqruns['908254_ST-E00205_2662_BBZZHATCXX'].fastq_files
# below is how to traverse the project -> samples -> libpreps -> seqruns tree to find all the FASTQs you want to feed into the workflow
# this is only a logging info - get rid of it in your real code
#
# for some reason the R2 is the first and R1 is the second in the fastq list
#
sample_names = []
for s in project.samples.keys():
for l in project.samples[s].libpreps.keys():
for sr in project.samples[s].libpreps[l].seqruns.keys():
for fq in project.samples[s].libpreps[l].seqruns[sr].fastq_files:
sample_names.append( s + "/" + l + "/" + sr + "/"+fq+" " )
# for sns in sample_names:
# LOG.info("Sample: " + dir_prefix + sns)
# end of demo log code
#
# To launch demo for each sample we are traversing the project object to collect all the fastq pairs
#
fastq_pairs = get_sample_fastq_pairs(sample,dir_prefix)
#
# notify charon about the project start
#
cs = CharonSession()
# TODO: finish trace information
# we are storing individual run traces in the trace file
#trace_file = config['database']['trace_tracking_prefix'] + str(project) + "_"+str(sample)
#LOG.info("Writing trace to "+trace_file)
cs.project_update(project.project_id, best_practice_analysis="hello_engine")
#
# the subprocess modules picks up stdout and stderr as well
#
referenceDir = config['hello_engine']['refbase']
workflow = config['hello_engine']['workflow']
try:
output = subprocess.check_output(["nextflow", "run", workflow,"--reads1",fastq_pairs[0],"--reads2",fastq_pairs[1],"--refbase",referenceDir ])
LOG.info(output)
except OSError as oe:
LOG.info(oe)
update_charon_with_local_jobs_status(config=config)
LOG.info("Done - bye")
return 0
示例6: create_charon_entries_from_project
# 需要导入模块: from ngi_pipeline.database.classes import CharonSession [as 别名]
# 或者: from ngi_pipeline.database.classes.CharonSession import project_update [as 别名]
def create_charon_entries_from_project(project, best_practice_analysis="whole_genome_reseq",
sequencing_facility="NGI-S",
force_overwrite=False, delete_existing=False,
retry_on_fail=True):
"""Given a project object, creates the relevant entries in Charon.
This code is remarkably shoddy as I created it in a hurry and then later
it became a part of the pipeline. Use at your own risk! Ha ha.
:param NGIProject project: The NGIProject object
:param str best_practice_analysis: The workflow to assign for this project (default "variant_calling")
:param str sequencing_facility: The facility that did the sequencing
:param bool force_overwrite: If this is set to true, overwrite existing entries in Charon (default false)
:param bool delete_existing: Don't just update existing entries, delete them and create new ones (default false)
"""
charon_session = CharonSession()
update_failed=False
try:
status = "OPEN"
LOG.info('Creating project "{}" with status "{}", best practice analysis "{}", '
'and sequencing_facility {}'.format(project, status,
best_practice_analysis,
sequencing_facility))
charon_session.project_create(projectid=project.project_id,
name=project.name,
status=status,
best_practice_analysis=best_practice_analysis,
sequencing_facility=sequencing_facility)
LOG.info('Project "{}" created in Charon.'.format(project))
except CharonError as e:
if e.status_code == 400:
if force_overwrite:
LOG.warn('Overwriting data for project "{}"'.format(project))
charon_session.project_update(projectid=project.project_id,
name=project.name,
status=status,
best_practice_analysis=best_practice_analysis,
sequencing_facility=sequencing_facility)
LOG.info('Project "{}" updated in Charon.'.format(project))
else:
LOG.info('Project "{}" already exists; moving to samples...'.format(project))
else:
raise
for sample in project:
if delete_existing:
LOG.warn('Deleting existing sample "{}"'.format(sample))
try:
charon_session.sample_delete(projectid=project.project_id,
sampleid=sample.name)
except CharonError as e:
update_failed=True
LOG.error('Could not delete sample "{}": {}'.format(sample, e))
try:
analysis_status = "TO_ANALYZE"
LOG.info('Creating sample "{}" with analysis_status "{}"'.format(sample, analysis_status))
charon_session.sample_create(projectid=project.project_id,
sampleid=sample.name,
analysis_status=analysis_status)
LOG.info('Project/sample "{}/{}" created in Charon.'.format(project, sample))
except CharonError as e:
if e.status_code == 400:
if force_overwrite:
LOG.warn('Overwriting data for project "{}" / '
'sample "{}"'.format(project, sample))
charon_session.sample_update(projectid=project.project_id,
sampleid=sample.name,
analysis_status=analysis_status)
LOG.info('Project/sample "{}/{}" updated in Charon.'.format(project, sample))
else:
LOG.info('Project "{}" / sample "{}" already exists; moving '
'to libpreps'.format(project, sample))
else:
update_failed=True
LOG.error(e)
continue
for libprep in sample:
if delete_existing:
LOG.warn('Deleting existing libprep "{}"'.format(libprep))
try:
charon_session.libprep_delete(projectid=project.project_id,
sampleid=sample.name,
libprepid=libprep.name)
except CharonError as e:
LOG.warn('Could not delete libprep "{}": {}'.format(libprep, e))
try:
qc = "PASSED"
LOG.info('Creating libprep "{}" with qc status "{}"'.format(libprep, qc))
charon_session.libprep_create(projectid=project.project_id,
sampleid=sample.name,
libprepid=libprep.name,
qc=qc)
LOG.info(('Project/sample/libprep "{}/{}/{}" created in '
'Charon').format(project, sample, libprep))
except CharonError as e:
if e.status_code == 400:
if force_overwrite:
LOG.warn('Overwriting data for project "{}" / '
'sample "{}" / libprep "{}"'.format(project, sample,
libprep))
charon_session.libprep_update(projectid=project.project_id,
sampleid=sample.name,
#.........这里部分代码省略.........
示例7: create_charon_entries_from_project
# 需要导入模块: from ngi_pipeline.database.classes import CharonSession [as 别名]
# 或者: from ngi_pipeline.database.classes.CharonSession import project_update [as 别名]
def create_charon_entries_from_project(project, workflow="NGI", force_overwrite=False):
"""Given a project object, creates the relevant entries
in Charon.
:param NGIProject project: The NGIProject object
:param str workflow: The workflow to assign for this project (default NGI)
:param bool force_overwrite: If this is set to true, overwrite existing entries in Charon (default false)
"""
charon_session = CharonSession()
try:
status="SEQUENCED"
LOG.info('Creating project "{}" with status "{}" and workflow "{}"'.format(project, status, workflow))
charon_session.project_create(projectid=project.project_id,
name=project.name,
status=status,
pipeline=workflow)
except CharonError:
if force_overwrite:
LOG.warn('Overwriting data for project "{}"'.format(project))
charon_session.project_update(projectid=project.project_id,
name=project.name,
status=status,
pipeline=workflow)
else:
LOG.info('Project "{}" already exists; moving to samples...'.format(project))
for sample in project:
try:
LOG.info('Creating sample "{}"'.format(sample))
charon_session.sample_create(projectid=project.project_id,
sampleid=sample.name,
status="NEW")
except CharonError:
if force_overwrite:
LOG.warn('Overwriting data for project "{}" / '
'sample "{}"'.format(project, sample))
charon_session.sample_update(projectid=project.project_id,
sampleid=sample.name,
status="NEW")
else:
LOG.info('Project "{}" / sample "{}" already exists; moving '
'to libpreps'.format(project, sample))
for libprep in sample:
try:
LOG.info('Creating libprep "{}"'.format(libprep))
charon_session.libprep_create(projectid=project.project_id,
sampleid=sample.name,
libprepid=libprep.name,
status="NEW")
except CharonError:
if force_overwrite:
LOG.warn('Overwriting data for project "{}" / '
'sample "{}" / libprep "{}"'.format(project, sample,
libprep))
charon_session.libprep_update(projectid=project.project_id,
sampleid=sample.name,
libprepid=libprep.name,
status="NEW")
else:
LOG.info('Project "{}" / sample "{}" / libprep "{}" already '
'exists; moving to libpreps'.format(project, sample, libprep))
for seqrun in libprep:
try:
LOG.info('Creating seqrun "{}"'.format(seqrun))
charon_session.seqrun_create(projectid=project.project_id,
sampleid=sample.name,
libprepid=libprep.name,
seqrunid=seqrun.name,
total_reads=0,
mean_autosomal_coverage=0,
sequencing_status="DONE",
alignment_status="NEW")
except CharonError as e:
if force_overwrite:
LOG.warn('Overwriting data for project "{}" / '
'sample "{}" / libprep "{}" / '
'seqrun "{}"'.format(project, sample,
libprep, seqrun))
charon_session.seqrun_update(projectid=project.project_id,
sampleid=sample.name,
libprepid=libprep.name,
seqrunid=seqrun.name,
status="NEW")
else:
LOG.info('Project "{}" / sample "{}" / libprep "{}" / '
'seqrun "{}" already exists; next...'.format(project, sample,
libprep, seqrun))
示例8: delete_delivery_token_in_charon
# 需要导入模块: from ngi_pipeline.database.classes import CharonSession [as 别名]
# 或者: from ngi_pipeline.database.classes.CharonSession import project_update [as 别名]
def delete_delivery_token_in_charon(self):
'''Removes delivery_token from Charon upon successful delivery
'''
charon_session = CharonSession()
charon_session.project_update(self.projectid, delivery_token='NO-TOKEN')
示例9: save_delivery_token_in_charon
# 需要导入模块: from ngi_pipeline.database.classes import CharonSession [as 别名]
# 或者: from ngi_pipeline.database.classes.CharonSession import project_update [as 别名]
def save_delivery_token_in_charon(self, delivery_token):
'''Updates delivery_token in Charon at project level
'''
charon_session = CharonSession()
charon_session.project_update(self.projectid, delivery_token=delivery_token)