Search is not available for this dataset
text
stringlengths
75
104k
def update_case_compounds(self, case_obj, build='37'): """Update the compounds for a case Loop over all coding intervals to get coordinates for all potential compound positions. Update all variants within a gene with a bulk operation. """ case_id = case_obj['_id'] # Pos...
def load_variant(self, variant_obj): """Load a variant object Args: variant_obj(dict) Returns: inserted_id """ # LOG.debug("Loading variant %s", variant_obj['_id']) try: result = self.variant_collection.insert_one(variant_obj) ...
def upsert_variant(self, variant_obj): """Load a variant object, if the object already exists update compounds. Args: variant_obj(dict) Returns: result """ LOG.debug("Upserting variant %s", variant_obj['_id']) try: result = self.varia...
def load_variant_bulk(self, variants): """Load a bulk of variants Args: variants(iterable(scout.models.Variant)) Returns: object_ids """ if not len(variants) > 0: return LOG.debug("Loading variant bulk") try: resu...
def _load_variants(self, variants, variant_type, case_obj, individual_positions, rank_threshold, institute_id, build=None, rank_results_header=None, vep_header=None, category='snv', sample_info = None): """Perform the loading of variants This is the functio...
def load_variants(self, case_obj, variant_type='clinical', category='snv', rank_threshold=None, chrom=None, start=None, end=None, gene_obj=None, build='37'): """Load variants for a case into scout. Load the variants for a specific analysis type and category i...
def assign(self, institute, case, user, link): """Assign a user to a case. This function will create an Event to log that a person has been assigned to a case. Also the user will be added to case "assignees". Arguments: institute (dict): A institute case (dict):...
def share(self, institute, case, collaborator_id, user, link): """Share a case with a new institute. Arguments: institute (dict): A Institute object case (dict): Case object collaborator_id (str): A instute id user (dict): A User object link (...
def diagnose(self, institute, case, user, link, level, omim_id, remove=False): """Diagnose a case using OMIM ids. Arguments: institute (dict): A Institute object case (dict): Case object user (dict): A User object link (str): The url to be used in the eve...
def mark_checked(self, institute, case, user, link, unmark=False): """Mark a case as checked from an analysis point of view. Arguments: institute (dict): A Institute object case (dict): Case object user (dict): A User object link (str...
def update_default_panels(self, institute_obj, case_obj, user_obj, link, panel_objs): """Update default panels for a case. Arguments: institute_obj (dict): A Institute object case_obj (dict): Case object user_obj (dict): A User object link (str): The url ...
def order_verification(self, institute, case, user, link, variant): """Create an event for a variant verification for a variant and an event for a variant verification for a case Arguments: institute (dict): A Institute object case (dict): Case object user (d...
def sanger_ordered(self, institute_id=None, user_id=None): """Get all variants with validations ever ordered. Args: institute_id(str) : The id of an institute user_id(str) : The id of an user Returns: sanger_ordered(list) : a list of dictionaries, each with ...
def validate(self, institute, case, user, link, variant, validate_type): """Mark validation status for a variant. Arguments: institute (dict): A Institute object case (dict): Case object user (dict): A User object link (str): The url to be used in the eve...
def mark_causative(self, institute, case, user, link, variant): """Create an event for marking a variant causative. Arguments: institute (dict): A Institute object case (dict): Case object user (dict): A User object link (str): The url to be used in the event ...
def update_dismiss_variant(self, institute, case, user, link, variant, dismiss_variant): """Create an event for updating the manual dismiss variant entry This function will create a event and update the dismiss variant field of the variant. Arguments:...
def update_acmg(self, institute_obj, case_obj, user_obj, link, variant_obj, acmg_str): """Create an event for updating the ACMG classification of a variant. Arguments: institute_obj (dict): A Institute object case_obj (dict): Case object user_obj (dict): A User objec...
def parse_ids(chrom, pos, ref, alt, case_id, variant_type): """Construct the necessary ids for a variant Args: chrom(str): Variant chromosome pos(int): Variant position ref(str): Variant reference alt(str): Variant alternative case_id(str): Unique case id variant...
def parse_simple_id(chrom, pos, ref, alt): """Parse the simple id for a variant Simple id is used as a human readable reference for a position, it is in no way unique. Args: chrom(str) pos(str) ref(str) alt(str) Returns: simple_id(str): The simple human rea...
def parse_variant_id(chrom, pos, ref, alt, variant_type): """Parse the variant id for a variant variant_id is used to identify variants within a certain type of analysis. It is not human readable since it is a md5 key. Args: chrom(str) pos(str) ref(str) alt(str) ...
def parse_display_name(chrom, pos, ref, alt, variant_type): """Parse the variant id for a variant This is used to display the variant in scout. Args: chrom(str) pos(str) ref(str) alt(str) variant_type(str): 'clinical' or 'research' Returns: variant_id(s...
def parse_document_id(chrom, pos, ref, alt, variant_type, case_id): """Parse the unique document id for a variant. This will always be unique in the database. Args: chrom(str) pos(str) ref(str) alt(str) variant_type(str): 'clinical' or 'research' case_id(str...
def convert(context, panel): """Convert a gene panel with hgnc symbols to a new one with hgnc ids.""" adapter = context.obj['adapter'] new_header = ["hgnc_id","hgnc_symbol","disease_associated_transcripts", "reduced_penetrance", "genetic_disease_models", "mosaicism", "datab...
def get_variantid(variant_obj, family_id): """Create a new variant id. Args: variant_obj(dict) family_id(str) Returns: new_id(str): The new variant id """ new_id = parse_document_id( chrom=variant_obj['chromosome'], pos=str(variant_obj['position']), ...
def cases(self, owner=None, collaborator=None, query=None, skip_assigned=False, has_causatives=False, reruns=False, finished=False, research_requested=False, is_research=False, status=None, phenotype_terms=False, pinned=False, cohort=False, name_query=None, yield_...
def nr_cases(self, institute_id=None): """Return the number of cases This function will change when we migrate to 3.7.1 Args: collaborator(str): Institute id Returns: nr_cases(int) """ query = {} if institute_id: query['coll...
def update_dynamic_gene_list(self, case, hgnc_symbols=None, hgnc_ids=None, phenotype_ids=None, build='37'): """Update the dynamic gene list for a case Adds a list of dictionaries to case['dynamic_gene_list'] that looks like { hgnc_symbol: str, ...
def case(self, case_id=None, institute_id=None, display_name=None): """Fetches a single case from database Use either the _id or combination of institute_id and display_name Args: case_id(str): _id for a caes institute_id(str): display_name(str) Yie...
def delete_case(self, case_id=None, institute_id=None, display_name=None): """Delete a single case from database Args: institute_id(str) case_id(str) Returns: case_obj(dict): The case that was deleted """ query = {} if case_id: ...
def load_case(self, config_data, update=False): """Load a case into the database Check if the owner and the institute exists. Args: config_data(dict): A dictionary with all the necessary information update(bool): If existing case should be updated Returns: ...
def _add_case(self, case_obj): """Add a case to the database If the case already exists exception is raised Args: case_obj(Case) """ if self.case(case_obj['_id']): raise IntegrityError("Case %s already exists in database" % case_obj['_id']) ...
def update_case(self, case_obj): """Update a case in the database The following will be updated: - collaborators: If new collaborators these will be added to the old ones - analysis_date: Is updated to the new date - analyses: The new analysis date will be added to o...
def replace_case(self, case_obj): """Replace a existing case with a new one Keeps the object id Args: case_obj(dict) Returns: updated_case(dict) """ # Todo: Figure out and describe when this method destroys a case if invoked instead of #...
def update_caseid(self, case_obj, family_id): """Update case id for a case across the database. This function is used when a case is a rerun or updated for another reason. Args: case_obj(dict) family_id(str): The new family id Returns: new_case(dict...
def submit_evaluation(self, variant_obj, user_obj, institute_obj, case_obj, link, criteria): """Submit an evaluation to the database Get all the relevant information, build a evaluation_obj Args: variant_obj(dict) user_obj(dict) institute_obj(dict) ...
def get_evaluations(self, variant_obj): """Return all evaluations for a certain variant. Args: variant_obj (dict): variant dict from the database Returns: pymongo.cursor: database cursor """ query = dict(variant_id=variant_obj['variant_id']) res ...
def parse_transcripts(transcript_lines): """Parse and massage the transcript information There could be multiple lines with information about the same transcript. This is why it is necessary to parse the transcripts first and then return a dictionary where all information has been merged. Args: ...
def parse_ensembl_gene_request(result): """Parse a dataframe with ensembl gene information Args: res(pandas.DataFrame) Yields: gene_info(dict) """ LOG.info("Parsing genes from request") for index, row in result.iterrows(): # print(index, row) ensembl_info = {} ...
def parse_ensembl_transcript_request(result): """Parse a dataframe with ensembl transcript information Args: res(pandas.DataFrame) Yields: transcript_info(dict) """ LOG.info("Parsing transcripts from request") keys = [ 'chrom', 'ensembl_gene_id', 'ensem...
def parse_ensembl_line(line, header): """Parse an ensembl formated line Args: line(list): A list with ensembl gene info header(list): A list with the header info Returns: ensembl_info(dict): A dictionary with the relevant info """ line = line.rstrip().sp...
def parse_ensembl_genes(lines): """Parse lines with ensembl formated genes This is designed to take a biomart dump with genes from ensembl. Mandatory columns are: 'Gene ID' 'Chromosome' 'Gene Start' 'Gene End' 'HGNC symbol Args: lines(iterable(str)): An iterable with en...
def parse_ensembl_exons(lines): """Parse lines with ensembl formated exons This is designed to take a biomart dump with exons from ensembl. Check documentation for spec for download Args: lines(iterable(str)): An iterable with ensembl formated exons Yields: ...
def parse_ensembl_exon_request(result): """Parse a dataframe with ensembl exon information Args: res(pandas.DataFrame) Yields: gene_info(dict) """ keys = [ 'chrom', 'gene', 'transcript', 'exon_id', 'exon_chrom_start', 'exon_chrom_end'...
def init_log(logger, filename=None, loglevel=None): """ Initializes the log file in the proper format. Arguments: filename (str): Path to a file. Or None if logging is to be disabled. loglevel (str): Determines the level of the log output. """ template = '[...
def parse_omim_line(line, header): """docstring for parse_omim_2_line""" omim_info = dict(zip(header, line.split('\t'))) return omim_info
def parse_genemap2(lines): """Parse the omim source file called genemap2.txt Explanation of Phenotype field: Brackets, "[ ]", indicate "nondiseases," mainly genetic variations that lead to apparently abnormal laboratory test values. Braces, "{ }", indicate mutations that contribute to suscept...
def parse_mim2gene(lines): """Parse the file called mim2gene This file describes what type(s) the different mim numbers have. The different entry types are: 'gene', 'gene/phenotype', 'moved/removed', 'phenotype', 'predominantly phenotypes' Where: gene: Is a gene entry gene/pheno...
def parse_omim_morbid(lines): """docstring for parse_omim_morbid""" header = [] for i,line in enumerate(lines): line = line.rstrip() if line.startswith('#'): if i < 10: if line.startswith('# Phenotype'): header = line[2:].split('\t') el...
def parse_mim_titles(lines): """Parse the mimTitles.txt file This file hold information about the description for each entry in omim. There is not information about entry type. parse_mim_titles collects the preferred title and maps it to the mim number. Args: lines(iterable): lines...
def get_mim_genes(genemap_lines, mim2gene_lines): """Get a dictionary with genes and their omim information Args: genemap_lines(iterable(str)) mim2gene_lines(iterable(str)) Returns. hgnc_genes(dict): A dictionary with hgnc_symbol as keys """ LOG.info("Get the m...
def get_mim_phenotypes(genemap_lines): """Get a dictionary with phenotypes Use the mim numbers for phenotypes as keys and phenotype information as values. Args: genemap_lines(iterable(str)) Returns: phenotypes_found(dict): A dictionary with mim_numbers as keys and ...
def cli(context, morbid, genemap, mim2gene, mim_titles, phenotypes): """Parse the omim files""" # if not (morbid and genemap and mim2gene, mim_titles): # print("Please provide all files") # context.abort() from scout.utils.handle import get_file_handle from pprint import pprint as pp ...
def convert_number(string): """Convert a string to number If int convert to int otherwise float If not possible return None """ res = None if isint(string): res = int(string) elif isfloat(string): res = float(string) return res
def case(context, case_id, case_name, institute, collaborator, vcf, vcf_sv, vcf_cancer, vcf_research, vcf_sv_research, vcf_cancer_research, peddy_ped, reupload_sv, rankscore_treshold, rankmodel_version): """ Update a case in the database """ adapter = context.obj['adapter'] if not ...
def setup_scout(adapter, institute_id='cust000', user_name='Clark Kent', user_mail='clark.kent@mail.com', api_key=None, demo=False): """docstring for setup_scout""" ########################## Delete previous information ########################## LOG.info("Deleting previous database") fo...
def export_transcripts(adapter, build='37'): """Export all transcripts from the database Args: adapter(scout.adapter.MongoAdapter) build(str) Yields: transcript(scout.models.Transcript) """ LOG.info("Exporting all transcripts") for tx_obj in adapter.transcripts...
def formatmonth(self, theyear, themonth, withyear=True, net=None, qs=None, template='happenings/partials/calendar/month_table.html'): """Return a formatted month as a table.""" context = self.get_context() context['month_start_date'] = date(self.yr, self.mo, 1) context['week_rows'] = [] ...
def formatday( self, day, weekday, day_template='happenings/partials/calendar/day_cell.html', noday_template='happenings/partials/calendar/day_noday_cell.html', popover_template='happenings/partials/calendar/popover.html', ): """Return a day as a table...
def formatday(self, day, weekday): """Return a day as a table cell.""" return super(MiniEventCalendar, self).formatday( day, weekday, day_template='happenings/partials/calendar/mini_day_cell.html', popover_template='happenings/partials/calendar/mini_popover.html', ...
def formatday(self, day, weekday): """Set some commonly used variables.""" self.wkday_not_today = '<td class="%s"><div class="td-inner">' % ( self.cssclasses[weekday]) self.wkday_today = ( '<td class="%s calendar-today"><div class="td-inner">' % ( self.cs...
def formatmonthname(self, theyear, themonth, withyear=True): """ Change colspan to "5", add "today" button, and return a month name as a table row. """ display_month = month_name[themonth] if isinstance(display_month, six.binary_type) and self.encoding: displ...
def popover_helper(self): """Populate variables used to build popovers.""" # when display_month = month_name[self.mo] if isinstance(display_month, six.binary_type) and self.encoding: display_month = display_month.decode('utf-8') self.when = ('<p><b>When:</b> ' + dis...
def formatday(self, day, weekday): """Return a day as a table cell.""" super(EventCalendar, self).formatday(day, weekday) now = get_now() self.day = day out = '' if day == 0: return '<td class="noday">&nbsp;</td>' # day outside month elif now.month =...
def formatday(self, day, weekday): """Return a day as a table cell.""" super(MiniEventCalendar, self).formatday(day, weekday) now = get_now() self.day = day if day == 0: return '<td class="noday">&nbsp;</td>' # day outside month elif now.month == self.mo and...
def get_panel_info(panel_lines=None, panel_id=None, institute=None, version=None, date=None, display_name=None): """Parse metadata for a gene panel For historical reasons it is possible to include all information about a gene panel in the header of a panel file. This function parses the ...
def parse_gene(gene_info): """Parse a gene line with information from a panel file Args: gene_info(dict): dictionary with gene info Returns: gene(dict): A dictionary with the gene information { 'hgnc_id': int, 'hgnc_symbol': s...
def parse_genes(gene_lines): """Parse a file with genes and return the hgnc ids Args: gene_lines(iterable(str)): Stream with genes Returns: genes(list(dict)): Dictionaries with relevant gene info """ genes = [] header = [] hgnc_identifiers = set() delimiter = '\t' #...
def parse_gene_panel(path, institute='cust000', panel_id='test', panel_type='clinical', date=datetime.now(), version=1.0, display_name=None, genes = None): """Parse the panel info and return a gene panel Args: path(str): Path to panel file institute(str): Name ...
def parse_panel_app_gene(app_gene, hgnc_map): """Parse a panel app formated gene Args: app_gene(dict): Dict with panel app info hgnc_map(dict): Map from hgnc_symbol to hgnc_id Returns: gene_info(dict): Scout infromation """ gene_info = {} confidence_level = app_...
def parse_panel_app_panel(panel_info, hgnc_map, institute='cust000', panel_type='clinical'): """Parse a PanelApp panel Args: panel_info(dict) hgnc_map(dict): Map from symbol to hgnc ids institute(str) panel_type(str) Returns: gene_panel(dict) """ dat...
def get_omim_panel_genes(genemap2_lines, mim2gene_lines, alias_genes): """Return all genes that should be included in the OMIM-AUTO panel Return the hgnc symbols Genes that have at least one 'established' or 'provisional' phenotype connection are included in the gene panel Args: ge...
def diseases(context): """Show all diseases in the database""" LOG.info("Running scout view diseases") adapter = context.obj['adapter'] disease_objs = adapter.disease_terms() nr_diseases = disease_objs.count() if nr_diseases == 0: click.echo("No diseases found") else: click...
def hpo(context): """ Update the hpo terms in the database. Fetch the latest release and update terms. """ LOG.info("Running scout update hpo") adapter = context.obj['adapter'] LOG.info("Dropping HPO terms") adapter.hpo_term_collection.drop() LOG.debug("HPO terms dropped") load_hpo...
def get_upcoming_events(self): """ Repeats an event and returns 'num' (or fewer) upcoming events from 'now'. """ if self.event.repeats('NEVER'): has_ended = False now_gt_start = self.now > self.event.l_start_date now_gt_end = self.now > self.ev...
def we_should_stop(self, start, start_): """ Checks 'start' to see if we should stop collecting upcoming events. 'start' should be a datetime.datetime, 'start_' should be the same as 'start', but it should be a datetime.date to allow comparison w/ end_repeat. """ ...
def users(store): """Display a list of all users and which institutes they belong to.""" user_objs = list(store.users()) total_events = store.user_events().count() for user_obj in user_objs: if user_obj.get('institutes'): user_obj['institutes'] = [store.institute(inst_id) for inst_id...
def parse_conservations(variant): """Parse the conservation predictors Args: variant(dict): A variant dictionary Returns: conservations(dict): A dictionary with the conservations """ conservations = {} conservations['gerp'] = parse_conservation( ...
def parse_conservation(variant, info_key): """Get the conservation prediction Args: variant(dict): A variant dictionary info_key(str) Returns: conservations(list): List of censervation terms """ raw_score = variant.INFO.get(info_key) conservations = ...
def get_next_event(event, now): """ Returns the next occurrence of a given event, relative to 'now'. The 'event' arg should be an iterable containing one element, namely the event we'd like to find the occurrence of. The reason for this is b/c the get_count() function of CountHandler, which this...
def get_dashboard_info(adapter, institute_id=None, slice_query=None): """Returns cases with phenotype If phenotypes are provided search for only those Args: adapter(adapter.MongoAdapter) institute_id(str): an institute _id slice_query(str): query to filter cases to obtain stat...
def get_general_case_info(adapter, institute_id=None, slice_query=None): """Return general information about cases Args: adapter(adapter.MongoAdapter) institute_id(str) slice_query(str): Query to filter cases to obtain statistics for. Returns: general(dict) """ g...
def get_case_groups(adapter, total_cases, institute_id=None, slice_query=None): """Return the information about case groups Args: store(adapter.MongoAdapter) total_cases(int): Total number of cases slice_query(str): Query to filter cases to obtain statistics for. Returns: c...
def get_analysis_types(adapter, total_cases, institute_id=None, slice_query=None): """ Return information about analysis types. Group cases based on analysis type for the individuals. Args: adapter(adapter.MongoAdapter) total_cases(int): Total number of cases institute_id(str) ...
def render_to_json_response(self, context, **kwargs): """ Returns a JSON response, transforming 'context' to make the payload. """ return HttpResponse( self.convert_context_to_json(context), content_type='application/json', **kwargs )
def convert_context_to_json(self, context): """ Get what we want out of the context dict and convert that to a JSON object. Note that this does no object serialization b/c we're not sending any objects. """ if 'month/shift' in self.request.path: # month calendar ...
def get_year_and_month(self, net, qs, **kwargs): """ Get the year and month. First tries from kwargs, then from querystrings. If none, or if cal_ignore qs is specified, sets year and month to this year and this month. """ now = c.get_now() year = now.year ...
def check_for_cancelled_events(self, d): """Check if any events are cancelled on the given date 'd'.""" for event in self.events: for cn in event.cancellations.all(): if cn.date == d: event.title += ' (CANCELLED)'
def load_hpo_term(self, hpo_obj): """Add a hpo object Arguments: hpo_obj(dict) """ LOG.debug("Loading hpo term %s into database", hpo_obj['_id']) try: self.hpo_term_collection.insert_one(hpo_obj) except DuplicateKeyError as err: raise...
def load_hpo_bulk(self, hpo_bulk): """Add a hpo object Arguments: hpo_bulk(list(scout.models.HpoTerm)) Returns: result: pymongo bulkwrite result """ LOG.debug("Loading hpo bulk") try: result = self.hpo_term_collection.insert_many(hp...
def hpo_term(self, hpo_id): """Fetch a hpo term Args: hpo_id(str) Returns: hpo_obj(dict) """ LOG.debug("Fetching hpo term %s", hpo_id) return self.hpo_term_collection.find_one({'_id': hpo_id})
def hpo_terms(self, query=None, hpo_term=None, text=None, limit=None): """Return all HPO terms If a query is sent hpo_terms will try to match with regex on term or description. Args: query(str): Part of a hpoterm or description hpo_term(str): Search for a specif...
def disease_term(self, disease_identifier): """Return a disease term Checks if the identifier is a disease number or a id Args: disease_identifier(str) Returns: disease_obj(dict) """ query = {} try: disease_identifier = int(d...
def disease_terms(self, hgnc_id=None): """Return all disease terms that overlaps a gene If no gene, return all disease terms Args: hgnc_id(int) Returns: iterable(dict): A list with all disease terms that match """ query = {} if hgnc_...
def load_disease_term(self, disease_obj): """Load a disease term into the database Args: disease_obj(dict) """ LOG.debug("Loading disease term %s into database", disease_obj['_id']) try: self.disease_term_collection.insert_one(disease_obj) except ...
def generate_hpo_gene_list(self, *hpo_terms): """Generate a sorted list with namedtuples of hpogenes Each namedtuple of the list looks like (hgnc_id, count) Args: hpo_terms(iterable(str)) Returns: hpo_genes(list(HpoGene)) """ ...
def cmd_tool(args=None): """ Command line tool for plotting and viewing info on filterbank files """ from argparse import ArgumentParser parser = ArgumentParser(description="Command line utility for reading and plotting filterbank files.") parser.add_argument('-p', action='store', default='ank', des...
def read_hdf5(self, filename, f_start=None, f_stop=None, t_start=None, t_stop=None, load_data=True): """ Populate Filterbank instance with data from HDF5 file Note: This is to be deprecated in future, please use Waterfall() to open files. """ print("W...
def _setup_freqs(self, f_start=None, f_stop=None): """ Setup frequency axis """ ## Setup frequency axis f0 = self.header[b'fch1'] f_delt = self.header[b'foff'] i_start, i_stop = 0, self.header[b'nchans'] if f_start: i_start = int((f_start - f0) / f_delt) ...
def _setup_time_axis(self, t_start=None, t_stop=None): """ Setup time axis. """ # now check to see how many integrations requested ii_start, ii_stop = 0, self.n_ints_in_file if t_start: ii_start = t_start if t_stop: ii_stop = t_stop n_ints = ii_s...
def read_filterbank(self, filename=None, f_start=None, f_stop=None, t_start=None, t_stop=None, load_data=True): """ Populate Filterbank instance with data from Filterbank file Note: This is to be deprecated in future, please use Waterfall() to open files. """...