Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def get_remote_content_len(self, remote, headers=None): if headers is None: headers = self._get_default_request_headers() req = urllib.request.Request(remote, headers=headers) try: response = urllib.request.urlopen(...
[ "\n :param remote:\n :return: size of remote file\n " ]
Please provide a description of the function:def compare_local_remote_bytes(self, remotefile, localfile, remote_headers=None): is_equal = True remote_size = self.get_remote_content_len(remotefile, remote_headers) local_size = self.get_local_file_size(localfile) if remote_size is...
[ "\n test to see if fetched file is the same size as the remote file\n using information in the content-length field in the HTTP header\n :return: True or False\n " ]
Please provide a description of the function:def get_eco_map(url): # this would go in a translation table but it is generated dynamicly # maybe when we move to a make driven system eco_map = {} request = urllib.request.Request(url) response = urllib.request.urlopen(reque...
[ "\n To conver the three column file to\n a hashmap we join primary and secondary keys,\n for example\n IEA\tGO_REF:0000002\tECO:0000256\n IEA\tGO_REF:0000003\tECO:0000501\n IEA\tDefault\tECO:0000501\n\n becomes\n IEA-GO_REF:0000002: ECO:0000256\n IEA-GO...
Please provide a description of the function:def declareAsOntology(self, graph): # <http://data.monarchinitiative.org/ttl/biogrid.ttl> a owl:Ontology ; # owl:versionInfo # <https://archive.monarchinitiative.org/YYYYMM/ttl/biogrid.ttl> model = Model(graph) # is self.ou...
[ "\n The file we output needs to be declared as an ontology,\n including it's version information.\n\n TEC: I am not convinced dipper reformating external data as RDF triples\n makes an OWL ontology (nor that it should be considered a goal).\n\n Proper ontologies are built by ontol...
Please provide a description of the function:def remove_backslash_r(filename, encoding): with open(filename, 'r', encoding=encoding, newline=r'\n') as filereader: contents = filereader.read() contents = re.sub(r'\r', '', contents) with open(filename, "w") as filewriter: ...
[ "\n A helpful utility to remove Carriage Return from any file.\n This will read a file into memory,\n and overwrite the contents of the original file.\n\n TODO: This function may be a liability\n\n :param filename:\n\n :return:\n\n " ]
Please provide a description of the function:def open_and_parse_yaml(yamlfile): # ??? what if the yaml file does not contain a dict datastructure? mapping = dict() if os.path.exists(os.path.join(os.path.dirname(__file__), yamlfile)): map_file = open(os.path.join(os.path.dir...
[ "\n :param file: String, path to file containing label-id mappings in\n the first two columns of each row\n :return: dict where keys are labels and values are ids\n " ]
Please provide a description of the function:def parse_mapping_file(file): id_map = {} if os.path.exists(os.path.join(os.path.dirname(__file__), file)): with open(os.path.join(os.path.dirname(__file__), file)) as tsvfile: reader = csv.reader(tsvfile, delimiter="\t") ...
[ "\n :param file: String, path to file containing label-id mappings\n in the first two columns of each row\n :return: dict where keys are labels and values are ids\n " ]
Please provide a description of the function:def load_local_translationtable(self, name): ''' Load "ingest specific" translation from whatever they called something to the ontology label we need to map it to. To facilitate seeing more ontology lables in dipper ingests a reverse m...
[]
Please provide a description of the function:def resolve(self, word, mandatory=True): ''' composite mapping given f(x) and g(x) here: localtt & globaltt respectivly return g(f(x))|g(x)||f(x)|x in order of preference returns x on fall through if finding a mapping i...
[]
Please provide a description of the function:def addGenotype( self, genotype_id, genotype_label, genotype_type=None, genotype_description=None ): if genotype_type is None: genotype_type = self.globaltt['intrinsic_genotype'] self.model.addIndi...
[ "\n If a genotype_type is not supplied,\n we will default to 'intrinsic_genotype'\n :param genotype_id:\n :param genotype_label:\n :param genotype_type:\n :param genotype_description:\n :return:\n\n " ]
Please provide a description of the function:def addAllele( self, allele_id, allele_label, allele_type=None, allele_description=None): # TODO should we accept a list of allele types? if allele_type is None: allele_type = self.globaltt['allele'] # TODO is th...
[ "\n Make an allele object.\n If no allele_type is added, it will default to a geno:allele\n :param allele_id: curie for allele (required)\n :param allele_label: label for allele (required)\n :param allele_type: id for an allele type (optional,\n recommended SO or GENO class...
Please provide a description of the function:def addGene( self, gene_id, gene_label, gene_type=None, gene_description=None ): ''' genes are classes ''' if gene_type is None: gene_type = self.globaltt['gene'] self.model.addClassToGraph(gene_id, gene_label, gene_type, g...
[]
Please provide a description of the function:def addDerivesFrom(self, child_id, parent_id): self.graph.addTriple( child_id, self.globaltt['derives_from'], parent_id) return
[ "\n We add a derives_from relationship between the child and parent id.\n Examples of uses include between:\n an allele and a construct or strain here,\n a cell line and it's parent genotype. Adding the parent and child to\n the graph should happen outside of this function call t...
Please provide a description of the function:def addAlleleOfGene(self, allele_id, gene_id, rel_id=None): if rel_id is None: rel_id = self.globaltt["is_allele_of"] self.graph.addTriple(allele_id, rel_id, gene_id) return
[ "\n We make the assumption here that if the relationship is not provided,\n it is a\n GENO:is_allele_of.\n\n Here, the allele should be a variant_locus, not a sequence alteration.\n :param allele_id:\n :param gene_id:\n :param rel_id:\n :return:\n\n " ]
Please provide a description of the function:def addAffectedLocus( self, allele_id, gene_id, rel_id=None): if rel_id is None: rel_id = self.globaltt['has_affected_feature'] self.graph.addTriple(allele_id, rel_id, gene_id) return
[ "\n We make the assumption here that if the relationship is not provided,\n it is a\n GENO:is_allele_of.\n\n Here, the allele should be a variant_locus, not a sequence alteration.\n :param allele_id:\n :param gene_id:\n :param rel_id:\n :return:\n\n " ]
Please provide a description of the function:def addGeneProduct( self, sequence_id, product_id, product_label=None, product_type=None): if product_label is not None and product_type is not None: self.model.addIndividualToGraph( product_id, product_label, product_...
[ "\n Add gene/variant/allele has_gene_product relationship\n Can be used to either describe a gene to transcript relationship\n or gene to protein\n :param sequence_id:\n :param product_id:\n :param product_label:\n :param product_type:\n :return:\n\n " ...
Please provide a description of the function:def addPolypeptide( self, polypeptide_id, polypeptide_label=None, transcript_id=None, polypeptide_type=None): if polypeptide_type is None: polypeptide_type = self.globaltt['polypeptide'] self.model.addIndividualToG...
[ "\n :param polypeptide_id:\n :param polypeptide_label:\n :param polypeptide_type:\n :param transcript_id:\n :return:\n\n " ]
Please provide a description of the function:def addPartsToVSLC( self, vslc_id, allele1_id, allele2_id, zygosity_id=None, allele1_rel=None, allele2_rel=None): # vslc has parts allele1/allele2 if allele1_id is not None: self.addParts(allele1_id, vslc_id, all...
[ "\n Here we add the parts to the VSLC. While traditionally alleles\n (reference or variant loci) are traditionally added, you can add any\n node (such as sequence_alterations for unlocated variations) to a vslc\n if they are known to be paired. However, if a sequence_alteration's\n ...
Please provide a description of the function:def addVSLCtoParent(self, vslc_id, parent_id): self.addParts(vslc_id, parent_id, self.globaltt['has_variant_part']) return
[ "\n The VSLC can either be added to a genotype or to a GVC.\n The vslc is added as a part of the parent.\n :param vslc_id:\n :param parent_id:\n :return:\n " ]
Please provide a description of the function:def addParts(self, part_id, parent_id, part_relationship=None): if part_relationship is None: part_relationship = self.globaltt['has_part'] # Fail loudly if parent or child identifiers are None if parent_id is None: ra...
[ "\n This will add a has_part (or subproperty) relationship between\n a parent_id and the supplied part.\n By default the relationship will be BFO:has_part,\n but any relationship could be given here.\n :param part_id:\n :param parent_id:\n :param part_relationship:\n...
Please provide a description of the function:def addTaxon(self, taxon_id, genopart_id): self.graph.addTriple( genopart_id, self.globaltt['in taxon'], taxon_id) return
[ "\n The supplied geno part will have the specified taxon added with\n RO:in_taxon relation.\n Generally the taxon is associated with a genomic_background,\n but could be added to any genotype part (including a gene,\n regulatory element, or sequence alteration).\n :param ta...
Please provide a description of the function:def addGeneTargetingReagent( self, reagent_id, reagent_label, reagent_type, gene_id, description=None): # TODO add default type to reagent_type self.model.addIndividualToGraph( reagent_id, reagent_label, reagent_t...
[ "\n Here, a gene-targeting reagent is added.\n The actual targets of this reagent should be added separately.\n :param reagent_id:\n :param reagent_label:\n :param reagent_type:\n\n :return:\n\n " ]
Please provide a description of the function:def addReagentTargetedGene( self, reagent_id, gene_id, targeted_gene_id=None, targeted_gene_label=None, description=None): # akin to a variant locus if targeted_gene_id is None: targeted_gene_id = '_' + gene_id + ...
[ "\n This will create the instance of a gene that is targeted by a molecular\n reagent (such as a morpholino or rnai).\n If an instance id is not supplied,\n we will create it as an anonymous individual which is of the type\n GENO:reagent_targeted_gene.\n We will also add th...
Please provide a description of the function:def addChromosome( self, chrom, tax_id, tax_label=None, build_id=None, build_label=None): family = Family(self.graph) # first, make the chromosome class, at the taxon level chr_id = makeChromID(str(chrom), tax_id) if tax_l...
[ "\n if it's just the chromosome, add it as an instance of a SO:chromosome,\n and add it to the genome. If a build is included,\n punn the chromosome as a subclass of SO:chromsome, and make the\n build-specific chromosome an instance of the supplied chr.\n The chr then becomes part...
Please provide a description of the function:def addChromosomeInstance( self, chr_num, reference_id, reference_label, chr_type=None): family = Family(self.graph) chr_id = makeChromID(str(chr_num), reference_id, 'MONARCH') chr_label = makeChromLabel(str(chr_num), reference_la...
[ "\n Add the supplied chromosome as an instance within the given reference\n :param chr_num:\n :param reference_id: for example, a build id like UCSC:hg19\n :param reference_label:\n :param chr_type: this is the class that this is an instance of.\n typically a genome-specifi...
Please provide a description of the function:def make_vslc_label(self, gene_label, allele1_label, allele2_label): vslc_label = '' if gene_label is None and allele1_label is None and allele2_label is None: LOG.error("Not enough info to make vslc label") return None ...
[ "\n Make a Variant Single Locus Complement (VSLC) in monarch-style.\n :param gene_label:\n :param allele1_label:\n :param allele2_label:\n :return:\n " ]
Please provide a description of the function:def get_ncbi_taxon_num_by_label(label): req = {'db': 'taxonomy', 'retmode': 'json', 'term': label} req.update(EREQ) request = SESSION.get(ESEARCH, params=req) LOG.info('fetching: %s', request.url) request.raise_for_status() ...
[ "\n Here we want to look up the NCBI Taxon id using some kind of label.\n It will only return a result if there is a unique hit.\n\n :return:\n\n " ]
Please provide a description of the function:def is_omim_disease(gene_id): SCIGRAPH_BASE = 'https://scigraph-ontology-dev.monarchinitiative.org/scigraph/graph/' session = requests.Session() adapter = requests.adapters.HTTPAdapter(max_retries=10) session.mount('https://', adapte...
[ "\n Process omim equivalencies by examining the monarch ontology scigraph\n As an alternative we could examine mondo.owl, since the ontology\n scigraph imports the output of this script which creates an odd circular\n dependency (even though we're querying mondo.owl through scigraph)\n\n...
Please provide a description of the function:def get_ncbi_id_from_symbol(gene_symbol): monarch_url = 'https://solr.monarchinitiative.org/solr/search/select' params = DipperUtil._get_solr_weight_settings() params["q"] = "{0} \"{0}\"".format(gene_symbol) params["fq"] = ["taxon:\"N...
[ "\n Get ncbi gene id from symbol using monarch and mygene services\n :param gene_symbol:\n :return:\n " ]
Please provide a description of the function:def set_association_id(self, assoc_id=None): if assoc_id is None: self.assoc_id = self.make_association_id( self.definedby, self.sub, self.rel, self.obj) else: self.assoc_id = assoc_id return self.asso...
[ "\n This will set the association ID based on the internal parts\n of the association.\n To be used in cases where an external association identifier\n should be used.\n\n :param assoc_id:\n\n :return:\n\n " ]
Please provide a description of the function:def make_association_id(definedby, sub, pred, obj, attributes=None): items_to_hash = [definedby, sub, pred, obj] if attributes is not None and len(attributes) > 0: items_to_hash += attributes items_to_hash = [x for x in items_to...
[ "\n A method to create unique identifiers for OBAN-style associations,\n based on all the parts of the association\n If any of the items is empty or None, it will convert it to blank.\n It effectively digests the string of concatonated values.\n Subclasses of Assoc can submit an ...
Please provide a description of the function:def parse(self, limit=None): if limit is not None: LOG.info("Only parsing first %d rows", limit) sgd_file = '/'.join((self.rawdir, self.files['sgd_phenotype']['file'])) columns = [ 'Feature Name', 'Feature Type', 'Gen...
[ "\n Override Source.parse()\n Args:\n :param limit (int, optional) limit the number of rows processed\n Returns:\n :return None\n " ]
Please provide a description of the function:def make_association(self, record): # prep record # remove description and mapp Experiment Type to apo term experiment_type = record['Experiment Type'].split('(')[0] experiment_type = experiment_type.split(',') record['experim...
[ "\n contstruct the association\n :param record:\n :return: modeled association of genotype to mammalian??? phenotype\n " ]
Please provide a description of the function:def setVersion(self, date_issued, version_id=None): if date_issued is not None: self.set_date_issued(date_issued) elif version_id is not None: self.set_version_by_num(version_id) else: LOG.error("date or v...
[ "\n Legacy function...\n should use the other set_* for version and date\n\n as of 2016-10-20 used in:\n\n dipper/sources/HPOAnnotations.py 139:\n dipper/sources/CTD.py 99:\n dipper/sources/BioGrid.py 100:\n dipper/sources/MGI.py 25...
Please provide a description of the function:def set_version_by_date(self, date_issued=None): if date_issued is not None: dat = date_issued elif self.date_issued is not None: dat = self.date_issued else: dat = self.date_accessed LOG.info(...
[ "\n This will set the version by the date supplied,\n the date already stored in the dataset description,\n or by the download date (today)\n :param date_issued:\n :return:\n " ]
Please provide a description of the function:def toRoman(num): if not 0 < num < 5000: raise ValueError("number %n out of range (must be 1..4999)", num) if int(num) != num: raise TypeError("decimals %n can not be converted", num) result = "" for numeral, integer in romanNumeralMap: ...
[ "convert integer to Roman numeral" ]
Please provide a description of the function:def fromRoman(strng): if not strng: raise TypeError('Input can not be blank') if not romanNumeralPattern.search(strng): raise ValueError('Invalid Roman numeral: %s', strng) result = 0 index = 0 for numeral, integer in romanNumeralMap...
[ "convert Roman numeral to integer" ]
Please provide a description of the function:def fetch(self, is_dl_forced=False): file_paths = self._get_file_paths(self.tax_ids, 'protein_links') self.get_files(is_dl_forced, file_paths) self.get_files(is_dl_forced, self.id_map_files)
[ "\n Override Source.fetch()\n Fetches resources from String\n\n We also fetch ensembl to determine if protein pairs are from\n the same species\n Args:\n :param is_dl_forced (bool): Force download\n Returns:\n :return None\n " ]
Please provide a description of the function:def parse(self, limit=None): if limit is not None: LOG.info("Only parsing first %d rows", limit) protein_paths = self._get_file_paths(self.tax_ids, 'protein_links') col = ['NCBI taxid', 'entrez', 'STRING'] for taxon in pr...
[ "\n Override Source.parse()\n Args:\n :param limit (int, optional) limit the number of rows processed\n Returns:\n :return None\n " ]
Please provide a description of the function:def _get_file_paths(self, tax_ids, file_type): file_paths = dict() if file_type not in self.files: raise KeyError("file type {} not configured".format(file_type)) for taxon in tax_ids: file_paths[taxon] = { ...
[ "\n Assemble file paths from tax ids\n Args:\n :param tax_ids (list) list of taxa\n Returns:\n :return file dict\n " ]
Please provide a description of the function:def process_fish(self, limit=None): LOG.info("Processing Fish Parts") raw = '/'.join((self.rawdir, self.files['fish_components']['file'])) if self.test_mode: graph = self.testgraph else: graph = self.graph ...
[ "\n Fish give identifiers to the \"effective genotypes\" that we create.\n We can match these by:\n Fish = (intrinsic) genotype + set of morpholinos\n\n We assume here that the intrinsic genotypes and their parts\n will be processed separately, prior to calling this function.\n\n ...
Please provide a description of the function:def _process_genotype_features(self, limit=None): raw = '/'.join((self.rawdir, self.files['geno']['file'])) if self.test_mode: graph = self.testgraph else: graph = self.graph model = Model(graph) taxo...
[ "\n Here we process the genotype_features file, which lists genotypes\n together with any intrinsic sequence alterations, their zygosity,\n and affected gene.\n Because we don't necessarily get allele pair (VSLC) ids\n in a single row, we iterate through the file and build up a ha...
Please provide a description of the function:def _process_genotype_backgrounds(self, limit=None): if self.test_mode: graph = self.testgraph else: graph = self.graph model = Model(graph) LOG.info("Processing genotype backgrounds") line_counter = 0...
[ "\n This table provides a mapping of genotypes to background genotypes\n Note that the background_id is also a genotype_id.\n\n Makes these triples:\n <ZFIN:genotype_id> GENO:has_reference_part <ZFIN:background_id>\n <ZFIN:background_id> a GENO:genomic_background\n <ZFIN:ba...
Please provide a description of the function:def _process_wildtypes(self, limit=None): if self.test_mode: graph = self.testgraph else: graph = self.graph # model = Model(graph) # unused LOG.info("Processing wildtype genotypes") line_counter = 0 ...
[ "\n This table provides the genotype IDs, name,\n and abbreviation of the wildtype genotypes.\n These are the typical genomic backgrounds...there's about 20 of them.\n http://zfin.org/downloads/wildtypes_fish.txt\n\n Triples created:\n <genotype id> a GENO:wildtype\n ...
Please provide a description of the function:def _process_stages(self, limit=None): if self.test_mode: graph = self.testgraph else: graph = self.graph model = Model(graph) LOG.info("Processing stages") line_counter = 0 raw = '/'.join((sel...
[ "\n This table provides mappings between ZFIN stage IDs and ZFS terms,\n and includes the starting and ending hours for the developmental stage.\n Currently only processing the mapping from the ZFIN stage ID\n to the ZFS ID.\n\n :param limit:\n :return:\n\n " ]
Please provide a description of the function:def _process_g2p(self, limit=None): LOG.info("Processing G2P") line_counter = 0 if self.test_mode: graph = self.testgraph else: graph = self.graph missing_zpids = list() mapped_zpids = list() ...
[ "\n Here, we process the fish-to-phenotype associations,\n which also include environmental perturbations.\n The phenotypes may also be recorded as observed at specific stages.\n We create association objects with as much of the information\n as possible.\n\n A full associa...
Please provide a description of the function:def _write_missing_zp_report(self, missing_zpids, include_normal=True): f = '/'.join((self.outdir, 'missing_zps.txt')) myset = set([','.join(x) for x in missing_zpids]) # missing_zpids = set(missing_zpids) # make it a unique set wi...
[ "\n This will write the sextuples of anatomy+quality to a file\n if they do not map to any current ZP definition.\n Set include_normal to False if you do not want to log\n the unmatched \"normal\" phenotypes.\n :param missing_zpids:\n :param include_normal:\n :return...
Please provide a description of the function:def _process_genes(self, limit=None): LOG.info("Processing genes") if self.test_mode: graph = self.testgraph else: graph = self.graph model = Model(graph) line_counter = 0 raw = '/'.join((self....
[ "\n This table provides the ZFIN gene id, the SO type of the gene,\n the gene symbol, and the NCBI Gene ID.\n\n Triples created:\n <gene id> a class\n <gene id> rdfs:label gene_symbol\n <gene id> equivalent class <ncbi_gene_id>\n :param limit:\n :return:\n\n ...
Please provide a description of the function:def _process_features(self, limit=None): if self.test_mode: graph = self.testgraph else: graph = self.graph model = Model(graph) LOG.info("Processing features") line_counter = 0 geno = Genotype(...
[ "\n This module provides information for the intrinsic\n and extrinsic genotype features of zebrafish.\n All items here are 'alterations', and are therefore instances.\n\n sequence alteration ID, SO type, abbreviation, and relationship to\n the affected gene, with the gene's ID, s...
Please provide a description of the function:def _process_feature_affected_genes(self, limit=None): # can use this to process and build the variant locus. # but will need to process through some kind of helper hash, # just like we do with the genotype file. # that's because eac...
[ "\n This table lists (intrinsic) genomic sequence alterations\n and their affected gene(s).\n It provides the sequence alteration ID, SO type, abbreviation,\n and relationship to the affected gene, with the gene's ID, symbol,\n and SO type (gene/pseudogene).\n\n Triples cre...
Please provide a description of the function:def _process_gene_marker_relationships(self, limit=None): if self.test_mode: graph = self.testgraph else: graph = self.graph model = Model(graph) LOG.info("Processing gene marker relationships") line_c...
[ "\n Gene-marker relationships include:\n clone contains gene,\n coding sequence of,\n contains polymorphism,\n gene contains small segment,\n gene encodes small segment,\n gene has artifact,\n gene hybridized by small segment,\n ...
Please provide a description of the function:def _process_pubinfo(self, limit=None): line_counter = 0 if self.test_mode: graph = self.testgraph else: graph = self.graph model = Model(graph) raw = '/'.join((self.rawdir, self.files['pubs']['file'])...
[ "\n This will pull the zfin internal publication information,\n and map them to their equivalent pmid, and make labels.\n\n Triples created:\n <pub_id> is an individual\n <pub_id> rdfs:label <pub_label>\n <pubmed_id> is an individual\n <pubmed_id> rdfs:label <pub_lab...
Please provide a description of the function:def _process_pub2pubmed(self, limit=None): line_counter = 0 if self.test_mode: graph = self.testgraph else: graph = self.graph model = Model(graph) raw = '/'.join((self.rawdir, self.files['pub2pubmed'][...
[ "\n This will pull the zfin internal publication to pubmed mappings.\n Somewhat redundant with the process_pubinfo method,\n but this includes additional mappings.\n\n <pub_id> is an individual\n <pub_id> rdfs:label <pub_label>\n <pubmed_id> is an individual\n <pubme...
Please provide a description of the function:def _process_targeting_reagents(self, reagent_type, limit=None): LOG.info("Processing Gene Targeting Reagents") if self.test_mode: graph = self.testgraph else: graph = self.graph line_counter = 0 model...
[ "\n This method processes the gene targeting knockdown reagents,\n such as morpholinos, talens, and crisprs.\n We create triples for the reagents and pass the data into a hash map\n for use in the pheno_enviro method.\n\n Morpholinos work similar to RNAi.\n TALENs are artif...
Please provide a description of the function:def _process_pheno_enviro(self, limit=None): LOG.info("Processing environments") if self.test_mode: graph = self.testgraph else: graph = self.graph line_counter = 0 env_hash = {} envo = Environ...
[ "\n The pheno_environment.txt (became pheno_environment_fish.txt?)\n file ties experimental conditions\n to an environment ID.\n An environment ID may have one or more associated conditions.\n Condition groups present:\n * chemical, physical, physiological,\n * salin...
Please provide a description of the function:def _process_mappings(self, limit=None): LOG.info("Processing chromosome mappings") if self.test_mode: graph = self.testgraph else: graph = self.graph line_counter = 0 model = Model(graph) geno...
[ "\n This function imports linkage mappings of various entities\n to genetic locations in cM or cR.\n Entities include sequence variants, BAC ends, cDNA, ESTs, genes,\n PAC ends, RAPDs, SNPs, SSLPs, and STSs.\n Status: NEEDS REVIEW\n :param limit:\n :return:\n\n ...
Please provide a description of the function:def _process_uniprot_ids(self, limit=None): LOG.info("Processing UniProt IDs") if self.test_mode: graph = self.testgraph else: graph = self.graph line_counter = 0 model = Model(graph) geno = Ge...
[ "\n This method processes the mappings from ZFIN gene IDs to UniProtKB IDs.\n\n Triples created:\n <zfin_gene_id> a class\n <zfin_gene_id> rdfs:label gene_symbol\n\n <uniprot_id> is an Individual\n <uniprot_id> has type <polypeptide>\n\n <zfin_gene_id> has_gene_produ...
Please provide a description of the function:def _process_human_orthos(self, limit=None): if self.test_mode: graph = self.testgraph else: graph = self.graph LOG.info("Processing human orthos") line_counter = 0 geno = Genotype(graph) # mo...
[ "\n This table provides ortholog mappings between zebrafish and humans.\n ZFIN has their own process of creating orthology mappings,\n that we take in addition to other orthology-calling sources\n (like PANTHER). We ignore the omim ids, and only use the gene_id.\n\n Triples create...
Please provide a description of the function:def _map_sextuple_to_phenotype( self, superterm1_id, subterm1_id, quality_id, superterm2_id, subterm2_id, modifier): zp_id = None # zfin uses free-text modifiers, # but we need to convert them to proper PATO classes f...
[ "\n This will take the 6-part EQ-style annotation\n used by ZFIN and return the ZP id.\n Currently relies on an external mapping file,\n but the method may be swapped out in the future\n :param superterm1_id:\n :param subterm1_id:\n :param quality_id:\n :param...
Please provide a description of the function:def _load_zp_mappings(self, file): zp_map = {} LOG.info("Loading ZP-to-EQ mappings") line_counter = 0 with open(file, 'r', encoding="utf-8") as csvfile: filereader = csv.reader(csvfile, delimiter='\t', quotechar='\"') ...
[ "\n Given a file that defines the mapping between\n ZFIN-specific EQ definitions and the automatically derived ZP ids,\n create a mapping here.\n This may be deprecated in the future\n :return:\n\n " ]
Please provide a description of the function:def _get_other_allele_by_zygosity(allele_id, zygosity): other_allele = None if zygosity == 'homozygous': other_allele = allele_id elif zygosity == 'hemizygous': other_allele = '0' elif zygosity == 'unknown': #...
[ "\n A helper function to switch on the zygosity,\n and return the appropriate allele id, or symbol.\n :param allele_id:\n :param zygosity:\n :return:\n " ]
Please provide a description of the function:def _make_variant_locus_id(gene_id, allele_id): varloci = '-'.join((gene_id, allele_id)) varloci = '_:' + re.sub(r'(ZFIN)?:', '', varloci) return varloci
[ "\n A convenience method to uniformly create variant loci.\n If we want to materialize these in the monarch space,\n then we wrap with the self.make_id function.\n :param gene_id:\n :param allele_id:\n :return:\n\n " ]
Please provide a description of the function:def get_orthology_sources_from_zebrafishmine(self): # For further documentation you can visit: # http://www.intermine.org/wiki/PythonClient # The following two lines will be needed in every python script: service = Service("http...
[ "\n Fetch the zfin gene to other species orthology annotations,\n together with the evidence for the assertion.\n Write the file locally to be read in a separate function.\n :return:\n\n " ]
Please provide a description of the function:def get_orthology_evidence_code(self, abbrev): ''' move to localtt & globltt ''' # AA Amino acid sequence comparison. # CE Coincident expression. # CL Conserved genome location (synteny). # FC Functional complementa...
[]
Please provide a description of the function:def parse(self, limit=None): if limit is not None: LOG.info("Only parsing first %s rows fo each file", str(limit)) LOG.info("Parsing files...") if self.test_only: self.test_mode = True self._process_diseases...
[ "\n :param limit:\n :return:\n\n " ]
Please provide a description of the function:def _process_pathways(self, limit=None): LOG.info("Processing pathways") if self.test_mode: graph = self.testgraph else: graph = self.graph model = Model(graph) line_counter = 0 path = Pathway(...
[ "\n This method adds the KEGG pathway IDs.\n These are the canonical pathways as defined in KEGG.\n We also encode the graphical depiction\n which maps 1:1 with the identifier.\n\n Triples created:\n <pathway_id> is a GO:signal_transduction\n <pathway_id> rdfs:label ...
Please provide a description of the function:def _process_diseases(self, limit=None): LOG.info("Processing diseases") if self.test_mode: graph = self.testgraph else: graph = self.graph line_counter = 0 model = Model(graph) raw = '/'.join(...
[ "\n This method processes the KEGG disease IDs.\n\n Triples created:\n <disease_id> is a class\n <disease_id> rdfs:label <disease_name>\n :param limit:\n :return:\n\n " ]
Please provide a description of the function:def _process_genes(self, limit=None): LOG.info("Processing genes") if self.test_mode: graph = self.testgraph else: graph = self.graph model = Model(graph) line_counter = 0 family = Family(graph...
[ "\n This method processes the KEGG gene IDs.\n The label for the gene is pulled as\n the first symbol in the list of gene symbols;\n the rest are added as synonyms.\n The long-form of the gene name is added as a definition.\n This is hardcoded to just processes human genes....
Please provide a description of the function:def _process_ortholog_classes(self, limit=None): LOG.info("Processing ortholog classes") if self.test_mode: graph = self.testgraph else: graph = self.graph model = Model(graph) line_counter = 0 ...
[ "\n This method add the KEGG orthology classes to the graph.\n\n If there's an embedded enzyme commission number,\n that is added as an xref.\n\n Triples created:\n <orthology_class_id> is a class\n <orthology_class_id> has label <orthology_symbols>\n <orthology_clas...
Please provide a description of the function:def _process_orthologs(self, raw, limit=None): LOG.info("Processing orthologs") if self.test_mode: graph = self.testgraph else: graph = self.graph model = Model(graph) line_counter = 0 with ope...
[ "\n This method maps orthologs for a species to the KEGG orthology classes.\n\n Triples created:\n <gene_id> is a class\n <orthology_class_id> is a class\n\n <assoc_id> has subject <gene_id>\n <assoc_id> has object <orthology_class_id>\n :param limit:\n :retur...
Please provide a description of the function:def _process_omim2gene(self, limit=None): LOG.info("Processing OMIM to KEGG gene") if self.test_mode: graph = self.testgraph else: graph = self.graph model = Model(graph) line_counter = 0 geno ...
[ "\n This method maps the OMIM IDs and KEGG gene ID.\n Currently split based on the link_type field.\n Equivalent link types are mapped as gene XRefs.\n Reverse link types are mapped as disease to gene associations.\n Original link types are currently skipped.\n\n Triples cr...
Please provide a description of the function:def _process_omim2disease(self, limit=None): LOG.info("Processing 1:1 KEGG disease to OMIM disease mappings") if self.test_mode: graph = self.testgraph else: graph = self.graph line_counter = 0 model =...
[ "\n This method maps the KEGG disease IDs to\n the corresponding OMIM disease IDs.\n Currently this only maps KEGG diseases and OMIM diseases that are 1:1.\n\n Triples created:\n <kegg_disease_id> is a class\n <omim_disease_id> is a class\n <kegg_disease_id> hasXref ...
Please provide a description of the function:def _process_genes_kegg2ncbi(self, limit=None): LOG.info("Processing KEGG gene IDs to NCBI gene IDs") if self.test_mode: graph = self.testgraph else: graph = self.graph model = Model(graph) line_counte...
[ "\n This method maps the KEGG human gene IDs\n to the corresponding NCBI Gene IDs.\n\n Triples created:\n <kegg_gene_id> is a class\n <ncbi_gene_id> is a class\n <kegg_gene_id> equivalentClass <ncbi_gene_id>\n :param limit:\n :return:\n\n " ]
Please provide a description of the function:def _process_pathway_pubmed(self, limit): LOG.info("Processing KEGG pathways to pubmed ids") if self.test_mode: graph = self.testgraph else: graph = self.graph line_counter = 0 raw = '/'.join((self.rawd...
[ "\n Indicate that a pathway is annotated directly to a paper (is about)\n via it's pubmed id.\n :param limit:\n :return:\n " ]
Please provide a description of the function:def _process_pathway_disease(self, limit): LOG.info("Processing KEGG pathways to disease ids") if self.test_mode: graph = self.testgraph else: graph = self.graph line_counter = 0 raw = '/'.join((self.r...
[ "\n We make a link between the pathway identifiers,\n and any diseases associated with them.\n Since we model diseases as processes, we make a triple saying that\n the pathway may be causally upstream of or within the disease process.\n\n :param limit:\n :return:\n\n ...
Please provide a description of the function:def _process_pathway_pathway(self, limit): LOG.info("Processing KEGG pathways to other ids") if self.test_mode: graph = self.testgraph else: graph = self.graph line_counter = 0 model = Model(graph) ...
[ "\n There are \"map\" and \"ko\" identifiers for pathways.\n This makes equivalence mapping between them, where they exist.\n :param limit:\n :return:\n\n " ]
Please provide a description of the function:def _process_pathway_ko(self, limit): LOG.info("Processing KEGG pathways to kegg ortholog classes") if self.test_mode: graph = self.testgraph else: graph = self.graph line_counter = 0 raw = '/'.join((s...
[ "\n This adds the kegg orthologous group (gene) to the canonical pathway.\n :param limit:\n\n :return:\n " ]
Please provide a description of the function:def _make_variant_locus_id(self, gene_id, disease_id): alt_locus_id = '_:'+re.sub( r':', '', gene_id) + '-' + re.sub(r':', '', disease_id) + 'VL' alt_label = self.label_hash.get(gene_id) disease_label = self.label_hash.get(disease...
[ "\n We actually want the association between the gene and the disease\n to be via an alternate locus not the \"wildtype\" gene itself.\n so we make an anonymous alternate locus,\n and put that in the association\n We also make the label for the anonymous class,\n and add it...
Please provide a description of the function:def add_gene_family_to_graph(self, family_id): family = Family(self.graph) gene_family = self.globaltt['gene_family'] # make the assumption that the genes # have already been added as classes previously self.model.addIndividu...
[ "\n Make an association between a group of genes and some grouping class.\n We make the assumption that the genes in the association\n are part of the supplied family_id, and that the genes have\n already been declared as classes elsewhere.\n The family_id is added as an individua...
Please provide a description of the function:def parse(self, limit=None): if self.test_only: self.test_mode = True if self.tax_ids is None: LOG.info("No taxon filter set; Dumping all orthologous associations.") else: LOG.info("Only the following tax...
[ "\n :return: None\n " ]
Please provide a description of the function:def _get_orthologs(self, limit): LOG.info("getting orthologs") if self.test_mode: graph = self.testgraph else: graph = self.graph model = Model(graph) unprocessed_gene_ids = set() # may be faster to ...
[ "\n This will process each of the specified pairwise orthology files,\n creating orthology associations based on the specified orthology code.\n this currently assumes that each of the orthology files is identically\n formatted. Relationships are made between genes here.\n\n There...
Please provide a description of the function:def _clean_up_gene_id(geneid, sp, curie_map): # special case for MGI geneid = re.sub(r'MGI:MGI:', 'MGI:', geneid) # rewrite Ensembl --> ENSEMBL geneid = re.sub(r'Ensembl', 'ENSEMBL', geneid) # rewrite Gene:CELE --> WormBase ...
[ "\n A series of identifier rewriting to conform with\n standard gene identifiers.\n :param geneid:\n :param sp:\n :return:\n " ]
Please provide a description of the function:def parse(self, limit=None): if limit is not None: LOG.info("Only parsing first %d rows", limit) LOG.info("Parsing files...") # pub_map = dict() # file_path = '/'.join((self.rawdir, # self.static_files['publicatio...
[ "\n Override Source.parse()\n Parses version and interaction information from CTD\n Args:\n :param limit (int, optional) limit the number of rows processed\n Returns:\n :return None\n " ]
Please provide a description of the function:def _parse_ctd_file(self, limit, file): row_count = 0 version_pattern = re.compile(r'^# Report created: (.+)$') is_versioned = False file_path = '/'.join((self.rawdir, file)) with gzip.open(file_path, 'rt') as tsvfile: ...
[ "\n Parses files in CTD.files dictionary\n Args:\n :param limit (int): limit the number of rows processed\n :param file (str): file name (must be defined in CTD.file)\n Returns:\n :return None\n " ]
Please provide a description of the function:def _process_pathway(self, row): model = Model(self.graph) self._check_list_len(row, 4) (gene_symbol, gene_id, pathway_name, pathway_id) = row if self.test_mode and (int(gene_id) not in self.test_geneids): return ...
[ "\n Process row of CTD data from CTD_genes_pathways.tsv.gz\n and generate triples\n Args:\n :param row (list): row of CTD data\n Returns:\n :return None\n " ]
Please provide a description of the function:def _fetch_disambiguating_assoc(self): disambig_file = '/'.join( (self.rawdir, self.static_files['publications']['file'])) assoc_file = '/'.join( (self.rawdir, self.files['chemical_disease_interactions']['file'])) # ...
[ "\n For any of the items in the chemical-disease association file that have\n ambiguous association types we fetch the disambiguated associations\n using the batch query API, and store these in a file. Elsewhere, we can\n loop through the file and create the appropriate associations.\n\n...
Please provide a description of the function:def _process_interactions(self, row): model = Model(self.graph) self._check_list_len(row, 10) (chem_name, chem_id, cas_rn, disease_name, disease_id, direct_evidence, inferred_gene_symbol, inference_score, omim_ids, pubmed_ids) = row ...
[ "\n Process row of CTD data from CTD_chemicals_diseases.tsv.gz\n and generate triples. Only create associations based on direct evidence\n (not using the inferred-via-gene), and unambiguous relationships.\n (Ambiguous ones will be processed in the sister method using the\n disambi...
Please provide a description of the function:def _process_disease2gene(self, row): # if self.test_mode: # graph = self.testgraph # else: # graph = self.graph # self._check_list_len(row, 9) # geno = Genotype(graph) # gu = GraphUtils(curie_map.get()) ...
[ "\n Here, we process the disease-to-gene associations.\n Note that we ONLY process direct associations\n (not inferred through chemicals).\n Furthermore, we also ONLY process \"marker/mechanism\" associations.\n\n We preferentially utilize OMIM identifiers over MESH identifiers\n ...
Please provide a description of the function:def _make_association(self, subject_id, object_id, rel_id, pubmed_ids): # TODO pass in the relevant Assoc class rather than relying on G2P assoc = G2PAssoc(self.graph, self.name, subject_id, object_id, rel_id) if pubmed_ids is not None and l...
[ "\n Make a reified association given an array of pubmed identifiers.\n\n Args:\n :param subject_id id of the subject of the association (gene/chem)\n :param object_id id of the object of the association (disease)\n :param rel_id relationship id\n :param p...
Please provide a description of the function:def _process_pubmed_ids(pubmed_ids): if pubmed_ids.strip() == '': id_list = [] else: id_list = pubmed_ids.split('|') for (i, val) in enumerate(id_list): id_list[i] = 'PMID:' + val return id_list
[ "\n Take a list of pubmed IDs and add PMID prefix\n Args:\n :param pubmed_ids - string representing publication\n ids seperated by a | symbol\n Returns:\n :return list: Pubmed curies\n\n " ]
Please provide a description of the function:def _getnode(self, curie): if re.match(r'^_:', curie): if self.are_bnodes_skized is True: node = self.skolemizeBlankNode(curie) else: node = curie elif re.match(r'^http|^ftp', curie): ...
[ "\n Returns IRI, or blank node curie/iri depending on\n self.skolemize_blank_node setting\n\n :param curie: str id as curie or iri\n :return:\n " ]
Please provide a description of the function:def _getLiteralXSDType(self, literal): if isinstance(literal, int): return self._getnode("xsd:integer") if isinstance(literal, float): return self._getnode("xsd:double")
[ "\n This could be much more nuanced, but for now\n if a literal is not a str, determine if it's\n a xsd int or double\n :param literal:\n :return: str - xsd full iri\n " ]
Please provide a description of the function:def add_assertion(self, assertion, agent, agent_label, date=None): self.model.addIndividualToGraph(assertion, None, self.globaltt['assertion']) self.add_agent_to_graph(agent, agent_label, self.globaltt['organization']) self.graph.addTriple(...
[ "\n Add assertion to graph\n :param assertion:\n :param agent:\n :param evidence_line:\n :param date:\n :return: None\n " ]
Please provide a description of the function:def fetch(self, is_dl_forced=False): (files_to_download, ftp) = self._get_file_list( self.files['anat_entity']['path'], self.files['anat_entity']['pattern']) LOG.info( 'Will Check \n%s\nfrom %s', '\n'...
[ "\n :param is_dl_forced: boolean, force download\n :return:\n " ]
Please provide a description of the function:def parse(self, limit=None): files_to_download, ftp = self._get_file_list( self.files['anat_entity']['path'], self.files['anat_entity']['pattern']) for dlname in files_to_download: localfile = '/'.join((self.rawdi...
[ "\n Given the input taxa, expects files in the raw directory\n with the name {tax_id}_anat_entity_all_data_Pan_troglodytes.tsv.zip\n\n :param limit: int Limit to top ranked anatomy associations per group\n :return: None\n " ]
Please provide a description of the function:def _parse_gene_anatomy(self, fh, limit): dataframe = pd.read_csv(fh, sep='\t') col = self.files['anat_entity']['columns'] if list(dataframe) != col: LOG.warning( '\nExpected headers: %s\nRecived headers: %s', co...
[ "\n Process anat_entity files with columns:\n Ensembl gene ID,gene name, anatomical entity ID,\n anatomical entity name, rank score, XRefs to BTO\n\n :param fh: filehandle\n :param limit: int, limit per group\n :return: None\n " ]
Please provide a description of the function:def _add_gene_anatomy_association(self, gene_id, anatomy_curie, rank): g2a_association = Assoc(self.graph, self.name) model = Model(self.graph) gene_curie = "ENSEMBL:{}".format(gene_id) rank = re.sub(r',', '', str(rank)) # ? can't d...
[ "\n :param gene_id: str Non curified ID\n :param gene_label: str Gene symbol\n :param anatomy_curie: str curified anatomy term\n :param rank: str rank\n :return: None\n " ]
Please provide a description of the function:def checkIfRemoteIsNewer(self, localfile, remote_size, remote_modify): is_remote_newer = False status = os.stat(localfile) LOG.info( "\nLocal file size: %i" "\nLocal Timestamp: %s", status[ST_SIZE], datetim...
[ "\n Overrides checkIfRemoteIsNewer in Source class\n\n :param localfile: str file path\n :param remote_size: str bytes\n :param remote_modify: str last modify date in the form 20160705042714\n :return: boolean True if remote file is newer else False\n " ]
Please provide a description of the function:def _convert_ftp_time_to_iso(ftp_time): date_time = datetime( int(ftp_time[:4]), int(ftp_time[4:6]), int(ftp_time[6:8]), int(ftp_time[8:10]), int(ftp_time[10:12]), int(ftp_time[12:14])) return date_time
[ "\n Convert datetime in the format 20160705042714 to a datetime object\n\n :return: datetime object\n " ]
Please provide a description of the function:def _get_file_list(self, working_dir, file_regex=re.compile(r'.*'), ftp=None): if ftp is None: ftp = ftplib.FTP(BGEE_FTP) ftp.login("anonymous", "info@monarchinitiative.org") working_dir = "{}{}".format(self.version, working...
[ "\n Get file list from ftp server filtered by taxon\n :return: Tuple of (Generator object with Tuple(\n file name, info object), ftp object)\n " ]