Search is not available for this dataset
text
stringlengths
75
104k
def parse_individuals(samples): """Parse the individual information Reformat sample information to proper individuals Args: samples(list(dict)) Returns: individuals(list(dict)) """ individuals = [] if len(samples) == 0: raise PedigreeError("No s...
def parse_case(config): """Parse case information from config or PED files. Args: config (dict): case config with detailed information Returns: dict: parsed case data """ if 'owner' not in config: raise ConfigError("A case has to have a owner") if 'family' not in confi...
def parse_ped(ped_stream, family_type='ped'): """Parse out minimal family information from a PED file. Args: ped_stream(iterable(str)) family_type(str): Format of the pedigree information Returns: family_id(str), samples(list[dict]) """ pedigree = FamilyParser(ped_stream, f...
def build_evaluation(variant_specific, variant_id, user_id, user_name, institute_id, case_id, classification, criteria): """Build a evaluation object ready to be inserted to database Args: variant_specific(str): md5 string for the specific variant variant_id(str): md5 strin...
def mt_report(context, case_id, test, outpath=None): """Export all mitochondrial variants for each sample of a case and write them to an excel file Args: adapter(MongoAdapter) case_id(str) test(bool): True if the function is called for testing purposes ...
def build_genotype(gt_call): """Build a genotype call Args: gt_call(dict) Returns: gt_obj(dict) gt_call = dict( sample_id = str, display_name = str, genotype_call = str, allele_depths = list, # int read_depth = int, genotype_...
def is_pathogenic(pvs, ps_terms, pm_terms, pp_terms): """Check if the criterias for Pathogenic is fullfilled The following are descriptions of Pathogenic clasification from ACMG paper: Pathogenic (i) 1 Very strong (PVS1) AND (a) ≥1 Strong (PS1–PS4) OR (b) ≥2 Moderate (PM1–PM6) OR ...
def is_likely_pathogenic(pvs, ps_terms, pm_terms, pp_terms): """Check if the criterias for Likely Pathogenic is fullfilled The following are descriptions of Likely Pathogenic clasification from ACMG paper: Likely pathogenic (i) 1 Very strong (PVS1) AND 1 moderate (PM1– PM6) OR (ii) 1 Strong (P...
def is_likely_benign(bs_terms, bp_terms): """Check if criterias for Likely Benign are fullfilled The following are descriptions of Likely Benign clasification from ACMG paper: Likely Benign (i) 1 Strong (BS1–BS4) and 1 supporting (BP1– BP7) OR (ii) ≥2 Supporting (BP1–BP7) Args: bs...
def get_acmg(acmg_terms): """Use the algorithm described in ACMG paper to get a ACMG calssification Args: acmg_terms(set(str)): A collection of prediction terms Returns: prediction(int): 0 - Uncertain Significanse 1 - Benign 2 - Likely Benign...
def add_gene_info(self, variant_obj, gene_panels=None): """Add extra information about genes from gene panels Args: variant_obj(dict): A variant from the database gene_panels(list(dict)): List of panels from database """ gene_panels = gene_panels or [] #...
def variants(self, case_id, query=None, variant_ids=None, category='snv', nr_of_variants=10, skip=0, sort_key='variant_rank'): """Returns variants specified in question for a specific case. If skip not equal to 0 skip the first n variants. Arguments: case_id(str): ...
def sanger_variants(self, institute_id=None, case_id=None): """Return all variants with sanger information Args: institute_id(str) case_id(str) Returns: res(pymongo.Cursor): A Cursor with all variants with sanger activity """ query = {'valida...
def variant(self, document_id, gene_panels=None, case_id=None): """Returns the specified variant. Arguments: document_id : A md5 key that represents the variant or "variant_id" gene_panels(List[GenePanel]) case_id (str): case id (will search with "variant...
def gene_variants(self, query=None, category='snv', variant_type=['clinical'], nr_of_variants=50, skip=0): """Return all variants seen in a given gene. If skip not equal to 0 skip the first n variants. Arguments: query(dict): A dictionary with ...
def verified(self, institute_id): """Return all verified variants for a given institute Args: institute_id(str): institute id Returns: res(list): a list with validated variants """ query = { 'verb' : 'validate', 'institute' : inst...
def get_causatives(self, institute_id, case_id=None): """Return all causative variants for an institute Args: institute_id(str) case_id(str) Yields: str: variant document id """ causatives = [] if case_id: ...
def check_causatives(self, case_obj=None, institute_obj=None): """Check if there are any variants that are previously marked causative Loop through all variants that are marked 'causative' for an institute and check if any of the variants are present in the current case. ...
def other_causatives(self, case_obj, variant_obj): """Find the same variant in other cases marked causative. Args: case_obj(dict) variant_obj(dict) Yields: other_variant(dict) """ # variant id without "*_[variant_type]" variant_id = v...
def delete_variants(self, case_id, variant_type, category=None): """Delete variants of one type for a case This is used when a case is reanalyzed Args: case_id(str): The case id variant_type(str): 'research' or 'clinical' category(str): '...
def overlapping(self, variant_obj): """Return overlapping variants. Look at the genes that a variant overlaps to. Then return all variants that overlap these genes. If variant_obj is sv it will return the overlapping snvs and oposite There is a problem when SVs are huge since t...
def evaluated_variants(self, case_id): """Returns variants that has been evaluated Return all variants, snvs/indels and svs from case case_id which have a entry for 'acmg_classification', 'manual_rank', 'dismiss_variant' or if they are commented. Args: case_id(str) ...
def get_region_vcf(self, case_obj, chrom=None, start=None, end=None, gene_obj=None, variant_type='clinical', category='snv', rank_threshold=None): """Produce a reduced vcf with variants from the specified coordinates This is used for the alignment viewer....
def sample_variants(self, variants, sample_name, category = 'snv'): """Given a list of variants get variant objects found in a specific patient Args: variants(list): a list of variant ids sample_name(str): a sample display name category(str): 'snv', 'sv' .. ...
def get_connection(host='localhost', port=27017, username=None, password=None, uri=None, mongodb=None, authdb=None, timeout=20, *args, **kwargs): """Get a client to the mongo database host(str): Host of database port(int): Port of database username(str) password(s...
def set_submission_objects(form_fields): """Creates a list of submission objects (variant and case-data) from the clinvar submission form in blueprints/variants/clinvar.html. Args: form_fields(dict): it's the submission form dictionary. Keys have the same names as CLINVAR_HEADER and CASEDATA_H...
def get_objects_from_form(variant_ids, form_fields, object_type): """Extract the objects to be saved in the clinvar database collection. object_type param specifies if these objects are variant or casedata objects Args: variant_ids(list): list of database variant ids form_fields(dict)...
def get_submission_variants(form_fields): """Extracts a list of variant ids from the clinvar submission form in blueprints/variants/clinvar.html (creation of a new clinvar submission). Args: form_fields(dict): it's the submission form dictionary. Keys have the same names as CLINVAR_HEADER and ...
def clinvar_submission_header(submission_objs, csv_type): """Determine which fields to include in csv header by checking a list of submission objects Args: submission_objs(list): a list of objects (variants or casedata) to include in a csv file csv_type(str) : 'variant_data' or 'cas...
def clinvar_submission_lines(submission_objs, submission_header): """Create the lines to include in a Clinvar submission csv file from a list of submission objects and a custom document header Args: submission_objs(list): a list of objects (variants or casedata) to include in a csv file ...
def load_transcripts(adapter, transcripts_lines=None, build='37', ensembl_genes=None): """Load all the transcripts Transcript information is from ensembl. Args: adapter(MongoAdapter) transcripts_lines(iterable): iterable with ensembl transcript lines build(str) ensembl_gene...
def panel(context, path, date, display_name, version, panel_type, panel_id, institute, omim, api_key, panel_app): """Add a gene panel to the database.""" adapter = context.obj['adapter'] institute = institute or 'cust000' if omim: api_key = api_key or context.obj.get('omim_api_key') if...
def build_exon(exon_info, build='37'): """Build a Exon object object Args: exon_info(dict): Exon information Returns: exon_obj(Exon) "exon_id": str, # str(chrom-start-end) "chrom": str, "start": int, "end": int, "trans...
def panel(context, panel_id, version): """Delete a version of a gene panel or all versions of a gene panel""" LOG.info("Running scout delete panel") adapter = context.obj['adapter'] panel_objs = adapter.gene_panels(panel_id=panel_id, version=version) if panel_objs.count() == 0: LOG.info("No...
def index(context): """Delete all indexes in the database""" LOG.info("Running scout delete index") adapter = context.obj['adapter'] for collection in adapter.db.collection_names(): adapter.db[collection].drop_indexes() LOG.info("All indexes deleted")
def user(context, mail): """Delete a user from the database""" LOG.info("Running scout delete user") adapter = context.obj['adapter'] user_obj = adapter.user(mail) if not user_obj: LOG.warning("User {0} could not be found in database".format(mail)) else: adapter.delete_user(mail)
def genes(context, build): """Delete all genes in the database""" LOG.info("Running scout delete genes") adapter = context.obj['adapter'] if build: LOG.info("Dropping genes collection for build: %s", build) else: LOG.info("Dropping genes collection") adapter.drop_genes()
def exons(context, build): """Delete all exons in the database""" LOG.info("Running scout delete exons") adapter = context.obj['adapter'] adapter.drop_exons(build)
def case(context, institute, case_id, display_name): """Delete a case and it's variants from the database""" adapter = context.obj['adapter'] if not (case_id or display_name): click.echo("Please specify what case to delete") context.abort() if display_name: if not institute: ...
def individuals(context, institute, causatives, case_id): """Show all individuals from all cases in the database""" LOG.info("Running scout view individuals") adapter = context.obj['adapter'] individuals = [] if case_id: case = adapter.case(case_id=case_id) if case: case...
def hpo_terms(case_obj): """Extract all phenotype-associated terms for a case. Drawback of this method is that it returns the same phenotype terms for each affected individual of the case. Args: case_obj(dict): a scout case object Returns: features(list): a li...
def omim_terms(case_obj): """Extract all OMIM phenotypes available for the case Args: case_obj(dict): a scout case object Returns: disorders(list): a list of OMIM disorder objects """ LOG.info("Collecting OMIM disorders for case {}".format(case_obj.get('display_name'))) disorders...
def genomic_features(store, case_obj, sample_name, genes_only): """Extract and parse matchmaker-like genomic features from pinned variants of a patient Args: store(MongoAdapter) : connection to the database case_obj(dict): a scout case object sample_name(str): sample display name...
def parse_matches(patient_id, match_objs): """Parse a list of matchmaker matches objects and returns a readable list of matches to display in matchmaker matches view. Args: patient_id(str): id of a mme patient match_objs(list): list of match objs returned by MME server for the patient ...
def cases(context, institute, display_name, case_id, nr_variants, variants_treshold): """Display cases from the database""" LOG.info("Running scout view institutes") adapter = context.obj['adapter'] models = [] if case_id: case_obj = adapter.case(case_id=case_id) if case_obj: ...
def load_user(user_email): """Returns the currently active user as an object.""" user_obj = store.user(user_email) user_inst = LoginUser(user_obj) if user_obj else None return user_inst
def login(): """Login a user if they have access.""" # store potential next param URL in the session if 'next' in request.args: session['next_url'] = request.args['next'] if current_app.config.get('GOOGLE'): callback_url = url_for('.authorized', _external=True) return google.aut...
def case_mme_update(self, case_obj, user_obj, mme_subm_obj): """Updates a case after a submission to MatchMaker Exchange Args: case_obj(dict): a scout case object user_obj(dict): a scout user object mme_subm_obj(dict): contains MME submission params an...
def case_mme_delete(self, case_obj, user_obj): """Delete a MatchMaker submission from a case record and creates the related event. Args: case_obj(dict): a scout case object user_obj(dict): a scout user object Returns: updated_case(dict): the updated...
def build_institute(internal_id, display_name, sanger_recipients=None, coverage_cutoff=None, frequency_cutoff=None): """Build a institute object Args: internal_id(str) display_name(str) sanger_recipients(list(str)): List with email addresses Returns: ins...
def delete_event(self, event_id): """Delete a event Arguments: event_id (str): The database key for the event """ LOG.info("Deleting event{0}".format(event_id)) if not isinstance(event_id, ObjectId): event_id = ObjectId(event_id) self.even...
def create_event(self, institute, case, user, link, category, verb, subject, level='specific', variant=None, content=None, panel=None): """Create a Event with the parameters given. Arguments: institute (dict): A institute case (dict): A ...
def events(self, institute, case=None, variant_id=None, level=None, comments=False, panel=None): """Fetch events from the database. Args: institute (dict): A institute case (dict): A case variant_id (str, optional): global variant id leve...
def user_events(self, user_obj=None): """Fetch all events by a specific user.""" query = dict(user_id=user_obj['_id']) if user_obj else dict() return self.event_collection.find(query)
def add_phenotype(self, institute, case, user, link, hpo_term=None, omim_term=None, is_group=False): """Add a new phenotype term to a case Create a phenotype term and event with the given information Args: institute (Institute): A Institute object ...
def remove_phenotype(self, institute, case, user, link, phenotype_id, is_group=False): """Remove an existing phenotype from a case Args: institute (dict): A Institute object case (dict): Case object user (dict): A User object link...
def comment(self, institute, case, user, link, variant=None, content="", comment_level="specific"): """Add a comment to a variant or a case. This function will create an Event to log that a user have commented on a variant. If a variant id is given it will be a variant comment. ...
def parse_genotypes(variant, individuals, individual_positions): """Parse the genotype calls for a variant Args: variant(cyvcf2.Variant) individuals: List[dict] individual_positions(dict) Returns: genotypes(list(dict)): A list of genotypes """ ...
def parse_genotype(variant, ind, pos): """Get the genotype information in the proper format Sv specific format fields: ##FORMAT=<ID=DV,Number=1,Type=Integer, Description="Number of paired-ends that support the event"> ##FORMAT=<ID=PE,Number=1,Type=Integer, Description="Number of paired-ends t...
def is_par(chromosome, position, build='37'): """Check if a variant is in the Pseudo Autosomal Region or not Args: chromosome(str) position(int) build(str): The genome build Returns: bool """ chrom_match = CHR_PATTERN.match(chromosome) chrom = chrom_matc...
def check_coordinates(chromosome, pos, coordinates): """Check if the variant is in the interval given by the coordinates Args: chromosome(str): Variant chromosome pos(int): Variant position coordinates(dict): Dictionary with the region of interest """ chrom_match...
def export_panels(adapter, panels, versions=None, build='37'): """Export all genes in gene panels Exports the union of genes in one or several gene panels to a bed like format with coordinates. Args: adapter(scout.adapter.MongoAdapter) panels(iterable(str)): Iterable with panel ids...
def export_gene_panels(adapter, panels, version=None): """Export the genes of a gene panel Takes a list of gene panel names and return the lines of the gene panels. Unlike export_panels this function only export the genes and extra information, not the coordinates. Args: adapter(M...
def hpo_terms(): """Render search box and view for HPO phenotype terms""" if request.method == 'GET': data = controllers.hpo_terms(store= store, limit=100) return data else: # POST. user is searching for a specific term or phenotype search_term = request.form.get('hpo_term') ...
def transcripts(context, build): """Export all transcripts to .bed like format""" LOG.info("Running scout export transcripts") adapter = context.obj['adapter'] header = ["#Chrom\tStart\tEnd\tTranscript\tRefSeq\tHgncID"] for line in header: click.echo(line) transcript_string = ("{0...
def exons(context, build): """Load exons into the scout database""" adapter = context.obj['adapter'] start = datetime.now() # Test if there are any exons loaded nr_exons = adapter.exons(build=build).count() if nr_exons: LOG.warning("Dropping all exons ") adapter.dr...
def intervals(context, build): """Show all indexes in the database""" LOG.info("Running scout view index") adapter = context.obj['adapter'] intervals = adapter.get_coding_intervals(build) nr_intervals = 0 longest = 0 for chrom in CHROMOSOMES: for iv in intervals[chrom]: ...
def region(context, hgnc_id, case_id, chromosome, start, end): """Load all variants in a region to a existing case""" adapter = context.obj['adapter'] load_region( adapter=adapter, case_id=case_id, hgnc_id=hgnc_id, chrom=chromosome, start=start, end=end )
def _get_kwargs(self, category, tag): """Helper function for getting category/tag kwargs.""" vals = { 'categories__title__iexact': category, 'tags__name__iexact': tag } kwargs = {} for k, v in vals.items(): if v: kwargs[k] = v ...
def get_first_and_last(year, month): """Returns two datetimes: first day and last day of given year&month""" ym_first = make_aware( datetime.datetime(year, month, 1), get_default_timezone() ) ym_last = make_aware( datetime.datetime(year, month, monthra...
def all_month_events(self, year, month, category=None, tag=None, loc=False, cncl=False): """ Returns all events that have an occurrence within the given month & year. """ kwargs = self._get_kwargs(category, tag) ym_first, ym_last = self.get_first_...
def live(self, now): """ Returns a queryset of events that will occur again after 'now'. Used to help generate a list of upcoming events. """ return self.model.objects.filter( Q(end_repeat=None) | Q(end_repeat__gte=now) | Q(start_date__gte=now) | Q(end_dat...
def build_user(user_info): """Build a user object Args: user_info(dict): A dictionary with user information Returns: user_obj(scout.models.User) """ try: email = user_info['email'] except KeyError as err: raise KeyError("A user has to have a email") ...
def parse_reqs(req_path='./requirements.txt'): """Recursively parse requirements from nested pip files.""" install_requires = [] with io.open(os.path.join(here, 'requirements.txt'), encoding='utf-8') as handle: # remove comments and empty lines lines = (line.strip() for line in handle ...
def existing_gene(store, panel_obj, hgnc_id): """Check if gene is already added to a panel.""" existing_genes = {gene['hgnc_id']: gene for gene in panel_obj['genes']} return existing_genes.get(hgnc_id)
def update_panel(store, panel_name, csv_lines, option): """Update an existing gene panel with genes. Args: store(scout.adapter.MongoAdapter) panel_name(str) csv_lines(iterable(str)): Stream with genes option(str): 'add' or 'replace' Returns: panel_obj(dict) """ ...
def new_panel(store, institute_id, panel_name, display_name, csv_lines): """Create a new gene panel. Args: store(scout.adapter.MongoAdapter) institute_id(str) panel_name(str) display_name(str) csv_lines(iterable(str)): Stream with genes Returns: panel_id: th...
def panel_export(store, panel_obj): """Preprocess a panel of genes.""" panel_obj['institute'] = store.institute(panel_obj['institute']) full_name = "{}({})".format(panel_obj['display_name'], panel_obj['version']) panel_obj['name_and_version'] = full_name return dict(panel=panel_obj)
def archive_info(database: Database, archive_case: dict) -> dict: """Get information about a case from archive.""" data = { 'collaborators': archive_case['collaborators'], 'synopsis': archive_case.get('synopsis'), 'assignees': [], 'suspects': [], 'causatives': [], ...
def migrate_case(adapter: MongoAdapter, scout_case: dict, archive_data: dict): """Migrate case information from archive.""" # update collaborators collaborators = list(set(scout_case['collaborators'] + archive_data['collaborators'])) if collaborators != scout_case['collaborators']: LOG.info(f"se...
def migrate(uri: str, archive_uri: str, case_id: str, dry: bool, force: bool): """Update all information that was manually annotated from a old instance.""" scout_client = MongoClient(uri) scout_database = scout_client[uri.rsplit('/', 1)[-1]] scout_adapter = MongoAdapter(database=scout_database) sco...
def research(context, case_id, institute, force): """Upload research variants to cases If a case is specified, all variants found for that case will be uploaded. If no cases are specified then all cases that have 'research_requested' will have there research variants uploaded "...
def load_hgnc(adapter, genes=None, ensembl_lines=None, hgnc_lines=None, exac_lines=None, mim2gene_lines=None, genemap_lines=None, hpo_lines=None, transcripts_lines=None, build='37', omim_api_key=''): """Load Genes and transcripts into the database If no resources are provided the co...
def load_hgnc_genes(adapter, genes = None, ensembl_lines=None, hgnc_lines=None, exac_lines=None, mim2gene_lines=None, genemap_lines=None, hpo_lines=None, build='37', omim_api_key=''): """Load genes into the database link_genes will collect information from all the different sources ...
def hpo(context, term, description): """Show all hpo terms in the database""" LOG.info("Running scout view hpo") adapter = context.obj['adapter'] if term: term = term.upper() if not term.startswith('HP:'): while len(term) < 7: term = '0' + term ter...
def build_gene(gene, hgncid_to_gene=None): """Build a gene object Has to build the transcripts for the genes to Args: gene(dict): Parsed information from the VCF hgncid_to_gene(dict): A map from hgnc_id -> hgnc_gene objects Returns: gene_obj(dict) ge...
def create_app(config_file=None, config=None): """Flask app factory function.""" app = Flask(__name__) app.config.from_pyfile('config.py') app.jinja_env.add_extension('jinja2.ext.do') if config: app.config.update(config) if config_file: app.config.from_pyfile(config_file) # ...
def configure_extensions(app): """Configure Flask extensions.""" extensions.toolbar.init_app(app) extensions.bootstrap.init_app(app) extensions.mongo.init_app(app) extensions.store.init_app(app) extensions.login_manager.init_app(app) extensions.oauth.init_app(app) extensions.mail.init_ap...
def register_blueprints(app): """Register Flask blueprints.""" app.register_blueprint(public.public_bp) app.register_blueprint(genes.genes_bp) app.register_blueprint(cases.cases_bp) app.register_blueprint(login.login_bp) app.register_blueprint(variants.variants_bp) app.register_blueprint(pan...
def configure_email_logging(app): """Setup logging of error/exceptions to email.""" import logging from scout.log import TlsSMTPHandler mail_handler = TlsSMTPHandler( mailhost=app.config['MAIL_SERVER'], fromaddr=app.config['MAIL_USERNAME'], toaddrs=app.config['ADMINS'], ...
def configure_coverage(app): """Setup coverage related extensions.""" # setup chanjo report app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True if app.debug else False if chanjo_api: chanjo_api.init_app(app) configure_template_filters(app) # register chanjo report blueprint ...
def aliases(context, build, symbol): """Show all alias symbols and how they map to ids""" LOG.info("Running scout view aliases") adapter = context.obj['adapter'] if symbol: alias_genes = {} res = adapter.gene_by_alias(symbol, build=build) for gene_obj in res: hgn...
def build_gene(gene_info, adapter): """Build a panel_gene object Args: gene_info(dict) Returns: gene_obj(dict) panel_gene = dict( hgnc_id = int, # required symbol = str, disease_associated_transcripts = list, # list of strings that...
def build_panel(panel_info, adapter): """Build a gene_panel object Args: panel_info(dict): A dictionary with panel information adapter (scout.adapter.MongoAdapter) Returns: panel_obj(dict) gene_panel = dict( panel_id = str, # required instit...
def verified(context, collaborator, test, outpath=None): """Export variants which have been verified for an institute and write them to an excel file. Args: collaborator(str): institute id test(bool): True if the function is called for testing purposes outpath(str): path to outp...
def variants(context, collaborator, document_id, case_id, json): """Export causatives for a collaborator in .vcf format""" LOG.info("Running scout export variants") adapter = context.obj['adapter'] collaborator = collaborator or 'cust000' variants = export_variants( adapter, collabo...
def get_vcf_entry(variant_obj, case_id=None): """ Get vcf entry from variant object Args: variant_obj(dict) Returns: variant_string(str): string representing variant in vcf format """ if variant_obj['category'] == 'snv': var_type = 'TYPE' else: ...
def serve(context, config, host, port, debug, livereload): """Start the web server.""" pymongo_config = dict( MONGO_HOST=context.obj['host'], MONGO_PORT=context.obj['port'], MONGO_DBNAME=context.obj['mongodb'], MONGO_USERNAME=context.obj['username'], MONGO_PASSWORD=contex...
def generate_md5_key(list_of_arguments): """ Generate an md5-key from a list of arguments. Args: list_of_arguments: A list of strings Returns: A md5-key object generated from the list of strings. """ for arg in list_of_arguments: if not isinstance(arg, string_types): ...
def init_app(self, app): """Setup via Flask.""" host = app.config.get('MONGO_HOST', 'localhost') port = app.config.get('MONGO_PORT', 27017) dbname = app.config['MONGO_DBNAME'] log.info("connecting to database: %s:%s/%s", host, port, dbname) self.setup(app.config['MONGO_DA...