本文整理汇总了Python中genologics.lims.Lims.get_samples方法的典型用法代码示例。如果您正苦于以下问题:Python Lims.get_samples方法的具体用法?Python Lims.get_samples怎么用?Python Lims.get_samples使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类genologics.lims.Lims
的用法示例。
在下文中一共展示了Lims.get_samples方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LimsService
# 需要导入模块: from genologics.lims import Lims [as 别名]
# 或者: from genologics.lims.Lims import get_samples [as 别名]
class LimsService(object):
name = "lims_service"
def __init__(self):
super(LimsService, self).__init__()
self.lims = Lims(BASEURI, USERNAME, PASSWORD)
self.lims.check_version()
@rpc
def sample(self, lims_id):
"""Get a sample from LIMS."""
sample_obj = LimsSample(self.lims, id=lims_id)
sample_dict = transform_entry(sample_obj)
return sample_dict
@rpc
def validate_sample(self, lims_id):
"""Validate information in the LIMS on sample level."""
logger.debug("fetch sample from LIMS")
sample_obj = LimsSample(self.lims, id=lims_id)
try:
case_id = sample_obj.udf["familyID"]
cust_id = sample_obj.udf["customer"]
except KeyError as error:
raise MissingLimsDataException(error.message)
except HTTPError as error:
raise LimsSampleNotFoundError(error.message)
@rpc
def ls_case(self, cust_id, case_id):
"""Fetch all samples for a case from the LIMS."""
sample_objs = self.lims.get_samples(udf={"customer": cust_id, "familyID": case_id})
sample_dicts = [transform_entry(sample) for sample in sample_objs]
analysis_types = set(sample["analysis_type"] for sample in sample_dicts)
case_data = {"analysis_types": list(analysis_types), "samples": sample_dicts}
return case_data
@rpc
def ls_project(self, project_id):
"""List all samples in a project."""
samples = self.lims.get_samples(projectname=project_id)
lims_ids = [sample.id for sample in samples]
return lims_ids
@rpc
def pedigree(self, cust_id, case_id):
"""Generate pedigree content for a case."""
ped_content = serialize_pedigree(self.lims, cust_id, case_id)
return ped_content
@rpc
def target_reads(self, lims_id):
"""Determine the amount of reads to be sequenced."""
sample_obj = LimsSample(self.lims, id=lims_id)
app_tag = analysis_info(sample_obj)
# millions of reads
target_reads = app_tag["reads"] * 1000000
return target_reads
示例2: main
# 需要导入模块: from genologics.lims import Lims [as 别名]
# 或者: from genologics.lims.Lims import get_samples [as 别名]
def main(args):
lims_db = get_session()
lims = Lims(BASEURI,USERNAME,PASSWORD)
with open(args.conf) as cf:
db_conf = yaml.load(cf)
couch = setupServer(db_conf)
db = couch["expected_yields"]
postgres_string="{} hours".format(args.hours)
project_ids=get_last_modified_projectids(lims_db, postgres_string)
for project in [Project(lims, id=x) for x in project_ids]:
samples_count = 0
samples = lims.get_samples(projectname=project.name)
for sample in samples:
if not("Status (manual)" in sample.udf and sample.udf["Status (manual)"] == "Aborted"):
samples_count +=1
try:
lanes_ordered = project.udf['Sequence units ordered (lanes)']
key = parse_sequencing_platform(project.udf['Sequencing platform'])
except:
continue
for row in db.view("yields/min_yield"):
db_key = [x.lower() if x else None for x in row.key]
if db_key==key:
try:
project.udf['Reads Min'] = float(row.value) * lanes_ordered / samples_count
project.put()
except ZeroDivisionError:
pass
示例3: __init__
# 需要导入模块: from genologics.lims import Lims [as 别名]
# 或者: from genologics.lims.Lims import get_samples [as 别名]
class ProjectReport:
def __init__(self, project_name):
self.project_name = project_name
self.project_source = os.path.join(cfg.query('sample','delivery_source'), project_name)
self.project_delivery = os.path.join(cfg.query('sample','delivery_dest'), project_name)
self.lims=Lims(**cfg.get('clarity'))
self.params = {'project_name':project_name}
self.results = {}
self.fill_sample_names_from_lims()
self.samples_delivered = self.read_metrics_csv(os.path.join(self.project_delivery, 'summary_metrics.csv'))
self.get_sample_param()
self.fill_project_information_from_lims()
def fill_project_information_from_lims(self):
project = self.lims.get_projects(name=self.project_name)[0]
self.project_info = {}
self.project_info['project_name']=['Project name:',self.project_name]
self.project_info['project_title']=['Project title:', project.udf.get('Project Title', '')]
self.project_info['enquiry'] = ['Enquiry no:', project.udf.get('Enquiry Number', '')]
self.project_info['quote'] = ['Quote no:', project.udf.get('Quote No.', '')]
self.project_info['researcher'] = ['Researcher:','%s %s (%s)'%(project.researcher.first_name,
project.researcher.last_name,
project.researcher.email)]
self.project_order = ['project_name', 'project_title', 'enquiry', 'quote', 'researcher']
def fill_sample_names_from_lims(self):
samples = self.lims.get_samples(projectname=self.project_name)
self.samples = [s.name for s in samples]
self.modified_samples = [re.sub(r'[: ]','_', s.name) for s in samples]
def get_library_workflow_from_sample(self, sample_name):
samples = self.lims.get_samples(projectname=self.project_name, name=sample_name)
if len(samples) == 1:
return samples[0].udf.get('Prep Workflow')
else:
app_logger.error('%s samples found for sample name %s'%sample_name)
def get_species_from_sample(self, sample_name):
samples = self.lims.get_samples(projectname=self.project_name, name=sample_name)
if len(samples) == 1:
s = samples[0].udf.get('Species')
return species_alias.get(s, s)
else:
app_logger.error('%s samples found for sample name %s'%sample_name)
def parse_program_csv(self, program_csv):
all_programs = {}
if os.path.exists(program_csv):
with open(program_csv) as open_prog:
for row in csv.reader(open_prog):
all_programs[row[0]]=row[1]
#TODO: change the hardcoded version of bcl2fastq
all_programs['bcl2fastq'] = '2.17.1.14'
for p in ['bcl2fastq','bcbio', 'bwa', 'gatk', 'samblaster']:
if p in all_programs:
self.params[p + '_version']=all_programs.get(p)
def parse_project_summary_yaml(self, summary_yaml):
with open(summary_yaml, 'r') as open_file:
full_yaml = yaml.safe_load(open_file)
sample_yaml=full_yaml['samples'][0]
path_to_bcbio = os.path.basename(os.path.dirname(sample_yaml['dirs']['galaxy']))
self.params['bcbio_version'] = path_to_bcbio.split('/')[-2]
if sample_yaml['genome_build'] == 'hg38':
self.params['genome_version'] = 'GRCh38 (with alt, decoy and HLA sequences)'
def read_metrics_csv(self, metrics_csv):
samples_to_info={}
with open(metrics_csv) as open_metrics:
reader = csv.DictReader(open_metrics, delimiter='\t', quoting=csv.QUOTE_NONE)
for row in reader:
samples_to_info[row['Sample Id']] = row
return samples_to_info
def get_sample_param(self):
self.fill_sample_names_from_lims()
project_size = 0
library_workflows=set()
species = set()
for sample in self.samples:
library_workflow = self.get_library_workflow_from_sample(sample)
library_workflows.add(library_workflow)
species.add(self.get_species_from_sample(sample))
if len(library_workflows) == 1 :
self.library_workflow = library_workflows.pop()
else:
app_logger.error('More than one workfkow used in project %s: %s'%(self.project_name, ', '.join(library_workflows)))
if len(species) == 1 :
self.species = species.pop()
else:
app_logger.error('More than one species used in project %s: %s'%(self.project_name, ', '.join(species)))
if self.library_workflow in ['TruSeq Nano DNA Sample Prep', None] :
self.template = 'truseq_nano_template'
#.........这里部分代码省略.........
示例4: LimsAPI
# 需要导入模块: from genologics.lims import Lims [as 别名]
# 或者: from genologics.lims.Lims import get_samples [as 别名]
class LimsAPI(object):
"""docstring for LimsAPI"""
def __init__(self, lims=None):
super(LimsAPI, self).__init__()
self.lims = lims
def init_app(self, app):
"""Connect with credentials from Flask app config."""
self.connect(**app.config['LIMS_CONFIG'])
def connect(self, baseuri, username, password):
"""Connect to the LIMS instance."""
self.lims = Lims(baseuri, username, password)
def sample(self, lims_id):
"""Get a sample from the LIMS."""
logger.debug('fetch sample from LIMS')
sample_obj = Sample(self.lims, id=lims_id)
try:
sample_json = transform_entry(sample_obj)
except KeyError as error:
message = "missing UDF: {}".format(error.message)
logger.warn(message)
raise MissingLimsDataException(message)
except HTTPError as error:
logger.warn('unknown lims id')
raise error
return sample_json
def samples(self, project_id=None, case=None, sample_ids=None, limit=20,
**kwargs):
if project_id:
sample_objs = self.lims.get_samples(projectname=project_id)
elif case:
sample_objs = self.lims.get_samples(udf={'customer': case[0],
'familyID': case[1]})
else:
sample_objs = self.lims.get_samples(**kwargs)
sample_dicts = []
for index, sample in enumerate(sample_objs):
if index < limit:
sample_dicts.append(transform_entry(sample))
else:
break
analysis_types = set(sample['analysis_type'] for sample in
sample_dicts)
case_data = {
'analysis_types': list(analysis_types),
'samples': sample_dicts
}
return case_data
def cases(self):
"""Return a list of cases from the database."""
samples = ((sample.udf['customer'], sample.udf['familyID'])
for sample in self.lims.get_samples()
if 'familyID' in sample.udf and 'customer' in sample.udf)
return samples
示例5: Lims
# 需要导入模块: from genologics.lims import Lims [as 别名]
# 或者: from genologics.lims.Lims import get_samples [as 别名]
Per Kraulis, Science for Life Laboratory, Stockholm, Sweden.
"""
from genologics.lims import Lims
# Login parameters for connecting to a LIMS instance.
# NOTE: Modify according to your setup.
from genologics.site_cloud import BASEURI, USERNAME, PASSWORD
# Create the LIMS interface instance, and check the connection and version.
lims = Lims(BASEURI, USERNAME, PASSWORD)
lims.check_version()
# Get the list of all samples.
samples = lims.get_samples()
print len(samples), 'samples in total'
# Get the list of samples in the project with the LIMS id KLL60.
project = lims.get_project('KLL60')
samples = lims.get_samples(projectlimsid=project.id)
print len(samples), 'samples in', project
print
# Get the sample with the LIMS id JGR58A21, and print info and its UDFs.
sample = lims.get_sample('JGR58A21')
print sample.id, sample.name, sample.date_received, sample.uri,
for key, value in sample.udf.items():
print ' ', key, '=', value
# Get the sample with the name 'Joels proper sample-20'.