def load_omim_panel(self, api_key, institute=None): """Create and load the OMIM-AUTO panel""" existing_panel = self.gene_panel(panel_id='OMIM-AUTO') if not existing_panel: LOG.warning("OMIM-AUTO does not exists in database") LOG.info('Creating a first version') version = 1.0 if existing_panel: version = float(math.floor(existing_panel['version']) + 1) LOG.info("Setting version to %s", version) try: mim_files = fetch_mim_files(api_key=api_key, genemap2=True, mim2genes=True) except Exception as err: raise err date_string = None # Get the correct date when omim files where released for line in mim_files['genemap2']: if 'Generated' in line: date_string = line.split(':')[-1].lstrip().rstrip() date_obj = get_date(date_string) if existing_panel: if existing_panel['date'] == date_obj: LOG.warning("There is no new version of OMIM") return panel_data = {} panel_data['path'] = None panel_data['type'] = 'clinical' panel_data['date'] = date_obj panel_data['panel_id'] = 'OMIM-AUTO' panel_data['institute'] = institute or 'cust002' panel_data['version'] = version panel_data['display_name'] = 'OMIM-AUTO' panel_data['genes'] = [] alias_genes = self.genes_by_alias() genes = get_omim_panel_genes( genemap2_lines = mim_files['genemap2'], mim2gene_lines = mim_files['mim2genes'], alias_genes = alias_genes, ) for gene in genes: panel_data['genes'].append(gene) panel_obj = build_panel(panel_data, self) if existing_panel: new_genes = self.compare_mim_panels(existing_panel, panel_obj) if new_genes: self.update_mim_version(new_genes, panel_obj, old_version=existing_panel['version']) else: LOG.info("The new version of omim does not differ from the old one") LOG.info("No update is added") return self.add_gene_panel(panel_obj)
def load_omim_panel(self, genemap2_lines, mim2gene_lines, institute=None): """Create and load the OMIM-AUTO panel If the panel already exists, update with new information and increase version Args: genemap_lines(iterable(str)): The genemap2 file information mim2gene_lines(iterable(str)): The mim2genes file information institute(str): What institute that is responsible. Default: 'cust002' """ institute = institute or "cust002" existing_panel = self.gene_panel(panel_id="OMIM-AUTO") if not existing_panel: LOG.warning("OMIM-AUTO does not exists in database") LOG.info("Creating a first version") version = 1.0 if existing_panel: version = float(math.floor(existing_panel["version"]) + 1) LOG.info("Setting version to %s", version) date_string = None # Get the correct date when omim files where released for line in genemap2_lines: if "Generated" in line: date_string = line.split(":")[-1].strip() break date_obj = get_date(date_string) if existing_panel: if existing_panel["date"] == date_obj: LOG.warning("There is no new version of OMIM") return panel_data = { "path": None, "type": "clinical", "date": date_obj, "panel_id": "OMIM-AUTO", "institute": institute, "version": version, "display_name": "OMIM-AUTO", "genes": [], } alias_genes = self.genes_by_alias() genes = get_omim_panel_genes( genemap2_lines=genemap2_lines, mim2gene_lines=mim2gene_lines, alias_genes=alias_genes, ) for gene in genes: panel_data["genes"].append(gene) panel_obj = build_panel(panel_data, self) if existing_panel: new_genes = self.compare_mim_panels(existing_panel, panel_obj) if not new_genes: LOG.info("The new version of omim does not differ from the old one") LOG.info("No update is added") return self.update_mim_version( new_genes, panel_obj, old_version=existing_panel["version"] ) self.add_gene_panel(panel_obj)
def load_omim_panel(self, api_key, institute=None): """Create and load the OMIM-AUTO panel""" existing_panel = self.gene_panel(panel_id='OMIM-AUTO') if not existing_panel: LOG.warning("OMIM-AUTO does not exists in database") LOG.info('Creating a first version') version = 1.0 if existing_panel: version = float(math.floor(existing_panel['version']) + 1) LOG.info("Setting version to %s", version) try: mim_files = fetch_mim_files(api_key=api_key, genemap2=True, mim2genes=True) except Exception as err: raise err date_string = None # Get the correct date when omim files where released for line in mim_files['genemap2']: if 'Generated' in line: date_string = line.split(':')[-1].lstrip().rstrip() date_obj = get_date(date_string) if existing_panel: if existing_panel['date'] == date_obj: LOG.warning("There is no new version of OMIM") return panel_data = {} panel_data['path'] = None panel_data['type'] = 'clinical' panel_data['date'] = date_obj panel_data['panel_id'] = 'OMIM-AUTO' panel_data['institute'] = institute or 'cust002' panel_data['version'] = version panel_data['display_name'] = 'OMIM-AUTO' panel_data['genes'] = [] alias_genes = self.genes_by_alias() genes = get_omim_panel_genes( genemap2_lines = mim_files['genemap2'], mim2gene_lines = mim_files['mim2genes'], alias_genes = alias_genes, ) for gene in genes: panel_data['genes'].append(gene) panel_obj = build_panel(panel_data, self) if existing_panel: new_genes = self.compare_mim_panels(existing_panel, panel_obj) if new_genes: self.update_mim_version(new_genes, panel_obj, old_version=existing_panel['version']) else: LOG.info("The new version of omim does not differ from the old one") LOG.info("No update is added") return self.add_gene_panel(panel_obj)