repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
tgbugs/pyontutils | ilxutils/ilxutils/simple_scicrunch_client.py | Client.search_by_label | def search_by_label(self, label):
''' Server returns anything that is simlar in any catagory '''
url_base = self.base_path + 'term/search/{term}?key={api_key}'
url = url_base.format(term=label, api_key=self.APIKEY)
return self.get(url) | python | def search_by_label(self, label):
''' Server returns anything that is simlar in any catagory '''
url_base = self.base_path + 'term/search/{term}?key={api_key}'
url = url_base.format(term=label, api_key=self.APIKEY)
return self.get(url) | [
"def",
"search_by_label",
"(",
"self",
",",
"label",
")",
":",
"url_base",
"=",
"self",
".",
"base_path",
"+",
"'term/search/{term}?key={api_key}'",
"url",
"=",
"url_base",
".",
"format",
"(",
"term",
"=",
"label",
",",
"api_key",
"=",
"self",
".",
"APIKEY",... | Server returns anything that is simlar in any catagory | [
"Server",
"returns",
"anything",
"that",
"is",
"simlar",
"in",
"any",
"catagory"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_scicrunch_client.py#L162-L166 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_scicrunch_client.py | Client.are_ilx | def are_ilx(self, ilx_ids):
''' Checks list of objects to see if they are usable ILX IDs '''
total_data = []
for ilx_id in ilx_ids:
ilx_id = ilx_id.replace('http', '').replace('.', '').replace('/', '')
data, success = self.get_data_from_ilx(ilx_id)
if success:... | python | def are_ilx(self, ilx_ids):
''' Checks list of objects to see if they are usable ILX IDs '''
total_data = []
for ilx_id in ilx_ids:
ilx_id = ilx_id.replace('http', '').replace('.', '').replace('/', '')
data, success = self.get_data_from_ilx(ilx_id)
if success:... | [
"def",
"are_ilx",
"(",
"self",
",",
"ilx_ids",
")",
":",
"total_data",
"=",
"[",
"]",
"for",
"ilx_id",
"in",
"ilx_ids",
":",
"ilx_id",
"=",
"ilx_id",
".",
"replace",
"(",
"'http'",
",",
"''",
")",
".",
"replace",
"(",
"'.'",
",",
"''",
")",
".",
... | Checks list of objects to see if they are usable ILX IDs | [
"Checks",
"list",
"of",
"objects",
"to",
"see",
"if",
"they",
"are",
"usable",
"ILX",
"IDs"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_scicrunch_client.py#L168-L178 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_scicrunch_client.py | Client.add_triple | def add_triple(self, subj, pred, obj):
''' Adds an entity property to an existing entity '''
subj_data, pred_data, obj_data = self.are_ilx([subj, pred, obj])
# RELATIONSHIP PROPERTY
if subj_data.get('id') and pred_data.get('id') and obj_data.get('id'):
if pred_data['type'] !=... | python | def add_triple(self, subj, pred, obj):
''' Adds an entity property to an existing entity '''
subj_data, pred_data, obj_data = self.are_ilx([subj, pred, obj])
# RELATIONSHIP PROPERTY
if subj_data.get('id') and pred_data.get('id') and obj_data.get('id'):
if pred_data['type'] !=... | [
"def",
"add_triple",
"(",
"self",
",",
"subj",
",",
"pred",
",",
"obj",
")",
":",
"subj_data",
",",
"pred_data",
",",
"obj_data",
"=",
"self",
".",
"are_ilx",
"(",
"[",
"subj",
",",
"pred",
",",
"obj",
"]",
")",
"# RELATIONSHIP PROPERTY",
"if",
"subj_d... | Adds an entity property to an existing entity | [
"Adds",
"an",
"entity",
"property",
"to",
"an",
"existing",
"entity"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_scicrunch_client.py#L180-L214 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_scicrunch_client.py | Client.add_relationship | def add_relationship(self, term1, relationship, term2):
''' Creates a relationship between 3 entities in database '''
url = self.base_path + 'term/add-relationship'
data = {'term1_id': term1['id'],
'relationship_tid': relationship['id'],
'term2_id': term2['id'],
... | python | def add_relationship(self, term1, relationship, term2):
''' Creates a relationship between 3 entities in database '''
url = self.base_path + 'term/add-relationship'
data = {'term1_id': term1['id'],
'relationship_tid': relationship['id'],
'term2_id': term2['id'],
... | [
"def",
"add_relationship",
"(",
"self",
",",
"term1",
",",
"relationship",
",",
"term2",
")",
":",
"url",
"=",
"self",
".",
"base_path",
"+",
"'term/add-relationship'",
"data",
"=",
"{",
"'term1_id'",
":",
"term1",
"[",
"'id'",
"]",
",",
"'relationship_tid'"... | Creates a relationship between 3 entities in database | [
"Creates",
"a",
"relationship",
"between",
"3",
"entities",
"in",
"database"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_scicrunch_client.py#L216-L225 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_scicrunch_client.py | Client.add_annotation | def add_annotation(self, entity, annotation, value):
''' Adds an annotation proprty to existing entity '''
url = self.base_path + 'term/add-annotation'
data = {'tid': entity['id'],
'annotation_tid': annotation['id'],
'value': value,
'term_version':... | python | def add_annotation(self, entity, annotation, value):
''' Adds an annotation proprty to existing entity '''
url = self.base_path + 'term/add-annotation'
data = {'tid': entity['id'],
'annotation_tid': annotation['id'],
'value': value,
'term_version':... | [
"def",
"add_annotation",
"(",
"self",
",",
"entity",
",",
"annotation",
",",
"value",
")",
":",
"url",
"=",
"self",
".",
"base_path",
"+",
"'term/add-annotation'",
"data",
"=",
"{",
"'tid'",
":",
"entity",
"[",
"'id'",
"]",
",",
"'annotation_tid'",
":",
... | Adds an annotation proprty to existing entity | [
"Adds",
"an",
"annotation",
"proprty",
"to",
"existing",
"entity"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_scicrunch_client.py#L227-L235 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_scicrunch_client.py | Client.custom_update | def custom_update(self, data, pred, obj):
''' Updates existing entity proprty based on the predicate input '''
if isinstance(data[pred], str): # for all simple properties of str value
data[pred] = str(obj)
else: # synonyms, superclasses, and existing_ids have special requirements
... | python | def custom_update(self, data, pred, obj):
''' Updates existing entity proprty based on the predicate input '''
if isinstance(data[pred], str): # for all simple properties of str value
data[pred] = str(obj)
else: # synonyms, superclasses, and existing_ids have special requirements
... | [
"def",
"custom_update",
"(",
"self",
",",
"data",
",",
"pred",
",",
"obj",
")",
":",
"if",
"isinstance",
"(",
"data",
"[",
"pred",
"]",
",",
"str",
")",
":",
"# for all simple properties of str value",
"data",
"[",
"pred",
"]",
"=",
"str",
"(",
"obj",
... | Updates existing entity proprty based on the predicate input | [
"Updates",
"existing",
"entity",
"proprty",
"based",
"on",
"the",
"predicate",
"input"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_scicrunch_client.py#L237-L274 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_scicrunch_client.py | Client.add_entity | def add_entity(self, rdf_type, superclass, label, definition=None):
''' Adds entity as long as it doesn't exist and has a usable
superclass ILX ID and rdf:type
'''
# Checks if you inputed the right type
rdf_type = rdf_type.lower().strip().replace('owl:Class', 'term')
... | python | def add_entity(self, rdf_type, superclass, label, definition=None):
''' Adds entity as long as it doesn't exist and has a usable
superclass ILX ID and rdf:type
'''
# Checks if you inputed the right type
rdf_type = rdf_type.lower().strip().replace('owl:Class', 'term')
... | [
"def",
"add_entity",
"(",
"self",
",",
"rdf_type",
",",
"superclass",
",",
"label",
",",
"definition",
"=",
"None",
")",
":",
"# Checks if you inputed the right type",
"rdf_type",
"=",
"rdf_type",
".",
"lower",
"(",
")",
".",
"strip",
"(",
")",
".",
"replace... | Adds entity as long as it doesn't exist and has a usable
superclass ILX ID and rdf:type | [
"Adds",
"entity",
"as",
"long",
"as",
"it",
"doesn",
"t",
"exist",
"and",
"has",
"a",
"usable",
"superclass",
"ILX",
"ID",
"and",
"rdf",
":",
"type"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_scicrunch_client.py#L331-L408 |
tgbugs/pyontutils | ttlser/ttlser/serializers.py | CustomTurtleSerializer.sortProperties | def sortProperties(self, properties): # modified to sort objects using their global rank
"""Take a hash from predicate uris to lists of values.
Sort the lists of values. Return a sorted list of properties."""
# Sort object lists
for prop, objects in properties.items():
o... | python | def sortProperties(self, properties): # modified to sort objects using their global rank
"""Take a hash from predicate uris to lists of values.
Sort the lists of values. Return a sorted list of properties."""
# Sort object lists
for prop, objects in properties.items():
o... | [
"def",
"sortProperties",
"(",
"self",
",",
"properties",
")",
":",
"# modified to sort objects using their global rank",
"# Sort object lists",
"for",
"prop",
",",
"objects",
"in",
"properties",
".",
"items",
"(",
")",
":",
"objects",
".",
"sort",
"(",
"key",
"=",... | Take a hash from predicate uris to lists of values.
Sort the lists of values. Return a sorted list of properties. | [
"Take",
"a",
"hash",
"from",
"predicate",
"uris",
"to",
"lists",
"of",
"values",
".",
"Sort",
"the",
"lists",
"of",
"values",
".",
"Return",
"a",
"sorted",
"list",
"of",
"properties",
"."
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ttlser/ttlser/serializers.py#L561-L569 |
tgbugs/pyontutils | ttlser/ttlser/serializers.py | CustomTurtleSerializer._buildPredicateHash | def _buildPredicateHash(self, subject): # XXX unmodified
"""
Build a hash key by predicate to a list of objects for the given
subject
"""
properties = {}
for s, p, o in self.store.triples((subject, None, None)):
oList = properties.get(p, [])
oList... | python | def _buildPredicateHash(self, subject): # XXX unmodified
"""
Build a hash key by predicate to a list of objects for the given
subject
"""
properties = {}
for s, p, o in self.store.triples((subject, None, None)):
oList = properties.get(p, [])
oList... | [
"def",
"_buildPredicateHash",
"(",
"self",
",",
"subject",
")",
":",
"# XXX unmodified",
"properties",
"=",
"{",
"}",
"for",
"s",
",",
"p",
",",
"o",
"in",
"self",
".",
"store",
".",
"triples",
"(",
"(",
"subject",
",",
"None",
",",
"None",
")",
")",... | Build a hash key by predicate to a list of objects for the given
subject | [
"Build",
"a",
"hash",
"key",
"by",
"predicate",
"to",
"a",
"list",
"of",
"objects",
"for",
"the",
"given",
"subject"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ttlser/ttlser/serializers.py#L571-L582 |
tgbugs/pyontutils | ttlser/ttlser/serializers.py | CustomTurtleSerializer.isValidList | def isValidList(self, l): # modified to flatten lists specified using [ a rdf:List; ] syntax
"""
Checks if l is a valid RDF list, i.e. no nodes have other properties.
"""
try:
if self.store.value(l, RDF.first) is None:
return False
except:
... | python | def isValidList(self, l): # modified to flatten lists specified using [ a rdf:List; ] syntax
"""
Checks if l is a valid RDF list, i.e. no nodes have other properties.
"""
try:
if self.store.value(l, RDF.first) is None:
return False
except:
... | [
"def",
"isValidList",
"(",
"self",
",",
"l",
")",
":",
"# modified to flatten lists specified using [ a rdf:List; ] syntax",
"try",
":",
"if",
"self",
".",
"store",
".",
"value",
"(",
"l",
",",
"RDF",
".",
"first",
")",
"is",
"None",
":",
"return",
"False",
... | Checks if l is a valid RDF list, i.e. no nodes have other properties. | [
"Checks",
"if",
"l",
"is",
"a",
"valid",
"RDF",
"list",
"i",
".",
"e",
".",
"no",
"nodes",
"have",
"other",
"properties",
"."
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ttlser/ttlser/serializers.py#L620-L637 |
tgbugs/pyontutils | ttlser/ttlser/serializers.py | CustomTurtleSerializer._write | def _write(self, value):
""" rename to write and import inspect to debut the callstack """
if ' ' in value:
s = inspect.stack()
fn = s[1].function
super().write('%%DEBUG {} %%'.format(fn))
super().write(value) | python | def _write(self, value):
""" rename to write and import inspect to debut the callstack """
if ' ' in value:
s = inspect.stack()
fn = s[1].function
super().write('%%DEBUG {} %%'.format(fn))
super().write(value) | [
"def",
"_write",
"(",
"self",
",",
"value",
")",
":",
"if",
"' '",
"in",
"value",
":",
"s",
"=",
"inspect",
".",
"stack",
"(",
")",
"fn",
"=",
"s",
"[",
"1",
"]",
".",
"function",
"super",
"(",
")",
".",
"write",
"(",
"'%%DEBUG {} %%'",
".",
"f... | rename to write and import inspect to debut the callstack | [
"rename",
"to",
"write",
"and",
"import",
"inspect",
"to",
"debut",
"the",
"callstack"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ttlser/ttlser/serializers.py#L737-L743 |
tgbugs/pyontutils | ttlser/ttlser/serializers.py | HtmlTurtleSerializer.serialize | def serialize(self, *args, **kwargs):
""" Modified to allow additional labels to be passed in. """
if 'labels' in kwargs:
# populate labels from outside the local graph
self._labels.update(kwargs['labels'])
super(HtmlTurtleSerializer, self).serialize(*args, **kwargs) | python | def serialize(self, *args, **kwargs):
""" Modified to allow additional labels to be passed in. """
if 'labels' in kwargs:
# populate labels from outside the local graph
self._labels.update(kwargs['labels'])
super(HtmlTurtleSerializer, self).serialize(*args, **kwargs) | [
"def",
"serialize",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'labels'",
"in",
"kwargs",
":",
"# populate labels from outside the local graph",
"self",
".",
"_labels",
".",
"update",
"(",
"kwargs",
"[",
"'labels'",
"]",
")",
... | Modified to allow additional labels to be passed in. | [
"Modified",
"to",
"allow",
"additional",
"labels",
"to",
"be",
"passed",
"in",
"."
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ttlser/ttlser/serializers.py#L818-L823 |
tgbugs/pyontutils | neurondm/neurondm/core.py | checkCalledInside | def checkCalledInside(classname, stack):
""" Fantastically inefficient! """
ok = False
for s in stack[1:]:
cc = s.code_context[0]
if 'class' in cc:
if '(' in cc:
bases = [b.strip() for b in cc.split('(')[1].split(')')[0].split(',')]
for base_name i... | python | def checkCalledInside(classname, stack):
""" Fantastically inefficient! """
ok = False
for s in stack[1:]:
cc = s.code_context[0]
if 'class' in cc:
if '(' in cc:
bases = [b.strip() for b in cc.split('(')[1].split(')')[0].split(',')]
for base_name i... | [
"def",
"checkCalledInside",
"(",
"classname",
",",
"stack",
")",
":",
"ok",
"=",
"False",
"for",
"s",
"in",
"stack",
"[",
"1",
":",
"]",
":",
"cc",
"=",
"s",
".",
"code_context",
"[",
"0",
"]",
"if",
"'class'",
"in",
"cc",
":",
"if",
"'('",
"in",... | Fantastically inefficient! | [
"Fantastically",
"inefficient!"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/neurondm/neurondm/core.py#L2424-L2445 |
tgbugs/pyontutils | neurondm/neurondm/core.py | addLNT | def addLNT(LocalName, phenoId, predicate, g=None): # XXX deprecated
""" Add a local name for a phenotype from a pair of identifiers """
if g is None:
s = inspect.stack(0) # horribly inefficient
checkCalledInside('LocalNameManager', s)
g = s[1][0].f_locals # get globals of calling scop... | python | def addLNT(LocalName, phenoId, predicate, g=None): # XXX deprecated
""" Add a local name for a phenotype from a pair of identifiers """
if g is None:
s = inspect.stack(0) # horribly inefficient
checkCalledInside('LocalNameManager', s)
g = s[1][0].f_locals # get globals of calling scop... | [
"def",
"addLNT",
"(",
"LocalName",
",",
"phenoId",
",",
"predicate",
",",
"g",
"=",
"None",
")",
":",
"# XXX deprecated",
"if",
"g",
"is",
"None",
":",
"s",
"=",
"inspect",
".",
"stack",
"(",
"0",
")",
"# horribly inefficient",
"checkCalledInside",
"(",
... | Add a local name for a phenotype from a pair of identifiers | [
"Add",
"a",
"local",
"name",
"for",
"a",
"phenotype",
"from",
"a",
"pair",
"of",
"identifiers"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/neurondm/neurondm/core.py#L2468-L2474 |
tgbugs/pyontutils | neurondm/neurondm/core.py | resetLocalNames | def resetLocalNames(g=None):
""" WARNING: Only call from top level! THIS DOES NOT RESET NAMES in an embeded IPython!!!
Remove any local names that have already been defined. """
if g is None:
g = inspect.stack(0)[1][0].f_locals # get globals of calling scope
for k in list(graphBase.LocalNa... | python | def resetLocalNames(g=None):
""" WARNING: Only call from top level! THIS DOES NOT RESET NAMES in an embeded IPython!!!
Remove any local names that have already been defined. """
if g is None:
g = inspect.stack(0)[1][0].f_locals # get globals of calling scope
for k in list(graphBase.LocalNa... | [
"def",
"resetLocalNames",
"(",
"g",
"=",
"None",
")",
":",
"if",
"g",
"is",
"None",
":",
"g",
"=",
"inspect",
".",
"stack",
"(",
"0",
")",
"[",
"1",
"]",
"[",
"0",
"]",
".",
"f_locals",
"# get globals of calling scope",
"for",
"k",
"in",
"list",
"... | WARNING: Only call from top level! THIS DOES NOT RESET NAMES in an embeded IPython!!!
Remove any local names that have already been defined. | [
"WARNING",
":",
"Only",
"call",
"from",
"top",
"level!",
"THIS",
"DOES",
"NOT",
"RESET",
"NAMES",
"in",
"an",
"embeded",
"IPython!!!",
"Remove",
"any",
"local",
"names",
"that",
"have",
"already",
"been",
"defined",
"."
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/neurondm/neurondm/core.py#L2491-L2501 |
tgbugs/pyontutils | neurondm/neurondm/core.py | Config.load_existing | def load_existing(self):
""" advanced usage allows loading multiple sets of neurons and using a config
object to keep track of the different graphs """
from pyontutils.closed_namespaces import rdfs
# bag existing
try:
next(iter(self.neurons()))
raise ... | python | def load_existing(self):
""" advanced usage allows loading multiple sets of neurons and using a config
object to keep track of the different graphs """
from pyontutils.closed_namespaces import rdfs
# bag existing
try:
next(iter(self.neurons()))
raise ... | [
"def",
"load_existing",
"(",
"self",
")",
":",
"from",
"pyontutils",
".",
"closed_namespaces",
"import",
"rdfs",
"# bag existing",
"try",
":",
"next",
"(",
"iter",
"(",
"self",
".",
"neurons",
"(",
")",
")",
")",
"raise",
"self",
".",
"ExistingNeuronsError",... | advanced usage allows loading multiple sets of neurons and using a config
object to keep track of the different graphs | [
"advanced",
"usage",
"allows",
"loading",
"multiple",
"sets",
"of",
"neurons",
"and",
"using",
"a",
"config",
"object",
"to",
"keep",
"track",
"of",
"the",
"different",
"graphs"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/neurondm/neurondm/core.py#L583-L636 |
tgbugs/pyontutils | neurondm/neurondm/core.py | graphBase.configGraphIO | def configGraphIO(remote_base,
local_base= None,
branch= 'master',
core_graph_paths= tuple(),
core_graph= None,
in_graph_paths= tuple(),
out_graph_path= Non... | python | def configGraphIO(remote_base,
local_base= None,
branch= 'master',
core_graph_paths= tuple(),
core_graph= None,
in_graph_paths= tuple(),
out_graph_path= Non... | [
"def",
"configGraphIO",
"(",
"remote_base",
",",
"local_base",
"=",
"None",
",",
"branch",
"=",
"'master'",
",",
"core_graph_paths",
"=",
"tuple",
"(",
")",
",",
"core_graph",
"=",
"None",
",",
"in_graph_paths",
"=",
"tuple",
"(",
")",
",",
"out_graph_path",... | We set this up to work this way because we can't
instantiate graphBase, it is a super class that needs
to be configurable and it needs to do so globally.
All the default values here are examples and not real.
You should write a local `def config` function as part
... | [
"We",
"set",
"this",
"up",
"to",
"work",
"this",
"way",
"because",
"we",
"can",
"t",
"instantiate",
"graphBase",
"it",
"is",
"a",
"super",
"class",
"that",
"needs",
"to",
"be",
"configurable",
"and",
"it",
"needs",
"to",
"do",
"so",
"globally",
".",
"A... | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/neurondm/neurondm/core.py#L765-L991 |
tgbugs/pyontutils | neurondm/neurondm/core.py | graphBase.python_header | def python_header(cls):
out = '#!/usr/bin/env python3.6\n'
out += f'from {cls.__import_name__} import *\n\n'
all_types = set(type(n) for n in cls.neurons())
_subs = [inspect.getsource(c) for c in subclasses(Neuron)
if c in all_types and Path(inspect.getfile(c)).exists()... | python | def python_header(cls):
out = '#!/usr/bin/env python3.6\n'
out += f'from {cls.__import_name__} import *\n\n'
all_types = set(type(n) for n in cls.neurons())
_subs = [inspect.getsource(c) for c in subclasses(Neuron)
if c in all_types and Path(inspect.getfile(c)).exists()... | [
"def",
"python_header",
"(",
"cls",
")",
":",
"out",
"=",
"'#!/usr/bin/env python3.6\\n'",
"out",
"+=",
"f'from {cls.__import_name__} import *\\n\\n'",
"all_types",
"=",
"set",
"(",
"type",
"(",
"n",
")",
"for",
"n",
"in",
"cls",
".",
"neurons",
"(",
")",
")",... | }} | [
"}}"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/neurondm/neurondm/core.py#L1018-L1047 |
tgbugs/pyontutils | neurondm/neurondm/core.py | graphBase.equivalentClass | def equivalentClass(self, *others):
""" as implemented this acts as a permenant bag union operator
and therefore should be used with extreme caution since
in any given context the computed label/identifier will
no longer reflect the entailed/reasoned bag
In a sta... | python | def equivalentClass(self, *others):
""" as implemented this acts as a permenant bag union operator
and therefore should be used with extreme caution since
in any given context the computed label/identifier will
no longer reflect the entailed/reasoned bag
In a sta... | [
"def",
"equivalentClass",
"(",
"self",
",",
"*",
"others",
")",
":",
"# FIXME this makes the data model mutable!",
"# TODO symmetry here",
"# serious modelling issue",
"# If you make two bags equivalent to eachother",
"# then in the set theory model it becomes impossible",
"# to have a s... | as implemented this acts as a permenant bag union operator
and therefore should be used with extreme caution since
in any given context the computed label/identifier will
no longer reflect the entailed/reasoned bag
In a static context this means that we might want to hav... | [
"as",
"implemented",
"this",
"acts",
"as",
"a",
"permenant",
"bag",
"union",
"operator",
"and",
"therefore",
"should",
"be",
"used",
"with",
"extreme",
"caution",
"since",
"in",
"any",
"given",
"context",
"the",
"computed",
"label",
"/",
"identifier",
"will",
... | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/neurondm/neurondm/core.py#L1084-L1111 |
tgbugs/pyontutils | neurondm/neurondm/core.py | graphBase.label_maker | def label_maker(self):
""" needed to defer loading of local conventions to avoid circular dependency issue """
if (not hasattr(graphBase, '_label_maker') or
graphBase._label_maker.local_conventions != graphBase.local_conventions):
graphBase._label_maker = LabelMaker(graphBase.loc... | python | def label_maker(self):
""" needed to defer loading of local conventions to avoid circular dependency issue """
if (not hasattr(graphBase, '_label_maker') or
graphBase._label_maker.local_conventions != graphBase.local_conventions):
graphBase._label_maker = LabelMaker(graphBase.loc... | [
"def",
"label_maker",
"(",
"self",
")",
":",
"if",
"(",
"not",
"hasattr",
"(",
"graphBase",
",",
"'_label_maker'",
")",
"or",
"graphBase",
".",
"_label_maker",
".",
"local_conventions",
"!=",
"graphBase",
".",
"local_conventions",
")",
":",
"graphBase",
".",
... | needed to defer loading of local conventions to avoid circular dependency issue | [
"needed",
"to",
"defer",
"loading",
"of",
"local",
"conventions",
"to",
"avoid",
"circular",
"dependency",
"issue"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/neurondm/neurondm/core.py#L1123-L1129 |
tgbugs/pyontutils | neurondm/neurondm/core.py | Neuron._graphify | def _graphify(self, *args, graph=None): # defined
""" Lift phenotypeEdges to Restrictions """
if graph is None:
graph = self.out_graph
################## LABELS ARE DEFINED HERE ##################
gl = self.genLabel
ll = self.localLabel
ol = self.origLabel
... | python | def _graphify(self, *args, graph=None): # defined
""" Lift phenotypeEdges to Restrictions """
if graph is None:
graph = self.out_graph
################## LABELS ARE DEFINED HERE ##################
gl = self.genLabel
ll = self.localLabel
ol = self.origLabel
... | [
"def",
"_graphify",
"(",
"self",
",",
"*",
"args",
",",
"graph",
"=",
"None",
")",
":",
"# defined",
"if",
"graph",
"is",
"None",
":",
"graph",
"=",
"self",
".",
"out_graph",
"################## LABELS ARE DEFINED HERE ##################",
"gl",
"=",
"self",
... | Lift phenotypeEdges to Restrictions | [
"Lift",
"phenotypeEdges",
"to",
"Restrictions"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/neurondm/neurondm/core.py#L2131-L2163 |
tgbugs/pyontutils | pyontutils/scigraph_deploy.py | run | def run(args):
if args['--debug']:
print(args)
# ignoring bamboo sequecing for the moment...
# check the build server to see if we have built the latest (or the specified commit)
# if yes just scp those to services
# if no check the web endpoint to see if latest matches build
# if yes fe... | python | def run(args):
if args['--debug']:
print(args)
# ignoring bamboo sequecing for the moment...
# check the build server to see if we have built the latest (or the specified commit)
# if yes just scp those to services
# if no check the web endpoint to see if latest matches build
# if yes fe... | [
"def",
"run",
"(",
"args",
")",
":",
"if",
"args",
"[",
"'--debug'",
"]",
":",
"print",
"(",
"args",
")",
"# ignoring bamboo sequecing for the moment...",
"# check the build server to see if we have built the latest (or the specified commit)",
"# if yes just scp those to services... | localhost:~/files/ontology-packages/scigraph/ | [
"localhost",
":",
"~",
"/",
"files",
"/",
"ontology",
"-",
"packages",
"/",
"scigraph",
"/"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/scigraph_deploy.py#L754-L796 |
tgbugs/pyontutils | pyontutils/scigraph_deploy.py | Builder.runOnExecutor | def runOnExecutor(self, *commands, oper=ACCEPT, defer_shell_expansion=False):
""" This runs in the executor of the current scope.
You cannot magically back out since there are no
gurantees that ssh keys will be in place (they shouldn't be). """
return self.makeOutput(EXE, command... | python | def runOnExecutor(self, *commands, oper=ACCEPT, defer_shell_expansion=False):
""" This runs in the executor of the current scope.
You cannot magically back out since there are no
gurantees that ssh keys will be in place (they shouldn't be). """
return self.makeOutput(EXE, command... | [
"def",
"runOnExecutor",
"(",
"self",
",",
"*",
"commands",
",",
"oper",
"=",
"ACCEPT",
",",
"defer_shell_expansion",
"=",
"False",
")",
":",
"return",
"self",
".",
"makeOutput",
"(",
"EXE",
",",
"commands",
",",
"oper",
"=",
"oper",
",",
"defer_shell_expan... | This runs in the executor of the current scope.
You cannot magically back out since there are no
gurantees that ssh keys will be in place (they shouldn't be). | [
"This",
"runs",
"in",
"the",
"executor",
"of",
"the",
"current",
"scope",
".",
"You",
"cannot",
"magically",
"back",
"out",
"since",
"there",
"are",
"no",
"gurantees",
"that",
"ssh",
"keys",
"will",
"be",
"in",
"place",
"(",
"they",
"shouldn",
"t",
"be",... | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/scigraph_deploy.py#L248-L252 |
tgbugs/pyontutils | pyontutils/scigraph_deploy.py | Builder.build | def build(self, mode=None, check=False):
""" Just shuffle the current call off to the build server with --local attached """
kwargs = {}
if not self.build_only: # don't try to deploy twice
kwargs[' --build-only'] = True
if not self.local:
kwargs['--local'] = True... | python | def build(self, mode=None, check=False):
""" Just shuffle the current call off to the build server with --local attached """
kwargs = {}
if not self.build_only: # don't try to deploy twice
kwargs[' --build-only'] = True
if not self.local:
kwargs['--local'] = True... | [
"def",
"build",
"(",
"self",
",",
"mode",
"=",
"None",
",",
"check",
"=",
"False",
")",
":",
"kwargs",
"=",
"{",
"}",
"if",
"not",
"self",
".",
"build_only",
":",
"# don't try to deploy twice",
"kwargs",
"[",
"' --build-only'",
"]",
"=",
"True",
"if",
... | Just shuffle the current call off to the build server with --local attached | [
"Just",
"shuffle",
"the",
"current",
"call",
"off",
"to",
"the",
"build",
"server",
"with",
"--",
"local",
"attached"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/scigraph_deploy.py#L398-L414 |
tgbugs/pyontutils | nifstd/nifstd_tools/parcellation/__init__.py | swanson | def swanson():
""" not really a parcellation scheme
NOTE: the defining information up here is now deprecated
it is kept around to keep the code further down happy """
source = Path(devconfig.resources, 'swanson_aligned.txt').as_posix()
ONT_PATH = 'http://ontology.neuinfo.org/NIF/ttl/generat... | python | def swanson():
""" not really a parcellation scheme
NOTE: the defining information up here is now deprecated
it is kept around to keep the code further down happy """
source = Path(devconfig.resources, 'swanson_aligned.txt').as_posix()
ONT_PATH = 'http://ontology.neuinfo.org/NIF/ttl/generat... | [
"def",
"swanson",
"(",
")",
":",
"source",
"=",
"Path",
"(",
"devconfig",
".",
"resources",
",",
"'swanson_aligned.txt'",
")",
".",
"as_posix",
"(",
")",
"ONT_PATH",
"=",
"'http://ontology.neuinfo.org/NIF/ttl/generated/'",
"filename",
"=",
"'swanson_hierarchies'",
"... | not really a parcellation scheme
NOTE: the defining information up here is now deprecated
it is kept around to keep the code further down happy | [
"not",
"really",
"a",
"parcellation",
"scheme",
"NOTE",
":",
"the",
"defining",
"information",
"up",
"here",
"is",
"now",
"deprecated",
"it",
"is",
"kept",
"around",
"to",
"keep",
"the",
"code",
"further",
"down",
"happy"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/nifstd/nifstd_tools/parcellation/__init__.py#L43-L269 |
tgbugs/pyontutils | pyontutils/core.py | relative_resources | def relative_resources(pathstring, failover='nifstd/resources'):
""" relative paths to resources in this repository
`failover` matches the location relative to the
github location (usually for prov purposes) """
if working_dir is None:
return Path(failover, pathstring).resolve()
els... | python | def relative_resources(pathstring, failover='nifstd/resources'):
""" relative paths to resources in this repository
`failover` matches the location relative to the
github location (usually for prov purposes) """
if working_dir is None:
return Path(failover, pathstring).resolve()
els... | [
"def",
"relative_resources",
"(",
"pathstring",
",",
"failover",
"=",
"'nifstd/resources'",
")",
":",
"if",
"working_dir",
"is",
"None",
":",
"return",
"Path",
"(",
"failover",
",",
"pathstring",
")",
".",
"resolve",
"(",
")",
"else",
":",
"return",
"Path",
... | relative paths to resources in this repository
`failover` matches the location relative to the
github location (usually for prov purposes) | [
"relative",
"paths",
"to",
"resources",
"in",
"this",
"repository",
"failover",
"matches",
"the",
"location",
"relative",
"to",
"the",
"github",
"location",
"(",
"usually",
"for",
"prov",
"purposes",
")"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/core.py#L28-L36 |
tgbugs/pyontutils | pyontutils/core.py | build | def build(*onts, fail=False, n_jobs=9, write=True):
""" Set n_jobs=1 for debug or embed() will crash. """
tail = lambda:tuple()
lonts = len(onts)
if lonts > 1:
for i, ont in enumerate(onts):
if ont.__name__ == 'parcBridge':
onts = onts[:-1]
def tail(o=... | python | def build(*onts, fail=False, n_jobs=9, write=True):
""" Set n_jobs=1 for debug or embed() will crash. """
tail = lambda:tuple()
lonts = len(onts)
if lonts > 1:
for i, ont in enumerate(onts):
if ont.__name__ == 'parcBridge':
onts = onts[:-1]
def tail(o=... | [
"def",
"build",
"(",
"*",
"onts",
",",
"fail",
"=",
"False",
",",
"n_jobs",
"=",
"9",
",",
"write",
"=",
"True",
")",
":",
"tail",
"=",
"lambda",
":",
"tuple",
"(",
")",
"lonts",
"=",
"len",
"(",
"onts",
")",
"if",
"lonts",
">",
"1",
":",
"fo... | Set n_jobs=1 for debug or embed() will crash. | [
"Set",
"n_jobs",
"=",
"1",
"for",
"debug",
"or",
"embed",
"()",
"will",
"crash",
"."
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/core.py#L53-L80 |
tgbugs/pyontutils | pyontutils/core.py | qname | def qname(uri, warning=False):
""" compute qname from defaults """
if warning:
print(tc.red('WARNING:'), tc.yellow(f'qname({uri}) is deprecated! please use OntId({uri}).curie'))
return __helper_graph.qname(uri) | python | def qname(uri, warning=False):
""" compute qname from defaults """
if warning:
print(tc.red('WARNING:'), tc.yellow(f'qname({uri}) is deprecated! please use OntId({uri}).curie'))
return __helper_graph.qname(uri) | [
"def",
"qname",
"(",
"uri",
",",
"warning",
"=",
"False",
")",
":",
"if",
"warning",
":",
"print",
"(",
"tc",
".",
"red",
"(",
"'WARNING:'",
")",
",",
"tc",
".",
"yellow",
"(",
"f'qname({uri}) is deprecated! please use OntId({uri}).curie'",
")",
")",
"return... | compute qname from defaults | [
"compute",
"qname",
"from",
"defaults"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/core.py#L447-L451 |
tgbugs/pyontutils | pyontutils/core.py | cull_prefixes | def cull_prefixes(graph, prefixes={k:v for k, v in uPREFIXES.items() if k != 'NIFTTL'},
cleanup=lambda ps, graph: None, keep=False):
""" Remove unused curie prefixes and normalize to a standard set. """
prefs = ['']
if keep:
prefixes.update({p:str(n) for p, n in graph.namespaces()}... | python | def cull_prefixes(graph, prefixes={k:v for k, v in uPREFIXES.items() if k != 'NIFTTL'},
cleanup=lambda ps, graph: None, keep=False):
""" Remove unused curie prefixes and normalize to a standard set. """
prefs = ['']
if keep:
prefixes.update({p:str(n) for p, n in graph.namespaces()}... | [
"def",
"cull_prefixes",
"(",
"graph",
",",
"prefixes",
"=",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"uPREFIXES",
".",
"items",
"(",
")",
"if",
"k",
"!=",
"'NIFTTL'",
"}",
",",
"cleanup",
"=",
"lambda",
"ps",
",",
"graph",
":",
"None",
","... | Remove unused curie prefixes and normalize to a standard set. | [
"Remove",
"unused",
"curie",
"prefixes",
"and",
"normalize",
"to",
"a",
"standard",
"set",
"."
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/core.py#L455-L486 |
tgbugs/pyontutils | pyontutils/core.py | displayTriples | def displayTriples(triples, qname=qname):
""" triples can also be an rdflib Graph instance """
[print(*(e[:5]
if isinstance(e, rdflib.BNode) else
qname(e)
for e in t), '.')
for t in sorted(triples)] | python | def displayTriples(triples, qname=qname):
""" triples can also be an rdflib Graph instance """
[print(*(e[:5]
if isinstance(e, rdflib.BNode) else
qname(e)
for e in t), '.')
for t in sorted(triples)] | [
"def",
"displayTriples",
"(",
"triples",
",",
"qname",
"=",
"qname",
")",
":",
"[",
"print",
"(",
"*",
"(",
"e",
"[",
":",
"5",
"]",
"if",
"isinstance",
"(",
"e",
",",
"rdflib",
".",
"BNode",
")",
"else",
"qname",
"(",
"e",
")",
"for",
"e",
"in... | triples can also be an rdflib Graph instance | [
"triples",
"can",
"also",
"be",
"an",
"rdflib",
"Graph",
"instance"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/core.py#L1171-L1177 |
tgbugs/pyontutils | pyontutils/core.py | makeGraph.write | def write(self, cull=False):
""" Serialize self.g and write to self.filename, set cull to true to remove unwanted prefixes """
if cull:
cull_prefixes(self).write()
else:
ser = self.g.serialize(format='nifttl')
with open(self.filename, 'wb') as f:
... | python | def write(self, cull=False):
""" Serialize self.g and write to self.filename, set cull to true to remove unwanted prefixes """
if cull:
cull_prefixes(self).write()
else:
ser = self.g.serialize(format='nifttl')
with open(self.filename, 'wb') as f:
... | [
"def",
"write",
"(",
"self",
",",
"cull",
"=",
"False",
")",
":",
"if",
"cull",
":",
"cull_prefixes",
"(",
"self",
")",
".",
"write",
"(",
")",
"else",
":",
"ser",
"=",
"self",
".",
"g",
".",
"serialize",
"(",
"format",
"=",
"'nifttl'",
")",
"wit... | Serialize self.g and write to self.filename, set cull to true to remove unwanted prefixes | [
"Serialize",
"self",
".",
"g",
"and",
"write",
"to",
"self",
".",
"filename",
"set",
"cull",
"to",
"true",
"to",
"remove",
"unwanted",
"prefixes"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/core.py#L177-L184 |
tgbugs/pyontutils | pyontutils/core.py | makeGraph.add_ap | def add_ap(self, id_, label=None, addPrefix=True):
""" Add id_ as an owl:AnnotationProperty"""
self.add_trip(id_, rdf.type, owl.AnnotationProperty)
if label:
self.add_trip(id_, rdfs.label, label)
if addPrefix:
prefix = ''.join([s.capitalize() for s in labe... | python | def add_ap(self, id_, label=None, addPrefix=True):
""" Add id_ as an owl:AnnotationProperty"""
self.add_trip(id_, rdf.type, owl.AnnotationProperty)
if label:
self.add_trip(id_, rdfs.label, label)
if addPrefix:
prefix = ''.join([s.capitalize() for s in labe... | [
"def",
"add_ap",
"(",
"self",
",",
"id_",
",",
"label",
"=",
"None",
",",
"addPrefix",
"=",
"True",
")",
":",
"self",
".",
"add_trip",
"(",
"id_",
",",
"rdf",
".",
"type",
",",
"owl",
".",
"AnnotationProperty",
")",
"if",
"label",
":",
"self",
".",... | Add id_ as an owl:AnnotationProperty | [
"Add",
"id_",
"as",
"an",
"owl",
":",
"AnnotationProperty"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/core.py#L240-L248 |
tgbugs/pyontutils | pyontutils/core.py | makeGraph.add_op | def add_op(self, id_, label=None, subPropertyOf=None, inverse=None, transitive=False, addPrefix=True):
""" Add id_ as an owl:ObjectProperty"""
self.add_trip(id_, rdf.type, owl.ObjectProperty)
if inverse:
self.add_trip(id_, owl.inverseOf, inverse)
if subPropertyOf:
... | python | def add_op(self, id_, label=None, subPropertyOf=None, inverse=None, transitive=False, addPrefix=True):
""" Add id_ as an owl:ObjectProperty"""
self.add_trip(id_, rdf.type, owl.ObjectProperty)
if inverse:
self.add_trip(id_, owl.inverseOf, inverse)
if subPropertyOf:
... | [
"def",
"add_op",
"(",
"self",
",",
"id_",
",",
"label",
"=",
"None",
",",
"subPropertyOf",
"=",
"None",
",",
"inverse",
"=",
"None",
",",
"transitive",
"=",
"False",
",",
"addPrefix",
"=",
"True",
")",
":",
"self",
".",
"add_trip",
"(",
"id_",
",",
... | Add id_ as an owl:ObjectProperty | [
"Add",
"id_",
"as",
"an",
"owl",
":",
"ObjectProperty"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/core.py#L250-L264 |
tgbugs/pyontutils | pyontutils/core.py | makeGraph.add_hierarchy | def add_hierarchy(self, parent, edge, child): # XXX DEPRECATED
""" Helper function to simplify the addition of part_of style
objectProperties to graphs. FIXME make a method of makeGraph?
"""
if type(parent) != rdflib.URIRef:
parent = self.check_thing(parent)
if ... | python | def add_hierarchy(self, parent, edge, child): # XXX DEPRECATED
""" Helper function to simplify the addition of part_of style
objectProperties to graphs. FIXME make a method of makeGraph?
"""
if type(parent) != rdflib.URIRef:
parent = self.check_thing(parent)
if ... | [
"def",
"add_hierarchy",
"(",
"self",
",",
"parent",
",",
"edge",
",",
"child",
")",
":",
"# XXX DEPRECATED",
"if",
"type",
"(",
"parent",
")",
"!=",
"rdflib",
".",
"URIRef",
":",
"parent",
"=",
"self",
".",
"check_thing",
"(",
"parent",
")",
"if",
"typ... | Helper function to simplify the addition of part_of style
objectProperties to graphs. FIXME make a method of makeGraph? | [
"Helper",
"function",
"to",
"simplify",
"the",
"addition",
"of",
"part_of",
"style",
"objectProperties",
"to",
"graphs",
".",
"FIXME",
"make",
"a",
"method",
"of",
"makeGraph?"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/core.py#L282-L298 |
tgbugs/pyontutils | pyontutils/core.py | makeGraph.add_restriction | def add_restriction(self, subject, predicate, object_):
""" Lift normal triples into restrictions using someValuesFrom. """
if type(object_) != rdflib.URIRef:
object_ = self.check_thing(object_)
if type(predicate) != rdflib.URIRef:
predicate = self.check_thing(predicate)... | python | def add_restriction(self, subject, predicate, object_):
""" Lift normal triples into restrictions using someValuesFrom. """
if type(object_) != rdflib.URIRef:
object_ = self.check_thing(object_)
if type(predicate) != rdflib.URIRef:
predicate = self.check_thing(predicate)... | [
"def",
"add_restriction",
"(",
"self",
",",
"subject",
",",
"predicate",
",",
"object_",
")",
":",
"if",
"type",
"(",
"object_",
")",
"!=",
"rdflib",
".",
"URIRef",
":",
"object_",
"=",
"self",
".",
"check_thing",
"(",
"object_",
")",
"if",
"type",
"("... | Lift normal triples into restrictions using someValuesFrom. | [
"Lift",
"normal",
"triples",
"into",
"restrictions",
"using",
"someValuesFrom",
"."
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/core.py#L300-L314 |
tgbugs/pyontutils | pyontutils/core.py | makeGraph.get_equiv_inter | def get_equiv_inter(self, curie):
""" get equivelant classes where curie is in an intersection """
start = self.qname(self.expand(curie)) # in case something is misaligned
qstring = """
SELECT DISTINCT ?match WHERE {
?match owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:fi... | python | def get_equiv_inter(self, curie):
""" get equivelant classes where curie is in an intersection """
start = self.qname(self.expand(curie)) # in case something is misaligned
qstring = """
SELECT DISTINCT ?match WHERE {
?match owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:fi... | [
"def",
"get_equiv_inter",
"(",
"self",
",",
"curie",
")",
":",
"start",
"=",
"self",
".",
"qname",
"(",
"self",
".",
"expand",
"(",
"curie",
")",
")",
"# in case something is misaligned",
"qstring",
"=",
"\"\"\"\n SELECT DISTINCT ?match WHERE {\n ?match ... | get equivelant classes where curie is in an intersection | [
"get",
"equivelant",
"classes",
"where",
"curie",
"is",
"in",
"an",
"intersection"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/core.py#L344-L351 |
tgbugs/pyontutils | pyontutils/core.py | makeGraph.qname | def qname(self, uri, generate=False):
""" Given a uri return the qname if it exists, otherwise return the uri. """
try:
prefix, namespace, name = self.g.namespace_manager.compute_qname(uri, generate=generate)
qname = ':'.join((prefix, name))
return qname
excep... | python | def qname(self, uri, generate=False):
""" Given a uri return the qname if it exists, otherwise return the uri. """
try:
prefix, namespace, name = self.g.namespace_manager.compute_qname(uri, generate=generate)
qname = ':'.join((prefix, name))
return qname
excep... | [
"def",
"qname",
"(",
"self",
",",
"uri",
",",
"generate",
"=",
"False",
")",
":",
"try",
":",
"prefix",
",",
"namespace",
",",
"name",
"=",
"self",
".",
"g",
".",
"namespace_manager",
".",
"compute_qname",
"(",
"uri",
",",
"generate",
"=",
"generate",
... | Given a uri return the qname if it exists, otherwise return the uri. | [
"Given",
"a",
"uri",
"return",
"the",
"qname",
"if",
"it",
"exists",
"otherwise",
"return",
"the",
"uri",
"."
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/core.py#L353-L360 |
SUSE-Enceladus/ipa | ipa/scripts/cli_utils.py | archive_history_item | def archive_history_item(item, destination, no_color):
"""
Archive the log and results file for the given history item.
Copy the files and update the results file in destination directory.
"""
log_src, description = split_history_item(item.strip())
# Get relative path for log:
# {provider}... | python | def archive_history_item(item, destination, no_color):
"""
Archive the log and results file for the given history item.
Copy the files and update the results file in destination directory.
"""
log_src, description = split_history_item(item.strip())
# Get relative path for log:
# {provider}... | [
"def",
"archive_history_item",
"(",
"item",
",",
"destination",
",",
"no_color",
")",
":",
"log_src",
",",
"description",
"=",
"split_history_item",
"(",
"item",
".",
"strip",
"(",
")",
")",
"# Get relative path for log:",
"# {provider}/{image}/{instance}/{timestamp}.lo... | Archive the log and results file for the given history item.
Copy the files and update the results file in destination directory. | [
"Archive",
"the",
"log",
"and",
"results",
"file",
"for",
"the",
"given",
"history",
"item",
"."
] | train | https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/scripts/cli_utils.py#L34-L73 |
SUSE-Enceladus/ipa | ipa/scripts/cli_utils.py | echo_results | def echo_results(data, no_color, verbose=False):
"""Print test results in nagios style format."""
try:
summary = data['summary']
except KeyError as error:
click.secho(
'The results json is missing key: %s' % error,
fg='red'
)
sys.exit(1)
if 'faile... | python | def echo_results(data, no_color, verbose=False):
"""Print test results in nagios style format."""
try:
summary = data['summary']
except KeyError as error:
click.secho(
'The results json is missing key: %s' % error,
fg='red'
)
sys.exit(1)
if 'faile... | [
"def",
"echo_results",
"(",
"data",
",",
"no_color",
",",
"verbose",
"=",
"False",
")",
":",
"try",
":",
"summary",
"=",
"data",
"[",
"'summary'",
"]",
"except",
"KeyError",
"as",
"error",
":",
"click",
".",
"secho",
"(",
"'The results json is missing key: %... | Print test results in nagios style format. | [
"Print",
"test",
"results",
"in",
"nagios",
"style",
"format",
"."
] | train | https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/scripts/cli_utils.py#L91-L120 |
SUSE-Enceladus/ipa | ipa/scripts/cli_utils.py | echo_results_file | def echo_results_file(results_file, no_color, verbose=False):
"""Print test results in nagios style format."""
try:
data = collect_results(results_file)
except ValueError:
echo_style(
'The results file is not the proper json format.',
no_color,
fg='red'
... | python | def echo_results_file(results_file, no_color, verbose=False):
"""Print test results in nagios style format."""
try:
data = collect_results(results_file)
except ValueError:
echo_style(
'The results file is not the proper json format.',
no_color,
fg='red'
... | [
"def",
"echo_results_file",
"(",
"results_file",
",",
"no_color",
",",
"verbose",
"=",
"False",
")",
":",
"try",
":",
"data",
"=",
"collect_results",
"(",
"results_file",
")",
"except",
"ValueError",
":",
"echo_style",
"(",
"'The results file is not the proper json ... | Print test results in nagios style format. | [
"Print",
"test",
"results",
"in",
"nagios",
"style",
"format",
"."
] | train | https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/scripts/cli_utils.py#L123-L142 |
SUSE-Enceladus/ipa | ipa/scripts/cli_utils.py | echo_verbose_results | def echo_verbose_results(data, no_color):
"""Print list of tests and result of each test."""
click.echo()
click.echo(
'\n'.join(
'{}: {}'.format(key, val) for key, val in data['info'].items()
)
)
click.echo()
for test in data['tests']:
if test['outcome'] == 'p... | python | def echo_verbose_results(data, no_color):
"""Print list of tests and result of each test."""
click.echo()
click.echo(
'\n'.join(
'{}: {}'.format(key, val) for key, val in data['info'].items()
)
)
click.echo()
for test in data['tests']:
if test['outcome'] == 'p... | [
"def",
"echo_verbose_results",
"(",
"data",
",",
"no_color",
")",
":",
"click",
".",
"echo",
"(",
")",
"click",
".",
"echo",
"(",
"'\\n'",
".",
"join",
"(",
"'{}: {}'",
".",
"format",
"(",
"key",
",",
"val",
")",
"for",
"key",
",",
"val",
"in",
"da... | Print list of tests and result of each test. | [
"Print",
"list",
"of",
"tests",
"and",
"result",
"of",
"each",
"test",
"."
] | train | https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/scripts/cli_utils.py#L152-L174 |
SUSE-Enceladus/ipa | ipa/scripts/cli_utils.py | get_log_file_from_item | def get_log_file_from_item(history):
"""
Return the log file based on provided history item.
Description is optional.
"""
try:
log_file, description = shlex.split(history)
except ValueError:
log_file = history.strip()
return log_file | python | def get_log_file_from_item(history):
"""
Return the log file based on provided history item.
Description is optional.
"""
try:
log_file, description = shlex.split(history)
except ValueError:
log_file = history.strip()
return log_file | [
"def",
"get_log_file_from_item",
"(",
"history",
")",
":",
"try",
":",
"log_file",
",",
"description",
"=",
"shlex",
".",
"split",
"(",
"history",
")",
"except",
"ValueError",
":",
"log_file",
"=",
"history",
".",
"strip",
"(",
")",
"return",
"log_file"
] | Return the log file based on provided history item.
Description is optional. | [
"Return",
"the",
"log",
"file",
"based",
"on",
"provided",
"history",
"item",
"."
] | train | https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/scripts/cli_utils.py#L177-L188 |
SUSE-Enceladus/ipa | ipa/scripts/cli_utils.py | results_history | def results_history(history_log, no_color):
"""Display a list of ipa test results history."""
try:
with open(history_log, 'r') as f:
lines = f.readlines()
except Exception as error:
echo_style(
'Unable to process results history log: %s' % error,
no_color,... | python | def results_history(history_log, no_color):
"""Display a list of ipa test results history."""
try:
with open(history_log, 'r') as f:
lines = f.readlines()
except Exception as error:
echo_style(
'Unable to process results history log: %s' % error,
no_color,... | [
"def",
"results_history",
"(",
"history_log",
",",
"no_color",
")",
":",
"try",
":",
"with",
"open",
"(",
"history_log",
",",
"'r'",
")",
"as",
"f",
":",
"lines",
"=",
"f",
".",
"readlines",
"(",
")",
"except",
"Exception",
"as",
"error",
":",
"echo_st... | Display a list of ipa test results history. | [
"Display",
"a",
"list",
"of",
"ipa",
"test",
"results",
"history",
"."
] | train | https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/scripts/cli_utils.py#L191-L207 |
SUSE-Enceladus/ipa | ipa/scripts/cli_utils.py | split_history_item | def split_history_item(history):
"""
Return the log file and optional description for item.
"""
try:
log_file, description = shlex.split(history)
except ValueError:
log_file = history.strip()
description = None
return log_file, description | python | def split_history_item(history):
"""
Return the log file and optional description for item.
"""
try:
log_file, description = shlex.split(history)
except ValueError:
log_file = history.strip()
description = None
return log_file, description | [
"def",
"split_history_item",
"(",
"history",
")",
":",
"try",
":",
"log_file",
",",
"description",
"=",
"shlex",
".",
"split",
"(",
"history",
")",
"except",
"ValueError",
":",
"log_file",
"=",
"history",
".",
"strip",
"(",
")",
"description",
"=",
"None",... | Return the log file and optional description for item. | [
"Return",
"the",
"log",
"file",
"and",
"optional",
"description",
"for",
"item",
"."
] | train | https://github.com/SUSE-Enceladus/ipa/blob/0845eed0ea25a27dbb059ad1016105fa60002228/ipa/scripts/cli_utils.py#L210-L220 |
tgbugs/pyontutils | pyontutils/utils.py | get_working_dir | def get_working_dir(script__file__):
""" hardcoded sets the 'equivalent' working directory if not in git """
start = Path(script__file__).resolve()
_root = Path(start.root)
working_dir = start
while not list(working_dir.glob('.git')):
if working_dir == _root:
return
work... | python | def get_working_dir(script__file__):
""" hardcoded sets the 'equivalent' working directory if not in git """
start = Path(script__file__).resolve()
_root = Path(start.root)
working_dir = start
while not list(working_dir.glob('.git')):
if working_dir == _root:
return
work... | [
"def",
"get_working_dir",
"(",
"script__file__",
")",
":",
"start",
"=",
"Path",
"(",
"script__file__",
")",
".",
"resolve",
"(",
")",
"_root",
"=",
"Path",
"(",
"start",
".",
"root",
")",
"working_dir",
"=",
"start",
"while",
"not",
"list",
"(",
"workin... | hardcoded sets the 'equivalent' working directory if not in git | [
"hardcoded",
"sets",
"the",
"equivalent",
"working",
"directory",
"if",
"not",
"in",
"git"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/utils.py#L23-L34 |
tgbugs/pyontutils | pyontutils/utils.py | sysidpath | def sysidpath(ignore_options=False):
""" get a unique identifier for the machine running this function """
# in the event we have to make our own
# this should not be passed in a as a parameter
# since we need these definitions to be more or less static
failover = Path('/tmp/machine-id')
if not... | python | def sysidpath(ignore_options=False):
""" get a unique identifier for the machine running this function """
# in the event we have to make our own
# this should not be passed in a as a parameter
# since we need these definitions to be more or less static
failover = Path('/tmp/machine-id')
if not... | [
"def",
"sysidpath",
"(",
"ignore_options",
"=",
"False",
")",
":",
"# in the event we have to make our own",
"# this should not be passed in a as a parameter",
"# since we need these definitions to be more or less static",
"failover",
"=",
"Path",
"(",
"'/tmp/machine-id'",
")",
"if... | get a unique identifier for the machine running this function | [
"get",
"a",
"unique",
"identifier",
"for",
"the",
"machine",
"running",
"this",
"function"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/utils.py#L45-L67 |
tgbugs/pyontutils | pyontutils/utils.py | chunk_list | def chunk_list(list_, size):
""" Split a list list_ into sublists of length size.
NOTE: len(chunks[-1]) <= size. """
ll = len(list_)
if ll <= size:
return [list_]
elif size == 0:
return list_ # or None ??
elif size == 1:
return [[l] for l in list_]
else:
c... | python | def chunk_list(list_, size):
""" Split a list list_ into sublists of length size.
NOTE: len(chunks[-1]) <= size. """
ll = len(list_)
if ll <= size:
return [list_]
elif size == 0:
return list_ # or None ??
elif size == 1:
return [[l] for l in list_]
else:
c... | [
"def",
"chunk_list",
"(",
"list_",
",",
"size",
")",
":",
"ll",
"=",
"len",
"(",
"list_",
")",
"if",
"ll",
"<=",
"size",
":",
"return",
"[",
"list_",
"]",
"elif",
"size",
"==",
"0",
":",
"return",
"list_",
"# or None ??",
"elif",
"size",
"==",
"1",... | Split a list list_ into sublists of length size.
NOTE: len(chunks[-1]) <= size. | [
"Split",
"a",
"list",
"list_",
"into",
"sublists",
"of",
"length",
"size",
".",
"NOTE",
":",
"len",
"(",
"chunks",
"[",
"-",
"1",
"]",
")",
"<",
"=",
"size",
"."
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/utils.py#L428-L443 |
tgbugs/pyontutils | pyontutils/scigraph_codegen.py | FAKECLASS.NICKNAME | def NICKNAME(selfPARAMSDEFAULT_OUTPUT):
""" DOCSTRING
"""
{params_conditional}
kwargs = {param_rest}
kwargs = {dict_comp}
param_rest = self._make_rest({required}, **kwargs)
url = self._basePath + ('{path}').format(**kwargs)
requests_params = {dict_comp2}
... | python | def NICKNAME(selfPARAMSDEFAULT_OUTPUT):
""" DOCSTRING
"""
{params_conditional}
kwargs = {param_rest}
kwargs = {dict_comp}
param_rest = self._make_rest({required}, **kwargs)
url = self._basePath + ('{path}').format(**kwargs)
requests_params = {dict_comp2}
... | [
"def",
"NICKNAME",
"(",
"selfPARAMSDEFAULT_OUTPUT",
")",
":",
"{",
"params_conditional",
"}",
"kwargs",
"=",
"{",
"param_rest",
"}",
"kwargs",
"=",
"{",
"dict_comp",
"}",
"param_rest",
"=",
"self",
".",
"_make_rest",
"(",
"{",
"required",
"}",
",",
"*",
"*... | DOCSTRING | [
"DOCSTRING"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/scigraph_codegen.py#L230-L240 |
tgbugs/pyontutils | pyontutils/scigraph_codegen.py | State.gencode | def gencode(self):
""" Run this to generate the code """
ledict = requests.get(self.api_url).json()
ledict = self.dotopdict(ledict)
out = self.dodict(ledict)
self._code = out | python | def gencode(self):
""" Run this to generate the code """
ledict = requests.get(self.api_url).json()
ledict = self.dotopdict(ledict)
out = self.dodict(ledict)
self._code = out | [
"def",
"gencode",
"(",
"self",
")",
":",
"ledict",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"api_url",
")",
".",
"json",
"(",
")",
"ledict",
"=",
"self",
".",
"dotopdict",
"(",
"ledict",
")",
"out",
"=",
"self",
".",
"dodict",
"(",
"ledict",
... | Run this to generate the code | [
"Run",
"this",
"to",
"generate",
"the",
"code"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/scigraph_codegen.py#L613-L618 |
tgbugs/pyontutils | pyontutils/scigraph_codegen.py | State2.dotopdict | def dotopdict(self, dict_):
""" Rewrite the 2.0 json to match what we feed the code for 1.2 """
mlookup = {'get':'GET', 'post':'POST'}
def rearrange(path, method_dict, method):
oid = method_dict['operationId']
self._paths[oid] = path
method_dict['nickname'] = ... | python | def dotopdict(self, dict_):
""" Rewrite the 2.0 json to match what we feed the code for 1.2 """
mlookup = {'get':'GET', 'post':'POST'}
def rearrange(path, method_dict, method):
oid = method_dict['operationId']
self._paths[oid] = path
method_dict['nickname'] = ... | [
"def",
"dotopdict",
"(",
"self",
",",
"dict_",
")",
":",
"mlookup",
"=",
"{",
"'get'",
":",
"'GET'",
",",
"'post'",
":",
"'POST'",
"}",
"def",
"rearrange",
"(",
"path",
",",
"method_dict",
",",
"method",
")",
":",
"oid",
"=",
"method_dict",
"[",
"'op... | Rewrite the 2.0 json to match what we feed the code for 1.2 | [
"Rewrite",
"the",
"2",
".",
"0",
"json",
"to",
"match",
"what",
"we",
"feed",
"the",
"code",
"for",
"1",
".",
"2"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/scigraph_codegen.py#L622-L666 |
tgbugs/pyontutils | pyontutils/ontload.py | local_imports | def local_imports(remote_base, local_base, ontologies, local_versions=tuple(), readonly=False, dobig=False, revert=False):
""" Read the import closure and use the local versions of the files. """
done = []
triples = set()
imported_iri_vs_ontology_iri = {}
p = owl.imports
oi = b'owl:imports'
... | python | def local_imports(remote_base, local_base, ontologies, local_versions=tuple(), readonly=False, dobig=False, revert=False):
""" Read the import closure and use the local versions of the files. """
done = []
triples = set()
imported_iri_vs_ontology_iri = {}
p = owl.imports
oi = b'owl:imports'
... | [
"def",
"local_imports",
"(",
"remote_base",
",",
"local_base",
",",
"ontologies",
",",
"local_versions",
"=",
"tuple",
"(",
")",
",",
"readonly",
"=",
"False",
",",
"dobig",
"=",
"False",
",",
"revert",
"=",
"False",
")",
":",
"done",
"=",
"[",
"]",
"t... | Read the import closure and use the local versions of the files. | [
"Read",
"the",
"import",
"closure",
"and",
"use",
"the",
"local",
"versions",
"of",
"the",
"files",
"."
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/ontload.py#L375-L467 |
tgbugs/pyontutils | pyontutils/obo_io.py | id_fix | def id_fix(value):
""" fix @prefix values for ttl """
if value.startswith('KSC_M'):
pass
else:
value = value.replace(':','_')
if value.startswith('ERO') or value.startswith('OBI') or value.startswith('GO') or value.startswith('UBERON') or value.startswith('IAO'):
value = ... | python | def id_fix(value):
""" fix @prefix values for ttl """
if value.startswith('KSC_M'):
pass
else:
value = value.replace(':','_')
if value.startswith('ERO') or value.startswith('OBI') or value.startswith('GO') or value.startswith('UBERON') or value.startswith('IAO'):
value = ... | [
"def",
"id_fix",
"(",
"value",
")",
":",
"if",
"value",
".",
"startswith",
"(",
"'KSC_M'",
")",
":",
"pass",
"else",
":",
"value",
"=",
"value",
".",
"replace",
"(",
"':'",
",",
"'_'",
")",
"if",
"value",
".",
"startswith",
"(",
"'ERO'",
")",
"or",... | fix @prefix values for ttl | [
"fix"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/obo_io.py#L105-L120 |
tgbugs/pyontutils | pyontutils/obo_io.py | OboFile.write | def write(self, filename, type_='obo'): #FIXME this is bugged
""" Write file, will not overwrite files with the same name
outputs to obo by default but can also output to ttl if
passed type_='ttl' when called.
"""
if os.path.exists(filename):
name, ext = file... | python | def write(self, filename, type_='obo'): #FIXME this is bugged
""" Write file, will not overwrite files with the same name
outputs to obo by default but can also output to ttl if
passed type_='ttl' when called.
"""
if os.path.exists(filename):
name, ext = file... | [
"def",
"write",
"(",
"self",
",",
"filename",
",",
"type_",
"=",
"'obo'",
")",
":",
"#FIXME this is bugged",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"name",
",",
"ext",
"=",
"filename",
".",
"rsplit",
"(",
"'.'",
",",
"1",
... | Write file, will not overwrite files with the same name
outputs to obo by default but can also output to ttl if
passed type_='ttl' when called. | [
"Write",
"file",
"will",
"not",
"overwrite",
"files",
"with",
"the",
"same",
"name",
"outputs",
"to",
"obo",
"by",
"default",
"but",
"can",
"also",
"output",
"to",
"ttl",
"if",
"passed",
"type_",
"=",
"ttl",
"when",
"called",
"."
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/obo_io.py#L189-L213 |
tgbugs/pyontutils | ilxutils/ilxutils/tools.py | string_profiler | def string_profiler(string, start_delimiter='(', end_delimiter=')', remove=True):
'''
long = '(life is is good) love world "(blah) blah" "here I am" once again "yes" blah '
print(string_profiler(long))
null = ''
print(string_profiler(null))
short = '(life love) yes(and much m... | python | def string_profiler(string, start_delimiter='(', end_delimiter=')', remove=True):
'''
long = '(life is is good) love world "(blah) blah" "here I am" once again "yes" blah '
print(string_profiler(long))
null = ''
print(string_profiler(null))
short = '(life love) yes(and much m... | [
"def",
"string_profiler",
"(",
"string",
",",
"start_delimiter",
"=",
"'('",
",",
"end_delimiter",
"=",
"')'",
",",
"remove",
"=",
"True",
")",
":",
"mark",
"=",
"0",
"string_list",
"=",
"[",
"]",
"tmp_string",
"=",
"''",
"for",
"i",
"in",
"range",
"("... | long = '(life is is good) love world "(blah) blah" "here I am" once again "yes" blah '
print(string_profiler(long))
null = ''
print(string_profiler(null))
short = '(life love) yes(and much more)'
print(string_profiler(short))
short = 'yes "life love"'
print(string... | [
"long",
"=",
"(",
"life",
"is",
"is",
"good",
")",
"love",
"world",
"(",
"blah",
")",
"blah",
"here",
"I",
"am",
"once",
"again",
"yes",
"blah",
"print",
"(",
"string_profiler",
"(",
"long",
"))",
"null",
"=",
"print",
"(",
"string_profiler",
"(",
"n... | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/tools.py#L11-L49 |
tgbugs/pyontutils | librdflib/librdflib/__init__.py | main | def main():
from IPython import embed
""" Python 3.6.6
ibttl 2.605194091796875
ttl 3.8316309452056885
diff lt - ttl -1.2264368534088135
librdfxml 31.267616748809814
rdfxml 58.25124502182007
diff lr - rl -26.983628273010254
simple time 17.405116319656372
"""
""" Python 3.5.3 ... | python | def main():
from IPython import embed
""" Python 3.6.6
ibttl 2.605194091796875
ttl 3.8316309452056885
diff lt - ttl -1.2264368534088135
librdfxml 31.267616748809814
rdfxml 58.25124502182007
diff lr - rl -26.983628273010254
simple time 17.405116319656372
"""
""" Python 3.5.3 ... | [
"def",
"main",
"(",
")",
":",
"from",
"IPython",
"import",
"embed",
"\"\"\" Python 3.5.3 (pypy3)\n libttl 2.387338638305664\n ttl 1.3430471420288086\n diff lt - ttl 1.0442914962768555\n librdfxml 24.70371127128601\n rdfxml 17.85916304588318\n diff lr - rl 6.844548225402832\n s... | Python 3.6.6
ibttl 2.605194091796875
ttl 3.8316309452056885
diff lt - ttl -1.2264368534088135
librdfxml 31.267616748809814
rdfxml 58.25124502182007
diff lr - rl -26.983628273010254
simple time 17.405116319656372 | [
"Python",
"3",
".",
"6",
".",
"6",
"ibttl",
"2",
".",
"605194091796875",
"ttl",
"3",
".",
"8316309452056885",
"diff",
"lt",
"-",
"ttl",
"-",
"1",
".",
"2264368534088135",
"librdfxml",
"31",
".",
"267616748809814",
"rdfxml",
"58",
".",
"25124502182007",
"di... | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/librdflib/librdflib/__init__.py#L125-L196 |
tgbugs/pyontutils | pyontutils/combinators.py | make_predicate_object_combinator | def make_predicate_object_combinator(function, p, o):
""" Combinator to hold predicate object pairs until a subject is supplied and then
call a function that accepts a subject, predicate, and object.
Create a combinator to defer production of a triple until the missing pieces are supplied.
... | python | def make_predicate_object_combinator(function, p, o):
""" Combinator to hold predicate object pairs until a subject is supplied and then
call a function that accepts a subject, predicate, and object.
Create a combinator to defer production of a triple until the missing pieces are supplied.
... | [
"def",
"make_predicate_object_combinator",
"(",
"function",
",",
"p",
",",
"o",
")",
":",
"def",
"predicate_object_combinator",
"(",
"subject",
")",
":",
"return",
"function",
"(",
"subject",
",",
"p",
",",
"o",
")",
"return",
"predicate_object_combinator"
] | Combinator to hold predicate object pairs until a subject is supplied and then
call a function that accepts a subject, predicate, and object.
Create a combinator to defer production of a triple until the missing pieces are supplied.
Note that the naming here tells you what is stored IN the comb... | [
"Combinator",
"to",
"hold",
"predicate",
"object",
"pairs",
"until",
"a",
"subject",
"is",
"supplied",
"and",
"then",
"call",
"a",
"function",
"that",
"accepts",
"a",
"subject",
"predicate",
"and",
"object",
"."
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/combinators.py#L17-L26 |
tgbugs/pyontutils | pyontutils/combinators.py | EquivalentClass.serialize | def serialize(self, subject, *objects_or_combinators):
""" object_combinators may also be URIRefs or Literals """
ec_s = rdflib.BNode()
if self.operator is not None:
if subject is not None:
yield subject, self.predicate, ec_s
yield from oc(ec_s)
... | python | def serialize(self, subject, *objects_or_combinators):
""" object_combinators may also be URIRefs or Literals """
ec_s = rdflib.BNode()
if self.operator is not None:
if subject is not None:
yield subject, self.predicate, ec_s
yield from oc(ec_s)
... | [
"def",
"serialize",
"(",
"self",
",",
"subject",
",",
"*",
"objects_or_combinators",
")",
":",
"ec_s",
"=",
"rdflib",
".",
"BNode",
"(",
")",
"if",
"self",
".",
"operator",
"is",
"not",
"None",
":",
"if",
"subject",
"is",
"not",
"None",
":",
"yield",
... | object_combinators may also be URIRefs or Literals | [
"object_combinators",
"may",
"also",
"be",
"URIRefs",
"or",
"Literals"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/combinators.py#L681-L707 |
shanbay/peeweext | peeweext/model.py | Model.update_with | def update_with(self, **query):
"""
secure update, mass assignment protected
"""
for k, v in self._filter_attrs(query).items():
setattr(self, k, v)
return self.save() | python | def update_with(self, **query):
"""
secure update, mass assignment protected
"""
for k, v in self._filter_attrs(query).items():
setattr(self, k, v)
return self.save() | [
"def",
"update_with",
"(",
"self",
",",
"*",
"*",
"query",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_filter_attrs",
"(",
"query",
")",
".",
"items",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"k",
",",
"v",
")",
"return",
"self",
".... | secure update, mass assignment protected | [
"secure",
"update",
"mass",
"assignment",
"protected"
] | train | https://github.com/shanbay/peeweext/blob/ff62a3d01e4584d50fde1944b9616c3b4236ecf0/peeweext/model.py#L53-L59 |
shanbay/peeweext | peeweext/model.py | Model._filter_attrs | def _filter_attrs(cls, attrs):
"""
attrs: { attr_name: attr_value }
if __attr_whitelist__ is True:
only attr in __attr_accessible__ AND not in __attr_protected__
will pass
else:
only attr not in __attr_protected__ OR in __attr_accessible__
... | python | def _filter_attrs(cls, attrs):
"""
attrs: { attr_name: attr_value }
if __attr_whitelist__ is True:
only attr in __attr_accessible__ AND not in __attr_protected__
will pass
else:
only attr not in __attr_protected__ OR in __attr_accessible__
... | [
"def",
"_filter_attrs",
"(",
"cls",
",",
"attrs",
")",
":",
"if",
"cls",
".",
"__attr_whitelist__",
":",
"whitelist",
"=",
"cls",
".",
"__attr_accessible__",
"-",
"cls",
".",
"__attr_protected__",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",... | attrs: { attr_name: attr_value }
if __attr_whitelist__ is True:
only attr in __attr_accessible__ AND not in __attr_protected__
will pass
else:
only attr not in __attr_protected__ OR in __attr_accessible__
will pass | [
"attrs",
":",
"{",
"attr_name",
":",
"attr_value",
"}",
"if",
"__attr_whitelist__",
"is",
"True",
":",
"only",
"attr",
"in",
"__attr_accessible__",
"AND",
"not",
"in",
"__attr_protected__",
"will",
"pass",
"else",
":",
"only",
"attr",
"not",
"in",
"__attr_prot... | train | https://github.com/shanbay/peeweext/blob/ff62a3d01e4584d50fde1944b9616c3b4236ecf0/peeweext/model.py#L62-L77 |
shanbay/peeweext | peeweext/model.py | Model._validate | def _validate(self):
"""Validate model data and save errors
"""
errors = {}
for name, validator in self._validators.items():
value = getattr(self, name)
try:
validator(self, value)
except ValidationError as e:
errors[n... | python | def _validate(self):
"""Validate model data and save errors
"""
errors = {}
for name, validator in self._validators.items():
value = getattr(self, name)
try:
validator(self, value)
except ValidationError as e:
errors[n... | [
"def",
"_validate",
"(",
"self",
")",
":",
"errors",
"=",
"{",
"}",
"for",
"name",
",",
"validator",
"in",
"self",
".",
"_validators",
".",
"items",
"(",
")",
":",
"value",
"=",
"getattr",
"(",
"self",
",",
"name",
")",
"try",
":",
"validator",
"("... | Validate model data and save errors | [
"Validate",
"model",
"data",
"and",
"save",
"errors"
] | train | https://github.com/shanbay/peeweext/blob/ff62a3d01e4584d50fde1944b9616c3b4236ecf0/peeweext/model.py#L115-L128 |
tgbugs/pyontutils | ilxutils/ilxutils/nltklib.py | penn_to_wn | def penn_to_wn(tag):
""" Convert between a Penn Treebank tag to a simplified Wordnet tag """
if tag.startswith('N'):
return 'n'
if tag.startswith('V'):
return 'v'
if tag.startswith('J'):
return 'a'
if tag.startswith('R'):
return 'r'
return None | python | def penn_to_wn(tag):
""" Convert between a Penn Treebank tag to a simplified Wordnet tag """
if tag.startswith('N'):
return 'n'
if tag.startswith('V'):
return 'v'
if tag.startswith('J'):
return 'a'
if tag.startswith('R'):
return 'r'
return None | [
"def",
"penn_to_wn",
"(",
"tag",
")",
":",
"if",
"tag",
".",
"startswith",
"(",
"'N'",
")",
":",
"return",
"'n'",
"if",
"tag",
".",
"startswith",
"(",
"'V'",
")",
":",
"return",
"'v'",
"if",
"tag",
".",
"startswith",
"(",
"'J'",
")",
":",
"return",... | Convert between a Penn Treebank tag to a simplified Wordnet tag | [
"Convert",
"between",
"a",
"Penn",
"Treebank",
"tag",
"to",
"a",
"simplified",
"Wordnet",
"tag"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/nltklib.py#L9-L23 |
tgbugs/pyontutils | ilxutils/ilxutils/nltklib.py | sentence_similarity | def sentence_similarity(sentence1, sentence2):
""" compute the sentence similarity using Wordnet """
# Tokenize and tag
sentence1 = pos_tag(word_tokenize(sentence1))
sentence2 = pos_tag(word_tokenize(sentence2))
# Get the synsets for the tagged words
synsets1 = [tagged_to_synset(*tagged_word) f... | python | def sentence_similarity(sentence1, sentence2):
""" compute the sentence similarity using Wordnet """
# Tokenize and tag
sentence1 = pos_tag(word_tokenize(sentence1))
sentence2 = pos_tag(word_tokenize(sentence2))
# Get the synsets for the tagged words
synsets1 = [tagged_to_synset(*tagged_word) f... | [
"def",
"sentence_similarity",
"(",
"sentence1",
",",
"sentence2",
")",
":",
"# Tokenize and tag",
"sentence1",
"=",
"pos_tag",
"(",
"word_tokenize",
"(",
"sentence1",
")",
")",
"sentence2",
"=",
"pos_tag",
"(",
"word_tokenize",
"(",
"sentence2",
")",
")",
"# Get... | compute the sentence similarity using Wordnet | [
"compute",
"the",
"sentence",
"similarity",
"using",
"Wordnet"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/nltklib.py#L36-L70 |
tgbugs/pyontutils | ilxutils/ilxutils/ontopandas.py | command_line | def command_line():
''' If you want to use the command line '''
from docopt import docopt
doc = docopt( __doc__, version=VERSION )
args = pd.Series({k.replace('--', ''): v for k, v in doc.items()})
if args.all:
graph = Graph2Pandas(args.file, _type='all')
elif args.type:
graph = ... | python | def command_line():
''' If you want to use the command line '''
from docopt import docopt
doc = docopt( __doc__, version=VERSION )
args = pd.Series({k.replace('--', ''): v for k, v in doc.items()})
if args.all:
graph = Graph2Pandas(args.file, _type='all')
elif args.type:
graph = ... | [
"def",
"command_line",
"(",
")",
":",
"from",
"docopt",
"import",
"docopt",
"doc",
"=",
"docopt",
"(",
"__doc__",
",",
"version",
"=",
"VERSION",
")",
"args",
"=",
"pd",
".",
"Series",
"(",
"{",
"k",
".",
"replace",
"(",
"'--'",
",",
"''",
")",
":"... | If you want to use the command line | [
"If",
"you",
"want",
"to",
"use",
"the",
"command",
"line"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/ontopandas.py#L279-L290 |
tgbugs/pyontutils | ilxutils/ilxutils/ontopandas.py | OntoPandas.save | def save(self, foldername: str, path_to_folder: str=None) -> None:
''' Saves entities into multiple files within the same folder because of pickle-recursive
errors that would happen if squeezed into one '''
self.create_pickle((self.g.namespaces, ))
self.df.to_pickle(output) | python | def save(self, foldername: str, path_to_folder: str=None) -> None:
''' Saves entities into multiple files within the same folder because of pickle-recursive
errors that would happen if squeezed into one '''
self.create_pickle((self.g.namespaces, ))
self.df.to_pickle(output) | [
"def",
"save",
"(",
"self",
",",
"foldername",
":",
"str",
",",
"path_to_folder",
":",
"str",
"=",
"None",
")",
"->",
"None",
":",
"self",
".",
"create_pickle",
"(",
"(",
"self",
".",
"g",
".",
"namespaces",
",",
")",
")",
"self",
".",
"df",
".",
... | Saves entities into multiple files within the same folder because of pickle-recursive
errors that would happen if squeezed into one | [
"Saves",
"entities",
"into",
"multiple",
"files",
"within",
"the",
"same",
"folder",
"because",
"of",
"pickle",
"-",
"recursive",
"errors",
"that",
"would",
"happen",
"if",
"squeezed",
"into",
"one"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/ontopandas.py#L54-L58 |
tgbugs/pyontutils | ilxutils/ilxutils/ontopandas.py | OntoPandas.qname | def qname(self, uri: str) -> str:
''' Returns qname of uri in rdflib graph while also saving it '''
try:
prefix, namespace, name = self.g.compute_qname(uri)
qname = prefix + ':' + name
return qname
except:
try:
print('prefix:', pref... | python | def qname(self, uri: str) -> str:
''' Returns qname of uri in rdflib graph while also saving it '''
try:
prefix, namespace, name = self.g.compute_qname(uri)
qname = prefix + ':' + name
return qname
except:
try:
print('prefix:', pref... | [
"def",
"qname",
"(",
"self",
",",
"uri",
":",
"str",
")",
"->",
"str",
":",
"try",
":",
"prefix",
",",
"namespace",
",",
"name",
"=",
"self",
".",
"g",
".",
"compute_qname",
"(",
"uri",
")",
"qname",
"=",
"prefix",
"+",
"':'",
"+",
"name",
"retur... | Returns qname of uri in rdflib graph while also saving it | [
"Returns",
"qname",
"of",
"uri",
"in",
"rdflib",
"graph",
"while",
"also",
"saving",
"it"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/ontopandas.py#L60-L73 |
tgbugs/pyontutils | ilxutils/ilxutils/ontopandas.py | OntoPandas.Graph2Pandas_converter | def Graph2Pandas_converter(self):
'''Updates self.g or self.path bc you could only choose 1'''
if isinstance(self.path, str) or isinstance(self.path, p):
self.path = str(self.path)
filetype = p(self.path).suffix
if filetype == '.pickle':
self.g = pick... | python | def Graph2Pandas_converter(self):
'''Updates self.g or self.path bc you could only choose 1'''
if isinstance(self.path, str) or isinstance(self.path, p):
self.path = str(self.path)
filetype = p(self.path).suffix
if filetype == '.pickle':
self.g = pick... | [
"def",
"Graph2Pandas_converter",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"path",
",",
"str",
")",
"or",
"isinstance",
"(",
"self",
".",
"path",
",",
"p",
")",
":",
"self",
".",
"path",
"=",
"str",
"(",
"self",
".",
"path",
")",... | Updates self.g or self.path bc you could only choose 1 | [
"Updates",
"self",
".",
"g",
"or",
"self",
".",
"path",
"bc",
"you",
"could",
"only",
"choose",
"1"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/ontopandas.py#L75-L117 |
tgbugs/pyontutils | ilxutils/ilxutils/ontopandas.py | OntoPandas.get_sparql_dataframe | def get_sparql_dataframe( self ):
''' Iterates through the sparql table and condenses it into a Pandas DataFrame '''
self.result = self.g.query(self.query)
cols = set() # set(['qname'])
indx = set()
data = {}
curr_subj = None # place marker for first subj to be processed
... | python | def get_sparql_dataframe( self ):
''' Iterates through the sparql table and condenses it into a Pandas DataFrame '''
self.result = self.g.query(self.query)
cols = set() # set(['qname'])
indx = set()
data = {}
curr_subj = None # place marker for first subj to be processed
... | [
"def",
"get_sparql_dataframe",
"(",
"self",
")",
":",
"self",
".",
"result",
"=",
"self",
".",
"g",
".",
"query",
"(",
"self",
".",
"query",
")",
"cols",
"=",
"set",
"(",
")",
"# set(['qname'])",
"indx",
"=",
"set",
"(",
")",
"data",
"=",
"{",
"}",... | Iterates through the sparql table and condenses it into a Pandas DataFrame | [
"Iterates",
"through",
"the",
"sparql",
"table",
"and",
"condenses",
"it",
"into",
"a",
"Pandas",
"DataFrame"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/ontopandas.py#L171-L259 |
tgbugs/pyontutils | ilxutils/ilxutils/ontopandas.py | OntoPandas.df | def df(self, qname_predicates:bool=False, keep_variable_type:bool=True) -> pd.DataFrame:
''' Multi funcitonal DataFrame with settings '''
local_df = self.df.copy()
if qname_predicates:
for col in self.columns:
local_df.rename({col: self.g.qname(col)})
if not k... | python | def df(self, qname_predicates:bool=False, keep_variable_type:bool=True) -> pd.DataFrame:
''' Multi funcitonal DataFrame with settings '''
local_df = self.df.copy()
if qname_predicates:
for col in self.columns:
local_df.rename({col: self.g.qname(col)})
if not k... | [
"def",
"df",
"(",
"self",
",",
"qname_predicates",
":",
"bool",
"=",
"False",
",",
"keep_variable_type",
":",
"bool",
"=",
"True",
")",
"->",
"pd",
".",
"DataFrame",
":",
"local_df",
"=",
"self",
".",
"df",
".",
"copy",
"(",
")",
"if",
"qname_predicate... | Multi funcitonal DataFrame with settings | [
"Multi",
"funcitonal",
"DataFrame",
"with",
"settings"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/ontopandas.py#L261-L270 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_rdflib.py | SimpleGraph.add_namespaces | def add_namespaces(self, namespaces: Dict[str, str]) -> None:
""" Adds a prefix to uri mapping (namespace) in bulk
Adds a namespace to replace any uris in iris with shortened prefixes
in order to make the file more readable. Not techniqually necessary.
Args: namespaces: prefix to uri m... | python | def add_namespaces(self, namespaces: Dict[str, str]) -> None:
""" Adds a prefix to uri mapping (namespace) in bulk
Adds a namespace to replace any uris in iris with shortened prefixes
in order to make the file more readable. Not techniqually necessary.
Args: namespaces: prefix to uri m... | [
"def",
"add_namespaces",
"(",
"self",
",",
"namespaces",
":",
"Dict",
"[",
"str",
",",
"str",
"]",
")",
"->",
"None",
":",
"for",
"prefix",
",",
"uri",
"in",
"namespaces",
".",
"items",
"(",
")",
":",
"self",
".",
"add_namespace",
"(",
"prefix",
"=",... | Adds a prefix to uri mapping (namespace) in bulk
Adds a namespace to replace any uris in iris with shortened prefixes
in order to make the file more readable. Not techniqually necessary.
Args: namespaces: prefix to uri mappings
Example:
add_namespaces(
name... | [
"Adds",
"a",
"prefix",
"to",
"uri",
"mapping",
"(",
"namespace",
")",
"in",
"bulk"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_rdflib.py#L42-L59 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_rdflib.py | SimpleGraph.qname | def qname(self, iri: str) -> str:
""" Get qualified name of uri in rdflib graph while also saving it
Args: iri: The iri that you want to replace the uri with a known prefix with
Returns: qualified name of the iri to be used as the new predicate
"""
prefix, namespace, name = sel... | python | def qname(self, iri: str) -> str:
""" Get qualified name of uri in rdflib graph while also saving it
Args: iri: The iri that you want to replace the uri with a known prefix with
Returns: qualified name of the iri to be used as the new predicate
"""
prefix, namespace, name = sel... | [
"def",
"qname",
"(",
"self",
",",
"iri",
":",
"str",
")",
"->",
"str",
":",
"prefix",
",",
"namespace",
",",
"name",
"=",
"self",
".",
"g",
".",
"compute_qname",
"(",
"uri",
")",
"qname",
"=",
"prefix",
"+",
"':'",
"+",
"name",
"self",
".",
"rqna... | Get qualified name of uri in rdflib graph while also saving it
Args: iri: The iri that you want to replace the uri with a known prefix with
Returns: qualified name of the iri to be used as the new predicate | [
"Get",
"qualified",
"name",
"of",
"uri",
"in",
"rdflib",
"graph",
"while",
"also",
"saving",
"it"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_rdflib.py#L61-L71 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_rdflib.py | SimpleGraph.add_namespace | def add_namespace(self, prefix: str, uri: str) -> Namespace:
""" Adds a prefix to uri mapping (namespace)
Adds a namespace to replace any uris in iris with shortened prefixes
in order to make the file more readable. Not techniqually necessary.
Args:
prefix: prefix that will... | python | def add_namespace(self, prefix: str, uri: str) -> Namespace:
""" Adds a prefix to uri mapping (namespace)
Adds a namespace to replace any uris in iris with shortened prefixes
in order to make the file more readable. Not techniqually necessary.
Args:
prefix: prefix that will... | [
"def",
"add_namespace",
"(",
"self",
",",
"prefix",
":",
"str",
",",
"uri",
":",
"str",
")",
"->",
"Namespace",
":",
"ns",
"=",
"Namespace",
"(",
"uri",
")",
"if",
"not",
"self",
".",
"namespaces",
".",
"get",
"(",
"prefix",
")",
":",
"self",
".",
... | Adds a prefix to uri mapping (namespace)
Adds a namespace to replace any uris in iris with shortened prefixes
in order to make the file more readable. Not techniqually necessary.
Args:
prefix: prefix that will substitute the uri in the iri
uri: the uri in the iri to be ... | [
"Adds",
"a",
"prefix",
"to",
"uri",
"mapping",
"(",
"namespace",
")"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_rdflib.py#L73-L100 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_rdflib.py | SimpleGraph.find_prefix | def find_prefix(self, iri: Union[URIRef, Literal, str]) -> Union[None, str]:
""" Finds if uri is in common_namespaces
Auto adds prefix if incoming iri has a uri in common_namespaces. If its not in the local
library, then it will just be spit out as the iri and not saved/condensed into qualified... | python | def find_prefix(self, iri: Union[URIRef, Literal, str]) -> Union[None, str]:
""" Finds if uri is in common_namespaces
Auto adds prefix if incoming iri has a uri in common_namespaces. If its not in the local
library, then it will just be spit out as the iri and not saved/condensed into qualified... | [
"def",
"find_prefix",
"(",
"self",
",",
"iri",
":",
"Union",
"[",
"URIRef",
",",
"Literal",
",",
"str",
"]",
")",
"->",
"Union",
"[",
"None",
",",
"str",
"]",
":",
"iri",
"=",
"str",
"(",
"iri",
")",
"max_iri_len",
"=",
"0",
"max_prefix",
"=",
"N... | Finds if uri is in common_namespaces
Auto adds prefix if incoming iri has a uri in common_namespaces. If its not in the local
library, then it will just be spit out as the iri and not saved/condensed into qualified
names.
The reason for the maxes is find the longest string match. This ... | [
"Finds",
"if",
"uri",
"is",
"in",
"common_namespaces"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_rdflib.py#L102-L127 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_rdflib.py | SimpleGraph.add_annotation | def add_annotation(
self,
subj: URIRef,
pred: URIRef,
obj: Union[Literal, URIRef],
a_p: URIRef ,
a_o: Union[Literal, URIRef],
) -> BNode:
""" Adds annotation to rdflib graph.
The annotation axiom will filled in if this is a... | python | def add_annotation(
self,
subj: URIRef,
pred: URIRef,
obj: Union[Literal, URIRef],
a_p: URIRef ,
a_o: Union[Literal, URIRef],
) -> BNode:
""" Adds annotation to rdflib graph.
The annotation axiom will filled in if this is a... | [
"def",
"add_annotation",
"(",
"self",
",",
"subj",
":",
"URIRef",
",",
"pred",
":",
"URIRef",
",",
"obj",
":",
"Union",
"[",
"Literal",
",",
"URIRef",
"]",
",",
"a_p",
":",
"URIRef",
",",
"a_o",
":",
"Union",
"[",
"Literal",
",",
"URIRef",
"]",
","... | Adds annotation to rdflib graph.
The annotation axiom will filled in if this is a new annotation for the triple.
Args:
subj: Entity subject to be annotated
pref: Entities Predicate Anchor to be annotated
obj: Entities Object Anchor to be annotated
a_p: A... | [
"Adds",
"annotation",
"to",
"rdflib",
"graph",
"."
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_rdflib.py#L129-L163 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_rdflib.py | SimpleGraph.add_triple | def add_triple(
self,
subj: Union[URIRef, str],
pred: Union[URIRef, str],
obj: Union[URIRef, Literal, str]
) -> None:
""" Adds triple to rdflib Graph
Triple can be of any subject, predicate, and object of the entity without a need for order.
... | python | def add_triple(
self,
subj: Union[URIRef, str],
pred: Union[URIRef, str],
obj: Union[URIRef, Literal, str]
) -> None:
""" Adds triple to rdflib Graph
Triple can be of any subject, predicate, and object of the entity without a need for order.
... | [
"def",
"add_triple",
"(",
"self",
",",
"subj",
":",
"Union",
"[",
"URIRef",
",",
"str",
"]",
",",
"pred",
":",
"Union",
"[",
"URIRef",
",",
"str",
"]",
",",
"obj",
":",
"Union",
"[",
"URIRef",
",",
"Literal",
",",
"str",
"]",
")",
"->",
"None",
... | Adds triple to rdflib Graph
Triple can be of any subject, predicate, and object of the entity without a need for order.
Args:
subj: Entity subject
pred: Entity predicate
obj: Entity object
Example:
In [1]: add_triple(
...: 'h... | [
"Adds",
"triple",
"to",
"rdflib",
"Graph"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_rdflib.py#L165-L191 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_rdflib.py | SimpleGraph.process_prefix | def process_prefix(self, prefix: str) -> Union[Namespace, None]:
""" Add namespace to graph if it has a local match
This allows qnames to be used without adding their respected namespaces if they are in
the common_namespaces local dict. This is is to save a butt-ton of time trying to see what
... | python | def process_prefix(self, prefix: str) -> Union[Namespace, None]:
""" Add namespace to graph if it has a local match
This allows qnames to be used without adding their respected namespaces if they are in
the common_namespaces local dict. This is is to save a butt-ton of time trying to see what
... | [
"def",
"process_prefix",
"(",
"self",
",",
"prefix",
":",
"str",
")",
"->",
"Union",
"[",
"Namespace",
",",
"None",
"]",
":",
"if",
"self",
".",
"namespaces",
".",
"get",
"(",
"prefix",
")",
":",
"return",
"self",
".",
"namespaces",
"[",
"prefix",
"]... | Add namespace to graph if it has a local match
This allows qnames to be used without adding their respected namespaces if they are in
the common_namespaces local dict. This is is to save a butt-ton of time trying to see what
the ontology has as far as uris go.
Args: prefix: prefix of t... | [
"Add",
"namespace",
"to",
"graph",
"if",
"it",
"has",
"a",
"local",
"match"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_rdflib.py#L193-L209 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_rdflib.py | SimpleGraph.process_subj_or_pred | def process_subj_or_pred(self, component: Union[URIRef, str]) -> URIRef:
""" Adds viable uri from iri or expands viable qname to iri to be triple ready
Need to have a viable qualified name (qname) in order to use a qname. You can make it
viable by either add the namespace beforehand with add_na... | python | def process_subj_or_pred(self, component: Union[URIRef, str]) -> URIRef:
""" Adds viable uri from iri or expands viable qname to iri to be triple ready
Need to have a viable qualified name (qname) in order to use a qname. You can make it
viable by either add the namespace beforehand with add_na... | [
"def",
"process_subj_or_pred",
"(",
"self",
",",
"component",
":",
"Union",
"[",
"URIRef",
",",
"str",
"]",
")",
"->",
"URIRef",
":",
"if",
"'http'",
"in",
"component",
":",
"prefix",
"=",
"self",
".",
"find_prefix",
"(",
"component",
")",
"# Find uri in i... | Adds viable uri from iri or expands viable qname to iri to be triple ready
Need to have a viable qualified name (qname) in order to use a qname. You can make it
viable by either add the namespace beforehand with add_namespace(s) or if its already
in the local common_namespaces preloaded.
... | [
"Adds",
"viable",
"uri",
"from",
"iri",
"or",
"expands",
"viable",
"qname",
"to",
"iri",
"to",
"be",
"triple",
"ready"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_rdflib.py#L211-L237 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_rdflib.py | SimpleGraph.process_obj | def process_obj(self, obj: Union[URIRef, Literal, str]) -> Union[URIRef, Literal]:
""" Gives component the proper node type
Args:
obj: Entity object to be converted to its appropriate node type
Returns:
URIRef or Literal type of the object provided.
Raises:
... | python | def process_obj(self, obj: Union[URIRef, Literal, str]) -> Union[URIRef, Literal]:
""" Gives component the proper node type
Args:
obj: Entity object to be converted to its appropriate node type
Returns:
URIRef or Literal type of the object provided.
Raises:
... | [
"def",
"process_obj",
"(",
"self",
",",
"obj",
":",
"Union",
"[",
"URIRef",
",",
"Literal",
",",
"str",
"]",
")",
"->",
"Union",
"[",
"URIRef",
",",
"Literal",
"]",
":",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
"or",
"isinstance",
"(",
"ob... | Gives component the proper node type
Args:
obj: Entity object to be converted to its appropriate node type
Returns:
URIRef or Literal type of the object provided.
Raises:
SystemExit: If object is a dict or list it becomes str with broken data. Needs to
... | [
"Gives",
"component",
"the",
"proper",
"node",
"type"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_rdflib.py#L239-L271 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_rdflib.py | SimpleGraph.serialize | def serialize(self, **kwargs) -> str:
""" rdflib.Graph().serialize wrapper
Original serialize cannot handle PosixPath from pathlib. You should ignore everything, but
destination and format. format is a must, but if you don't include a destination, it will
just return the formated graph ... | python | def serialize(self, **kwargs) -> str:
""" rdflib.Graph().serialize wrapper
Original serialize cannot handle PosixPath from pathlib. You should ignore everything, but
destination and format. format is a must, but if you don't include a destination, it will
just return the formated graph ... | [
"def",
"serialize",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"str",
":",
"kwargs",
"=",
"{",
"key",
":",
"str",
"(",
"value",
")",
"for",
"key",
",",
"value",
"in",
"kwargs",
".",
"items",
"(",
")",
"}",
"return",
"self",
".",
"g",
".",... | rdflib.Graph().serialize wrapper
Original serialize cannot handle PosixPath from pathlib. You should ignore everything, but
destination and format. format is a must, but if you don't include a destination, it will
just return the formated graph as an str output.
Args:
desti... | [
"rdflib",
".",
"Graph",
"()",
".",
"serialize",
"wrapper"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_rdflib.py#L273-L289 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_rdflib.py | SimpleGraph.remove_triple | def remove_triple(
self,
subj: URIRef,
pred: URIRef,
obj: Union[URIRef, Literal]
) -> None:
""" Removes triple from rdflib Graph
You must input the triple in its URIRef or Literal form for each node exactly the way it
was inputed or it wil... | python | def remove_triple(
self,
subj: URIRef,
pred: URIRef,
obj: Union[URIRef, Literal]
) -> None:
""" Removes triple from rdflib Graph
You must input the triple in its URIRef or Literal form for each node exactly the way it
was inputed or it wil... | [
"def",
"remove_triple",
"(",
"self",
",",
"subj",
":",
"URIRef",
",",
"pred",
":",
"URIRef",
",",
"obj",
":",
"Union",
"[",
"URIRef",
",",
"Literal",
"]",
")",
"->",
"None",
":",
"self",
".",
"g",
".",
"remove",
"(",
"(",
"subj",
",",
"pred",
","... | Removes triple from rdflib Graph
You must input the triple in its URIRef or Literal form for each node exactly the way it
was inputed or it will not delete the triple.
Args:
subj: Entity subject to be removed it its the only node with this subject; else this is
just... | [
"Removes",
"triple",
"from",
"rdflib",
"Graph"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_rdflib.py#L291-L308 |
tgbugs/pyontutils | ilxutils/ilxutils/simple_rdflib.py | SimpleGraph.print_graph | def print_graph(self, format: str = 'turtle') -> str:
""" prints serialized formated rdflib Graph """
print(self.g.serialize(format=format).decode('utf-8')) | python | def print_graph(self, format: str = 'turtle') -> str:
""" prints serialized formated rdflib Graph """
print(self.g.serialize(format=format).decode('utf-8')) | [
"def",
"print_graph",
"(",
"self",
",",
"format",
":",
"str",
"=",
"'turtle'",
")",
"->",
"str",
":",
"print",
"(",
"self",
".",
"g",
".",
"serialize",
"(",
"format",
"=",
"format",
")",
".",
"decode",
"(",
"'utf-8'",
")",
")"
] | prints serialized formated rdflib Graph | [
"prints",
"serialized",
"formated",
"rdflib",
"Graph"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/simple_rdflib.py#L310-L312 |
tgbugs/pyontutils | ilxutils/ilxutils/scicrunch_client.py | scicrunch.identifierSearches | def identifierSearches(self,
ids=None,
LIMIT=25,
_print=True,
crawl=False):
"""parameters( data = "list of term_ids" )"""
url_base = self.base_url + '/api/1/term/view/{id}' + '?key=' + self.api_ke... | python | def identifierSearches(self,
ids=None,
LIMIT=25,
_print=True,
crawl=False):
"""parameters( data = "list of term_ids" )"""
url_base = self.base_url + '/api/1/term/view/{id}' + '?key=' + self.api_ke... | [
"def",
"identifierSearches",
"(",
"self",
",",
"ids",
"=",
"None",
",",
"LIMIT",
"=",
"25",
",",
"_print",
"=",
"True",
",",
"crawl",
"=",
"False",
")",
":",
"url_base",
"=",
"self",
".",
"base_url",
"+",
"'/api/1/term/view/{id}'",
"+",
"'?key='",
"+",
... | parameters( data = "list of term_ids" ) | [
"parameters",
"(",
"data",
"=",
"list",
"of",
"term_ids",
")"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/scicrunch_client.py#L310-L323 |
tgbugs/pyontutils | ilxutils/ilxutils/scicrunch_client.py | scicrunch.ilxSearches | def ilxSearches(self,
ilx_ids=None,
LIMIT=25,
_print=True,
crawl=False):
"""parameters( data = "list of ilx_ids" )"""
url_base = self.base_url + "/api/1/ilx/search/identifier/{identifier}?key={APIKEY}"
urls = [url_ba... | python | def ilxSearches(self,
ilx_ids=None,
LIMIT=25,
_print=True,
crawl=False):
"""parameters( data = "list of ilx_ids" )"""
url_base = self.base_url + "/api/1/ilx/search/identifier/{identifier}?key={APIKEY}"
urls = [url_ba... | [
"def",
"ilxSearches",
"(",
"self",
",",
"ilx_ids",
"=",
"None",
",",
"LIMIT",
"=",
"25",
",",
"_print",
"=",
"True",
",",
"crawl",
"=",
"False",
")",
":",
"url_base",
"=",
"self",
".",
"base_url",
"+",
"\"/api/1/ilx/search/identifier/{identifier}?key={APIKEY}\... | parameters( data = "list of ilx_ids" ) | [
"parameters",
"(",
"data",
"=",
"list",
"of",
"ilx_ids",
")"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/scicrunch_client.py#L325-L338 |
tgbugs/pyontutils | ilxutils/ilxutils/scicrunch_client.py | scicrunch.updateTerms | def updateTerms(self, data:list, LIMIT:int=20, _print:bool=True, crawl:bool=False,) -> list:
""" Updates existing entities
Args:
data:
needs:
id <str>
ilx_id <str>
options:
... | python | def updateTerms(self, data:list, LIMIT:int=20, _print:bool=True, crawl:bool=False,) -> list:
""" Updates existing entities
Args:
data:
needs:
id <str>
ilx_id <str>
options:
... | [
"def",
"updateTerms",
"(",
"self",
",",
"data",
":",
"list",
",",
"LIMIT",
":",
"int",
"=",
"20",
",",
"_print",
":",
"bool",
"=",
"True",
",",
"crawl",
":",
"bool",
"=",
"False",
",",
")",
"->",
"list",
":",
"url_base",
"=",
"self",
".",
"base_u... | Updates existing entities
Args:
data:
needs:
id <str>
ilx_id <str>
options:
definition <str> #bug with qutations
superclasses ... | [
"Updates",
"existing",
"entities"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/scicrunch_client.py#L340-L398 |
tgbugs/pyontutils | ilxutils/ilxutils/scicrunch_client.py | scicrunch.addTerms | def addTerms(self, data, LIMIT=25, _print=True, crawl=False):
"""
need:
label <str>
type term, cde, anntation, or relationship <str>
options:
definition <str> #bug with qutations
sup... | python | def addTerms(self, data, LIMIT=25, _print=True, crawl=False):
"""
need:
label <str>
type term, cde, anntation, or relationship <str>
options:
definition <str> #bug with qutations
sup... | [
"def",
"addTerms",
"(",
"self",
",",
"data",
",",
"LIMIT",
"=",
"25",
",",
"_print",
"=",
"True",
",",
"crawl",
"=",
"False",
")",
":",
"needed",
"=",
"set",
"(",
"[",
"'label'",
",",
"'type'",
",",
"]",
")",
"url_base",
"=",
"self",
".",
"base_u... | need:
label <str>
type term, cde, anntation, or relationship <str>
options:
definition <str> #bug with qutations
superclasses [{'id':<int>}]
synonyms [{'literal':<str>}]
... | [
"need",
":",
"label",
"<str",
">",
"type",
"term",
"cde",
"anntation",
"or",
"relationship",
"<str",
">",
"options",
":",
"definition",
"<str",
">",
"#bug",
"with",
"qutations",
"superclasses",
"[",
"{",
"id",
":",
"<int",
">",
"}",
"]",
"synonyms",
"[",... | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/scicrunch_client.py#L400-L464 |
tgbugs/pyontutils | ilxutils/ilxutils/scicrunch_client.py | scicrunch.getAnnotations_via_tid | def getAnnotations_via_tid(self,
tids,
LIMIT=25,
_print=True,
crawl=False):
"""
tids = list of term ids that possess the annoations
"""
url_base = self.base_url + \... | python | def getAnnotations_via_tid(self,
tids,
LIMIT=25,
_print=True,
crawl=False):
"""
tids = list of term ids that possess the annoations
"""
url_base = self.base_url + \... | [
"def",
"getAnnotations_via_tid",
"(",
"self",
",",
"tids",
",",
"LIMIT",
"=",
"25",
",",
"_print",
"=",
"True",
",",
"crawl",
"=",
"False",
")",
":",
"url_base",
"=",
"self",
".",
"base_url",
"+",
"'/api/1/term/get-annotations/{tid}?key='",
"+",
"self",
".",... | tids = list of term ids that possess the annoations | [
"tids",
"=",
"list",
"of",
"term",
"ids",
"that",
"possess",
"the",
"annoations"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/scicrunch_client.py#L502-L516 |
tgbugs/pyontutils | ilxutils/ilxutils/scicrunch_client.py | scicrunch.getAnnotations_via_id | def getAnnotations_via_id(self,
annotation_ids,
LIMIT=25,
_print=True,
crawl=False):
"""tids = list of strings or ints that are the ids of the annotations themselves"""
url_base = self... | python | def getAnnotations_via_id(self,
annotation_ids,
LIMIT=25,
_print=True,
crawl=False):
"""tids = list of strings or ints that are the ids of the annotations themselves"""
url_base = self... | [
"def",
"getAnnotations_via_id",
"(",
"self",
",",
"annotation_ids",
",",
"LIMIT",
"=",
"25",
",",
"_print",
"=",
"True",
",",
"crawl",
"=",
"False",
")",
":",
"url_base",
"=",
"self",
".",
"base_url",
"+",
"'/api/1/term/get-annotation/{id}?key='",
"+",
"self",... | tids = list of strings or ints that are the ids of the annotations themselves | [
"tids",
"=",
"list",
"of",
"strings",
"or",
"ints",
"that",
"are",
"the",
"ids",
"of",
"the",
"annotations",
"themselves"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/scicrunch_client.py#L518-L530 |
tgbugs/pyontutils | ilxutils/ilxutils/scicrunch_client.py | scicrunch.updateAnnotations | def updateAnnotations(self,
data,
LIMIT=25,
_print=True,
crawl=False,):
"""data = [{'id', 'tid', 'annotation_tid', 'value', 'comment', 'upvote', 'downvote',
'curator_status', 'withdrawn', 'term_versio... | python | def updateAnnotations(self,
data,
LIMIT=25,
_print=True,
crawl=False,):
"""data = [{'id', 'tid', 'annotation_tid', 'value', 'comment', 'upvote', 'downvote',
'curator_status', 'withdrawn', 'term_versio... | [
"def",
"updateAnnotations",
"(",
"self",
",",
"data",
",",
"LIMIT",
"=",
"25",
",",
"_print",
"=",
"True",
",",
"crawl",
"=",
"False",
",",
")",
":",
"url_base",
"=",
"self",
".",
"base_url",
"+",
"'/api/1/term/edit-annotation/{id}'",
"# id of annotation not t... | data = [{'id', 'tid', 'annotation_tid', 'value', 'comment', 'upvote', 'downvote',
'curator_status', 'withdrawn', 'term_version', 'annotation_term_version', 'orig_uid',
'orig_time'}] | [
"data",
"=",
"[",
"{",
"id",
"tid",
"annotation_tid",
"value",
"comment",
"upvote",
"downvote",
"curator_status",
"withdrawn",
"term_version",
"annotation_term_version",
"orig_uid",
"orig_time",
"}",
"]"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/scicrunch_client.py#L532-L558 |
tgbugs/pyontutils | ilxutils/ilxutils/scicrunch_client.py | scicrunch.deleteAnnotations | def deleteAnnotations(self,
annotation_ids,
LIMIT=25,
_print=True,
crawl=False,):
"""data = list of ids"""
url_base = self.base_url + \
'/api/1/term/edit-annotation/{annotation_id}' # id ... | python | def deleteAnnotations(self,
annotation_ids,
LIMIT=25,
_print=True,
crawl=False,):
"""data = list of ids"""
url_base = self.base_url + \
'/api/1/term/edit-annotation/{annotation_id}' # id ... | [
"def",
"deleteAnnotations",
"(",
"self",
",",
"annotation_ids",
",",
"LIMIT",
"=",
"25",
",",
"_print",
"=",
"True",
",",
"crawl",
"=",
"False",
",",
")",
":",
"url_base",
"=",
"self",
".",
"base_url",
"+",
"'/api/1/term/edit-annotation/{annotation_id}'",
"# i... | data = list of ids | [
"data",
"=",
"list",
"of",
"ids"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/scicrunch_client.py#L560-L588 |
tgbugs/pyontutils | ilxutils/ilxutils/scicrunch_client.py | scicrunch.addRelationships | def addRelationships(
self,
data: list,
LIMIT: int = 20,
_print: bool = True,
crawl: bool = False,
) -> list:
"""
data = [{
"term1_id", "term2_id", "relationship_tid",
"term1_version", "term2_version",
"relationship_term... | python | def addRelationships(
self,
data: list,
LIMIT: int = 20,
_print: bool = True,
crawl: bool = False,
) -> list:
"""
data = [{
"term1_id", "term2_id", "relationship_tid",
"term1_version", "term2_version",
"relationship_term... | [
"def",
"addRelationships",
"(",
"self",
",",
"data",
":",
"list",
",",
"LIMIT",
":",
"int",
"=",
"20",
",",
"_print",
":",
"bool",
"=",
"True",
",",
"crawl",
":",
"bool",
"=",
"False",
",",
")",
"->",
"list",
":",
"url_base",
"=",
"self",
".",
"b... | data = [{
"term1_id", "term2_id", "relationship_tid",
"term1_version", "term2_version",
"relationship_term_version",}] | [
"data",
"=",
"[",
"{",
"term1_id",
"term2_id",
"relationship_tid",
"term1_version",
"term2_version",
"relationship_term_version",
"}",
"]"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/scicrunch_client.py#L590-L618 |
tgbugs/pyontutils | ilxutils/ilxutils/scicrunch_client.py | scicrunch.deprecate_entity | def deprecate_entity(
self,
ilx_id: str,
note = None,
) -> None:
""" Tagged term in interlex to warn this term is no longer used
There isn't an proper way to delete a term and so we have to mark it so I can
extrapolate that in mysql/ttl loads.
Args:
... | python | def deprecate_entity(
self,
ilx_id: str,
note = None,
) -> None:
""" Tagged term in interlex to warn this term is no longer used
There isn't an proper way to delete a term and so we have to mark it so I can
extrapolate that in mysql/ttl loads.
Args:
... | [
"def",
"deprecate_entity",
"(",
"self",
",",
"ilx_id",
":",
"str",
",",
"note",
"=",
"None",
",",
")",
"->",
"None",
":",
"term_id",
",",
"term_version",
"=",
"[",
"(",
"d",
"[",
"'id'",
"]",
",",
"d",
"[",
"'version'",
"]",
")",
"for",
"d",
"in"... | Tagged term in interlex to warn this term is no longer used
There isn't an proper way to delete a term and so we have to mark it so I can
extrapolate that in mysql/ttl loads.
Args:
term_id: id of the term of which to be deprecated
term_version: version of the term of wh... | [
"Tagged",
"term",
"in",
"interlex",
"to",
"warn",
"this",
"term",
"is",
"no",
"longer",
"used"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/scicrunch_client.py#L647-L684 |
tgbugs/pyontutils | ilxutils/ilxutils/scicrunch_client.py | scicrunch.force_add_term | def force_add_term(self, entity: dict):
""" Need to add an entity that already has a label existing in InterLex?
Well this is the function for you!
entity:
need:
label <str>
type term, cde, pde, fde, an... | python | def force_add_term(self, entity: dict):
""" Need to add an entity that already has a label existing in InterLex?
Well this is the function for you!
entity:
need:
label <str>
type term, cde, pde, fde, an... | [
"def",
"force_add_term",
"(",
"self",
",",
"entity",
":",
"dict",
")",
":",
"needed",
"=",
"set",
"(",
"[",
"'label'",
",",
"'type'",
",",
"]",
")",
"url_ilx_add",
"=",
"self",
".",
"base_url",
"+",
"'/api/1/ilx/add'",
"url_term_add",
"=",
"self",
".",
... | Need to add an entity that already has a label existing in InterLex?
Well this is the function for you!
entity:
need:
label <str>
type term, cde, pde, fde, anntation, or relationship <str>
optio... | [
"Need",
"to",
"add",
"an",
"entity",
"that",
"already",
"has",
"a",
"label",
"existing",
"in",
"InterLex?",
"Well",
"this",
"is",
"the",
"function",
"for",
"you!"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/scicrunch_client.py#L783-L841 |
tgbugs/pyontutils | ilxutils/ilxutils/database_client.py | DatabaseClient.create_df_file_with_query | def create_df_file_with_query(self, query, output):
""" Dumps in df in chunks to avoid crashes.
"""
chunk_size = 100000
offset = 0
data = defaultdict(lambda : defaultdict(list))
with open(output, 'wb') as outfile:
query = query.replace(';', '')
qu... | python | def create_df_file_with_query(self, query, output):
""" Dumps in df in chunks to avoid crashes.
"""
chunk_size = 100000
offset = 0
data = defaultdict(lambda : defaultdict(list))
with open(output, 'wb') as outfile:
query = query.replace(';', '')
qu... | [
"def",
"create_df_file_with_query",
"(",
"self",
",",
"query",
",",
"output",
")",
":",
"chunk_size",
"=",
"100000",
"offset",
"=",
"0",
"data",
"=",
"defaultdict",
"(",
"lambda",
":",
"defaultdict",
"(",
"list",
")",
")",
"with",
"open",
"(",
"output",
... | Dumps in df in chunks to avoid crashes. | [
"Dumps",
"in",
"df",
"in",
"chunks",
"to",
"avoid",
"crashes",
"."
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/database_client.py#L53-L74 |
tgbugs/pyontutils | ilxutils/ilxutils/mydifflib.py | diff | def diff(s1, s2):
''' --word-diff=porcelain clone'''
delta = difflib.Differ().compare(s1.split(), s2.split())
difflist = []
fullline = ''
for line in delta:
if line[0] == '?':
continue
elif line[0] == ' ':
fullline += line.strip() + ' '
else:
... | python | def diff(s1, s2):
''' --word-diff=porcelain clone'''
delta = difflib.Differ().compare(s1.split(), s2.split())
difflist = []
fullline = ''
for line in delta:
if line[0] == '?':
continue
elif line[0] == ' ':
fullline += line.strip() + ' '
else:
... | [
"def",
"diff",
"(",
"s1",
",",
"s2",
")",
":",
"delta",
"=",
"difflib",
".",
"Differ",
"(",
")",
".",
"compare",
"(",
"s1",
".",
"split",
"(",
")",
",",
"s2",
".",
"split",
"(",
")",
")",
"difflist",
"=",
"[",
"]",
"fullline",
"=",
"''",
"for... | --word-diff=porcelain clone | [
"--",
"word",
"-",
"diff",
"=",
"porcelain",
"clone"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/mydifflib.py#L7-L24 |
tgbugs/pyontutils | ilxutils/ilxutils/mydifflib.py | diffcolor | def diffcolor(s1, s2):
''' --word-diff=color clone '''
string = ''
for line in diff(s1, s2):
if line[0] == '-':
string += ' ' + TermColors.red(line[2:])
elif line[0] == '+':
string += ' ' + TermColors.green(line[2:])
else:
string += ' ' + line
... | python | def diffcolor(s1, s2):
''' --word-diff=color clone '''
string = ''
for line in diff(s1, s2):
if line[0] == '-':
string += ' ' + TermColors.red(line[2:])
elif line[0] == '+':
string += ' ' + TermColors.green(line[2:])
else:
string += ' ' + line
... | [
"def",
"diffcolor",
"(",
"s1",
",",
"s2",
")",
":",
"string",
"=",
"''",
"for",
"line",
"in",
"diff",
"(",
"s1",
",",
"s2",
")",
":",
"if",
"line",
"[",
"0",
"]",
"==",
"'-'",
":",
"string",
"+=",
"' '",
"+",
"TermColors",
".",
"red",
"(",
"l... | --word-diff=color clone | [
"--",
"word",
"-",
"diff",
"=",
"color",
"clone"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/mydifflib.py#L27-L37 |
tgbugs/pyontutils | ilxutils/ilxutils/mydifflib.py | create_html | def create_html(s1, s2, output='test.html'):
''' creates basic html based on the diff of 2 strings '''
html = difflib.HtmlDiff().make_file(s1.split(), s2.split())
with open(output, 'w') as f:
f.write(html) | python | def create_html(s1, s2, output='test.html'):
''' creates basic html based on the diff of 2 strings '''
html = difflib.HtmlDiff().make_file(s1.split(), s2.split())
with open(output, 'w') as f:
f.write(html) | [
"def",
"create_html",
"(",
"s1",
",",
"s2",
",",
"output",
"=",
"'test.html'",
")",
":",
"html",
"=",
"difflib",
".",
"HtmlDiff",
"(",
")",
".",
"make_file",
"(",
"s1",
".",
"split",
"(",
")",
",",
"s2",
".",
"split",
"(",
")",
")",
"with",
"open... | creates basic html based on the diff of 2 strings | [
"creates",
"basic",
"html",
"based",
"on",
"the",
"diff",
"of",
"2",
"strings"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/mydifflib.py#L45-L49 |
tgbugs/pyontutils | ilxutils/ilxutils/mydifflib.py | traverse_data | def traverse_data(obj, key_target):
''' will traverse nested list and dicts until key_target equals the current dict key '''
if isinstance(obj, str) and '.json' in str(obj):
obj = json.load(open(obj, 'r'))
if isinstance(obj, list):
queue = obj.copy()
elif isinstance(obj, dict):
q... | python | def traverse_data(obj, key_target):
''' will traverse nested list and dicts until key_target equals the current dict key '''
if isinstance(obj, str) and '.json' in str(obj):
obj = json.load(open(obj, 'r'))
if isinstance(obj, list):
queue = obj.copy()
elif isinstance(obj, dict):
q... | [
"def",
"traverse_data",
"(",
"obj",
",",
"key_target",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"str",
")",
"and",
"'.json'",
"in",
"str",
"(",
"obj",
")",
":",
"obj",
"=",
"json",
".",
"load",
"(",
"open",
"(",
"obj",
",",
"'r'",
")",
")",... | will traverse nested list and dicts until key_target equals the current dict key | [
"will",
"traverse",
"nested",
"list",
"and",
"dicts",
"until",
"key_target",
"equals",
"the",
"current",
"dict",
"key"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/mydifflib.py#L52-L78 |
tgbugs/pyontutils | ilxutils/ilxutils/mydifflib.py | json_diff | def json_diff(json1, json2, key_target, get_just_diff=True, porcelain=False):
''' creates a (keyname + diff) key within the json of the same layer which key_target resides.
Ex: json1={'definition':'data of key_target'}, json2={'definition':'data of key_target'}
key_target = 'definition'
Usage:
... | python | def json_diff(json1, json2, key_target, get_just_diff=True, porcelain=False):
''' creates a (keyname + diff) key within the json of the same layer which key_target resides.
Ex: json1={'definition':'data of key_target'}, json2={'definition':'data of key_target'}
key_target = 'definition'
Usage:
... | [
"def",
"json_diff",
"(",
"json1",
",",
"json2",
",",
"key_target",
",",
"get_just_diff",
"=",
"True",
",",
"porcelain",
"=",
"False",
")",
":",
"json1",
"=",
"json_secretary",
"(",
"json1",
")",
"json2",
"=",
"json_secretary",
"(",
"json2",
")",
"obj1",
... | creates a (keyname + diff) key within the json of the same layer which key_target resides.
Ex: json1={'definition':'data of key_target'}, json2={'definition':'data of key_target'}
key_target = 'definition'
Usage:
json_diff (
json_data1, json_data1 can be both [{..}] ... | [
"creates",
"a",
"(",
"keyname",
"+",
"diff",
")",
"key",
"within",
"the",
"json",
"of",
"the",
"same",
"layer",
"which",
"key_target",
"resides",
".",
"Ex",
":",
"json1",
"=",
"{",
"definition",
":",
"data",
"of",
"key_target",
"}",
"json2",
"=",
"{",
... | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/mydifflib.py#L89-L119 |
tgbugs/pyontutils | pyontutils/utils_extra.py | memoryCheck | def memoryCheck(vms_max_kb):
""" Lookup vms_max using getCurrentVMSKb """
safety_factor = 1.2
vms_max = vms_max_kb
vms_gigs = vms_max / 1024 ** 2
buffer = safety_factor * vms_max
buffer_gigs = buffer / 1024 ** 2
vm = psutil.virtual_memory()
free_gigs = vm.available / 1024 ** 2
if vm.... | python | def memoryCheck(vms_max_kb):
""" Lookup vms_max using getCurrentVMSKb """
safety_factor = 1.2
vms_max = vms_max_kb
vms_gigs = vms_max / 1024 ** 2
buffer = safety_factor * vms_max
buffer_gigs = buffer / 1024 ** 2
vm = psutil.virtual_memory()
free_gigs = vm.available / 1024 ** 2
if vm.... | [
"def",
"memoryCheck",
"(",
"vms_max_kb",
")",
":",
"safety_factor",
"=",
"1.2",
"vms_max",
"=",
"vms_max_kb",
"vms_gigs",
"=",
"vms_max",
"/",
"1024",
"**",
"2",
"buffer",
"=",
"safety_factor",
"*",
"vms_max",
"buffer_gigs",
"=",
"buffer",
"/",
"1024",
"**",... | Lookup vms_max using getCurrentVMSKb | [
"Lookup",
"vms_max",
"using",
"getCurrentVMSKb"
] | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/utils_extra.py#L76-L88 |
shanbay/peeweext | peeweext/mixins.py | SequenceMixin._sequence_query | def _sequence_query(self):
"""
query all sequence rows
"""
klass = self.__class__
query = klass.select().where(klass.sequence.is_null(False))
seq_scope_field_names =\
(self.__seq_scope_field_name__ or '').split(',')
for name in seq_scope_field_names:
... | python | def _sequence_query(self):
"""
query all sequence rows
"""
klass = self.__class__
query = klass.select().where(klass.sequence.is_null(False))
seq_scope_field_names =\
(self.__seq_scope_field_name__ or '').split(',')
for name in seq_scope_field_names:
... | [
"def",
"_sequence_query",
"(",
"self",
")",
":",
"klass",
"=",
"self",
".",
"__class__",
"query",
"=",
"klass",
".",
"select",
"(",
")",
".",
"where",
"(",
"klass",
".",
"sequence",
".",
"is_null",
"(",
"False",
")",
")",
"seq_scope_field_names",
"=",
... | query all sequence rows | [
"query",
"all",
"sequence",
"rows"
] | train | https://github.com/shanbay/peeweext/blob/ff62a3d01e4584d50fde1944b9616c3b4236ecf0/peeweext/mixins.py#L29-L42 |
tgbugs/pyontutils | pyontutils/sheets.py | update_sheet_values | def update_sheet_values(spreadsheet_name, sheet_name, values, spreadsheet_service=None):
SPREADSHEET_ID = devconfig.secrets(spreadsheet_name)
if spreadsheet_service is None:
service = get_oauth_service(readonly=False)
ss = service.spreadsheets()
else:
ss = spreadsheet_service
"""... | python | def update_sheet_values(spreadsheet_name, sheet_name, values, spreadsheet_service=None):
SPREADSHEET_ID = devconfig.secrets(spreadsheet_name)
if spreadsheet_service is None:
service = get_oauth_service(readonly=False)
ss = service.spreadsheets()
else:
ss = spreadsheet_service
"""... | [
"def",
"update_sheet_values",
"(",
"spreadsheet_name",
",",
"sheet_name",
",",
"values",
",",
"spreadsheet_service",
"=",
"None",
")",
":",
"SPREADSHEET_ID",
"=",
"devconfig",
".",
"secrets",
"(",
"spreadsheet_name",
")",
"if",
"spreadsheet_service",
"is",
"None",
... | requests = [
{'updateCells': {
'start': {'sheetId': TODO,
'rowIndex': 0,
'columnIndex': 0}
'rows': {'values'}
}
}]
response = ss.batchUpdate(
spreadsheetId=SPREADSHEET_ID, range=sheet_name,
body=body).execute... | [
"requests",
"=",
"[",
"{",
"updateCells",
":",
"{",
"start",
":",
"{",
"sheetId",
":",
"TODO",
"rowIndex",
":",
"0",
"columnIndex",
":",
"0",
"}",
"rows",
":",
"{",
"values",
"}",
"}",
"}",
"]",
"response",
"=",
"ss",
".",
"batchUpdate",
"(",
"spre... | train | https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/sheets.py#L32-L59 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.