INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Display a specific structural variant.
def sv_variant(institute_id, case_name, variant_id): """Display a specific structural variant.""" data = controllers.sv_variant(store, institute_id, case_name, variant_id) return data
Display a specific STR variant.
def str_variant(institute_id, case_name, variant_id): """Display a specific STR variant.""" data = controllers.str_variant(store, institute_id, case_name, variant_id) return data
Update user - defined information about a variant: manual rank & ACMG.
def variant_update(institute_id, case_name, variant_id): """Update user-defined information about a variant: manual rank & ACMG.""" institute_obj, case_obj = institute_and_case(store, institute_id, case_name) variant_obj = store.variant(variant_id) user_obj = store.user(current_user.email) link = re...
Start procedure to validate variant using other techniques.
def verify(institute_id, case_name, variant_id, variant_category, order): """Start procedure to validate variant using other techniques.""" institute_obj, case_obj = institute_and_case(store, institute_id, case_name) variant_obj = store.variant(variant_id) user_obj = store.user(current_user.email) ...
Build a clinVar submission form for a variant.
def clinvar(institute_id, case_name, variant_id): """Build a clinVar submission form for a variant.""" data = controllers.clinvar_export(store, institute_id, case_name, variant_id) if request.method == 'GET': return data else: #POST form_dict = request.form.to_dict() submission_o...
Show cancer variants overview.
def cancer_variants(institute_id, case_name): """Show cancer variants overview.""" data = controllers.cancer_variants(store, request.args, institute_id, case_name) return data
ACMG classification form.
def variant_acmg(institute_id, case_name, variant_id): """ACMG classification form.""" if request.method == 'GET': data = controllers.variant_acmg(store, institute_id, case_name, variant_id) return data else: criteria = [] criteria_terms = request.form.getlist('criteria') ...
Show or delete an ACMG evaluation.
def evaluation(evaluation_id): """Show or delete an ACMG evaluation.""" evaluation_obj = store.get_evaluation(evaluation_id) controllers.evaluation(store, evaluation_obj) if request.method == 'POST': link = url_for('.variant', institute_id=evaluation_obj['institute']['_id'], ...
Calculate an ACMG classification from submitted criteria.
def acmg(): """Calculate an ACMG classification from submitted criteria.""" criteria = request.args.getlist('criterion') classification = get_acmg(criteria) return jsonify(dict(classification=classification))
Parse gene panel file and fill in HGNC symbols for filter.
def upload_panel(institute_id, case_name): """Parse gene panel file and fill in HGNC symbols for filter.""" file = form.symbol_file.data if file.filename == '': flash('No selected file', 'warning') return redirect(request.referrer) try: stream = io.StringIO(file.stream.read().d...
Download all verified variants for user s cases
def download_verified(): """Download all verified variants for user's cases""" user_obj = store.user(current_user.email) user_institutes = user_obj.get('institutes') temp_excel_dir = os.path.join(variants_bp.static_folder, 'verified_folder') os.makedirs(temp_excel_dir, exist_ok=True) written_fi...
Return a dictionary with hgnc symbols as keys
def genes_by_alias(hgnc_genes): """Return a dictionary with hgnc symbols as keys Value of the dictionaries are information about the hgnc ids for a symbol. If the symbol is primary for a gene then 'true_id' will exist. A list of hgnc ids that the symbol points to is in ids. Args: hgnc_gene...
Add the coordinates from ensembl Args: genes ( dict ): Dictionary with all genes ensembl_lines ( iteable ): Iteable with raw ensembl info
def add_ensembl_info(genes, ensembl_lines): """Add the coordinates from ensembl Args: genes(dict): Dictionary with all genes ensembl_lines(iteable): Iteable with raw ensembl info """ LOG.info("Adding ensembl coordinates") # Parse and add the ensembl gene info if isinsta...
Add information from the exac genes Currently we only add the pLi score on gene level The exac resource only use HGNC symbol to identify genes so we need our alias mapping. Args: genes ( dict ): Dictionary with all genes alias_genes ( dict ): Genes mapped to all aliases ensembl_lines ( iteable ): Iteable with raw ensem...
def add_exac_info(genes, alias_genes, exac_lines): """Add information from the exac genes Currently we only add the pLi score on gene level The exac resource only use HGNC symbol to identify genes so we need our alias mapping. Args: genes(dict): Dictionary with all genes ...
Add omim information We collect information on what phenotypes that are associated with a gene what inheritance models that are associated and the correct omim id. Args: genes ( dict ): Dictionary with all genes alias_genes ( dict ): Genes mapped to all aliases genemap_lines ( iterable ): Iterable with raw omim info mi...
def add_omim_info(genes, alias_genes, genemap_lines, mim2gene_lines): """Add omim information We collect information on what phenotypes that are associated with a gene, what inheritance models that are associated and the correct omim id. Args: genes(dict): Dictionary with all genes ...
Add information of incomplete penetrance
def add_incomplete_penetrance(genes, alias_genes, hpo_lines): """Add information of incomplete penetrance""" LOG.info("Add incomplete penetrance info") for hgnc_symbol in get_incomplete_penetrance_genes(hpo_lines): for hgnc_id in get_correct_ids(hgnc_symbol, alias_genes): genes[hgnc_id][...
Try to get the correct gene based on hgnc_symbol The HGNC symbol is unfortunately not a persistent gene identifier. Many of the resources that are used by Scout only provides the hgnc symbol to identify a gene. We need a way to guess what gene is pointed at. Args: hgnc_symbol ( str ): The symbol used by a resource alia...
def get_correct_ids(hgnc_symbol, alias_genes): """Try to get the correct gene based on hgnc_symbol The HGNC symbol is unfortunately not a persistent gene identifier. Many of the resources that are used by Scout only provides the hgnc symbol to identify a gene. We need a way to guess what gene is p...
Gather information from different sources and return a gene dict
def link_genes(ensembl_lines, hgnc_lines, exac_lines, mim2gene_lines, genemap_lines, hpo_lines): """Gather information from different sources and return a gene dict Extract information collected from a number of sources and combine them into a gene dict with HGNC symbols as keys. hgnc_i...
Send a request to MatchMaker and return its response
def matchmaker_request(url, token, method, content_type=None, accept=None, data=None): """Send a request to MatchMaker and return its response Args: url(str): url to send request to token(str): MME server authorization token method(str): 'GET', 'POST' or 'DELETE' content_type(st...
Return the available MatchMaker nodes
def mme_nodes(mme_base_url, token): """Return the available MatchMaker nodes Args: mme_base_url(str): base URL of MME service token(str): MME server authorization token Returns: nodes(list): a list of node disctionaries """ nodes = [] if not mme_base_url or not token: ...
Get the cytoband coordinate for a position
def get_cytoband_coordinates(chrom, pos): """Get the cytoband coordinate for a position Args: chrom(str) pos(int) Returns: coordinate(str) """ coordinate = "" if chrom in CYTOBANDS: for interval in CYTOBANDS[chrom][pos]: coordinate = interval.data ...
Get the subcategory for a VCF variant
def get_sub_category(alt_len, ref_len, category, svtype=None): """Get the subcategory for a VCF variant The sub categories are: 'snv', 'indel', 'del', 'ins', 'dup', 'bnd', 'inv' Args: alt_len(int) ref_len(int) category(str) svtype(str) Returns: subcateg...
Return the length of a variant
def get_length(alt_len, ref_len, category, pos, end, svtype=None, svlen=None): """Return the length of a variant Args: alt_len(int) ref_len(int) category(str) svtype(str) svlen(int) """ # -1 would indicate uncertain length length = -1 if category in ('snv...
Return the end coordinate for a variant
def get_end(pos, alt, category, snvend=None, svend=None, svlen=None): """Return the end coordinate for a variant Args: pos(int) alt(str) category(str) snvend(str) svend(int) svlen(int) Returns: end(int) """ # If nothing is known we set end to...
Find out the coordinates for a variant
def parse_coordinates(variant, category): """Find out the coordinates for a variant Args: variant(cyvcf2.Variant) Returns: coordinates(dict): A dictionary on the form: { 'position':<int>, 'end':<int>, 'end_chrom':<str>, 'length':<int>...
Parse iterable with cytoband coordinates Args: lines ( iterable ): Strings on format chr1 \ t2300000 \ t5400000 \ tp36. 32 \ tgpos25 Returns: cytobands ( dict ): Dictionary with chromosome names as keys and interval trees as values
def parse_cytoband(lines): """Parse iterable with cytoband coordinates Args: lines(iterable): Strings on format "chr1\t2300000\t5400000\tp36.32\tgpos25" Returns: cytobands(dict): Dictionary with chromosome names as keys and interval trees as values ...
docstring for cli
def cli(infile): """docstring for cli""" lines = get_file_handle(infile) cytobands = parse_cytoband(lines) print("Check some coordinates:") print("checking chrom 1 pos 2") intervals = cytobands['1'][2] for interval in intervals: print(interval) print(interval.begin)...
Update a gene panel in the database We need to update the actual gene panel and then all cases that refers to the panel. Args: adapter ( scout. adapter. MongoAdapter ) panel_name ( str ): Unique name for a gene panel panel_version ( float ) new_version ( float ) new_date ( datetime. datetime ) Returns: updated_panel ( ...
def update_panel(adapter, panel_name, panel_version, new_version=None, new_date=None): """Update a gene panel in the database We need to update the actual gene panel and then all cases that refers to the panel. Args: adapter(scout.adapter.MongoAdapter) panel_name(str): Unique name ...
scout: manage interactions with a scout instance.
def cli(context, mongodb, username, password, authdb, host, port, loglevel, config, demo): """scout: manage interactions with a scout instance.""" # log_format = "%(message)s" if sys.stdout.isatty() else None log_format = None coloredlogs.install(level=loglevel, fmt=log_format) LOG.info("Running sco...
Parse an exac formated line Args: line ( list ): A list with exac gene info header ( list ): A list with the header info Returns: exac_info ( dict ): A dictionary with the relevant info
def parse_exac_line(line, header): """Parse an exac formated line Args: line(list): A list with exac gene info header(list): A list with the header info Returns: exac_info(dict): A dictionary with the relevant info """ exac_gene = {} spli...
Parse lines with exac formated genes This is designed to take a dump with genes from exac. This is downloaded from: ftp. broadinstitute. org/ pub/ ExAC_release// release0. 3/ functional_gene_constraint/ fordist_cleaned_exac_r03_march16_z_pli_rec_null_data. txt Args: lines ( iterable ( str )): An iterable with ExAC form...
def parse_exac_genes(lines): """Parse lines with exac formated genes This is designed to take a dump with genes from exac. This is downloaded from: ftp.broadinstitute.org/pub/ExAC_release//release0.3/functional_gene_constraint/ fordist_cleaned_exac_r03_march16_z_pli...
Show all panels for a case.
def panels(): """Show all panels for a case.""" if request.method == 'POST': # update an existing panel csv_file = request.files['csv_file'] content = csv_file.stream.read() lines = None try: if b'\n' in content: lines = content.decode('utf-8',...
Display ( and add pending updates to ) a specific gene panel.
def panel(panel_id): """Display (and add pending updates to) a specific gene panel.""" panel_obj = store.gene_panel(panel_id) or store.panel(panel_id) if request.method == 'POST': raw_hgnc_id = request.form['hgnc_id'] if '|' in raw_hgnc_id: raw_hgnc_id = raw_hgnc_id.split(' | ', ...
Update panel to a new version.
def panel_update(panel_id): """Update panel to a new version.""" panel_obj = store.panel(panel_id) update_version = request.form.get('version', None) new_panel_id = store.apply_pending(panel_obj, update_version) return redirect(url_for('panels.panel', panel_id=new_panel_id))
Export panel to PDF file
def panel_export(panel_id): """Export panel to PDF file""" panel_obj = store.panel(panel_id) data = controllers.panel_export(store, panel_obj) data['report_created_at'] = datetime.datetime.now().strftime("%Y-%m-%d") html_report = render_template('panels/panel_pdf_simple.html', **data) return ren...
Edit additional information about a panel gene.
def gene_edit(panel_id, hgnc_id): """Edit additional information about a panel gene.""" panel_obj = store.panel(panel_id) hgnc_gene = store.hgnc_gene(hgnc_id) panel_gene = controllers.existing_gene(store, panel_obj, hgnc_id) form = PanelGeneForm() transcript_choices = [] for transcript in h...
Add delivery report to an existing case.
def delivery_report(context, case_id, report_path, update): """Add delivery report to an existing case.""" adapter = context.obj['adapter'] try: load_delivery_report(adapter=adapter, case_id=case_id, report_path=report_path, update=update) L...
Parse a peddy. ped file Args: lines ( iterable ( str )) Returns: peddy_ped ( list ( dict ))
def parse_peddy_ped(lines): """Parse a peddy.ped file Args: lines(iterable(str)) Returns: peddy_ped(list(dict)) """ peddy_ped = [] header = [] for i,line in enumerate(lines): line = line.rstrip() if i == 0: # Header line heade...
Parse a. ped_check. csv file Args: lines ( iterable ( str )) Returns: ped_check ( list ( dict ))
def parse_peddy_ped_check(lines): """Parse a .ped_check.csv file Args: lines(iterable(str)) Returns: ped_check(list(dict)) """ ped_check = [] header = [] for i,line in enumerate(lines): line = line.rstrip() if i == 0: # Header line ...
Parse a. ped_check. csv file Args: lines ( iterable ( str )) Returns: sex_check ( list ( dict ))
def parse_peddy_sex_check(lines): """Parse a .ped_check.csv file Args: lines(iterable(str)) Returns: sex_check(list(dict)) """ sex_check = [] header = [] for i,line in enumerate(lines): line = line.rstrip() if i == 0: # Header line ...
Retrieves a list of HPO terms from scout database
def hpo_terms(store, query = None, limit = None): """Retrieves a list of HPO terms from scout database Args: store (obj): an adapter to the scout database query (str): the term to search in the database limit (str): the number of desired results Returns: hpo_phenotypes (dic...
Show all objects in the whitelist collection
def whitelist(context): """Show all objects in the whitelist collection""" LOG.info("Running scout view users") adapter = context.obj['adapter'] ## TODO add a User interface to the adapter for whitelist_obj in adapter.whitelist_collection.find(): click.echo(whitelist_obj['_id'])
Build a small phenotype object
def build_phenotype(phenotype_id, adapter): """Build a small phenotype object Build a dictionary with phenotype_id and description Args: phenotype_id (str): The phenotype id adapter (scout.adapter.MongoAdapter) Returns: phenotype_obj (dict): dict( phen...
Build a case object that is to be inserted to the database
def build_case(case_data, adapter): """Build a case object that is to be inserted to the database Args: case_data (dict): A dictionary with the relevant case information adapter (scout.adapter.MongoAdapter) Returns: case_obj (dict): A case object dict( case_id = str, #...
Parse information about a gene.
def gene(store, hgnc_id): """Parse information about a gene.""" res = {'builds': {'37': None, '38': None}, 'symbol': None, 'description': None, 'ensembl_id': None, 'record': None} for build in res['builds']: record = store.hgnc_gene(hgnc_id, build=build) if record: record['posi...
Fetch matching genes and convert to JSON.
def genes_to_json(store, query): """Fetch matching genes and convert to JSON.""" gene_query = store.hgnc_genes(query, search=True) json_terms = [{'name': "{} | {} ({})".format(gene['hgnc_id'], gene['hgnc_symbol'], ', '.join(gene['aliases'])), ...
Display the Scout dashboard.
def index(): """Display the Scout dashboard.""" accessible_institutes = current_user.institutes if not 'admin' in current_user.roles: accessible_institutes = current_user.institutes if not accessible_institutes: flash('Not allowed to see information - please visit the dashboard l...
Simple tag - returns the weekday of the given ( year month day ) or of given ( weekday_number ).
def weekday(year_or_num, month=None, day=None, full=False): """Simple tag - returns the weekday of the given (year, month, day) or of given (weekday_number). Usage (in template): {% weekday 2014 3 3 %} Result: Mon Return abbreviation by default. To return full name: pass full=True {% weekda...
Return a requests response from url Args: url ( str ) Returns: decoded_data ( str ): Decoded response
def get_request(url): """Return a requests response from url Args: url(str) Returns: decoded_data(str): Decoded response """ try: LOG.info("Requesting %s", url) response = urllib.request.urlopen(url) if url.endswith('.gz'): LOG.info("Deco...
Fetch a resource and return the resulting lines in a list Send file_name to get more clean log messages Args: url ( str ) Returns: lines ( list ( str ))
def fetch_resource(url): """Fetch a resource and return the resulting lines in a list Send file_name to get more clean log messages Args: url(str) Returns: lines(list(str)) """ try: data = get_request(url) lines = data.split('\n') except Exception as...
Fetch the necessary mim files using a api key Args: api_key ( str ): A api key necessary to fetch mim data Returns: mim_files ( dict ): A dictionary with the neccesary files
def fetch_mim_files(api_key, mim2genes=False, mimtitles=False, morbidmap=False, genemap2=False): """Fetch the necessary mim files using a api key Args: api_key(str): A api key necessary to fetch mim data Returns: mim_files(dict): A dictionary with the neccesary files """ L...
Fetch the ensembl genes Args: build ( str ): [ 37 38 ]
def fetch_ensembl_genes(build='37'): """Fetch the ensembl genes Args: build(str): ['37', '38'] """ if build == '37': url = 'http://grch37.ensembl.org' else: url = 'http://www.ensembl.org' LOG.info("Fetching ensembl genes from %s", url) dataset_name = 'hsapie...
Fetch the ensembl genes Args: build ( str ): [ 37 38 ]
def fetch_ensembl_exons(build='37'): """Fetch the ensembl genes Args: build(str): ['37', '38'] """ LOG.info("Fetching ensembl exons build %s ...", build) if build == '37': url = 'http://grch37.ensembl.org' else: url = 'http://www.ensembl.org' dataset_name = ...
Fetch the hgnc genes file from ftp:// ftp. ebi. ac. uk/ pub/ databases/ genenames/ new/ tsv/ hgnc_complete_set. txt Returns: hgnc_gene_lines ( list ( str ))
def fetch_hgnc(): """Fetch the hgnc genes file from ftp://ftp.ebi.ac.uk/pub/databases/genenames/new/tsv/hgnc_complete_set.txt Returns: hgnc_gene_lines(list(str)) """ file_name = "hgnc_complete_set.txt" url = 'ftp://ftp.ebi.ac.uk/pub/databases/genenames/new/tsv/{0}'.format(file_...
Fetch the file with exac constraint scores Returns: exac_lines ( iterable ( str ))
def fetch_exac_constraint(): """Fetch the file with exac constraint scores Returns: exac_lines(iterable(str)) """ file_name = 'fordist_cleaned_exac_r03_march16_z_pli_rec_null_data.txt' url = ('ftp://ftp.broadinstitute.org/pub/ExAC_release/release0.3/functional_gene_constraint' ...
Fetch the necessary mim files using a api key Args: api_key ( str ): A api key necessary to fetch mim data Returns: mim_files ( dict ): A dictionary with the neccesary files
def fetch_hpo_files(hpogenes=False, hpoterms=False, phenotype_to_terms=False, hpodisease=False): """Fetch the necessary mim files using a api key Args: api_key(str): A api key necessary to fetch mim data Returns: mim_files(dict): A dictionary with the neccesary files """ L...
Show all transcripts in the database
def transcripts(context, build, hgnc_id, json): """Show all transcripts in the database""" LOG.info("Running scout view transcripts") adapter = context.obj['adapter'] if not json: click.echo("Chromosome\tstart\tend\ttranscript_id\thgnc_id\trefseq\tis_primary") for tx_obj in adapter.transcri...
Adds an occurrence key to the event object w/ a list of occurrences and adds a popover ( for use with twitter bootstrap ). The occurrence is added so that each event can be aware of what day ( s ) it occurs in the month.
def add_occurrences(events, count): """ Adds an occurrence key to the event object w/ a list of occurrences and adds a popover (for use with twitter bootstrap). The occurrence is added so that each event can be aware of what day(s) it occurs in the month. """ for day in count: for it...
A function that returns an html calendar for the given month in the given year with the number of events for that month shown on the generated calendar. Start_day is the day the calendar should start on ( default is Monday ).
def month_display(year, month, all_month_events, start_day, net, qs, mini=False, request=None, context=None): """ A function that returns an html calendar for the given month in the given year, with the number of events for that month shown on the generated calendar. Start_day is the d...
Returns the events that occur on the given day. Works by getting all occurrences for the month then drilling down to only those occurring on the given day.
def day_display(year, month, all_month_events, day): """ Returns the events that occur on the given day. Works by getting all occurrences for the month, then drilling down to only those occurring on the given day. """ # Get a dict with all of the events for the month count = CountHandler(yea...
Pre - process list of variants.
def variants(store, institute_obj, case_obj, variants_query, page=1, per_page=50): """Pre-process list of variants.""" variant_count = variants_query.count() skip_count = per_page * max(page - 1, 0) more_variants = True if variant_count > (skip_count + per_page) else False variant_res = variants_que...
Pre - process list of SV variants.
def sv_variants(store, institute_obj, case_obj, variants_query, page=1, per_page=50): """Pre-process list of SV variants.""" skip_count = (per_page * max(page - 1, 0)) more_variants = True if variants_query.count() > (skip_count + per_page) else False genome_build = case_obj.get('genome_build', '37') ...
Pre - process list of STR variants.
def str_variants(store, institute_obj, case_obj, variants_query, page=1, per_page=50): """Pre-process list of STR variants.""" # Nothing unique to STRs on this level. Inheritance? return variants(store, institute_obj, case_obj, variants_query, page, per_page)
Pre - process an STR variant entry for detail page.
def str_variant(store, institute_id, case_name, variant_id): """Pre-process an STR variant entry for detail page. Adds information to display variant Args: store(scout.adapter.MongoAdapter) institute_id(str) case_name(str) variant_id(str) Returns: detailed_info...
Pre - process an SV variant entry for detail page.
def sv_variant(store, institute_id, case_name, variant_id=None, variant_obj=None, add_case=True, get_overlapping=True): """Pre-process an SV variant entry for detail page. Adds information to display variant Args: store(scout.adapter.MongoAdapter) institute_id(str) c...
Parse information about variants.
def parse_variant(store, institute_obj, case_obj, variant_obj, update=False, genome_build='37', get_compounds = True): """Parse information about variants. - Adds information about compounds - Updates the information about compounds if necessary and 'update=True' Args: store(...
Get variants info to be exported to file one list ( line ) per variant.
def variant_export_lines(store, case_obj, variants_query): """Get variants info to be exported to file, one list (line) per variant. Args: store(scout.adapter.MongoAdapter) case_obj(scout.models.Case) variants_query: a list of variant objects, each one is a dictionary ...
Returns a header for the CSV file with the filtered variants to be exported.
def variants_export_header(case_obj): """Returns a header for the CSV file with the filtered variants to be exported. Args: case_obj(scout.models.Case) Returns: header: includes the fields defined in scout.constants.variants_export EXPORT_HEADER + AD_ref...
Get variant information
def get_variant_info(genes): """Get variant information""" data = {'canonical_transcripts': []} for gene_obj in genes: if not gene_obj.get('canonical_transcripts'): tx = gene_obj['transcripts'][0] tx_id = tx['transcript_id'] exon = tx.get('exon', '-') ...
Get sift predictions from genes.
def get_predictions(genes): """Get sift predictions from genes.""" data = { 'sift_predictions': [], 'polyphen_predictions': [], 'region_annotations': [], 'functional_annotations': [] } for gene_obj in genes: for pred_key in data: gene_key = pred_key[:-...
Pre - process case for the variant view.
def variant_case(store, case_obj, variant_obj): """Pre-process case for the variant view. Adds information about files from case obj to variant Args: store(scout.adapter.MongoAdapter) case_obj(scout.models.Case) variant_obj(scout.models.Variant) """ case_obj['bam_files'] = ...
Find out BAI file by extension given the BAM file.
def find_bai_file(bam_file): """Find out BAI file by extension given the BAM file.""" bai_file = bam_file.replace('.bam', '.bai') if not os.path.exists(bai_file): # try the other convention bai_file = "{}.bai".format(bam_file) return bai_file
Pre - process a single variant for the detailed variant view.
def variant(store, institute_obj, case_obj, variant_id=None, variant_obj=None, add_case=True, add_other=True, get_overlapping=True): """Pre-process a single variant for the detailed variant view. Adds information from case and institute that is not present on the variant object Args: ...
Query observations for a variant.
def observations(store, loqusdb, case_obj, variant_obj): """Query observations for a variant.""" composite_id = ("{this[chromosome]}_{this[position]}_{this[reference]}_" "{this[alternative]}".format(this=variant_obj)) obs_data = loqusdb.get_variant({'_id': composite_id}) or {} obs_da...
Parse variant genes.
def parse_gene(gene_obj, build=None): """Parse variant genes.""" build = build or 37 if gene_obj.get('common'): add_gene_links(gene_obj, build) refseq_transcripts = [] for tx_obj in gene_obj['transcripts']: parse_transcript(gene_obj, tx_obj, build) # select ...
Parse variant gene transcript ( VEP ).
def parse_transcript(gene_obj, tx_obj, build=None): """Parse variant gene transcript (VEP).""" build = build or 37 add_tx_links(tx_obj, build) if tx_obj.get('refseq_id'): gene_name = (gene_obj['common']['hgnc_symbol'] if gene_obj['common'] else gene_obj['hgnc_id']) ...
Generate amino acid change as a string.
def transcript_str(transcript_obj, gene_name=None): """Generate amino acid change as a string.""" if transcript_obj.get('exon'): gene_part, part_count_raw = 'exon', transcript_obj['exon'] elif transcript_obj.get('intron'): gene_part, part_count_raw = 'intron', transcript_obj['intron'] el...
Calculate end position for a variant.
def end_position(variant_obj): """Calculate end position for a variant.""" alt_bases = len(variant_obj['alternative']) num_bases = max(len(variant_obj['reference']), alt_bases) return variant_obj['position'] + (num_bases - 1)
Returns a judgement on the overall frequency of the variant.
def frequency(variant_obj): """Returns a judgement on the overall frequency of the variant. Combines multiple metrics into a single call. """ most_common_frequency = max(variant_obj.get('thousand_genomes_frequency') or 0, variant_obj.get('exac_frequency') or 0) if mo...
Convert to human readable version of CLINSIG evaluation.
def clinsig_human(variant_obj): """Convert to human readable version of CLINSIG evaluation.""" for clinsig_obj in variant_obj['clnsig']: # The clinsig objects allways have a accession if isinstance(clinsig_obj['accession'], int): # New version link = "https://www.ncbi.nlm...
Compose link to 1000G page for detailed information.
def thousandg_link(variant_obj, build=None): """Compose link to 1000G page for detailed information.""" dbsnp_id = variant_obj.get('dbsnp_id') build = build or 37 if not dbsnp_id: return None if build == 37: url_template = ("http://grch37.ensembl.org/Homo_sapiens/Variation/Explore"...
Compose link to COSMIC Database.
def cosmic_link(variant_obj): """Compose link to COSMIC Database. Args: variant_obj(scout.models.Variant) Returns: url_template(str): Link to COSMIIC database if cosmic id is present """ cosmic_ids = variant_obj.get('cosmic_ids') if not cosmic_ids: return None els...
Compose link to Beacon Network.
def beacon_link(variant_obj, build=None): """Compose link to Beacon Network.""" build = build or 37 url_template = ("https://beacon-network.org/#/search?pos={this[position]}&" "chrom={this[chromosome]}&allele={this[alternative]}&" "ref={this[reference]}&rs=GRCh37") ...
Compose link to UCSC.
def ucsc_link(variant_obj, build=None): """Compose link to UCSC.""" build = build or 37 url_template = ("http://genome.ucsc.edu/cgi-bin/hgTracks?db=hg19&" "position=chr{this[chromosome]}:{this[position]}" "-{this[position]}&dgv=pack&knownGene=pack&omimGene=pac...
Translate SPIDEX annotation to human readable string.
def spidex_human(variant_obj): """Translate SPIDEX annotation to human readable string.""" if variant_obj.get('spidex') is None: return 'not_reported' elif abs(variant_obj['spidex']) < SPIDEX_HUMAN['low']['pos'][1]: return 'low' elif abs(variant_obj['spidex']) < SPIDEX_HUMAN['medium']['p...
Gather information from common gene information.
def expected_inheritance(variant_obj): """Gather information from common gene information.""" manual_models = set() for gene in variant_obj.get('genes', []): manual_models.update(gene.get('manual_inheritance', [])) return list(manual_models)
Return info about callers.
def callers(variant_obj, category='snv'): """Return info about callers.""" calls = set() for caller in CALLERS[category]: if variant_obj.get(caller['id']): calls.add((caller['name'], variant_obj[caller['id']])) return list(calls)
Sand a verification email and register the verification in the database
def variant_verification(store, mail, institute_obj, case_obj, user_obj, variant_obj, sender, variant_url, order, comment, url_builder=url_for): """Sand a verification email and register the verification in the database Args: store(scout.adapter.MongoAdapter) mail(scout.server.exten...
Builds the html code for the variant verification emails ( order verification and cancel verification )
def verification_email_body(case_name, url, display_name, category, subcategory, breakpoint_1, breakpoint_2, hgnc_symbol, panels, gtcalls, tx_changes, name, comment): """ Builds the html code for the variant verification emails (order verification and cancel verification) Args: case_nam...
Fetch data related to cancer variants for a case.
def cancer_variants(store, request_args, institute_id, case_name): """Fetch data related to cancer variants for a case.""" institute_obj, case_obj = institute_and_case(store, institute_id, case_name) form = CancerFiltersForm(request_args) variants_query = store.variants(case_obj['_id'], category='cancer...
Gather the required data for creating the clinvar submission form
def clinvar_export(store, institute_id, case_name, variant_id): """Gather the required data for creating the clinvar submission form Args: store(scout.adapter.MongoAdapter) institute_id(str): Institute ID case_name(str): case ID variant_id(str): variant._id ...
Collects all variants from the clinvar submission collection with a specific submission_id
def get_clinvar_submission(store, institute_id, case_name, variant_id, submission_id): """Collects all variants from the clinvar submission collection with a specific submission_id Args: store(scout.adapter.MongoAdapter) institute_id(str): Institute ID case_name(str): ca...
Collect data relevant for rendering ACMG classification form.
def variant_acmg(store, institute_id, case_name, variant_id): """Collect data relevant for rendering ACMG classification form.""" institute_obj, case_obj = institute_and_case(store, institute_id, case_name) variant_obj = store.variant(variant_id) return dict(institute=institute_obj, case=case_obj, varia...
Calculate an ACMG classification based on a list of criteria.
def variant_acmg_post(store, institute_id, case_name, variant_id, user_email, criteria): """Calculate an ACMG classification based on a list of criteria.""" institute_obj, case_obj = institute_and_case(store, institute_id, case_name) variant_obj = store.variant(variant_id) user_obj = store.user(user_ema...
Fetch and fill - in evaluation object.
def evaluation(store, evaluation_obj): """Fetch and fill-in evaluation object.""" evaluation_obj['institute'] = store.institute(evaluation_obj['institute_id']) evaluation_obj['case'] = store.case(evaluation_obj['case_id']) evaluation_obj['variant'] = store.variant(evaluation_obj['variant_specific']) ...
Parse out HGNC symbols from a stream.
def upload_panel(store, institute_id, case_name, stream): """Parse out HGNC symbols from a stream.""" institute_obj, case_obj = institute_and_case(store, institute_id, case_name) raw_symbols = [line.strip().split('\t')[0] for line in stream if line and not line.startswith('#')] # chec...
Collect all verified variants in a list on institutes and save them to file
def verified_excel_file(store, institute_list, temp_excel_dir): """Collect all verified variants in a list on institutes and save them to file Args: store(adapter.MongoAdapter) institute_list(list): a list of institute ids temp_excel_dir(os.Path): folder where the temp excel files are w...
Build a hpo_term object Check that the information is correct and add the correct hgnc ids to the array of genes. Args: hpo_info ( dict ) Returns: hpo_obj ( scout. models. HpoTerm ): A dictionary with hpo information
def build_hpo_term(hpo_info): """Build a hpo_term object Check that the information is correct and add the correct hgnc ids to the array of genes. Args: hpo_info(dict) Returns: hpo_obj(scout.models.HpoTerm): A dictionary with hpo information ...
Export all genes from the database
def export_genes(adapter, build='37'): """Export all genes from the database""" LOG.info("Exporting all genes to .bed format") for gene_obj in adapter.all_genes(build=build): yield gene_obj
Get the clnsig information
def parse_clnsig(acc, sig, revstat, transcripts): """Get the clnsig information Args: acc(str): The clnsig accession number, raw from vcf sig(str): The clnsig significance score, raw from vcf revstat(str): The clnsig revstat, raw from vcf transcripts(iterable(dict)) Returns...