Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def is_async_call(func):
'''inspect.iscoroutinefunction that looks through partials.'''
while isinstance(func, partial):
func = func.func
return inspect.iscoroutinefunction(func) | [] |
Please provide a description of the function:def from_string(cls, string, *, default_func=None):
'''Construct a NetAddress from a string and return a (host, port) pair.
If either (or both) is missing and default_func is provided, it is called with
ServicePart.HOST or ServicePart.PORT to get a d... | [] |
Please provide a description of the function:def from_string(cls, string, *, default_func=None):
'''Construct a Service from a string.
If default_func is provided and any ServicePart is missing, it is called with
default_func(protocol, part) to obtain the missing part.
'''
if no... | [] |
Please provide a description of the function:def _process_phenotype_hpoa(self, raw, limit):
src_key = 'hpoa'
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
model = Model(graph)
filedate = datetime.utcfromtimestamp(
... | [
"\n see info on format here:\n http://www.human-phenotype-ontology.org/contao/index.php/annotation-guide.html\n\n :param raw:\n :param limit:\n :return:\n\n "
] |
Please provide a description of the function:def get_common_files(self):
# curl -sLu "username:personal-acess-token" \
# GITAPI + "/hpo-annotation-data/tarball/master" > hpoa.tgz
repo_dir = self.rawdir + '/git'
username = CONF['user']['hpoa']
response = requests.get(
... | [
"\n Fetch the hpo-annotation-data\n [repository](https://github.com/monarch-initiative/hpo-annotation-data.git)\n as a tarball\n\n :return:\n\n "
] |
Please provide a description of the function:def add_common_files_to_file_list(self):
'''
The (several thousands) common-disease files from the repo tarball
are added to the files object.
try adding the 'common-disease-mondo' files as well?
'''
repo_dir = '/'... | [] |
Please provide a description of the function:def process_all_common_disease_files(self, limit=None):
LOG.info("Iterating over all common disease files")
common_file_count = 0
total_processed = "" # stopgap gill we fix common-disease files
unpadded_doids = "" # stopgap gill we... | [
"\n Loop through all of the files that we previously fetched from git,\n creating the disease-phenotype association.\n :param limit:\n :return:\n\n "
] |
Please provide a description of the function:def process_common_disease_file(self, raw, unpadded_doids, limit=None):
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
assoc_count = 0
replace_id_flag = False
col = self.small_files... | [
"\n Make disaese-phenotype associations.\n Some identifiers need clean up:\n * DOIDs are listed as DOID-DOID: --> DOID:\n * DOIDs may be unnecessarily zero-padded.\n these are remapped to their non-padded equivalent.\n\n :param raw:\n :param unpadded_doids:\n ... |
Please provide a description of the function:def replace(oldstr, newstr, infile, dryrun=False):
linelist = []
with open(infile) as reader:
for item in reader:
newitem = re.sub(oldstr, newstr, item)
linelist.append(newitem)
if dryrun is False:
with open(infile, "... | [
"\n Sed-like Replace function..\n Usage: pysed.replace(<Old string>, <Replacement String>, <Text File>)\n Example: pysed.replace('xyz', 'XYZ', '/path/to/file.txt')\n\n This will dump the output to STDOUT instead of changing the input file.\n Example 'DRYRUN':\n pysed.replace('xyz', 'XYZ', '/path/t... |
Please provide a description of the function:def rmlinematch(oldstr, infile, dryrun=False):
linelist = []
with open(infile) as reader:
for item in reader:
rmitem = re.match(r'.*{}'.format(oldstr), item)
# if isinstance(rmitem) == isinstance(None): Not quite sure the intent... | [
"\n Sed-like line deletion function based on given string..\n Usage: pysed.rmlinematch(<Unwanted string>, <Text File>)\n Example: pysed.rmlinematch('xyz', '/path/to/file.txt')\n Example:\n 'DRYRUN': pysed.rmlinematch('xyz', '/path/to/file.txt', dryrun=True)\n This will dump the output to STDOUT in... |
Please provide a description of the function:def rmlinenumber(linenumber, infile, dryrun=False):
linelist = []
linecounter = 0
if isinstance(linenumber, int):
exit()
with open(infile) as reader:
for item in reader:
linecounter = linecounter + 1
if linecounte... | [
"\n Sed-like line deletion function based on given line number..\n Usage: pysed.rmlinenumber(<Unwanted Line Number>, <Text File>)\n Example: pysed.rmlinenumber(10, '/path/to/file.txt')\n Example 'DRYRUN': pysed.rmlinenumber(10, '/path/to/file.txt', dryrun=True)\n #This will dump the output to STDOUT ... |
Please provide a description of the function:def fetch(self, is_dl_forced=False):
self.get_files(is_dl_forced)
ncbi = NCBIGene(self.graph_type, self.are_bnodes_skized)
# ncbi.fetch()
gene_group = ncbi.files['gene_group']
self.fetch_from_url(
gene_group['url'... | [
"\n :param is_dl_forced:\n :return:\n "
] |
Please provide a description of the function:def scrub(self):
LOG.info("Scrubbing out the nasty characters that break our parser.")
myfile = '/'.join((self.rawdir, self.files['data']['file']))
tmpfile = '/'.join((self.rawdir, self.files['data']['file']+'.tmp.gz'))
tmp = gzip.o... | [
"\n The XML file seems to have mixed-encoding;\n we scrub out the control characters\n from the file for processing.\n\n i.e.?i\n omia.xml:1555328.28: PCDATA invalid Char value 2\n <field name=\"journal\">Bulletin et M\u0002emoires de la Soci\u0002et\u0002e Centrale de M\u0... |
Please provide a description of the function:def find_omim_type(self):
'''
This f(x) needs to be rehomed and shared.
Use OMIM's discription of their identifiers
to heuristically partition them into genes | phenotypes-diseases
type could be
- `obsolete` Check `omim_re... | [] |
Please provide a description of the function:def process_species(self, limit):
myfile = '/'.join((self.rawdir, self.files['data']['file']))
fh = gzip.open(myfile, 'rb')
filereader = io.TextIOWrapper(fh, newline="")
filereader.readline() # remove the xml declaration line
... | [
"\n Loop through the xml file and process the species.\n We add elements to the graph, and store the\n id-to-label in the label_hash dict.\n :param limit:\n :return:\n "
] |
Please provide a description of the function:def process_classes(self, limit):
myfile = '/'.join((self.rawdir, self.files['data']['file']))
fh = gzip.open(myfile, 'rb')
filereader = io.TextIOWrapper(fh, newline="")
filereader.readline() # remove the xml declaration line
... | [
"\n After all species have been processed .\n Loop through the xml file and process the articles,\n breed, genes, phenes, and phenotype-grouping classes.\n We add elements to the graph,\n and store the id-to-label in the label_hash dict,\n along with the internal key-to-ext... |
Please provide a description of the function:def process_associations(self, limit):
myfile = '/'.join((self.rawdir, self.files['data']['file']))
f = gzip.open(myfile, 'rb')
filereader = io.TextIOWrapper(f, newline="")
filereader.readline() # remove the xml declaration line
... | [
"\n Loop through the xml file and process the article-breed, article-phene,\n breed-phene, phene-gene associations, and the external links to LIDA.\n\n :param limit:\n :return:\n\n "
] |
Please provide a description of the function:def _process_article_phene_row(self, row):
# article_id, phene_id, added_by
# look up the article in the hashmap
phenotype_id = self.id_hash['phene'].get(row['phene_id'])
article_id = self.id_hash['article'].get(row['article_id'])
... | [
"\n Linking articles to species-specific phenes.\n\n :param row:\n :return:\n "
] |
Please provide a description of the function:def _process_omia_omim_map(self, row):
# omia_id, omim_id, added_by
model = Model(self.graph)
omia_id = 'OMIA:' + row['omia_id']
omim_id = 'OMIM:' + row['omim_id']
# also store this for use when we say that a given animal is
... | [
"\n Links OMIA groups to OMIM equivalents.\n :param row:\n :return:\n "
] |
Please provide a description of the function:def _process_group_mpo_row(self, row):
omia_id = 'OMIA:' + row['omia_id']
mpo_num = int(row['MPO_no'])
mpo_id = 'MP:' + str(mpo_num).zfill(7)
assoc = D2PAssoc(self.graph, self.name, omia_id, mpo_id)
assoc.add_association_to_g... | [
"\n Make OMIA to MP associations\n :param row:\n :return:\n "
] |
Please provide a description of the function:def filter_keep_phenotype_entry_ids(self, entry):
'''
doubt this should be kept
'''
omim_id = str(entry['mimNumber'])
otype = self.globaltt['obsolete']
if omim_id in self.omim_type:
otype = self.omim_type[omim_i... | [] |
Please provide a description of the function:def clean_up_omim_genes(self):
'''
Attempt to limit omim links to diseases and not genes/locus
'''
# get all the omim ids
allomim_curie = set()
for omia in self.omia_omim_map:
allomim_curie.update(self.omia_omim... | [] |
Please provide a description of the function:def make_spo(sub, prd, obj):
'''
Decorates the three given strings as a line of ntriples
'''
# To establish string as a curie and expand,
# we use a global curie_map(.yaml)
# sub are allways uri (unless a bnode)
# prd are allways uri (unless prd... | [] |
Please provide a description of the function:def write_spo(sub, prd, obj):
'''
write triples to a buffer incase we decide to drop them
'''
rcvtriples.append(make_spo(sub, prd, obj)) | [] |
Please provide a description of the function:def scv_link(scv_sig, rcv_trip):
'''
Creates links between SCV based on their pathonicty/significance calls
# GENO:0000840 - GENO:0000840 --> is_equilavent_to SEPIO:0000098
# GENO:0000841 - GENO:0000841 --> is_equilavent_to SEPIO:0000098
# GENO:0000843 -... | [] |
Please provide a description of the function:def resolve(label):
'''
composite mapping
given f(x) and g(x) here: GLOBALTT & LOCALTT respectivly
in order of preference
return g(f(x))|f(x)|g(x) | x
TODO consider returning x on fall through
: return label's mapping
'''
term_id = la... | [] |
Please provide a description of the function:def _process_ddg2p_annotations(self, limit):
line_counter = 0
if self.graph is not None:
graph = self.graph
else:
graph = self.graph
# in order for this to work, we need to map the HGNC id-symbol;
hgn... | [
"\n The ddg2p annotations associate a gene symbol to an omim disease,\n along with some HPO ids and pubs. The gene symbols come from gencode,\n which in turn come from HGNC official gene symbols. Therefore,\n we use the HGNC source class to get the id/symbol mapping for\n use in ... |
Please provide a description of the function:def make_allele_by_consequence(self, consequence, gene_id, gene_symbol):
allele_id = None
# Loss of function : Nonsense, frame-shifting indel,
# essential splice site mutation, whole gene deletion or any other
# mutation where f... | [
"\n Given a \"consequence\" label that describes a variation type,\n create an anonymous variant of the specified gene as an instance of\n that consequence type.\n\n :param consequence:\n :param gene_id:\n :param gene_symbol:\n :return: allele_id\n "
] |
Please provide a description of the function:def parse(self, limit: Optional[int]=None):
if limit is not None:
LOG.info("Only parsing first %d rows", limit)
LOG.info("Parsing files...")
file_path = '/'.join((
self.rawdir, self.files['developmental_disorders']['f... | [
"\n Here we parse each row of the gene to phenotype file\n\n We create anonymous variants along with their attributes\n (allelic requirement, functional consequence)\n and connect these to genes and diseases\n\n genes are connected to variants via\n global_terms['has_affect... |
Please provide a description of the function:def _add_gene_disease(self, row): # ::List getting syntax error here
col = self.files['developmental_disorders']['columns']
if len(row) != len(col):
raise ValueError("Unexpected number of fields for row {}".format(row))
variant... | [
"\n Parse and add gene variant disease model\n Model building happens in _build_gene_disease_model\n\n :param row {List}: single row from DDG2P.csv\n :return: None\n "
] |
Please provide a description of the function:def _build_gene_disease_model(
self,
gene_id,
relation_id,
disease_id,
variant_label,
consequence_predicate=None,
consequence_id=None,
allelic_requirement=None,
pmids=... | [
"\n Builds gene variant disease model\n\n :return: None\n "
] |
Please provide a description of the function:def _process_qtls_genetic_location(
self, raw, txid, common_name, limit=None):
aql_curie = self.files[common_name + '_cm']['curie']
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
... | [
"\n This function processes\n\n Triples created:\n\n :param limit:\n :return:\n\n "
] |
Please provide a description of the function:def _process_qtls_genomic_location(
self, raw, txid, build_id, build_label, common_name, limit=None):
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
model = Model(graph)
line_cou... | [
"\n This method\n\n Triples created:\n\n :param limit:\n :return:\n "
] |
Please provide a description of the function:def _process_trait_mappings(self, raw, limit=None):
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
line_counter = 0
model = Model(graph)
with open(raw, 'r') as csvfile:
... | [
"\n This method mapps traits from/to ...\n\n Triples created:\n\n :param limit:\n :return:\n "
] |
Please provide a description of the function:def _get_identifiers(self, limit):
LOG.info("getting identifier mapping")
line_counter = 0
f = '/'.join((self.rawdir, self.files['identifiers']['file']))
myzip = ZipFile(f, 'r')
# assume that the first entry is the item
... | [
"\n This will process the id mapping file provided by Biogrid.\n The file has a very large header, which we scan past,\n then pull the identifiers, and make equivalence axioms\n\n :param limit:\n :return:\n\n "
] |
Please provide a description of the function:def makeChromID(chrom, reference=None, prefix=None):
# blank nodes
if reference is None:
LOG.warning('No reference for this chr. You may have conflicting ids')
# replace any chr-like prefixes with blank to standardize
chrid = re.sub(r'ch(r?)[oms... | [
"\n This will take a chromosome number and a NCBI taxon number,\n and create a unique identifier for the chromosome. These identifiers\n are made in the @base space like:\n Homo sapiens (9606) chr1 ==> :9606chr1\n Mus musculus (10090) chrX ==> :10090chrX\n\n :param chrom: the chromosome (preferab... |
Please provide a description of the function:def addFeatureStartLocation(
self, coordinate, reference_id, strand=None, position_types=None):
# make an object for the start, which has:
# {coordinate : integer, reference : reference_id, types = []}
self.start = self._getLocat... | [
"\n Adds coordinate details for the start of this feature.\n :param coordinate:\n :param reference_id:\n :param strand:\n :param position_types:\n\n :return:\n\n "
] |
Please provide a description of the function:def addFeatureEndLocation(
self, coordinate, reference_id, strand=None, position_types=None):
self.stop = self._getLocation(coordinate, reference_id, strand, position_types)
return | [
"\n Adds the coordinate details for the end of this feature\n :param coordinate:\n :param reference_id:\n :param strand:\n\n :return:\n\n "
] |
Please provide a description of the function:def _getLocation(self, coordinate, reference_id, strand, position_types):
loc = {}
loc['coordinate'] = coordinate
loc['reference'] = reference_id
loc['type'] = []
strand_id = self._getStrandType(strand)
if strand_id i... | [
"\n Make an object for the location, which has:\n {coordinate : integer, reference : reference_id, types = []}\n where the strand is indicated in the type array\n :param coordinate:\n :param reference_id:\n :param strand:\n :param position_types:\n\n :return:\... |
Please provide a description of the function:def _getStrandType(self, strand):
# TODO make this a dictionary/enum: PLUS, MINUS, BOTH, UNKNOWN
strand_id = None
if strand == '+':
strand_id = self.globaltt['plus_strand']
elif strand == '-':
strand_id = sel... | [
"\n :param strand:\n :return:\n "
] |
Please provide a description of the function:def addFeatureToGraph(
self, add_region=True, region_id=None, feature_as_class=False):
if feature_as_class:
self.model.addClassToGraph(
self.fid, self.label, self.ftype, self.description)
else:
sel... | [
"\n We make the assumption here that all features are instances.\n The features are located on a region,\n which begins and ends with faldo:Position\n The feature locations leverage the Faldo model,\n which has a general structure like:\n Triples:\n feature_id a feat... |
Please provide a description of the function:def _makePositionId(self, reference, coordinate, types=None):
if reference is None:
LOG.error("Trying to make position with no reference.")
return None
curie = '_:'
reference = re.sub(r'\w+\:', '', reference, 1)
... | [
"\n Note that positions should have a reference (we will enforce).\n Only exact positions need a coordinate.\n :param reference:\n :param coordinate:\n :param types:\n :return:\n "
] |
Please provide a description of the function:def addPositionToGraph(
self, reference_id, position, position_types=None, strand=None):
pos_id = self._makePositionId(reference_id, position, position_types)
if position is not None:
self.graph.addTriple(
pos_... | [
"\n Add the positional information to the graph, following the faldo model.\n We assume that if the strand is None,\n we give it a generic \"Position\" only.\n Triples:\n my_position a (any of: faldo:(((Both|Plus|Minus)Strand)|Exact)Position)\n faldo:position Integer(numeri... |
Please provide a description of the function:def addSubsequenceOfFeature(self, parentid):
self.graph.addTriple(self.fid, self.globaltt['is subsequence of'], parentid)
# this should be expected to be done in reasoning not ETL
self.graph.addTriple(parentid, self.globaltt['has subsequence'... | [
"\n This will add reciprocal triples like:\n feature <is subsequence of> parent\n parent has_subsequence feature\n :param graph:\n :param parentid:\n\n :return:\n\n "
] |
Please provide a description of the function:def addTaxonToFeature(self, taxonid):
self.taxon = taxonid
self.graph.addTriple(self.fid, self.globaltt['in taxon'], self.taxon)
return | [
"\n Given the taxon id, this will add the following triple:\n feature in_taxon taxonid\n :param graph:\n :param taxonid:\n :return:\n "
] |
Please provide a description of the function:def add_supporting_evidence(self, evidence_line, evidence_type=None, label=None):
self.graph.addTriple(
self.association, self.globaltt['has_supporting_evidence_line'],
evidence_line)
if evidence_type is not None:
... | [
"\n Add supporting line of evidence node to association id\n\n :param evidence_line: curie or iri, evidence line\n :param evidence_type: curie or iri, evidence type if available\n :return: None\n "
] |
Please provide a description of the function:def add_data_individual(self, data_curie, label=None, ind_type=None):
part_length = len(data_curie.split(':'))
if part_length == 0:
curie = "_:{}".format(data_curie)
elif part_length > 2:
raise ValueError("Misformatted... | [
"\n Add data individual\n :param data_curie: str either curie formatted or long string,\n long strings will be converted to bnodes\n :param type: str curie\n :param label: str\n :return: None\n "
] |
Please provide a description of the function:def add_supporting_data(self, evidence_line, measurement_dict):
for measurement in measurement_dict:
self.graph.addTriple(
evidence_line, self.globaltt['has_evidence_item'], measurement)
self.graph.addTriple(
... | [
"\n Add supporting data\n :param evidence_line:\n :param data_object: dict, where keys are curies or iris\n and values are measurement values for example:\n {\n \"_:1234\" : \"1.53E07\"\n \"_:4567\": \"20.25\"\n }\n Note: assumes mea... |
Please provide a description of the function:def add_supporting_publication(
self, evidence_line, publication, label=None, pub_type=None):
self.graph.addTriple(
evidence_line, self.globaltt['evidence_has_supporting_reference'], publication)
self.model.addIndividualToGrap... | [
"\n <evidence> <evidence_has_supporting_reference> <source>\n <source> <rdf:type> <type>\n <source> <rdfs:label> \"label\"\n :param evidence_line: str curie\n :param publication: str curie\n :param label: optional, str type as curie\n :param type: optional, str type ... |
Please provide a description of the function:def add_source(self, evidence_line, source, label=None, src_type=None):
self.graph.addTriple(evidence_line, self.globaltt['source'], source)
self.model.addIndividualToGraph(source, label, src_type)
return | [
"\n Applies the triples:\n <evidence> <dc:source> <source>\n <source> <rdf:type> <type>\n <source> <rdfs:label> \"label\"\n\n TODO this should belong in a higher level class\n :param evidence_line: str curie\n :param source: str source as curie\n :param label:... |
Please provide a description of the function:def _process_phenotype_data(self, limit):
src_key = 'catalog'
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
model = Model(graph)
fname = '/'.join((self.rawdir, self.files[src_key][... | [
"\n NOTE: If a Strain carries more than one mutation,\n then each Mutation description,\n i.e., the set: (\n Mutation Type - Chromosome - Gene Symbol -\n Gene Name - Allele Symbol - Allele Name)\n will require a separate line.\n\n Note that MMRRC curates phen... |
Please provide a description of the function:def write(graph, fileformat=None, filename=None):
filewriter = None
if fileformat is None:
fileformat = 'turtle'
if filename is not None:
with open(filename, 'wb') as filewriter:
LOG.info("Writing tri... | [
"\n A basic graph writer (to stdout) for any of the sources.\n this will write raw triples in rdfxml, unless specified.\n to write turtle, specify format='turtle'\n an optional file can be supplied instead of stdout\n :return: None\n\n "
] |
Please provide a description of the function:def get_properties_from_graph(graph):
# collapse to single list
property_set = set()
for row in graph.predicates():
property_set.add(row)
return property_set | [
"\n Wrapper for RDFLib.graph.predicates() that returns a unique set\n :param graph: RDFLib.graph\n :return: set, set of properties\n "
] |
Please provide a description of the function:def _get_chrbands(self, limit, taxon):
if limit is None:
limit = sys.maxsize # practical limit anyway
model = Model(self.graph)
line_counter = 0
myfile = '/'.join((self.rawdir, self.files[taxon]['file']))
LOG.in... | [
"\n :param limit:\n :return:\n\n "
] |
Please provide a description of the function:def _create_genome_builds(self):
# TODO add more species
graph = self.graph
geno = Genotype(graph)
model = Model(graph)
LOG.info("Adding equivalent assembly identifiers")
for sp in self.species:
tax_id = ... | [
"\n Various resources will map variations to either UCSC (hg*)\n or to NCBI assemblies. Here we create the equivalences between them.\n Data taken from:\n https://genome.ucsc.edu/FAQ/FAQreleases.html#release1\n\n :return:\n\n "
] |
Please provide a description of the function:def add_association_to_graph(self):
Assoc.add_association_to_graph(self)
# make a blank stage
if self.start_stage_id or self.end_stage_id is not None:
stage_process_id = '-'.join((str(self.start_stage_id),
... | [
"\n Overrides Association by including bnode support\n\n The reified relationship between a genotype (or any genotype part)\n and a phenotype is decorated with some provenance information.\n This makes the assumption that\n both the genotype and phenotype are classes.\n\n ... |
Please provide a description of the function:def make_g2p_id(self):
attributes = [self.environment_id, self.start_stage_id, self.end_stage_id]
assoc_id = self.make_association_id(
self.definedby, self.entity_id, self.rel, self.phenotype_id, attributes)
return assoc_id | [
"\n Make an association id for phenotypic associations that is defined by:\n source of association +\n (Annot subject) +\n relationship +\n phenotype/disease +\n environment +\n start stage +\n end stage\n\n :return:\n\n "
] |
Please provide a description of the function:def _process_diseasegene(self, limit):
if self.test_mode:
graph = self.testgraph
else:
graph = self.graph
line_counter = 0
model = Model(graph)
myfile = '/'.join((self.rawdir, self.files['disease-gene... | [
"\n :param limit:\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)
rgd_file = '/'.join(
(self.rawdir, self.files['rat_gene2mammalian_phenotype']['file']))
# ontobio gafparser implemented ... | [
"\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):
model = Model(self.graph)
record['relation']['id'] = self.resolve("has phenotype")
# define the triple
gene = record['subject']['id']
relation = record['relation']['id']
phenotype =... | [
"\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 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...")
self._process_straininfo(limit)
# the following will provide us the hash-loo... | [
"\n MPD data is delivered in four separate csv files and one xml file,\n which we process iteratively and write out as\n one large graph.\n\n :param limit:\n :return:\n "
] |
Please provide a description of the function:def _process_strainmeans_file(self, limit):
LOG.info("Processing strain means ...")
line_counter = 0
raw = '/'.join((self.rawdir, self.files['strainmeans']['file']))
with gzip.open(raw, 'rb') as f:
f = io.TextIOWrapper(f)
... | [
"\n This will store the entire set of strain means in a hash.\n Not the most efficient representation,\n but easy access.\n We will loop through this later to then apply cutoffs\n and add associations\n :param limit:\n :return:\n\n "
] |
Please provide a description of the function:def _add_g2p_assoc(self, graph, strain_id, sex, assay_id, phenotypes, comment):
geno = Genotype(graph)
model = Model(graph)
eco_id = self.globaltt['experimental phenotypic evidence']
strain_label = self.idlabel_hash.get(strain_id)
... | [
"\n Create an association between a sex-specific strain id\n and each of the phenotypes.\n Here, we create a genotype from the strain,\n and a sex-specific genotype.\n Each of those genotypes are created as anonymous nodes.\n\n The evidence code is hardcoded to be:\n ... |
Please provide a description of the function:def build_measurement_description(row, localtt):
(measnum,
mpdsector,
projsym,
varname,
descrip,
units,
method,
intervention,
paneldesc,
datatype,
sextested,
nstrainste... | [
"\n As of 9/28/2017 intparm is no longer in the measurements.tsv\n if intparm is not None and intervention != \"\":\n description += \\\n \". This represents the [\" + intparm + \\\n \"] arm, using materials and methods that included [\" + \\\n m... |
Please provide a description of the function:def _add_assertion_provenance(
self,
assoc_id,
evidence_line_bnode
):
provenance_model = Provenance(self.graph)
model = Model(self.graph)
assertion_bnode = self.make_id(
"assertion{0}{1}".fo... | [
"\n Add assertion level provenance, currently always IMPC\n :param assoc_id:\n :param evidence_line_bnode:\n :return:\n "
] |
Please provide a description of the function:def _add_study_provenance(
self,
phenotyping_center,
colony,
project_fullname,
pipeline_name,
pipeline_stable_id,
procedure_stable_id,
procedure_name,
parameter_stable... | [
"\n :param phenotyping_center: str, from self.files['all']\n :param colony: str, from self.files['all']\n :param project_fullname: str, from self.files['all']\n :param pipeline_name: str, from self.files['all']\n :param pipeline_stable_id: str, from self.files['all']\n :par... |
Please provide a description of the function:def _add_evidence(
self,
assoc_id,
eco_id,
p_value,
percentage_change,
effect_size,
study_bnode
):
evidence_model = Evidence(self.graph, assoc_id)
provenance_mod... | [
"\n :param assoc_id: assoc curie used to reify a\n genotype to phenotype association, generated in _process_data()\n :param eco_id: eco_id as curie, hardcoded in _process_data()\n :param p_value: str, from self.files['all']\n :param percentage_change: str, from self.files['all']\n... |
Please provide a description of the function:def parse_checksum_file(self, file):
checksums = dict()
file_path = '/'.join((self.rawdir, file))
with open(file_path, 'rt') as tsvfile:
reader = csv.reader(tsvfile, delimiter=' ')
for row in reader:
(c... | [
"\n :param file\n :return dict\n\n "
] |
Please provide a description of the function:def compare_checksums(self):
is_match = True
reference_checksums = self.parse_checksum_file(
self.files['checksum']['file'])
for md5, file in reference_checksums.items():
if os.path.isfile('/'.join((self.rawdir, file))... | [
"\n test to see if fetched file matches checksum from ebi\n :return: True or False\n\n "
] |
Please provide a description of the function:def addClassToGraph(
self, class_id, label=None, class_type=None, description=None
):
assert class_id is not None
self.graph.addTriple(
class_id, self.globaltt['type'], self.globaltt['class'])
if label is not None... | [
"\n Any node added to the graph will get at least 3 triples:\n *(node, type, owl:Class) and\n *(node, label, literal(label))\n *if a type is added,\n then the node will be an OWL:subclassOf that the type\n *if a description is provided,\n it will also get add... |
Please provide a description of the function:def addDeprecatedClass(self, old_id, new_ids=None):
self.graph.addTriple(
old_id, self.globaltt['type'], self.globaltt['class'])
self._addReplacementIds(old_id, new_ids) | [
"\n Will mark the oldid as a deprecated class.\n if one newid is supplied, it will mark it as replaced by.\n if >1 newid is supplied, it will mark it with consider properties\n :param old_id: str - the class id to deprecate\n :param new_ids: list - the class list that is\n ... |
Please provide a description of the function:def addDeprecatedIndividual(self, old_id, new_ids=None):
self.graph.addTriple(
old_id, self.globaltt['type'], self.globaltt['named_individual'])
self._addReplacementIds(old_id, new_ids) | [
"\n Will mark the oldid as a deprecated individual.\n if one newid is supplied, it will mark it as replaced by.\n if >1 newid is supplied, it will mark it with consider properties\n :param g:\n :param oldid: the individual id to deprecate\n :param newids: the individual idl... |
Please provide a description of the function:def addSynonym(
self, class_id, synonym, synonym_type=None):
if synonym_type is None:
synonym_type = self.globaltt['has_exact_synonym']
if synonym is not None:
self.graph.addTriple(
class_id, syno... | [
"\n Add the synonym as a property of the class cid.\n Assume it is an exact synonym, unless otherwise specified\n :param g:\n :param cid: class id\n :param synonym: the literal synonym label\n :param synonym_type: the CURIE of the synonym type (not the URI)\n :return... |
Please provide a description of the function:def makeLeader(self, node_id):
self.graph.addTriple(
node_id, self.globaltt['clique_leader'], True, object_is_literal=True,
literal_type='xsd:boolean') | [
"\n Add an annotation property to the given ```node_id```\n to be the clique_leader.\n This is a monarchism.\n :param node_id:\n :return:\n "
] |
Please provide a description of the function:def _addSexSpecificity(self, subject_id, sex):
self.graph.addTriple(subject_id, self.globaltt['has_sex_specificty'], sex) | [
"\n Add sex specificity to a subject (eg association node)\n\n In our modeling we use this to add a qualifier to a triple\n for example, this genotype to phenotype association\n is specific to this sex (see MGI, IMPC)\n\n This expects the client to define the ontology term\n ... |
Please provide a description of the function:def main():
parser = argparse.ArgumentParser(usage=__doc__)
parser.add_argument('--config', '-c', required=True, help='JSON configuration file')
parser.add_argument('--out', '-o', required=False, help='output directory', default="./")
parser.add_argume... | [
"\n Zebrafish:\n 1. Map ENSP to ZFIN Ids using Intermine\n 2. Map deprecated ENSP IDs to ensembl genes\n by querying the ensembl database then use\n intermine to resolve to gene IDs\n Mouse: Map deprecated ENSP IDs to ensembl genes\n by querying the ensembl database... |
Please provide a description of the function:def query_mousemine(intermine_url: str, gene_id: str) -> IntermineResult:
service = Service(intermine_url)
query = service.new_query("SequenceFeature")
query.add_view("primaryIdentifier")
query.add_constraint("SequenceFeature", "LOOKUP", "{}".format(gene... | [
"\n :param intermine_url: intermine server, eg\n http://www.mousemine.org/mousemine/service\n :param gene_id: gene ID, eg ENSMUSG00000063180\n :return: Intermine_Result object\n "
] |
Please provide a description of the function:def fetch_protein_list(self, taxon_id):
protein_list = list()
# col = self.columns['ensembl_biomart']
col = ['ensembl_peptide_id', ]
params = urllib.parse.urlencode(
{'query': self._build_biomart_gene_query(taxon_id, col)... | [
"\n Fetch a list of proteins for a species in biomart\n :param taxid:\n :return: list\n "
] |
Please provide a description of the function:def fetch_protein_gene_map(self, taxon_id):
protein_dict = dict()
# col = self.columns['ensembl_biomart']
col = ['ensembl_peptide_id', 'ensembl_gene_id']
raw_query = self._build_biomart_gene_query(taxon_id, col)
params = urll... | [
"\n Fetch a list of proteins for a species in biomart\n :param taxid:\n :return: dict\n "
] |
Please provide a description of the function:def _build_biomart_gene_query(self, taxid, cols_to_fetch):
taxid = str(taxid)
# basic stuff for ensembl ids.
if taxid != '9606': # drop hgnc column
cols_to_fetch = [x for x in cols_to_fetch if x != 'hgnc_id']
# LOG.inf... | [
"\n Building url to fetch equivalent identifiers via Biomart Restful API.\n Documentation at\n http://uswest.ensembl.org/info/data/biomart/biomart_restful.html\n :param taxid:\n :param array of ensembl biomart attributes to include\n :return:\n\n "
] |
Please provide a description of the function:def fetch(self, is_dl_forced=False):
self.get_files(is_dl_forced)
# load and tag a list of OMIM IDs with types
self.omim_type = self.find_omim_type()
return | [
"\n We fetch GeneReviews id-label map and id-omim mapping files from NCBI.\n :return: None\n "
] |
Please provide a description of the function:def parse(self, limit=None):
if self.test_only:
self.test_mode = True
self._get_titles(limit)
self._get_equivids(limit)
self.create_books()
self.process_nbk_html(limit)
# no test subset for now; test ==... | [
"\n :return: None\n "
] |
Please provide a description of the function:def _get_equivids(self, limit):
raw = '/'.join((self.rawdir, self.files['idmap']['file']))
model = Model(self.graph)
LOG.info('Looping over %s', raw)
# we look some stuff up in OMIM, so initialize here
# omim = OMIM(self.graph... | [
"\n The file processed here is of the format:\n #NBK_id GR_shortname OMIM\n NBK1103 trimethylaminuria 136132\n NBK1103 trimethylaminuria 602079\n NBK1104 cdls 122470\n Where each of the rows represents a mapping between\n a gr id and an omim id. The... |
Please provide a description of the function:def _get_titles(self, limit):
raw = '/'.join((self.rawdir, self.files['titles']['file']))
model = Model(self.graph)
col = ['GR_shortname', 'GR_Title', 'NBK_id', 'PMID']
with open(raw, 'r', encoding='latin-1') as csvfile:
... | [
"\n The file processed here is of the format:\n #NBK_id GR_shortname OMIM\n NBK1103 trimethylaminuria 136132\n NBK1103 trimethylaminuria 602079\n NBK1104 cdls 122470\n Where each of the rows represents a mapping between\n a gr id and an omim id. The... |
Please provide a description of the function:def process_nbk_html(self, limit):
model = Model(self.graph)
cnt = 0
books_not_found = set()
clin_des_regx = re.compile(r".*Summary.sec0")
lit_cite_regex = re.compile(r".*Literature_Cited")
pubmed_regex = re.compile(r... | [
"\n Here we process the gene reviews books to fetch\n the clinical descriptions to include in the ontology.\n We only use books that have been acquired manually,\n as NCBI Bookshelf does not permit automated downloads.\n This parser will only process the books that are found in\n ... |
Please provide a description of the function:def find_omim_type(self):
'''
This f(x) needs to be rehomed and shared.
Use OMIM's discription of their identifiers
to heuristically partition them into genes | phenotypes-diseases
type could be
- `obsolete` Check `omim_re... | [] |
Please provide a description of the function:def addPathway(
self, pathway_id, pathway_label, pathway_type=None,
pathway_description=None):
if pathway_type is None:
pathway_type = self.globaltt['cellular_process']
self.model.addClassToGraph(
path... | [
"\n Adds a pathway as a class. If no specific type is specified, it will\n default to a subclass of \"GO:cellular_process\" and \"PW:pathway\".\n :param pathway_id:\n :param pathway_label:\n :param pathway_type:\n :param pathway_description:\n :return:\n "
] |
Please provide a description of the function:def addGeneToPathway(self, gene_id, pathway_id):
gene_product = '_:'+re.sub(r':', '', gene_id) + 'product'
self.model.addIndividualToGraph(
gene_product, None, self.globaltt['gene_product'])
self.graph.addTriple(
gene... | [
"\n When adding a gene to a pathway, we create an intermediate\n 'gene product' that is involved in\n the pathway, through a blank node.\n\n gene_id RO:has_gene_product _gene_product\n _gene_product RO:involved_in pathway_id\n\n :param pathway_id:\n :param gene_id:\n... |
Please provide a description of the function:def addComponentToPathway(self, component_id, pathway_id):
self.graph.addTriple(component_id, self.globaltt['involved in'], pathway_id)
return | [
"\n This can be used directly when the component is directly involved in\n the pathway. If a transforming event is performed on the component\n first, then the addGeneToPathway should be used instead.\n\n :param pathway_id:\n :param component_id:\n :return:\n "
] |
Please provide a description of the function:def fetch(self, is_dl_forced=False):
dir_path = Path(self.rawdir)
aeolus_file = dir_path / self.files['aeolus']['file']
if self.checkIfRemoteIsNewer(aeolus_file):
aeolis_fh = aeolus_file.open('w')
aeolis_fh.write("[\n"... | [
"\n Note there is a unpublished mydrug client that works like this:\n from mydrug import MyDrugInfo\n md = MyDrugInfo()\n r = list(md.query('_exists_:aeolus', fetch_all=True))\n\n :param is_dl_forced: boolean, force download\n :return:\n "
] |
Please provide a description of the function:def parse(self, limit=None, or_limit=1):
dir_path = Path(self.rawdir)
aeolus_file = dir_path / self.files['aeolus']['file']
aeolus_fh = aeolus_file.open('r')
count = 0
for line in aeolus_fh.readlines():
if limit is... | [
"\n Parse mydrug files\n :param limit: int limit json docs processed\n :param or_limit: int odds ratio limit\n :return: None\n "
] |
Please provide a description of the function:def _add_outcome_provenance(self, association, outcome):
provenance = Provenance(self.graph)
base = self.curie_map.get_base()
provenance.add_agent_to_graph(base, 'Monarch Initiative')
self.graph.addTriple(association, self.globaltt['... | [
"\n :param association: str association curie\n :param outcome: dict (json)\n :return: None\n "
] |
Please provide a description of the function:def _add_outcome_evidence(self, association, outcome):
evidence = Evidence(self.graph, association)
source = {
'curie': "DOI:10.5061/dryad.8q0s4/1",
'label': "Data from: A curated and standardized adverse "
... | [
"\n :param association: str association curie\n :param outcome: dict (json)\n :return: None\n "
] |
Please provide a description of the function:def checkIfRemoteIsNewer(self, localfile):
is_remote_newer = False
if localfile.exists() and localfile.stat().st_size > 0:
LOG.info("File exists locally, using cache")
else:
is_remote_newer = True
LOG.info(... | [
"\n Need to figure out how biothings records releases,\n for now if the file exists we will assume it is\n a fully downloaded cache\n :param localfile: str file path\n :return: boolean True if remote file is newer else False\n "
] |
Please provide a description of the function:def write(self, fmt='turtle', stream=None):
fmt_ext = {
'rdfxml': 'xml',
'turtle': 'ttl',
'nt': 'nt', # ntriples
'nquads': 'nq',
'n3': 'n3' # notation3
}
# make th... | [
"\n This convenience method will write out all of the graphs\n associated with the source.\n Right now these are hardcoded to be a single \"graph\"\n and a \"src_dataset.ttl\" and a \"src_test.ttl\"\n If you do not supply stream='stdout'\n it will default write these to fil... |
Please provide a description of the function:def checkIfRemoteIsNewer(self, remote, local, headers):
LOG.info(
"Checking if remote file \n(%s)\n is newer than local \n(%s)",
remote, local)
# check if local file exists
# if no local file, then remote is newer
... | [
"\n Given a remote file location, and the corresponding local file\n this will check the datetime stamp on the files to see if the remote\n one is newer.\n This is a convenience method to be used so that we don't have to\n re-fetch files that we already have saved locally\n ... |
Please provide a description of the function:def get_files(self, is_dl_forced, files=None):
fstat = None
if files is None:
files = self.files
for fname in files:
LOG.info("Getting %s", fname)
headers = None
filesource = files[fname]
... | [
"\n Given a set of files for this source, it will go fetch them, and\n set a default version by date. If you need to set the version number\n by another method, then it can be set again.\n :param is_dl_forced - boolean\n :param files dict - override instance files dict\n :... |
Please provide a description of the function:def fetch_from_url(
self, remotefile, localfile=None, is_dl_forced=False, headers=None):
# The 'file' dict in the ingest script is where 'headers' may be found
# e.g. OMIM.py has: 'headers': {'User-Agent': 'Mozilla/5.0'}
respon... | [
"\n Given a remote url and a local filename, attempt to determine\n if the remote file is newer; if it is,\n fetch the remote file and save it to the specified localfile,\n reporting the basic file information once it is downloaded\n :param remotefile: URL of remote file to fetch\... |
Please provide a description of the function:def process_xml_table(self, elem, table_name, processing_function, limit):
line_counter = 0
table_data = elem.find("[@name='" + table_name + "']")
if table_data is not None:
LOG.info("Processing " + table_name)
row = ... | [
"\n This is a convenience function to process the elements of an xml dump of\n a mysql relational database.\n The \"elem\" is akin to a mysql table, with it's name of ```table_name```.\n It will process each ```row``` given the ```processing_function``` supplied.\n :param elem: Th... |
Please provide a description of the function:def _check_list_len(row, length):
if len(row) != length:
raise Exception(
"row length does not match expected length of " +
str(length) + "\nrow: " + str(row)) | [
"\n Sanity check for csv parser\n :param row\n :param length\n :return:None\n "
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.