repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
ssalentin/plip | plip/modules/pymolplip.py | PyMOLVisualizer.show_sbridges | def show_sbridges(self):
"""Visualize salt bridges."""
for i, saltb in enumerate(self.plcomplex.saltbridges):
if saltb.protispos:
for patom in saltb.positive_atoms:
cmd.select('PosCharge-P', 'PosCharge-P or (id %i & %s)' % (patom, self.protname))
... | python | def show_sbridges(self):
"""Visualize salt bridges."""
for i, saltb in enumerate(self.plcomplex.saltbridges):
if saltb.protispos:
for patom in saltb.positive_atoms:
cmd.select('PosCharge-P', 'PosCharge-P or (id %i & %s)' % (patom, self.protname))
... | [
"def",
"show_sbridges",
"(",
"self",
")",
":",
"for",
"i",
",",
"saltb",
"in",
"enumerate",
"(",
"self",
".",
"plcomplex",
".",
"saltbridges",
")",
":",
"if",
"saltb",
".",
"protispos",
":",
"for",
"patom",
"in",
"saltb",
".",
"positive_atoms",
":",
"c... | Visualize salt bridges. | [
"Visualize",
"salt",
"bridges",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/pymolplip.py#L193-L219 |
ssalentin/plip | plip/modules/pymolplip.py | PyMOLVisualizer.show_wbridges | def show_wbridges(self):
"""Visualize water bridges."""
for bridge in self.plcomplex.waterbridges:
if bridge.protisdon:
cmd.select('HBondDonor-P', 'HBondDonor-P or (id %i & %s)' % (bridge.don_id, self.protname))
cmd.select('HBondAccept-L', 'HBondAccept-L or (i... | python | def show_wbridges(self):
"""Visualize water bridges."""
for bridge in self.plcomplex.waterbridges:
if bridge.protisdon:
cmd.select('HBondDonor-P', 'HBondDonor-P or (id %i & %s)' % (bridge.don_id, self.protname))
cmd.select('HBondAccept-L', 'HBondAccept-L or (i... | [
"def",
"show_wbridges",
"(",
"self",
")",
":",
"for",
"bridge",
"in",
"self",
".",
"plcomplex",
".",
"waterbridges",
":",
"if",
"bridge",
".",
"protisdon",
":",
"cmd",
".",
"select",
"(",
"'HBondDonor-P'",
",",
"'HBondDonor-P or (id %i & %s)'",
"%",
"(",
"br... | Visualize water bridges. | [
"Visualize",
"water",
"bridges",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/pymolplip.py#L221-L242 |
ssalentin/plip | plip/modules/pymolplip.py | PyMOLVisualizer.show_metal | def show_metal(self):
"""Visualize metal coordination."""
metal_complexes = self.plcomplex.metal_complexes
if not len(metal_complexes) == 0:
self.select_by_ids('Metal-M', self.metal_ids)
for metal_complex in metal_complexes:
cmd.select('tmp_m', 'id %i' % m... | python | def show_metal(self):
"""Visualize metal coordination."""
metal_complexes = self.plcomplex.metal_complexes
if not len(metal_complexes) == 0:
self.select_by_ids('Metal-M', self.metal_ids)
for metal_complex in metal_complexes:
cmd.select('tmp_m', 'id %i' % m... | [
"def",
"show_metal",
"(",
"self",
")",
":",
"metal_complexes",
"=",
"self",
".",
"plcomplex",
".",
"metal_complexes",
"if",
"not",
"len",
"(",
"metal_complexes",
")",
"==",
"0",
":",
"self",
".",
"select_by_ids",
"(",
"'Metal-M'",
",",
"self",
".",
"metal_... | Visualize metal coordination. | [
"Visualize",
"metal",
"coordination",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/pymolplip.py#L244-L267 |
ssalentin/plip | plip/modules/pymolplip.py | PyMOLVisualizer.selections_cleanup | def selections_cleanup(self):
"""Cleans up non-used selections"""
if not len(self.plcomplex.unpaired_hba_idx) == 0:
self.select_by_ids('Unpaired-HBA', self.plcomplex.unpaired_hba_idx, selection_exists=True)
if not len(self.plcomplex.unpaired_hbd_idx) == 0:
self.select_by... | python | def selections_cleanup(self):
"""Cleans up non-used selections"""
if not len(self.plcomplex.unpaired_hba_idx) == 0:
self.select_by_ids('Unpaired-HBA', self.plcomplex.unpaired_hba_idx, selection_exists=True)
if not len(self.plcomplex.unpaired_hbd_idx) == 0:
self.select_by... | [
"def",
"selections_cleanup",
"(",
"self",
")",
":",
"if",
"not",
"len",
"(",
"self",
".",
"plcomplex",
".",
"unpaired_hba_idx",
")",
"==",
"0",
":",
"self",
".",
"select_by_ids",
"(",
"'Unpaired-HBA'",
",",
"self",
".",
"plcomplex",
".",
"unpaired_hba_idx",
... | Cleans up non-used selections | [
"Cleans",
"up",
"non",
"-",
"used",
"selections"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/pymolplip.py#L269-L289 |
ssalentin/plip | plip/modules/pymolplip.py | PyMOLVisualizer.selections_group | def selections_group(self):
"""Group all selections"""
cmd.group('Structures', '%s %s %sCartoon' % (self.protname, self.ligname, self.protname))
cmd.group('Interactions', 'Hydrophobic HBonds HalogenBonds WaterBridges PiCation PiStackingP PiStackingT '
'Saltbridg... | python | def selections_group(self):
"""Group all selections"""
cmd.group('Structures', '%s %s %sCartoon' % (self.protname, self.ligname, self.protname))
cmd.group('Interactions', 'Hydrophobic HBonds HalogenBonds WaterBridges PiCation PiStackingP PiStackingT '
'Saltbridg... | [
"def",
"selections_group",
"(",
"self",
")",
":",
"cmd",
".",
"group",
"(",
"'Structures'",
",",
"'%s %s %sCartoon'",
"%",
"(",
"self",
".",
"protname",
",",
"self",
".",
"ligname",
",",
"self",
".",
"protname",
")",
")",
"cmd",
".",
"group",
"(",
"'In... | Group all selections | [
"Group",
"all",
"selections"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/pymolplip.py#L291-L303 |
ssalentin/plip | plip/modules/pymolplip.py | PyMOLVisualizer.additional_cleanup | def additional_cleanup(self):
"""Cleanup of various representations"""
cmd.remove('not alt ""+A') # Remove alternate conformations
cmd.hide('labels', 'Interactions') # Hide labels of lines
cmd.disable('%sCartoon' % self.protname)
cmd.hide('everything', 'hydrogens') | python | def additional_cleanup(self):
"""Cleanup of various representations"""
cmd.remove('not alt ""+A') # Remove alternate conformations
cmd.hide('labels', 'Interactions') # Hide labels of lines
cmd.disable('%sCartoon' % self.protname)
cmd.hide('everything', 'hydrogens') | [
"def",
"additional_cleanup",
"(",
"self",
")",
":",
"cmd",
".",
"remove",
"(",
"'not alt \"\"+A'",
")",
"# Remove alternate conformations",
"cmd",
".",
"hide",
"(",
"'labels'",
",",
"'Interactions'",
")",
"# Hide labels of lines",
"cmd",
".",
"disable",
"(",
"'%sC... | Cleanup of various representations | [
"Cleanup",
"of",
"various",
"representations"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/pymolplip.py#L305-L311 |
ssalentin/plip | plip/modules/pymolplip.py | PyMOLVisualizer.zoom_to_ligand | def zoom_to_ligand(self):
"""Zoom in too ligand and its interactions."""
cmd.center(self.ligname)
cmd.orient(self.ligname)
cmd.turn('x', 110) # If the ligand is aligned with the longest axis, aromatic rings are hidden
if 'AllBSRes' in cmd.get_names("selections"):
cmd... | python | def zoom_to_ligand(self):
"""Zoom in too ligand and its interactions."""
cmd.center(self.ligname)
cmd.orient(self.ligname)
cmd.turn('x', 110) # If the ligand is aligned with the longest axis, aromatic rings are hidden
if 'AllBSRes' in cmd.get_names("selections"):
cmd... | [
"def",
"zoom_to_ligand",
"(",
"self",
")",
":",
"cmd",
".",
"center",
"(",
"self",
".",
"ligname",
")",
"cmd",
".",
"orient",
"(",
"self",
".",
"ligname",
")",
"cmd",
".",
"turn",
"(",
"'x'",
",",
"110",
")",
"# If the ligand is aligned with the longest ax... | Zoom in too ligand and its interactions. | [
"Zoom",
"in",
"too",
"ligand",
"and",
"its",
"interactions",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/pymolplip.py#L313-L323 |
ssalentin/plip | plip/modules/pymolplip.py | PyMOLVisualizer.save_session | def save_session(self, outfolder, override=None):
"""Saves a PyMOL session file."""
filename = '%s_%s' % (self.protname.upper(), "_".join(
[self.hetid, self.plcomplex.chain, self.plcomplex.position]))
if override is not None:
filename = override
cmd.save("/".join(... | python | def save_session(self, outfolder, override=None):
"""Saves a PyMOL session file."""
filename = '%s_%s' % (self.protname.upper(), "_".join(
[self.hetid, self.plcomplex.chain, self.plcomplex.position]))
if override is not None:
filename = override
cmd.save("/".join(... | [
"def",
"save_session",
"(",
"self",
",",
"outfolder",
",",
"override",
"=",
"None",
")",
":",
"filename",
"=",
"'%s_%s'",
"%",
"(",
"self",
".",
"protname",
".",
"upper",
"(",
")",
",",
"\"_\"",
".",
"join",
"(",
"[",
"self",
".",
"hetid",
",",
"se... | Saves a PyMOL session file. | [
"Saves",
"a",
"PyMOL",
"session",
"file",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/pymolplip.py#L325-L331 |
ssalentin/plip | plip/modules/pymolplip.py | PyMOLVisualizer.png_workaround | def png_workaround(self, filepath, width=1200, height=800):
"""Workaround for (a) severe bug(s) in PyMOL preventing ray-traced images to be produced in command-line mode.
Use this function in case neither cmd.ray() or cmd.png() work.
"""
sys.stdout = sys.__stdout__
cmd.feedback('... | python | def png_workaround(self, filepath, width=1200, height=800):
"""Workaround for (a) severe bug(s) in PyMOL preventing ray-traced images to be produced in command-line mode.
Use this function in case neither cmd.ray() or cmd.png() work.
"""
sys.stdout = sys.__stdout__
cmd.feedback('... | [
"def",
"png_workaround",
"(",
"self",
",",
"filepath",
",",
"width",
"=",
"1200",
",",
"height",
"=",
"800",
")",
":",
"sys",
".",
"stdout",
"=",
"sys",
".",
"__stdout__",
"cmd",
".",
"feedback",
"(",
"'disable'",
",",
"'movie'",
",",
"'everything'",
"... | Workaround for (a) severe bug(s) in PyMOL preventing ray-traced images to be produced in command-line mode.
Use this function in case neither cmd.ray() or cmd.png() work. | [
"Workaround",
"for",
"(",
"a",
")",
"severe",
"bug",
"(",
"s",
")",
"in",
"PyMOL",
"preventing",
"ray",
"-",
"traced",
"images",
"to",
"be",
"produced",
"in",
"command",
"-",
"line",
"mode",
".",
"Use",
"this",
"function",
"in",
"case",
"neither",
"cmd... | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/pymolplip.py#L333-L378 |
ssalentin/plip | plip/modules/pymolplip.py | PyMOLVisualizer.save_picture | def save_picture(self, outfolder, filename):
"""Saves a picture"""
self.set_fancy_ray()
self.png_workaround("/".join([outfolder, filename])) | python | def save_picture(self, outfolder, filename):
"""Saves a picture"""
self.set_fancy_ray()
self.png_workaround("/".join([outfolder, filename])) | [
"def",
"save_picture",
"(",
"self",
",",
"outfolder",
",",
"filename",
")",
":",
"self",
".",
"set_fancy_ray",
"(",
")",
"self",
".",
"png_workaround",
"(",
"\"/\"",
".",
"join",
"(",
"[",
"outfolder",
",",
"filename",
"]",
")",
")"
] | Saves a picture | [
"Saves",
"a",
"picture"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/pymolplip.py#L380-L383 |
ssalentin/plip | plip/modules/pymolplip.py | PyMOLVisualizer.set_fancy_ray | def set_fancy_ray(self):
"""Give the molecule a flat, modern look."""
cmd.set('light_count', 6)
cmd.set('spec_count', 1.5)
cmd.set('shininess', 4)
cmd.set('specular', 0.3)
cmd.set('reflect', 1.6)
cmd.set('ambient', 0)
cmd.set('direct', 0)
cmd.set('... | python | def set_fancy_ray(self):
"""Give the molecule a flat, modern look."""
cmd.set('light_count', 6)
cmd.set('spec_count', 1.5)
cmd.set('shininess', 4)
cmd.set('specular', 0.3)
cmd.set('reflect', 1.6)
cmd.set('ambient', 0)
cmd.set('direct', 0)
cmd.set('... | [
"def",
"set_fancy_ray",
"(",
"self",
")",
":",
"cmd",
".",
"set",
"(",
"'light_count'",
",",
"6",
")",
"cmd",
".",
"set",
"(",
"'spec_count'",
",",
"1.5",
")",
"cmd",
".",
"set",
"(",
"'shininess'",
",",
"4",
")",
"cmd",
".",
"set",
"(",
"'specular... | Give the molecule a flat, modern look. | [
"Give",
"the",
"molecule",
"a",
"flat",
"modern",
"look",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/pymolplip.py#L385-L396 |
ssalentin/plip | plip/modules/pymolplip.py | PyMOLVisualizer.adapt_for_peptides | def adapt_for_peptides(self):
"""Adapt visualization for peptide ligands and interchain contacts"""
cmd.hide('sticks', self.ligname)
cmd.set('cartoon_color', 'lightorange', self.ligname)
cmd.show('cartoon', self.ligname)
cmd.show('sticks', "byres *-L")
cmd.util.cnc(self.l... | python | def adapt_for_peptides(self):
"""Adapt visualization for peptide ligands and interchain contacts"""
cmd.hide('sticks', self.ligname)
cmd.set('cartoon_color', 'lightorange', self.ligname)
cmd.show('cartoon', self.ligname)
cmd.show('sticks', "byres *-L")
cmd.util.cnc(self.l... | [
"def",
"adapt_for_peptides",
"(",
"self",
")",
":",
"cmd",
".",
"hide",
"(",
"'sticks'",
",",
"self",
".",
"ligname",
")",
"cmd",
".",
"set",
"(",
"'cartoon_color'",
",",
"'lightorange'",
",",
"self",
".",
"ligname",
")",
"cmd",
".",
"show",
"(",
"'car... | Adapt visualization for peptide ligands and interchain contacts | [
"Adapt",
"visualization",
"for",
"peptide",
"ligands",
"and",
"interchain",
"contacts"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/pymolplip.py#L398-L406 |
ssalentin/plip | plip/modules/pymolplip.py | PyMOLVisualizer.refinements | def refinements(self):
"""Refinements for the visualization"""
# Show sticks for all residues interacing with the ligand
cmd.select('AllBSRes', 'byres (Hydrophobic-P or HBondDonor-P or HBondAccept-P or PosCharge-P or NegCharge-P or '
'StackRings-P or PiCatRing-P o... | python | def refinements(self):
"""Refinements for the visualization"""
# Show sticks for all residues interacing with the ligand
cmd.select('AllBSRes', 'byres (Hydrophobic-P or HBondDonor-P or HBondAccept-P or PosCharge-P or NegCharge-P or '
'StackRings-P or PiCatRing-P o... | [
"def",
"refinements",
"(",
"self",
")",
":",
"# Show sticks for all residues interacing with the ligand",
"cmd",
".",
"select",
"(",
"'AllBSRes'",
",",
"'byres (Hydrophobic-P or HBondDonor-P or HBondAccept-P or PosCharge-P or NegCharge-P or '",
"'StackRings-P or PiCatRing-P or HalogenAcc... | Refinements for the visualization | [
"Refinements",
"for",
"the",
"visualization"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/pymolplip.py#L411-L454 |
ella/ella | ella/core/cache/utils.py | get_cached_object | def get_cached_object(model, timeout=CACHE_TIMEOUT, **kwargs):
"""
Return a cached object. If the object does not exist in the cache, create it.
Params:
model - ContentType instance representing the model's class or the model class itself
timeout - TTL for the item in cache, defaults to CAC... | python | def get_cached_object(model, timeout=CACHE_TIMEOUT, **kwargs):
"""
Return a cached object. If the object does not exist in the cache, create it.
Params:
model - ContentType instance representing the model's class or the model class itself
timeout - TTL for the item in cache, defaults to CAC... | [
"def",
"get_cached_object",
"(",
"model",
",",
"timeout",
"=",
"CACHE_TIMEOUT",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"model",
",",
"ContentType",
")",
":",
"model_ct",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
... | Return a cached object. If the object does not exist in the cache, create it.
Params:
model - ContentType instance representing the model's class or the model class itself
timeout - TTL for the item in cache, defaults to CACHE_TIMEOUT
**kwargs - lookup parameters for content_type.get_object... | [
"Return",
"a",
"cached",
"object",
".",
"If",
"the",
"object",
"does",
"not",
"exist",
"in",
"the",
"cache",
"create",
"it",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/cache/utils.py#L70-L107 |
ella/ella | ella/core/cache/utils.py | get_cached_objects | def get_cached_objects(pks, model=None, timeout=CACHE_TIMEOUT, missing=RAISE):
"""
Return a list of objects with given PKs using cache.
Params:
pks - list of Primary Key values to look up or list of content_type_id, pk tuples
model - ContentType instance representing the model's class or th... | python | def get_cached_objects(pks, model=None, timeout=CACHE_TIMEOUT, missing=RAISE):
"""
Return a list of objects with given PKs using cache.
Params:
pks - list of Primary Key values to look up or list of content_type_id, pk tuples
model - ContentType instance representing the model's class or th... | [
"def",
"get_cached_objects",
"(",
"pks",
",",
"model",
"=",
"None",
",",
"timeout",
"=",
"CACHE_TIMEOUT",
",",
"missing",
"=",
"RAISE",
")",
":",
"if",
"model",
"is",
"not",
"None",
":",
"if",
"not",
"isinstance",
"(",
"model",
",",
"ContentType",
")",
... | Return a list of objects with given PKs using cache.
Params:
pks - list of Primary Key values to look up or list of content_type_id, pk tuples
model - ContentType instance representing the model's class or the model class itself
timeout - TTL for the items in cache, defaults to CACHE_TIMEOU... | [
"Return",
"a",
"list",
"of",
"objects",
"with",
"given",
"PKs",
"using",
"cache",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/cache/utils.py#L113-L184 |
ella/ella | ella/core/cache/utils.py | get_cached_object_or_404 | def get_cached_object_or_404(model, timeout=CACHE_TIMEOUT, **kwargs):
"""
Shortcut that will raise Http404 if there is no object matching the query
see get_cached_object for params description
"""
try:
return get_cached_object(model, timeout=timeout, **kwargs)
except ObjectDoesNotExist,... | python | def get_cached_object_or_404(model, timeout=CACHE_TIMEOUT, **kwargs):
"""
Shortcut that will raise Http404 if there is no object matching the query
see get_cached_object for params description
"""
try:
return get_cached_object(model, timeout=timeout, **kwargs)
except ObjectDoesNotExist,... | [
"def",
"get_cached_object_or_404",
"(",
"model",
",",
"timeout",
"=",
"CACHE_TIMEOUT",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"get_cached_object",
"(",
"model",
",",
"timeout",
"=",
"timeout",
",",
"*",
"*",
"kwargs",
")",
"except",
"Obje... | Shortcut that will raise Http404 if there is no object matching the query
see get_cached_object for params description | [
"Shortcut",
"that",
"will",
"raise",
"Http404",
"if",
"there",
"is",
"no",
"object",
"matching",
"the",
"query"
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/cache/utils.py#L187-L196 |
ssalentin/plip | plip/modules/supplemental.py | tmpfile | def tmpfile(prefix, direc):
"""Returns the path to a newly created temporary file."""
return tempfile.mktemp(prefix=prefix, suffix='.pdb', dir=direc) | python | def tmpfile(prefix, direc):
"""Returns the path to a newly created temporary file."""
return tempfile.mktemp(prefix=prefix, suffix='.pdb', dir=direc) | [
"def",
"tmpfile",
"(",
"prefix",
",",
"direc",
")",
":",
"return",
"tempfile",
".",
"mktemp",
"(",
"prefix",
"=",
"prefix",
",",
"suffix",
"=",
"'.pdb'",
",",
"dir",
"=",
"direc",
")"
] | Returns the path to a newly created temporary file. | [
"Returns",
"the",
"path",
"to",
"a",
"newly",
"created",
"temporary",
"file",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L41-L43 |
ssalentin/plip | plip/modules/supplemental.py | extract_pdbid | def extract_pdbid(string):
"""Use regular expressions to get a PDB ID from a string"""
p = re.compile("[0-9][0-9a-z]{3}")
m = p.search(string.lower())
try:
return m.group()
except AttributeError:
return "UnknownProtein" | python | def extract_pdbid(string):
"""Use regular expressions to get a PDB ID from a string"""
p = re.compile("[0-9][0-9a-z]{3}")
m = p.search(string.lower())
try:
return m.group()
except AttributeError:
return "UnknownProtein" | [
"def",
"extract_pdbid",
"(",
"string",
")",
":",
"p",
"=",
"re",
".",
"compile",
"(",
"\"[0-9][0-9a-z]{3}\"",
")",
"m",
"=",
"p",
".",
"search",
"(",
"string",
".",
"lower",
"(",
")",
")",
"try",
":",
"return",
"m",
".",
"group",
"(",
")",
"except"... | Use regular expressions to get a PDB ID from a string | [
"Use",
"regular",
"expressions",
"to",
"get",
"a",
"PDB",
"ID",
"from",
"a",
"string"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L52-L59 |
ssalentin/plip | plip/modules/supplemental.py | whichrestype | def whichrestype(atom):
"""Returns the residue name of an Pybel or OpenBabel atom."""
atom = atom if not isinstance(atom, Atom) else atom.OBAtom # Convert to OpenBabel Atom
return atom.GetResidue().GetName() if atom.GetResidue() is not None else None | python | def whichrestype(atom):
"""Returns the residue name of an Pybel or OpenBabel atom."""
atom = atom if not isinstance(atom, Atom) else atom.OBAtom # Convert to OpenBabel Atom
return atom.GetResidue().GetName() if atom.GetResidue() is not None else None | [
"def",
"whichrestype",
"(",
"atom",
")",
":",
"atom",
"=",
"atom",
"if",
"not",
"isinstance",
"(",
"atom",
",",
"Atom",
")",
"else",
"atom",
".",
"OBAtom",
"# Convert to OpenBabel Atom",
"return",
"atom",
".",
"GetResidue",
"(",
")",
".",
"GetName",
"(",
... | Returns the residue name of an Pybel or OpenBabel atom. | [
"Returns",
"the",
"residue",
"name",
"of",
"an",
"Pybel",
"or",
"OpenBabel",
"atom",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L62-L65 |
ssalentin/plip | plip/modules/supplemental.py | whichresnumber | def whichresnumber(atom):
"""Returns the residue number of an Pybel or OpenBabel atom (numbering as in original PDB file)."""
atom = atom if not isinstance(atom, Atom) else atom.OBAtom # Convert to OpenBabel Atom
return atom.GetResidue().GetNum() if atom.GetResidue() is not None else None | python | def whichresnumber(atom):
"""Returns the residue number of an Pybel or OpenBabel atom (numbering as in original PDB file)."""
atom = atom if not isinstance(atom, Atom) else atom.OBAtom # Convert to OpenBabel Atom
return atom.GetResidue().GetNum() if atom.GetResidue() is not None else None | [
"def",
"whichresnumber",
"(",
"atom",
")",
":",
"atom",
"=",
"atom",
"if",
"not",
"isinstance",
"(",
"atom",
",",
"Atom",
")",
"else",
"atom",
".",
"OBAtom",
"# Convert to OpenBabel Atom",
"return",
"atom",
".",
"GetResidue",
"(",
")",
".",
"GetNum",
"(",
... | Returns the residue number of an Pybel or OpenBabel atom (numbering as in original PDB file). | [
"Returns",
"the",
"residue",
"number",
"of",
"an",
"Pybel",
"or",
"OpenBabel",
"atom",
"(",
"numbering",
"as",
"in",
"original",
"PDB",
"file",
")",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L68-L71 |
ssalentin/plip | plip/modules/supplemental.py | whichchain | def whichchain(atom):
"""Returns the residue number of an PyBel or OpenBabel atom."""
atom = atom if not isinstance(atom, Atom) else atom.OBAtom # Convert to OpenBabel Atom
return atom.GetResidue().GetChain() if atom.GetResidue() is not None else None | python | def whichchain(atom):
"""Returns the residue number of an PyBel or OpenBabel atom."""
atom = atom if not isinstance(atom, Atom) else atom.OBAtom # Convert to OpenBabel Atom
return atom.GetResidue().GetChain() if atom.GetResidue() is not None else None | [
"def",
"whichchain",
"(",
"atom",
")",
":",
"atom",
"=",
"atom",
"if",
"not",
"isinstance",
"(",
"atom",
",",
"Atom",
")",
"else",
"atom",
".",
"OBAtom",
"# Convert to OpenBabel Atom",
"return",
"atom",
".",
"GetResidue",
"(",
")",
".",
"GetChain",
"(",
... | Returns the residue number of an PyBel or OpenBabel atom. | [
"Returns",
"the",
"residue",
"number",
"of",
"an",
"PyBel",
"or",
"OpenBabel",
"atom",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L74-L77 |
ssalentin/plip | plip/modules/supplemental.py | euclidean3d | def euclidean3d(v1, v2):
"""Faster implementation of euclidean distance for the 3D case."""
if not len(v1) == 3 and len(v2) == 3:
print("Vectors are not in 3D space. Returning None.")
return None
return np.sqrt((v1[0] - v2[0]) ** 2 + (v1[1] - v2[1]) ** 2 + (v1[2] - v2[2]) ** 2) | python | def euclidean3d(v1, v2):
"""Faster implementation of euclidean distance for the 3D case."""
if not len(v1) == 3 and len(v2) == 3:
print("Vectors are not in 3D space. Returning None.")
return None
return np.sqrt((v1[0] - v2[0]) ** 2 + (v1[1] - v2[1]) ** 2 + (v1[2] - v2[2]) ** 2) | [
"def",
"euclidean3d",
"(",
"v1",
",",
"v2",
")",
":",
"if",
"not",
"len",
"(",
"v1",
")",
"==",
"3",
"and",
"len",
"(",
"v2",
")",
"==",
"3",
":",
"print",
"(",
"\"Vectors are not in 3D space. Returning None.\"",
")",
"return",
"None",
"return",
"np",
... | Faster implementation of euclidean distance for the 3D case. | [
"Faster",
"implementation",
"of",
"euclidean",
"distance",
"for",
"the",
"3D",
"case",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L84-L89 |
ssalentin/plip | plip/modules/supplemental.py | vector | def vector(p1, p2):
"""Vector from p1 to p2.
:param p1: coordinates of point p1
:param p2: coordinates of point p2
:returns : numpy array with vector coordinates
"""
return None if len(p1) != len(p2) else np.array([p2[i] - p1[i] for i in range(len(p1))]) | python | def vector(p1, p2):
"""Vector from p1 to p2.
:param p1: coordinates of point p1
:param p2: coordinates of point p2
:returns : numpy array with vector coordinates
"""
return None if len(p1) != len(p2) else np.array([p2[i] - p1[i] for i in range(len(p1))]) | [
"def",
"vector",
"(",
"p1",
",",
"p2",
")",
":",
"return",
"None",
"if",
"len",
"(",
"p1",
")",
"!=",
"len",
"(",
"p2",
")",
"else",
"np",
".",
"array",
"(",
"[",
"p2",
"[",
"i",
"]",
"-",
"p1",
"[",
"i",
"]",
"for",
"i",
"in",
"range",
"... | Vector from p1 to p2.
:param p1: coordinates of point p1
:param p2: coordinates of point p2
:returns : numpy array with vector coordinates | [
"Vector",
"from",
"p1",
"to",
"p2",
".",
":",
"param",
"p1",
":",
"coordinates",
"of",
"point",
"p1",
":",
"param",
"p2",
":",
"coordinates",
"of",
"point",
"p2",
":",
"returns",
":",
"numpy",
"array",
"with",
"vector",
"coordinates"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L92-L98 |
ssalentin/plip | plip/modules/supplemental.py | vecangle | def vecangle(v1, v2, deg=True):
"""Calculate the angle between two vectors
:param v1: coordinates of vector v1
:param v2: coordinates of vector v2
:returns : angle in degree or rad
"""
if np.array_equal(v1, v2):
return 0.0
dm = np.dot(v1, v2)
cm = np.linalg.norm(v1) * np.linalg.n... | python | def vecangle(v1, v2, deg=True):
"""Calculate the angle between two vectors
:param v1: coordinates of vector v1
:param v2: coordinates of vector v2
:returns : angle in degree or rad
"""
if np.array_equal(v1, v2):
return 0.0
dm = np.dot(v1, v2)
cm = np.linalg.norm(v1) * np.linalg.n... | [
"def",
"vecangle",
"(",
"v1",
",",
"v2",
",",
"deg",
"=",
"True",
")",
":",
"if",
"np",
".",
"array_equal",
"(",
"v1",
",",
"v2",
")",
":",
"return",
"0.0",
"dm",
"=",
"np",
".",
"dot",
"(",
"v1",
",",
"v2",
")",
"cm",
"=",
"np",
".",
"lina... | Calculate the angle between two vectors
:param v1: coordinates of vector v1
:param v2: coordinates of vector v2
:returns : angle in degree or rad | [
"Calculate",
"the",
"angle",
"between",
"two",
"vectors",
":",
"param",
"v1",
":",
"coordinates",
"of",
"vector",
"v1",
":",
"param",
"v2",
":",
"coordinates",
"of",
"vector",
"v2",
":",
"returns",
":",
"angle",
"in",
"degree",
"or",
"rad"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L101-L112 |
ssalentin/plip | plip/modules/supplemental.py | normalize_vector | def normalize_vector(v):
"""Take a vector and return the normalized vector
:param v: a vector v
:returns : normalized vector v
"""
norm = np.linalg.norm(v)
return v/norm if not norm == 0 else v | python | def normalize_vector(v):
"""Take a vector and return the normalized vector
:param v: a vector v
:returns : normalized vector v
"""
norm = np.linalg.norm(v)
return v/norm if not norm == 0 else v | [
"def",
"normalize_vector",
"(",
"v",
")",
":",
"norm",
"=",
"np",
".",
"linalg",
".",
"norm",
"(",
"v",
")",
"return",
"v",
"/",
"norm",
"if",
"not",
"norm",
"==",
"0",
"else",
"v"
] | Take a vector and return the normalized vector
:param v: a vector v
:returns : normalized vector v | [
"Take",
"a",
"vector",
"and",
"return",
"the",
"normalized",
"vector",
":",
"param",
"v",
":",
"a",
"vector",
"v",
":",
"returns",
":",
"normalized",
"vector",
"v"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L115-L121 |
ssalentin/plip | plip/modules/supplemental.py | centroid | def centroid(coo):
"""Calculates the centroid from a 3D point cloud and returns the coordinates
:param coo: Array of coordinate arrays
:returns : centroid coordinates as list
"""
return list(map(np.mean, (([c[0] for c in coo]), ([c[1] for c in coo]), ([c[2] for c in coo])))) | python | def centroid(coo):
"""Calculates the centroid from a 3D point cloud and returns the coordinates
:param coo: Array of coordinate arrays
:returns : centroid coordinates as list
"""
return list(map(np.mean, (([c[0] for c in coo]), ([c[1] for c in coo]), ([c[2] for c in coo])))) | [
"def",
"centroid",
"(",
"coo",
")",
":",
"return",
"list",
"(",
"map",
"(",
"np",
".",
"mean",
",",
"(",
"(",
"[",
"c",
"[",
"0",
"]",
"for",
"c",
"in",
"coo",
"]",
")",
",",
"(",
"[",
"c",
"[",
"1",
"]",
"for",
"c",
"in",
"coo",
"]",
"... | Calculates the centroid from a 3D point cloud and returns the coordinates
:param coo: Array of coordinate arrays
:returns : centroid coordinates as list | [
"Calculates",
"the",
"centroid",
"from",
"a",
"3D",
"point",
"cloud",
"and",
"returns",
"the",
"coordinates",
":",
"param",
"coo",
":",
"Array",
"of",
"coordinate",
"arrays",
":",
"returns",
":",
"centroid",
"coordinates",
"as",
"list"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L124-L129 |
ssalentin/plip | plip/modules/supplemental.py | cluster_doubles | def cluster_doubles(double_list):
"""Given a list of doubles, they are clustered if they share one element
:param double_list: list of doubles
:returns : list of clusters (tuples)
"""
location = {} # hashtable of which cluster each element is in
clusters = []
# Go through each double
fo... | python | def cluster_doubles(double_list):
"""Given a list of doubles, they are clustered if they share one element
:param double_list: list of doubles
:returns : list of clusters (tuples)
"""
location = {} # hashtable of which cluster each element is in
clusters = []
# Go through each double
fo... | [
"def",
"cluster_doubles",
"(",
"double_list",
")",
":",
"location",
"=",
"{",
"}",
"# hashtable of which cluster each element is in",
"clusters",
"=",
"[",
"]",
"# Go through each double",
"for",
"t",
"in",
"double_list",
":",
"a",
",",
"b",
"=",
"t",
"[",
"0",
... | Given a list of doubles, they are clustered if they share one element
:param double_list: list of doubles
:returns : list of clusters (tuples) | [
"Given",
"a",
"list",
"of",
"doubles",
"they",
"are",
"clustered",
"if",
"they",
"share",
"one",
"element",
":",
"param",
"double_list",
":",
"list",
"of",
"doubles",
":",
"returns",
":",
"list",
"of",
"clusters",
"(",
"tuples",
")"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L151-L189 |
ssalentin/plip | plip/modules/supplemental.py | create_folder_if_not_exists | def create_folder_if_not_exists(folder_path):
"""Creates a folder if it does not exists."""
folder_path = tilde_expansion(folder_path)
folder_path = "".join([folder_path, '/']) if not folder_path[-1] == '/' else folder_path
direc = os.path.dirname(folder_path)
if not folder_exists(direc):
os... | python | def create_folder_if_not_exists(folder_path):
"""Creates a folder if it does not exists."""
folder_path = tilde_expansion(folder_path)
folder_path = "".join([folder_path, '/']) if not folder_path[-1] == '/' else folder_path
direc = os.path.dirname(folder_path)
if not folder_exists(direc):
os... | [
"def",
"create_folder_if_not_exists",
"(",
"folder_path",
")",
":",
"folder_path",
"=",
"tilde_expansion",
"(",
"folder_path",
")",
"folder_path",
"=",
"\"\"",
".",
"join",
"(",
"[",
"folder_path",
",",
"'/'",
"]",
")",
"if",
"not",
"folder_path",
"[",
"-",
... | Creates a folder if it does not exists. | [
"Creates",
"a",
"folder",
"if",
"it",
"does",
"not",
"exists",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L206-L212 |
ssalentin/plip | plip/modules/supplemental.py | initialize_pymol | def initialize_pymol(options):
"""Initializes PyMOL"""
import pymol
# Pass standard arguments of function to prevent PyMOL from printing out PDB headers (workaround)
pymol.finish_launching(args=['pymol', options, '-K'])
pymol.cmd.reinitialize() | python | def initialize_pymol(options):
"""Initializes PyMOL"""
import pymol
# Pass standard arguments of function to prevent PyMOL from printing out PDB headers (workaround)
pymol.finish_launching(args=['pymol', options, '-K'])
pymol.cmd.reinitialize() | [
"def",
"initialize_pymol",
"(",
"options",
")",
":",
"import",
"pymol",
"# Pass standard arguments of function to prevent PyMOL from printing out PDB headers (workaround)",
"pymol",
".",
"finish_launching",
"(",
"args",
"=",
"[",
"'pymol'",
",",
"options",
",",
"'-K'",
"]",... | Initializes PyMOL | [
"Initializes",
"PyMOL"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L223-L228 |
ssalentin/plip | plip/modules/supplemental.py | start_pymol | def start_pymol(quiet=False, options='-p', run=False):
"""Starts up PyMOL and sets general options. Quiet mode suppresses all PyMOL output.
Command line options can be passed as the second argument."""
import pymol
pymol.pymol_argv = ['pymol', '%s' % options] + sys.argv[1:]
if run:
initializ... | python | def start_pymol(quiet=False, options='-p', run=False):
"""Starts up PyMOL and sets general options. Quiet mode suppresses all PyMOL output.
Command line options can be passed as the second argument."""
import pymol
pymol.pymol_argv = ['pymol', '%s' % options] + sys.argv[1:]
if run:
initializ... | [
"def",
"start_pymol",
"(",
"quiet",
"=",
"False",
",",
"options",
"=",
"'-p'",
",",
"run",
"=",
"False",
")",
":",
"import",
"pymol",
"pymol",
".",
"pymol_argv",
"=",
"[",
"'pymol'",
",",
"'%s'",
"%",
"options",
"]",
"+",
"sys",
".",
"argv",
"[",
"... | Starts up PyMOL and sets general options. Quiet mode suppresses all PyMOL output.
Command line options can be passed as the second argument. | [
"Starts",
"up",
"PyMOL",
"and",
"sets",
"general",
"options",
".",
"Quiet",
"mode",
"suppresses",
"all",
"PyMOL",
"output",
".",
"Command",
"line",
"options",
"can",
"be",
"passed",
"as",
"the",
"second",
"argument",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L231-L239 |
ssalentin/plip | plip/modules/supplemental.py | nucleotide_linkage | def nucleotide_linkage(residues):
"""Support for DNA/RNA ligands by finding missing covalent linkages to stitch DNA/RNA together."""
nuc_covalent = []
#######################################
# Basic support for RNA/DNA as ligand #
#######################################
nucleotides = ['A', 'C',... | python | def nucleotide_linkage(residues):
"""Support for DNA/RNA ligands by finding missing covalent linkages to stitch DNA/RNA together."""
nuc_covalent = []
#######################################
# Basic support for RNA/DNA as ligand #
#######################################
nucleotides = ['A', 'C',... | [
"def",
"nucleotide_linkage",
"(",
"residues",
")",
":",
"nuc_covalent",
"=",
"[",
"]",
"#######################################",
"# Basic support for RNA/DNA as ligand #",
"#######################################",
"nucleotides",
"=",
"[",
"'A'",
",",
"'C'",
",",
"'T'",
",... | Support for DNA/RNA ligands by finding missing covalent linkages to stitch DNA/RNA together. | [
"Support",
"for",
"DNA",
"/",
"RNA",
"ligands",
"by",
"finding",
"missing",
"covalent",
"linkages",
"to",
"stitch",
"DNA",
"/",
"RNA",
"together",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L242-L271 |
ssalentin/plip | plip/modules/supplemental.py | ring_is_planar | def ring_is_planar(ring, r_atoms):
"""Given a set of ring atoms, check if the ring is sufficiently planar
to be considered aromatic"""
normals = []
for a in r_atoms:
adj = pybel.ob.OBAtomAtomIter(a.OBAtom)
# Check for neighboring atoms in the ring
n_coords = [pybel.Atom(neigh).co... | python | def ring_is_planar(ring, r_atoms):
"""Given a set of ring atoms, check if the ring is sufficiently planar
to be considered aromatic"""
normals = []
for a in r_atoms:
adj = pybel.ob.OBAtomAtomIter(a.OBAtom)
# Check for neighboring atoms in the ring
n_coords = [pybel.Atom(neigh).co... | [
"def",
"ring_is_planar",
"(",
"ring",
",",
"r_atoms",
")",
":",
"normals",
"=",
"[",
"]",
"for",
"a",
"in",
"r_atoms",
":",
"adj",
"=",
"pybel",
".",
"ob",
".",
"OBAtomAtomIter",
"(",
"a",
".",
"OBAtom",
")",
"# Check for neighboring atoms in the ring",
"n... | Given a set of ring atoms, check if the ring is sufficiently planar
to be considered aromatic | [
"Given",
"a",
"set",
"of",
"ring",
"atoms",
"check",
"if",
"the",
"ring",
"is",
"sufficiently",
"planar",
"to",
"be",
"considered",
"aromatic"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L274-L289 |
ssalentin/plip | plip/modules/supplemental.py | classify_by_name | def classify_by_name(names):
"""Classify a (composite) ligand by the HETID(s)"""
if len(names) > 3: # Polymer
if len(set(config.RNA).intersection(set(names))) != 0:
ligtype = 'RNA'
elif len(set(config.DNA).intersection(set(names))) != 0:
ligtype = 'DNA'
else:
... | python | def classify_by_name(names):
"""Classify a (composite) ligand by the HETID(s)"""
if len(names) > 3: # Polymer
if len(set(config.RNA).intersection(set(names))) != 0:
ligtype = 'RNA'
elif len(set(config.DNA).intersection(set(names))) != 0:
ligtype = 'DNA'
else:
... | [
"def",
"classify_by_name",
"(",
"names",
")",
":",
"if",
"len",
"(",
"names",
")",
">",
"3",
":",
"# Polymer",
"if",
"len",
"(",
"set",
"(",
"config",
".",
"RNA",
")",
".",
"intersection",
"(",
"set",
"(",
"names",
")",
")",
")",
"!=",
"0",
":",
... | Classify a (composite) ligand by the HETID(s) | [
"Classify",
"a",
"(",
"composite",
")",
"ligand",
"by",
"the",
"HETID",
"(",
"s",
")"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L292-L311 |
ssalentin/plip | plip/modules/supplemental.py | sort_members_by_importance | def sort_members_by_importance(members):
"""Sort the members of a composite ligand according to two criteria:
1. Split up in main and ion group. Ion groups are located behind the main group.
2. Within each group, sort by chain and position."""
main = [x for x in members if x[0] not in config.METAL_IONS]... | python | def sort_members_by_importance(members):
"""Sort the members of a composite ligand according to two criteria:
1. Split up in main and ion group. Ion groups are located behind the main group.
2. Within each group, sort by chain and position."""
main = [x for x in members if x[0] not in config.METAL_IONS]... | [
"def",
"sort_members_by_importance",
"(",
"members",
")",
":",
"main",
"=",
"[",
"x",
"for",
"x",
"in",
"members",
"if",
"x",
"[",
"0",
"]",
"not",
"in",
"config",
".",
"METAL_IONS",
"]",
"ion",
"=",
"[",
"x",
"for",
"x",
"in",
"members",
"if",
"x"... | Sort the members of a composite ligand according to two criteria:
1. Split up in main and ion group. Ion groups are located behind the main group.
2. Within each group, sort by chain and position. | [
"Sort",
"the",
"members",
"of",
"a",
"composite",
"ligand",
"according",
"to",
"two",
"criteria",
":",
"1",
".",
"Split",
"up",
"in",
"main",
"and",
"ion",
"group",
".",
"Ion",
"groups",
"are",
"located",
"behind",
"the",
"main",
"group",
".",
"2",
"."... | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L314-L323 |
ssalentin/plip | plip/modules/supplemental.py | get_isomorphisms | def get_isomorphisms(reference, lig):
"""Get all isomorphisms of the ligand."""
query = pybel.ob.CompileMoleculeQuery(reference.OBMol)
mappr = pybel.ob.OBIsomorphismMapper.GetInstance(query)
if all:
isomorphs = pybel.ob.vvpairUIntUInt()
mappr.MapAll(lig.OBMol, isomorphs)
else:
... | python | def get_isomorphisms(reference, lig):
"""Get all isomorphisms of the ligand."""
query = pybel.ob.CompileMoleculeQuery(reference.OBMol)
mappr = pybel.ob.OBIsomorphismMapper.GetInstance(query)
if all:
isomorphs = pybel.ob.vvpairUIntUInt()
mappr.MapAll(lig.OBMol, isomorphs)
else:
... | [
"def",
"get_isomorphisms",
"(",
"reference",
",",
"lig",
")",
":",
"query",
"=",
"pybel",
".",
"ob",
".",
"CompileMoleculeQuery",
"(",
"reference",
".",
"OBMol",
")",
"mappr",
"=",
"pybel",
".",
"ob",
".",
"OBIsomorphismMapper",
".",
"GetInstance",
"(",
"q... | Get all isomorphisms of the ligand. | [
"Get",
"all",
"isomorphisms",
"of",
"the",
"ligand",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L326-L339 |
ssalentin/plip | plip/modules/supplemental.py | canonicalize | def canonicalize(lig, preserve_bond_order=False):
"""Get the canonical atom order for the ligand."""
atomorder = None
# Get canonical atom order
lig = pybel.ob.OBMol(lig.OBMol)
if not preserve_bond_order:
for bond in pybel.ob.OBMolBondIter(lig):
if bond.GetBondOrder() != 1:
... | python | def canonicalize(lig, preserve_bond_order=False):
"""Get the canonical atom order for the ligand."""
atomorder = None
# Get canonical atom order
lig = pybel.ob.OBMol(lig.OBMol)
if not preserve_bond_order:
for bond in pybel.ob.OBMolBondIter(lig):
if bond.GetBondOrder() != 1:
... | [
"def",
"canonicalize",
"(",
"lig",
",",
"preserve_bond_order",
"=",
"False",
")",
":",
"atomorder",
"=",
"None",
"# Get canonical atom order",
"lig",
"=",
"pybel",
".",
"ob",
".",
"OBMol",
"(",
"lig",
".",
"OBMol",
")",
"if",
"not",
"preserve_bond_order",
":... | Get the canonical atom order for the ligand. | [
"Get",
"the",
"canonical",
"atom",
"order",
"for",
"the",
"ligand",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L342-L371 |
ssalentin/plip | plip/modules/supplemental.py | int32_to_negative | def int32_to_negative(int32):
"""Checks if a suspicious number (e.g. ligand position) is in fact a negative number represented as a
32 bit integer and returns the actual number.
"""
dct = {}
if int32 == 4294967295: # Special case in some structures (note, this is just a workaround)
return -... | python | def int32_to_negative(int32):
"""Checks if a suspicious number (e.g. ligand position) is in fact a negative number represented as a
32 bit integer and returns the actual number.
"""
dct = {}
if int32 == 4294967295: # Special case in some structures (note, this is just a workaround)
return -... | [
"def",
"int32_to_negative",
"(",
"int32",
")",
":",
"dct",
"=",
"{",
"}",
"if",
"int32",
"==",
"4294967295",
":",
"# Special case in some structures (note, this is just a workaround)",
"return",
"-",
"1",
"for",
"i",
"in",
"range",
"(",
"-",
"1000",
",",
"-",
... | Checks if a suspicious number (e.g. ligand position) is in fact a negative number represented as a
32 bit integer and returns the actual number. | [
"Checks",
"if",
"a",
"suspicious",
"number",
"(",
"e",
".",
"g",
".",
"ligand",
"position",
")",
"is",
"in",
"fact",
"a",
"negative",
"number",
"represented",
"as",
"a",
"32",
"bit",
"integer",
"and",
"returns",
"the",
"actual",
"number",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L374-L386 |
ssalentin/plip | plip/modules/supplemental.py | read_pdb | def read_pdb(pdbfname, as_string=False):
"""Reads a given PDB file and returns a Pybel Molecule."""
pybel.ob.obErrorLog.StopLogging() # Suppress all OpenBabel warnings
if os.name != 'nt': # Resource module not available for Windows
maxsize = resource.getrlimit(resource.RLIMIT_STACK)[-1]
re... | python | def read_pdb(pdbfname, as_string=False):
"""Reads a given PDB file and returns a Pybel Molecule."""
pybel.ob.obErrorLog.StopLogging() # Suppress all OpenBabel warnings
if os.name != 'nt': # Resource module not available for Windows
maxsize = resource.getrlimit(resource.RLIMIT_STACK)[-1]
re... | [
"def",
"read_pdb",
"(",
"pdbfname",
",",
"as_string",
"=",
"False",
")",
":",
"pybel",
".",
"ob",
".",
"obErrorLog",
".",
"StopLogging",
"(",
")",
"# Suppress all OpenBabel warnings",
"if",
"os",
".",
"name",
"!=",
"'nt'",
":",
"# Resource module not available f... | Reads a given PDB file and returns a Pybel Molecule. | [
"Reads",
"a",
"given",
"PDB",
"file",
"and",
"returns",
"a",
"Pybel",
"Molecule",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L389-L396 |
ssalentin/plip | plip/modules/supplemental.py | read | def read(fil):
"""Returns a file handler and detects gzipped files."""
if os.path.splitext(fil)[-1] == '.gz':
return gzip.open(fil, 'rb')
elif os.path.splitext(fil)[-1] == '.zip':
zf = zipfile.ZipFile(fil, 'r')
return zf.open(zf.infolist()[0].filename)
else:
return open(f... | python | def read(fil):
"""Returns a file handler and detects gzipped files."""
if os.path.splitext(fil)[-1] == '.gz':
return gzip.open(fil, 'rb')
elif os.path.splitext(fil)[-1] == '.zip':
zf = zipfile.ZipFile(fil, 'r')
return zf.open(zf.infolist()[0].filename)
else:
return open(f... | [
"def",
"read",
"(",
"fil",
")",
":",
"if",
"os",
".",
"path",
".",
"splitext",
"(",
"fil",
")",
"[",
"-",
"1",
"]",
"==",
"'.gz'",
":",
"return",
"gzip",
".",
"open",
"(",
"fil",
",",
"'rb'",
")",
"elif",
"os",
".",
"path",
".",
"splitext",
"... | Returns a file handler and detects gzipped files. | [
"Returns",
"a",
"file",
"handler",
"and",
"detects",
"gzipped",
"files",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L399-L407 |
ssalentin/plip | plip/modules/supplemental.py | readmol | def readmol(path, as_string=False):
"""Reads the given molecule file and returns the corresponding Pybel molecule as well as the input file type.
In contrast to the standard Pybel implementation, the file is closed properly."""
supported_formats = ['pdb']
# Fix for Windows-generated files: Remove carria... | python | def readmol(path, as_string=False):
"""Reads the given molecule file and returns the corresponding Pybel molecule as well as the input file type.
In contrast to the standard Pybel implementation, the file is closed properly."""
supported_formats = ['pdb']
# Fix for Windows-generated files: Remove carria... | [
"def",
"readmol",
"(",
"path",
",",
"as_string",
"=",
"False",
")",
":",
"supported_formats",
"=",
"[",
"'pdb'",
"]",
"# Fix for Windows-generated files: Remove carriage return characters",
"if",
"\"\\r\"",
"in",
"path",
"and",
"as_string",
":",
"path",
"=",
"path",... | Reads the given molecule file and returns the corresponding Pybel molecule as well as the input file type.
In contrast to the standard Pybel implementation, the file is closed properly. | [
"Reads",
"the",
"given",
"molecule",
"file",
"and",
"returns",
"the",
"corresponding",
"Pybel",
"molecule",
"as",
"well",
"as",
"the",
"input",
"file",
"type",
".",
"In",
"contrast",
"to",
"the",
"standard",
"Pybel",
"implementation",
"the",
"file",
"is",
"c... | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L410-L442 |
ssalentin/plip | plip/modules/supplemental.py | colorlog | def colorlog(msg, color, bold=False, blink=False):
"""Colors messages on non-Windows systems supporting ANSI escape."""
# ANSI Escape Codes
PINK_COL = '\x1b[35m'
GREEN_COL = '\x1b[32m'
RED_COL = '\x1b[31m'
YELLOW_COL = '\x1b[33m'
BLINK = '\x1b[5m'
RESET = '\x1b[0m'
if platform.syst... | python | def colorlog(msg, color, bold=False, blink=False):
"""Colors messages on non-Windows systems supporting ANSI escape."""
# ANSI Escape Codes
PINK_COL = '\x1b[35m'
GREEN_COL = '\x1b[32m'
RED_COL = '\x1b[31m'
YELLOW_COL = '\x1b[33m'
BLINK = '\x1b[5m'
RESET = '\x1b[0m'
if platform.syst... | [
"def",
"colorlog",
"(",
"msg",
",",
"color",
",",
"bold",
"=",
"False",
",",
"blink",
"=",
"False",
")",
":",
"# ANSI Escape Codes",
"PINK_COL",
"=",
"'\\x1b[35m'",
"GREEN_COL",
"=",
"'\\x1b[32m'",
"RED_COL",
"=",
"'\\x1b[31m'",
"YELLOW_COL",
"=",
"'\\x1b[33m'... | Colors messages on non-Windows systems supporting ANSI escape. | [
"Colors",
"messages",
"on",
"non",
"-",
"Windows",
"systems",
"supporting",
"ANSI",
"escape",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L455-L477 |
ssalentin/plip | plip/modules/supplemental.py | write_message | def write_message(msg, indent=False, mtype='standard', caption=False):
"""Writes message if verbose mode is set."""
if (mtype == 'debug' and config.DEBUG) or (mtype != 'debug' and config.VERBOSE) or mtype == 'error':
message(msg, indent=indent, mtype=mtype, caption=caption) | python | def write_message(msg, indent=False, mtype='standard', caption=False):
"""Writes message if verbose mode is set."""
if (mtype == 'debug' and config.DEBUG) or (mtype != 'debug' and config.VERBOSE) or mtype == 'error':
message(msg, indent=indent, mtype=mtype, caption=caption) | [
"def",
"write_message",
"(",
"msg",
",",
"indent",
"=",
"False",
",",
"mtype",
"=",
"'standard'",
",",
"caption",
"=",
"False",
")",
":",
"if",
"(",
"mtype",
"==",
"'debug'",
"and",
"config",
".",
"DEBUG",
")",
"or",
"(",
"mtype",
"!=",
"'debug'",
"a... | Writes message if verbose mode is set. | [
"Writes",
"message",
"if",
"verbose",
"mode",
"is",
"set",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L480-L483 |
ssalentin/plip | plip/modules/supplemental.py | message | def message(msg, indent=False, mtype='standard', caption=False):
"""Writes messages in verbose mode"""
if caption:
msg = '\n' + msg + '\n' + '-'*len(msg) + '\n'
if mtype == 'warning':
msg = colorlog('Warning: ' + msg, 'yellow')
if mtype == 'error':
msg = colorlog('Error: ' + ms... | python | def message(msg, indent=False, mtype='standard', caption=False):
"""Writes messages in verbose mode"""
if caption:
msg = '\n' + msg + '\n' + '-'*len(msg) + '\n'
if mtype == 'warning':
msg = colorlog('Warning: ' + msg, 'yellow')
if mtype == 'error':
msg = colorlog('Error: ' + ms... | [
"def",
"message",
"(",
"msg",
",",
"indent",
"=",
"False",
",",
"mtype",
"=",
"'standard'",
",",
"caption",
"=",
"False",
")",
":",
"if",
"caption",
":",
"msg",
"=",
"'\\n'",
"+",
"msg",
"+",
"'\\n'",
"+",
"'-'",
"*",
"len",
"(",
"msg",
")",
"+",... | Writes messages in verbose mode | [
"Writes",
"messages",
"in",
"verbose",
"mode"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/supplemental.py#L486-L500 |
ella/ella | ella/core/templatetags/related.py | do_related | def do_related(parser, token):
"""
Get N related models into a context variable optionally specifying a
named related finder.
**Usage**::
{% related <limit>[ query_type] [app.model, ...] for <object> as <result> %}
**Parameters**::
================================== ... | python | def do_related(parser, token):
"""
Get N related models into a context variable optionally specifying a
named related finder.
**Usage**::
{% related <limit>[ query_type] [app.model, ...] for <object> as <result> %}
**Parameters**::
================================== ... | [
"def",
"do_related",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"obj_var",
",",
"count",
",",
"var_name",
",",
"mods",
",",
"finder",
"=",
"parse_related_tag",
"(",
"bits",
")",
"return",
"RelatedNode",
... | Get N related models into a context variable optionally specifying a
named related finder.
**Usage**::
{% related <limit>[ query_type] [app.model, ...] for <object> as <result> %}
**Parameters**::
================================== ===========================================... | [
"Get",
"N",
"related",
"models",
"into",
"a",
"context",
"variable",
"optionally",
"specifying",
"a",
"named",
"related",
"finder",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/templatetags/related.py#L68-L98 |
ella/ella | ella/core/models/publishable.py | PublishableBox | def PublishableBox(publishable, box_type, nodelist, model=None):
"add some content type info of self.target"
if not model:
model = publishable.content_type.model_class()
box_class = model.box_class
if box_class == PublishableBox:
box_class = Box
return box_class(publishable, box_typ... | python | def PublishableBox(publishable, box_type, nodelist, model=None):
"add some content type info of self.target"
if not model:
model = publishable.content_type.model_class()
box_class = model.box_class
if box_class == PublishableBox:
box_class = Box
return box_class(publishable, box_typ... | [
"def",
"PublishableBox",
"(",
"publishable",
",",
"box_type",
",",
"nodelist",
",",
"model",
"=",
"None",
")",
":",
"if",
"not",
"model",
":",
"model",
"=",
"publishable",
".",
"content_type",
".",
"model_class",
"(",
")",
"box_class",
"=",
"model",
".",
... | add some content type info of self.target | [
"add",
"some",
"content",
"type",
"info",
"of",
"self",
".",
"target"
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/models/publishable.py#L23-L31 |
ella/ella | ella/core/models/publishable.py | ListingBox | def ListingBox(listing, *args, **kwargs):
" Delegate the boxing to the target's Box class. "
obj = listing.publishable
return obj.box_class(obj, *args, **kwargs) | python | def ListingBox(listing, *args, **kwargs):
" Delegate the boxing to the target's Box class. "
obj = listing.publishable
return obj.box_class(obj, *args, **kwargs) | [
"def",
"ListingBox",
"(",
"listing",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"listing",
".",
"publishable",
"return",
"obj",
".",
"box_class",
"(",
"obj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Delegate the boxing to the target's Box class. | [
"Delegate",
"the",
"boxing",
"to",
"the",
"target",
"s",
"Box",
"class",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/models/publishable.py#L225-L228 |
ella/ella | ella/core/models/publishable.py | Publishable.get_absolute_url | def get_absolute_url(self, domain=False):
" Get object's URL. "
category = self.category
kwargs = {
'slug': self.slug,
}
if self.static:
kwargs['id'] = self.pk
if category.tree_parent_id:
kwargs['category'] = category.tree_pat... | python | def get_absolute_url(self, domain=False):
" Get object's URL. "
category = self.category
kwargs = {
'slug': self.slug,
}
if self.static:
kwargs['id'] = self.pk
if category.tree_parent_id:
kwargs['category'] = category.tree_pat... | [
"def",
"get_absolute_url",
"(",
"self",
",",
"domain",
"=",
"False",
")",
":",
"category",
"=",
"self",
".",
"category",
"kwargs",
"=",
"{",
"'slug'",
":",
"self",
".",
"slug",
",",
"}",
"if",
"self",
".",
"static",
":",
"kwargs",
"[",
"'id'",
"]",
... | Get object's URL. | [
"Get",
"object",
"s",
"URL",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/models/publishable.py#L90-L120 |
ella/ella | ella/core/models/publishable.py | Publishable.is_published | def is_published(self):
"Return True if the Publishable is currently active."
cur_time = now()
return self.published and cur_time > self.publish_from and \
(self.publish_to is None or cur_time < self.publish_to) | python | def is_published(self):
"Return True if the Publishable is currently active."
cur_time = now()
return self.published and cur_time > self.publish_from and \
(self.publish_to is None or cur_time < self.publish_to) | [
"def",
"is_published",
"(",
"self",
")",
":",
"cur_time",
"=",
"now",
"(",
")",
"return",
"self",
".",
"published",
"and",
"cur_time",
">",
"self",
".",
"publish_from",
"and",
"(",
"self",
".",
"publish_to",
"is",
"None",
"or",
"cur_time",
"<",
"self",
... | Return True if the Publishable is currently active. | [
"Return",
"True",
"if",
"the",
"Publishable",
"is",
"currently",
"active",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/models/publishable.py#L218-L222 |
ella/ella | ella/core/box.py | Box.resolve_params | def resolve_params(self, text):
" Parse the parameters into a dict. "
params = MultiValueDict()
for line in text.split('\n'):
pair = line.split(':', 1)
if len(pair) == 2:
params.appendlist(pair[0].strip(), pair[1].strip())
return params | python | def resolve_params(self, text):
" Parse the parameters into a dict. "
params = MultiValueDict()
for line in text.split('\n'):
pair = line.split(':', 1)
if len(pair) == 2:
params.appendlist(pair[0].strip(), pair[1].strip())
return params | [
"def",
"resolve_params",
"(",
"self",
",",
"text",
")",
":",
"params",
"=",
"MultiValueDict",
"(",
")",
"for",
"line",
"in",
"text",
".",
"split",
"(",
"'\\n'",
")",
":",
"pair",
"=",
"line",
".",
"split",
"(",
"':'",
",",
"1",
")",
"if",
"len",
... | Parse the parameters into a dict. | [
"Parse",
"the",
"parameters",
"into",
"a",
"dict",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/box.py#L49-L56 |
ella/ella | ella/core/box.py | Box.prepare | def prepare(self, context):
"""
Do the pre-processing - render and parse the parameters and
store them for further use in self.params.
"""
self.params = {}
# no params, not even a newline
if not self.nodelist:
return
# just static text, no va... | python | def prepare(self, context):
"""
Do the pre-processing - render and parse the parameters and
store them for further use in self.params.
"""
self.params = {}
# no params, not even a newline
if not self.nodelist:
return
# just static text, no va... | [
"def",
"prepare",
"(",
"self",
",",
"context",
")",
":",
"self",
".",
"params",
"=",
"{",
"}",
"# no params, not even a newline",
"if",
"not",
"self",
".",
"nodelist",
":",
"return",
"# just static text, no vars, assume one TextNode",
"if",
"not",
"self",
".",
"... | Do the pre-processing - render and parse the parameters and
store them for further use in self.params. | [
"Do",
"the",
"pre",
"-",
"processing",
"-",
"render",
"and",
"parse",
"the",
"parameters",
"and",
"store",
"them",
"for",
"further",
"use",
"in",
"self",
".",
"params",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/box.py#L58-L85 |
ella/ella | ella/core/box.py | Box.get_context | def get_context(self):
" Get context to render the template. "
return {
'content_type_name' : str(self.name),
'content_type_verbose_name' : self.verbose_name,
'content_type_verbose_name_plural' : self.verbose_name_plural,
'object' : self.ob... | python | def get_context(self):
" Get context to render the template. "
return {
'content_type_name' : str(self.name),
'content_type_verbose_name' : self.verbose_name,
'content_type_verbose_name_plural' : self.verbose_name_plural,
'object' : self.ob... | [
"def",
"get_context",
"(",
"self",
")",
":",
"return",
"{",
"'content_type_name'",
":",
"str",
"(",
"self",
".",
"name",
")",
",",
"'content_type_verbose_name'",
":",
"self",
".",
"verbose_name",
",",
"'content_type_verbose_name_plural'",
":",
"self",
".",
"verb... | Get context to render the template. | [
"Get",
"context",
"to",
"render",
"the",
"template",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/box.py#L87-L95 |
ella/ella | ella/core/box.py | Box.render | def render(self, context):
self.prepare(context)
" Cached wrapper around self._render(). "
if getattr(settings, 'DOUBLE_RENDER', False) and self.can_double_render:
if 'SECOND_RENDER' not in context:
return self.double_render()
key = self.get_cache_key()
... | python | def render(self, context):
self.prepare(context)
" Cached wrapper around self._render(). "
if getattr(settings, 'DOUBLE_RENDER', False) and self.can_double_render:
if 'SECOND_RENDER' not in context:
return self.double_render()
key = self.get_cache_key()
... | [
"def",
"render",
"(",
"self",
",",
"context",
")",
":",
"self",
".",
"prepare",
"(",
"context",
")",
"if",
"getattr",
"(",
"settings",
",",
"'DOUBLE_RENDER'",
",",
"False",
")",
"and",
"self",
".",
"can_double_render",
":",
"if",
"'SECOND_RENDER'",
"not",
... | Cached wrapper around self._render(). | [
"Cached",
"wrapper",
"around",
"self",
".",
"_render",
"()",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/box.py#L97-L111 |
ella/ella | ella/core/box.py | Box._get_template_list | def _get_template_list(self):
" Get the hierarchy of templates belonging to the object/box_type given. "
t_list = []
if hasattr(self.obj, 'category_id') and self.obj.category_id:
cat = self.obj.category
base_path = 'box/category/%s/content_type/%s/' % (cat.path, self.name... | python | def _get_template_list(self):
" Get the hierarchy of templates belonging to the object/box_type given. "
t_list = []
if hasattr(self.obj, 'category_id') and self.obj.category_id:
cat = self.obj.category
base_path = 'box/category/%s/content_type/%s/' % (cat.path, self.name... | [
"def",
"_get_template_list",
"(",
"self",
")",
":",
"t_list",
"=",
"[",
"]",
"if",
"hasattr",
"(",
"self",
".",
"obj",
",",
"'category_id'",
")",
"and",
"self",
".",
"obj",
".",
"category_id",
":",
"cat",
"=",
"self",
".",
"obj",
".",
"category",
"ba... | Get the hierarchy of templates belonging to the object/box_type given. | [
"Get",
"the",
"hierarchy",
"of",
"templates",
"belonging",
"to",
"the",
"object",
"/",
"box_type",
"given",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/box.py#L121-L141 |
ella/ella | ella/core/box.py | Box._render | def _render(self, context):
" The main function that takes care of the rendering. "
if self.template_name:
t = loader.get_template(self.template_name)
else:
t_list = self._get_template_list()
t = loader.select_template(t_list)
context.update(self.get_... | python | def _render(self, context):
" The main function that takes care of the rendering. "
if self.template_name:
t = loader.get_template(self.template_name)
else:
t_list = self._get_template_list()
t = loader.select_template(t_list)
context.update(self.get_... | [
"def",
"_render",
"(",
"self",
",",
"context",
")",
":",
"if",
"self",
".",
"template_name",
":",
"t",
"=",
"loader",
".",
"get_template",
"(",
"self",
".",
"template_name",
")",
"else",
":",
"t_list",
"=",
"self",
".",
"_get_template_list",
"(",
")",
... | The main function that takes care of the rendering. | [
"The",
"main",
"function",
"that",
"takes",
"care",
"of",
"the",
"rendering",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/box.py#L143-L154 |
ella/ella | ella/core/box.py | Box.get_cache_key | def get_cache_key(self):
" Return a cache key constructed from the box's parameters. "
if not self.is_model:
return None
pars = ''
if self.params:
pars = ','.join(':'.join((smart_str(key), smart_str(self.params[key]))) for key in sorted(self.params.keys()))
... | python | def get_cache_key(self):
" Return a cache key constructed from the box's parameters. "
if not self.is_model:
return None
pars = ''
if self.params:
pars = ','.join(':'.join((smart_str(key), smart_str(self.params[key]))) for key in sorted(self.params.keys()))
... | [
"def",
"get_cache_key",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_model",
":",
"return",
"None",
"pars",
"=",
"''",
"if",
"self",
".",
"params",
":",
"pars",
"=",
"','",
".",
"join",
"(",
"':'",
".",
"join",
"(",
"(",
"smart_str",
"(",
... | Return a cache key constructed from the box's parameters. | [
"Return",
"a",
"cache",
"key",
"constructed",
"from",
"the",
"box",
"s",
"parameters",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/box.py#L156-L167 |
ella/ella | ella/core/models/main.py | Category.save | def save(self, **kwargs):
"Override save() to construct tree_path based on the category's parent."
old_tree_path = self.tree_path
if self.tree_parent:
if self.tree_parent.tree_path:
self.tree_path = '%s/%s' % (self.tree_parent.tree_path, self.slug)
else:
... | python | def save(self, **kwargs):
"Override save() to construct tree_path based on the category's parent."
old_tree_path = self.tree_path
if self.tree_parent:
if self.tree_parent.tree_path:
self.tree_path = '%s/%s' % (self.tree_parent.tree_path, self.slug)
else:
... | [
"def",
"save",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"old_tree_path",
"=",
"self",
".",
"tree_path",
"if",
"self",
".",
"tree_parent",
":",
"if",
"self",
".",
"tree_parent",
".",
"tree_path",
":",
"self",
".",
"tree_path",
"=",
"'%s/%s'",
"%"... | Override save() to construct tree_path based on the category's parent. | [
"Override",
"save",
"()",
"to",
"construct",
"tree_path",
"based",
"on",
"the",
"category",
"s",
"parent",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/models/main.py#L129-L145 |
ella/ella | ella/core/models/main.py | Category.get_absolute_url | def get_absolute_url(self):
"""
Returns absolute URL for the category.
"""
if not self.tree_parent_id:
url = reverse('root_homepage')
else:
url = reverse('category_detail', kwargs={'category' : self.tree_path})
if self.site_id != settings.SITE_ID:
... | python | def get_absolute_url(self):
"""
Returns absolute URL for the category.
"""
if not self.tree_parent_id:
url = reverse('root_homepage')
else:
url = reverse('category_detail', kwargs={'category' : self.tree_path})
if self.site_id != settings.SITE_ID:
... | [
"def",
"get_absolute_url",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"tree_parent_id",
":",
"url",
"=",
"reverse",
"(",
"'root_homepage'",
")",
"else",
":",
"url",
"=",
"reverse",
"(",
"'category_detail'",
",",
"kwargs",
"=",
"{",
"'category'",
":",... | Returns absolute URL for the category. | [
"Returns",
"absolute",
"URL",
"for",
"the",
"category",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/models/main.py#L169-L180 |
ella/ella | ella/core/templatetags/core.py | listing | def listing(parser, token):
"""
Tag that will obtain listing of top objects for a given category and store them in context under given name.
Usage::
{% listing <limit>[ from <offset>][of <app.model>[, <app.model>[, ...]]][ for <category> ] [with children|descendents] [using listing_handler] as <re... | python | def listing(parser, token):
"""
Tag that will obtain listing of top objects for a given category and store them in context under given name.
Usage::
{% listing <limit>[ from <offset>][of <app.model>[, <app.model>[, ...]]][ for <category> ] [with children|descendents] [using listing_handler] as <re... | [
"def",
"listing",
"(",
"parser",
",",
"token",
")",
":",
"var_name",
",",
"parameters",
"=",
"listing_parse",
"(",
"token",
".",
"split_contents",
"(",
")",
")",
"return",
"ListingNode",
"(",
"var_name",
",",
"parameters",
")"
] | Tag that will obtain listing of top objects for a given category and store them in context under given name.
Usage::
{% listing <limit>[ from <offset>][of <app.model>[, <app.model>[, ...]]][ for <category> ] [with children|descendents] [using listing_handler] as <result> %}
Parameters:
======... | [
"Tag",
"that",
"will",
"obtain",
"listing",
"of",
"top",
"objects",
"for",
"a",
"given",
"category",
"and",
"store",
"them",
"in",
"context",
"under",
"given",
"name",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/templatetags/core.py#L50-L88 |
ella/ella | ella/core/templatetags/core.py | do_box | def do_box(parser, token):
"""
Tag Node representing our idea of a reusable box. It can handle multiple
parameters in its body which will then be accessible via ``{{ box.params
}}`` in the template being rendered.
.. note::
The inside of the box will be rendered only when redering the box i... | python | def do_box(parser, token):
"""
Tag Node representing our idea of a reusable box. It can handle multiple
parameters in its body which will then be accessible via ``{{ box.params
}}`` in the template being rendered.
.. note::
The inside of the box will be rendered only when redering the box i... | [
"def",
"do_box",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"nodelist",
"=",
"parser",
".",
"parse",
"(",
"(",
"'end'",
"+",
"bits",
"[",
"0",
"]",
",",
")",
")",
"parser",
".",
"delete_first_token",... | Tag Node representing our idea of a reusable box. It can handle multiple
parameters in its body which will then be accessible via ``{{ box.params
}}`` in the template being rendered.
.. note::
The inside of the box will be rendered only when redering the box in
current context and the ``obj... | [
"Tag",
"Node",
"representing",
"our",
"idea",
"of",
"a",
"reusable",
"box",
".",
"It",
"can",
"handle",
"multiple",
"parameters",
"in",
"its",
"body",
"which",
"will",
"then",
"be",
"accessible",
"via",
"{{",
"box",
".",
"params",
"}}",
"in",
"the",
"tem... | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/templatetags/core.py#L221-L296 |
ella/ella | ella/core/templatetags/core.py | do_render | def do_render(parser, token):
"""
Renders a rich-text field using defined markup.
Example::
{% render some_var %}
"""
bits = token.split_contents()
if len(bits) != 2:
raise template.TemplateSyntaxError()
return RenderNode(bits[1]) | python | def do_render(parser, token):
"""
Renders a rich-text field using defined markup.
Example::
{% render some_var %}
"""
bits = token.split_contents()
if len(bits) != 2:
raise template.TemplateSyntaxError()
return RenderNode(bits[1]) | [
"def",
"do_render",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
"!=",
"2",
":",
"raise",
"template",
".",
"TemplateSyntaxError",
"(",
")",
"return",
"RenderNode",
"(",
"bi... | Renders a rich-text field using defined markup.
Example::
{% render some_var %} | [
"Renders",
"a",
"rich",
"-",
"text",
"field",
"using",
"defined",
"markup",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/templatetags/core.py#L332-L345 |
ella/ella | ella/core/templatetags/core.py | ipblur | def ipblur(text): # brutalizer ;-)
""" blurs IP address """
import re
m = re.match(r'^(\d{1,3}\.\d{1,3}\.\d{1,3}\.)\d{1,3}.*', text)
if not m:
return text
return '%sxxx' % m.group(1) | python | def ipblur(text): # brutalizer ;-)
""" blurs IP address """
import re
m = re.match(r'^(\d{1,3}\.\d{1,3}\.\d{1,3}\.)\d{1,3}.*', text)
if not m:
return text
return '%sxxx' % m.group(1) | [
"def",
"ipblur",
"(",
"text",
")",
":",
"# brutalizer ;-)",
"import",
"re",
"m",
"=",
"re",
".",
"match",
"(",
"r'^(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.)\\d{1,3}.*'",
",",
"text",
")",
"if",
"not",
"m",
":",
"return",
"text",
"return",
"'%sxxx'",
"%",
"m",
".",... | blurs IP address | [
"blurs",
"IP",
"address"
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/templatetags/core.py#L349-L355 |
ella/ella | ella/utils/installedapps.py | register | def register(app_name, modules):
"""
simple module registering for later usage
we don't want to import admin.py in models.py
"""
global INSTALLED_APPS_REGISTER
mod_list = INSTALLED_APPS_REGISTER.get(app_name, [])
if isinstance(modules, basestring):
mod_list.append(modules)
elif ... | python | def register(app_name, modules):
"""
simple module registering for later usage
we don't want to import admin.py in models.py
"""
global INSTALLED_APPS_REGISTER
mod_list = INSTALLED_APPS_REGISTER.get(app_name, [])
if isinstance(modules, basestring):
mod_list.append(modules)
elif ... | [
"def",
"register",
"(",
"app_name",
",",
"modules",
")",
":",
"global",
"INSTALLED_APPS_REGISTER",
"mod_list",
"=",
"INSTALLED_APPS_REGISTER",
".",
"get",
"(",
"app_name",
",",
"[",
"]",
")",
"if",
"isinstance",
"(",
"modules",
",",
"basestring",
")",
":",
"... | simple module registering for later usage
we don't want to import admin.py in models.py | [
"simple",
"module",
"registering",
"for",
"later",
"usage",
"we",
"don",
"t",
"want",
"to",
"import",
"admin",
".",
"py",
"in",
"models",
".",
"py"
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/utils/installedapps.py#L11-L24 |
ella/ella | ella/utils/installedapps.py | call_modules | def call_modules(auto_discover=()):
"""
this is called in project urls.py
for registering desired modules (eg.: admin.py)
"""
for app in settings.INSTALLED_APPS:
modules = set(auto_discover)
if app in INSTALLED_APPS_REGISTER:
modules.update(INSTALLED_APPS_REGISTER[app])
... | python | def call_modules(auto_discover=()):
"""
this is called in project urls.py
for registering desired modules (eg.: admin.py)
"""
for app in settings.INSTALLED_APPS:
modules = set(auto_discover)
if app in INSTALLED_APPS_REGISTER:
modules.update(INSTALLED_APPS_REGISTER[app])
... | [
"def",
"call_modules",
"(",
"auto_discover",
"=",
"(",
")",
")",
":",
"for",
"app",
"in",
"settings",
".",
"INSTALLED_APPS",
":",
"modules",
"=",
"set",
"(",
"auto_discover",
")",
"if",
"app",
"in",
"INSTALLED_APPS_REGISTER",
":",
"modules",
".",
"update",
... | this is called in project urls.py
for registering desired modules (eg.: admin.py) | [
"this",
"is",
"called",
"in",
"project",
"urls",
".",
"py",
"for",
"registering",
"desired",
"modules",
"(",
"eg",
".",
":",
"admin",
".",
"py",
")"
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/utils/installedapps.py#L27-L45 |
ella/ella | ella/core/related_finders.py | related_by_category | def related_by_category(obj, count, collected_so_far, mods=[], only_from_same_site=True):
"""
Returns other Publishable objects related to ``obj`` by using the same
category principle. Returns up to ``count`` objects.
"""
related = []
# top objects in given category
if count > 0:
fro... | python | def related_by_category(obj, count, collected_so_far, mods=[], only_from_same_site=True):
"""
Returns other Publishable objects related to ``obj`` by using the same
category principle. Returns up to ``count`` objects.
"""
related = []
# top objects in given category
if count > 0:
fro... | [
"def",
"related_by_category",
"(",
"obj",
",",
"count",
",",
"collected_so_far",
",",
"mods",
"=",
"[",
"]",
",",
"only_from_same_site",
"=",
"True",
")",
":",
"related",
"=",
"[",
"]",
"# top objects in given category",
"if",
"count",
">",
"0",
":",
"from",... | Returns other Publishable objects related to ``obj`` by using the same
category principle. Returns up to ``count`` objects. | [
"Returns",
"other",
"Publishable",
"objects",
"related",
"to",
"obj",
"by",
"using",
"the",
"same",
"category",
"principle",
".",
"Returns",
"up",
"to",
"count",
"objects",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/related_finders.py#L7-L29 |
ella/ella | ella/core/related_finders.py | directly_related | def directly_related(obj, count, collected_so_far, mods=[], only_from_same_site=True):
"""
Returns objects related to ``obj`` up to ``count`` by searching
``Related`` instances for the ``obj``.
"""
# manually entered dependencies
qset = Related.objects.filter(publishable=obj)
if mods:
... | python | def directly_related(obj, count, collected_so_far, mods=[], only_from_same_site=True):
"""
Returns objects related to ``obj`` up to ``count`` by searching
``Related`` instances for the ``obj``.
"""
# manually entered dependencies
qset = Related.objects.filter(publishable=obj)
if mods:
... | [
"def",
"directly_related",
"(",
"obj",
",",
"count",
",",
"collected_so_far",
",",
"mods",
"=",
"[",
"]",
",",
"only_from_same_site",
"=",
"True",
")",
":",
"# manually entered dependencies",
"qset",
"=",
"Related",
".",
"objects",
".",
"filter",
"(",
"publish... | Returns objects related to ``obj`` up to ``count`` by searching
``Related`` instances for the ``obj``. | [
"Returns",
"objects",
"related",
"to",
"obj",
"up",
"to",
"count",
"by",
"searching",
"Related",
"instances",
"for",
"the",
"obj",
"."
] | train | https://github.com/ella/ella/blob/4a1414991f649dc21c4b777dc6b41a922a13faa7/ella/core/related_finders.py#L32-L44 |
ssalentin/plip | plip/modules/report.py | StructureReport.construct_xml_tree | def construct_xml_tree(self):
"""Construct the basic XML tree"""
report = et.Element('report')
plipversion = et.SubElement(report, 'plipversion')
plipversion.text = __version__
date_of_creation = et.SubElement(report, 'date_of_creation')
date_of_creation.text = time.strft... | python | def construct_xml_tree(self):
"""Construct the basic XML tree"""
report = et.Element('report')
plipversion = et.SubElement(report, 'plipversion')
plipversion.text = __version__
date_of_creation = et.SubElement(report, 'date_of_creation')
date_of_creation.text = time.strft... | [
"def",
"construct_xml_tree",
"(",
"self",
")",
":",
"report",
"=",
"et",
".",
"Element",
"(",
"'report'",
")",
"plipversion",
"=",
"et",
".",
"SubElement",
"(",
"report",
",",
"'plipversion'",
")",
"plipversion",
".",
"text",
"=",
"__version__",
"date_of_cre... | Construct the basic XML tree | [
"Construct",
"the",
"basic",
"XML",
"tree"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/report.py#L37-L73 |
ssalentin/plip | plip/modules/report.py | StructureReport.construct_txt_file | def construct_txt_file(self):
"""Construct the header of the txt file"""
textlines = ['Prediction of noncovalent interactions for PDB structure %s' % self.mol.pymol_name.upper(), ]
textlines.append("=" * len(textlines[0]))
textlines.append('Created on %s using PLIP v%s\n' % (time.strftim... | python | def construct_txt_file(self):
"""Construct the header of the txt file"""
textlines = ['Prediction of noncovalent interactions for PDB structure %s' % self.mol.pymol_name.upper(), ]
textlines.append("=" * len(textlines[0]))
textlines.append('Created on %s using PLIP v%s\n' % (time.strftim... | [
"def",
"construct_txt_file",
"(",
"self",
")",
":",
"textlines",
"=",
"[",
"'Prediction of noncovalent interactions for PDB structure %s'",
"%",
"self",
".",
"mol",
".",
"pymol_name",
".",
"upper",
"(",
")",
",",
"]",
"textlines",
".",
"append",
"(",
"\"=\"",
"*... | Construct the header of the txt file | [
"Construct",
"the",
"header",
"of",
"the",
"txt",
"file"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/report.py#L75-L87 |
ssalentin/plip | plip/modules/report.py | StructureReport.get_bindingsite_data | def get_bindingsite_data(self):
"""Get the additional data for the binding sites"""
for i, site in enumerate(sorted(self.mol.interaction_sets)):
s = self.mol.interaction_sets[site]
bindingsite = BindingSiteReport(s).generate_xml()
bindingsite.set('id', str(i + 1))
... | python | def get_bindingsite_data(self):
"""Get the additional data for the binding sites"""
for i, site in enumerate(sorted(self.mol.interaction_sets)):
s = self.mol.interaction_sets[site]
bindingsite = BindingSiteReport(s).generate_xml()
bindingsite.set('id', str(i + 1))
... | [
"def",
"get_bindingsite_data",
"(",
"self",
")",
":",
"for",
"i",
",",
"site",
"in",
"enumerate",
"(",
"sorted",
"(",
"self",
".",
"mol",
".",
"interaction_sets",
")",
")",
":",
"s",
"=",
"self",
".",
"mol",
".",
"interaction_sets",
"[",
"site",
"]",
... | Get the additional data for the binding sites | [
"Get",
"the",
"additional",
"data",
"for",
"the",
"binding",
"sites"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/report.py#L89-L103 |
ssalentin/plip | plip/modules/report.py | StructureReport.write_xml | def write_xml(self, as_string=False):
"""Write the XML report"""
if not as_string:
et.ElementTree(self.xmlreport).write('{}/{}.xml'.format(self.outpath, self.outputprefix), pretty_print=True, xml_declaration=True)
else:
output = et.tostring(self.xmlreport, pretty_print=Tr... | python | def write_xml(self, as_string=False):
"""Write the XML report"""
if not as_string:
et.ElementTree(self.xmlreport).write('{}/{}.xml'.format(self.outpath, self.outputprefix), pretty_print=True, xml_declaration=True)
else:
output = et.tostring(self.xmlreport, pretty_print=Tr... | [
"def",
"write_xml",
"(",
"self",
",",
"as_string",
"=",
"False",
")",
":",
"if",
"not",
"as_string",
":",
"et",
".",
"ElementTree",
"(",
"self",
".",
"xmlreport",
")",
".",
"write",
"(",
"'{}/{}.xml'",
".",
"format",
"(",
"self",
".",
"outpath",
",",
... | Write the XML report | [
"Write",
"the",
"XML",
"report"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/report.py#L105-L113 |
ssalentin/plip | plip/modules/report.py | StructureReport.write_txt | def write_txt(self, as_string=False):
"""Write the TXT report"""
if not as_string:
with open('{}/{}.txt'.format(self.outpath, self.outputprefix), 'w') as f:
[f.write(textline + '\n') for textline in self.txtreport]
else:
output = '\n'.join(self.txtreport)
... | python | def write_txt(self, as_string=False):
"""Write the TXT report"""
if not as_string:
with open('{}/{}.txt'.format(self.outpath, self.outputprefix), 'w') as f:
[f.write(textline + '\n') for textline in self.txtreport]
else:
output = '\n'.join(self.txtreport)
... | [
"def",
"write_txt",
"(",
"self",
",",
"as_string",
"=",
"False",
")",
":",
"if",
"not",
"as_string",
":",
"with",
"open",
"(",
"'{}/{}.txt'",
".",
"format",
"(",
"self",
".",
"outpath",
",",
"self",
".",
"outputprefix",
")",
",",
"'w'",
")",
"as",
"f... | Write the TXT report | [
"Write",
"the",
"TXT",
"report"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/report.py#L115-L124 |
ssalentin/plip | plip/modules/report.py | BindingSiteReport.write_section | def write_section(self, name, features, info, f):
"""Provides formatting for one section (e.g. hydrogen bonds)"""
if not len(info) == 0:
f.write('\n\n### %s ###\n' % name)
f.write('%s\n' % '\t'.join(features))
for line in info:
f.write('%s\n' % '\t'.jo... | python | def write_section(self, name, features, info, f):
"""Provides formatting for one section (e.g. hydrogen bonds)"""
if not len(info) == 0:
f.write('\n\n### %s ###\n' % name)
f.write('%s\n' % '\t'.join(features))
for line in info:
f.write('%s\n' % '\t'.jo... | [
"def",
"write_section",
"(",
"self",
",",
"name",
",",
"features",
",",
"info",
",",
"f",
")",
":",
"if",
"not",
"len",
"(",
"info",
")",
"==",
"0",
":",
"f",
".",
"write",
"(",
"'\\n\\n### %s ###\\n'",
"%",
"name",
")",
"f",
".",
"write",
"(",
"... | Provides formatting for one section (e.g. hydrogen bonds) | [
"Provides",
"formatting",
"for",
"one",
"section",
"(",
"e",
".",
"g",
".",
"hydrogen",
"bonds",
")"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/report.py#L275-L281 |
ssalentin/plip | plip/modules/report.py | BindingSiteReport.rst_table | def rst_table(self, array):
"""Given an array, the function formats and returns and table in rST format."""
# Determine cell width for each column
cell_dict = {}
for i, row in enumerate(array):
for j, val in enumerate(row):
if j not in cell_dict:
... | python | def rst_table(self, array):
"""Given an array, the function formats and returns and table in rST format."""
# Determine cell width for each column
cell_dict = {}
for i, row in enumerate(array):
for j, val in enumerate(row):
if j not in cell_dict:
... | [
"def",
"rst_table",
"(",
"self",
",",
"array",
")",
":",
"# Determine cell width for each column",
"cell_dict",
"=",
"{",
"}",
"for",
"i",
",",
"row",
"in",
"enumerate",
"(",
"array",
")",
":",
"for",
"j",
",",
"val",
"in",
"enumerate",
"(",
"row",
")",
... | Given an array, the function formats and returns and table in rST format. | [
"Given",
"an",
"array",
"the",
"function",
"formats",
"and",
"returns",
"and",
"table",
"in",
"rST",
"format",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/report.py#L283-L322 |
ssalentin/plip | plip/modules/report.py | BindingSiteReport.generate_txt | def generate_txt(self):
"""Generates an flat text report for a single binding site"""
txt = []
titletext = '%s (%s) - %s' % (self.bsid, self.longname, self.ligtype)
txt.append(titletext)
for i, member in enumerate(self.lig_members[1:]):
txt.append(' + %s' % ":".join... | python | def generate_txt(self):
"""Generates an flat text report for a single binding site"""
txt = []
titletext = '%s (%s) - %s' % (self.bsid, self.longname, self.ligtype)
txt.append(titletext)
for i, member in enumerate(self.lig_members[1:]):
txt.append(' + %s' % ":".join... | [
"def",
"generate_txt",
"(",
"self",
")",
":",
"txt",
"=",
"[",
"]",
"titletext",
"=",
"'%s (%s) - %s'",
"%",
"(",
"self",
".",
"bsid",
",",
"self",
".",
"longname",
",",
"self",
".",
"ligtype",
")",
"txt",
".",
"append",
"(",
"titletext",
")",
"for",... | Generates an flat text report for a single binding site | [
"Generates",
"an",
"flat",
"text",
"report",
"for",
"a",
"single",
"binding",
"site"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/report.py#L324-L361 |
ssalentin/plip | plip/modules/report.py | BindingSiteReport.generate_xml | def generate_xml(self):
"""Generates an XML-formatted report for a single binding site"""
report = et.Element('bindingsite')
identifiers = et.SubElement(report, 'identifiers')
longname = et.SubElement(identifiers, 'longname')
ligtype = et.SubElement(identifiers, 'ligtype')
... | python | def generate_xml(self):
"""Generates an XML-formatted report for a single binding site"""
report = et.Element('bindingsite')
identifiers = et.SubElement(report, 'identifiers')
longname = et.SubElement(identifiers, 'longname')
ligtype = et.SubElement(identifiers, 'ligtype')
... | [
"def",
"generate_xml",
"(",
"self",
")",
":",
"report",
"=",
"et",
".",
"Element",
"(",
"'bindingsite'",
")",
"identifiers",
"=",
"et",
".",
"SubElement",
"(",
"report",
",",
"'identifiers'",
")",
"longname",
"=",
"et",
".",
"SubElement",
"(",
"identifiers... | Generates an XML-formatted report for a single binding site | [
"Generates",
"an",
"XML",
"-",
"formatted",
"report",
"for",
"a",
"single",
"binding",
"site"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/report.py#L363-L477 |
ssalentin/plip | plip/modules/mp.py | pool_args | def pool_args(function, sequence, kwargs):
"""Return a single iterator of n elements of lists of length 3, given a sequence of len n."""
return zip(itertools.repeat(function), sequence, itertools.repeat(kwargs)) | python | def pool_args(function, sequence, kwargs):
"""Return a single iterator of n elements of lists of length 3, given a sequence of len n."""
return zip(itertools.repeat(function), sequence, itertools.repeat(kwargs)) | [
"def",
"pool_args",
"(",
"function",
",",
"sequence",
",",
"kwargs",
")",
":",
"return",
"zip",
"(",
"itertools",
".",
"repeat",
"(",
"function",
")",
",",
"sequence",
",",
"itertools",
".",
"repeat",
"(",
"kwargs",
")",
")"
] | Return a single iterator of n elements of lists of length 3, given a sequence of len n. | [
"Return",
"a",
"single",
"iterator",
"of",
"n",
"elements",
"of",
"lists",
"of",
"length",
"3",
"given",
"a",
"sequence",
"of",
"len",
"n",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/mp.py#L30-L32 |
ssalentin/plip | plip/modules/mp.py | parallel_fn | def parallel_fn(f):
"""Simple wrapper function, returning a parallel version of the given function f.
The function f must have one argument and may have an arbitray number of
keyword arguments. """
def simple_parallel(func, sequence, **args):
""" f takes an element of sequence as input an... | python | def parallel_fn(f):
"""Simple wrapper function, returning a parallel version of the given function f.
The function f must have one argument and may have an arbitray number of
keyword arguments. """
def simple_parallel(func, sequence, **args):
""" f takes an element of sequence as input an... | [
"def",
"parallel_fn",
"(",
"f",
")",
":",
"def",
"simple_parallel",
"(",
"func",
",",
"sequence",
",",
"*",
"*",
"args",
")",
":",
"\"\"\" f takes an element of sequence as input and the keyword args in **args\"\"\"",
"if",
"'processes'",
"in",
"args",
":",
"processes... | Simple wrapper function, returning a parallel version of the given function f.
The function f must have one argument and may have an arbitray number of
keyword arguments. | [
"Simple",
"wrapper",
"function",
"returning",
"a",
"parallel",
"version",
"of",
"the",
"given",
"function",
"f",
".",
"The",
"function",
"f",
"must",
"have",
"one",
"argument",
"and",
"may",
"have",
"an",
"arbitray",
"number",
"of",
"keyword",
"arguments",
"... | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/mp.py#L35-L56 |
ssalentin/plip | plip/modules/preparation.py | PDBParser.parse_pdb | def parse_pdb(self):
"""Extracts additional information from PDB files.
I. When reading in a PDB file, OpenBabel numbers ATOMS and HETATOMS continously.
In PDB files, TER records are also counted, leading to a different numbering system.
This functions reads in a PDB file and provides a ... | python | def parse_pdb(self):
"""Extracts additional information from PDB files.
I. When reading in a PDB file, OpenBabel numbers ATOMS and HETATOMS continously.
In PDB files, TER records are also counted, leading to a different numbering system.
This functions reads in a PDB file and provides a ... | [
"def",
"parse_pdb",
"(",
"self",
")",
":",
"if",
"self",
".",
"as_string",
":",
"fil",
"=",
"self",
".",
"pdbpath",
".",
"rstrip",
"(",
"'\\n'",
")",
".",
"split",
"(",
"'\\n'",
")",
"# Removing trailing newline character",
"else",
":",
"f",
"=",
"read",... | Extracts additional information from PDB files.
I. When reading in a PDB file, OpenBabel numbers ATOMS and HETATOMS continously.
In PDB files, TER records are also counted, leading to a different numbering system.
This functions reads in a PDB file and provides a mapping as a dictionary.
... | [
"Extracts",
"additional",
"information",
"from",
"PDB",
"files",
".",
"I",
".",
"When",
"reading",
"in",
"a",
"PDB",
"file",
"OpenBabel",
"numbers",
"ATOMS",
"and",
"HETATOMS",
"continously",
".",
"In",
"PDB",
"files",
"TER",
"records",
"are",
"also",
"count... | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L43-L117 |
ssalentin/plip | plip/modules/preparation.py | PDBParser.fix_pdbline | def fix_pdbline(self, pdbline, lastnum):
"""Fix a PDB line if information is missing."""
pdbqt_conversion = {
"HD": "H", "HS": "H", "NA": "N",
"NS": "N", "OA": "O", "OS": "O", "SA": "S"}
fixed = False
newnum = 0
forbidden_characters = "[^a-zA-Z0-9_]"
... | python | def fix_pdbline(self, pdbline, lastnum):
"""Fix a PDB line if information is missing."""
pdbqt_conversion = {
"HD": "H", "HS": "H", "NA": "N",
"NS": "N", "OA": "O", "OS": "O", "SA": "S"}
fixed = False
newnum = 0
forbidden_characters = "[^a-zA-Z0-9_]"
... | [
"def",
"fix_pdbline",
"(",
"self",
",",
"pdbline",
",",
"lastnum",
")",
":",
"pdbqt_conversion",
"=",
"{",
"\"HD\"",
":",
"\"H\"",
",",
"\"HS\"",
":",
"\"H\"",
",",
"\"NA\"",
":",
"\"N\"",
",",
"\"NS\"",
":",
"\"N\"",
",",
"\"OA\"",
":",
"\"O\"",
",",
... | Fix a PDB line if information is missing. | [
"Fix",
"a",
"PDB",
"line",
"if",
"information",
"is",
"missing",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L119-L206 |
ssalentin/plip | plip/modules/preparation.py | PDBParser.get_linkage | def get_linkage(self, line):
"""Get the linkage information from a LINK entry PDB line."""
conf1, id1, chain1, pos1 = line[16].strip(), line[17:20].strip(), line[21].strip(), int(line[22:26])
conf2, id2, chain2, pos2 = line[46].strip(), line[47:50].strip(), line[51].strip(), int(line[52:56])
... | python | def get_linkage(self, line):
"""Get the linkage information from a LINK entry PDB line."""
conf1, id1, chain1, pos1 = line[16].strip(), line[17:20].strip(), line[21].strip(), int(line[22:26])
conf2, id2, chain2, pos2 = line[46].strip(), line[47:50].strip(), line[51].strip(), int(line[52:56])
... | [
"def",
"get_linkage",
"(",
"self",
",",
"line",
")",
":",
"conf1",
",",
"id1",
",",
"chain1",
",",
"pos1",
"=",
"line",
"[",
"16",
"]",
".",
"strip",
"(",
")",
",",
"line",
"[",
"17",
":",
"20",
"]",
".",
"strip",
"(",
")",
",",
"line",
"[",
... | Get the linkage information from a LINK entry PDB line. | [
"Get",
"the",
"linkage",
"information",
"from",
"a",
"LINK",
"entry",
"PDB",
"line",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L208-L213 |
ssalentin/plip | plip/modules/preparation.py | LigandFinder.getpeptides | def getpeptides(self, chain):
"""If peptide ligand chains are defined via the command line options,
try to extract the underlying ligand formed by all residues in the
given chain without water
"""
all_from_chain = [o for o in pybel.ob.OBResidueIter(
self.proteincomple... | python | def getpeptides(self, chain):
"""If peptide ligand chains are defined via the command line options,
try to extract the underlying ligand formed by all residues in the
given chain without water
"""
all_from_chain = [o for o in pybel.ob.OBResidueIter(
self.proteincomple... | [
"def",
"getpeptides",
"(",
"self",
",",
"chain",
")",
":",
"all_from_chain",
"=",
"[",
"o",
"for",
"o",
"in",
"pybel",
".",
"ob",
".",
"OBResidueIter",
"(",
"self",
".",
"proteincomplex",
".",
"OBMol",
")",
"if",
"o",
".",
"GetChain",
"(",
")",
"==",... | If peptide ligand chains are defined via the command line options,
try to extract the underlying ligand formed by all residues in the
given chain without water | [
"If",
"peptide",
"ligand",
"chains",
"are",
"defined",
"via",
"the",
"command",
"line",
"options",
"try",
"to",
"extract",
"the",
"underlying",
"ligand",
"formed",
"by",
"all",
"residues",
"in",
"the",
"given",
"chain",
"without",
"water"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L229-L241 |
ssalentin/plip | plip/modules/preparation.py | LigandFinder.getligs | def getligs(self):
"""Get all ligands from a PDB file and prepare them for analysis.
Returns all non-empty ligands.
"""
if config.PEPTIDES == [] and config.INTRA is None:
# Extract small molecule ligands (default)
ligands = []
# Filter for ligands us... | python | def getligs(self):
"""Get all ligands from a PDB file and prepare them for analysis.
Returns all non-empty ligands.
"""
if config.PEPTIDES == [] and config.INTRA is None:
# Extract small molecule ligands (default)
ligands = []
# Filter for ligands us... | [
"def",
"getligs",
"(",
"self",
")",
":",
"if",
"config",
".",
"PEPTIDES",
"==",
"[",
"]",
"and",
"config",
".",
"INTRA",
"is",
"None",
":",
"# Extract small molecule ligands (default)",
"ligands",
"=",
"[",
"]",
"# Filter for ligands using lists",
"ligand_residues... | Get all ligands from a PDB file and prepare them for analysis.
Returns all non-empty ligands. | [
"Get",
"all",
"ligands",
"from",
"a",
"PDB",
"file",
"and",
"prepare",
"them",
"for",
"analysis",
".",
"Returns",
"all",
"non",
"-",
"empty",
"ligands",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L243-L284 |
ssalentin/plip | plip/modules/preparation.py | LigandFinder.extract_ligand | def extract_ligand(self, kmer):
"""Extract the ligand by copying atoms and bonds and assign all information necessary for later steps."""
data = namedtuple('ligand', 'mol hetid chain position water members longname type atomorder can_to_pdb')
members = [(res.GetName(), res.GetChain(), int32_to_n... | python | def extract_ligand(self, kmer):
"""Extract the ligand by copying atoms and bonds and assign all information necessary for later steps."""
data = namedtuple('ligand', 'mol hetid chain position water members longname type atomorder can_to_pdb')
members = [(res.GetName(), res.GetChain(), int32_to_n... | [
"def",
"extract_ligand",
"(",
"self",
",",
"kmer",
")",
":",
"data",
"=",
"namedtuple",
"(",
"'ligand'",
",",
"'mol hetid chain position water members longname type atomorder can_to_pdb'",
")",
"members",
"=",
"[",
"(",
"res",
".",
"GetName",
"(",
")",
",",
"res",... | Extract the ligand by copying atoms and bonds and assign all information necessary for later steps. | [
"Extract",
"the",
"ligand",
"by",
"copying",
"atoms",
"and",
"bonds",
"and",
"assign",
"all",
"information",
"necessary",
"for",
"later",
"steps",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L286-L367 |
ssalentin/plip | plip/modules/preparation.py | LigandFinder.is_het_residue | def is_het_residue(self, obres):
"""Given an OBResidue, determines if the residue is indeed a possible ligand
in the PDB file"""
if not obres.GetResidueProperty(0):
# If the residue is NOT amino (0)
# It can be amino_nucleo, coenzme, ion, nucleo, protein, purine, pyrimidi... | python | def is_het_residue(self, obres):
"""Given an OBResidue, determines if the residue is indeed a possible ligand
in the PDB file"""
if not obres.GetResidueProperty(0):
# If the residue is NOT amino (0)
# It can be amino_nucleo, coenzme, ion, nucleo, protein, purine, pyrimidi... | [
"def",
"is_het_residue",
"(",
"self",
",",
"obres",
")",
":",
"if",
"not",
"obres",
".",
"GetResidueProperty",
"(",
"0",
")",
":",
"# If the residue is NOT amino (0)",
"# It can be amino_nucleo, coenzme, ion, nucleo, protein, purine, pyrimidine, solvent",
"# In these cases, it ... | Given an OBResidue, determines if the residue is indeed a possible ligand
in the PDB file | [
"Given",
"an",
"OBResidue",
"determines",
"if",
"the",
"residue",
"is",
"indeed",
"a",
"possible",
"ligand",
"in",
"the",
"PDB",
"file"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L369-L386 |
ssalentin/plip | plip/modules/preparation.py | LigandFinder.filter_for_ligands | def filter_for_ligands(self):
"""Given an OpenBabel Molecule, get all ligands, their names, and water"""
candidates1 = [o for o in pybel.ob.OBResidueIter(
self.proteincomplex.OBMol) if not o.GetResidueProperty(9) and self.is_het_residue(o)]
if config.DNARECEPTOR: # If DNA is the r... | python | def filter_for_ligands(self):
"""Given an OpenBabel Molecule, get all ligands, their names, and water"""
candidates1 = [o for o in pybel.ob.OBResidueIter(
self.proteincomplex.OBMol) if not o.GetResidueProperty(9) and self.is_het_residue(o)]
if config.DNARECEPTOR: # If DNA is the r... | [
"def",
"filter_for_ligands",
"(",
"self",
")",
":",
"candidates1",
"=",
"[",
"o",
"for",
"o",
"in",
"pybel",
".",
"ob",
".",
"OBResidueIter",
"(",
"self",
".",
"proteincomplex",
".",
"OBMol",
")",
"if",
"not",
"o",
".",
"GetResidueProperty",
"(",
"9",
... | Given an OpenBabel Molecule, get all ligands, their names, and water | [
"Given",
"an",
"OpenBabel",
"Molecule",
"get",
"all",
"ligands",
"their",
"names",
"and",
"water"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L388-L418 |
ssalentin/plip | plip/modules/preparation.py | LigandFinder.identify_kmers | def identify_kmers(self, residues):
"""Using the covalent linkage information, find out which fragments/subunits form a ligand."""
# Remove all those not considered by ligands and pairings including alternate conformations
ligdoubles = [[(link.id1, link.chain1, link.pos1),
... | python | def identify_kmers(self, residues):
"""Using the covalent linkage information, find out which fragments/subunits form a ligand."""
# Remove all those not considered by ligands and pairings including alternate conformations
ligdoubles = [[(link.id1, link.chain1, link.pos1),
... | [
"def",
"identify_kmers",
"(",
"self",
",",
"residues",
")",
":",
"# Remove all those not considered by ligands and pairings including alternate conformations",
"ligdoubles",
"=",
"[",
"[",
"(",
"link",
".",
"id1",
",",
"link",
".",
"chain1",
",",
"link",
".",
"pos1",
... | Using the covalent linkage information, find out which fragments/subunits form a ligand. | [
"Using",
"the",
"covalent",
"linkage",
"information",
"find",
"out",
"which",
"fragments",
"/",
"subunits",
"form",
"a",
"ligand",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L420-L447 |
ssalentin/plip | plip/modules/preparation.py | Mapper.id_to_atom | def id_to_atom(self, idx):
"""Returns the atom for a given original ligand ID.
To do this, the ID is mapped to the protein first and then the atom returned.
"""
mapped_idx = self.mapid(idx, 'reversed')
return pybel.Atom(self.original_structure.GetAtom(mapped_idx)) | python | def id_to_atom(self, idx):
"""Returns the atom for a given original ligand ID.
To do this, the ID is mapped to the protein first and then the atom returned.
"""
mapped_idx = self.mapid(idx, 'reversed')
return pybel.Atom(self.original_structure.GetAtom(mapped_idx)) | [
"def",
"id_to_atom",
"(",
"self",
",",
"idx",
")",
":",
"mapped_idx",
"=",
"self",
".",
"mapid",
"(",
"idx",
",",
"'reversed'",
")",
"return",
"pybel",
".",
"Atom",
"(",
"self",
".",
"original_structure",
".",
"GetAtom",
"(",
"mapped_idx",
")",
")"
] | Returns the atom for a given original ligand ID.
To do this, the ID is mapped to the protein first and then the atom returned. | [
"Returns",
"the",
"atom",
"for",
"a",
"given",
"original",
"ligand",
"ID",
".",
"To",
"do",
"this",
"the",
"ID",
"is",
"mapped",
"to",
"the",
"protein",
"first",
"and",
"then",
"the",
"atom",
"returned",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L469-L474 |
ssalentin/plip | plip/modules/preparation.py | Mol.hydrophobic_atoms | def hydrophobic_atoms(self, all_atoms):
"""Select all carbon atoms which have only carbons and/or hydrogens as direct neighbors."""
atom_set = []
data = namedtuple('hydrophobic', 'atom orig_atom orig_idx')
atm = [a for a in all_atoms if a.atomicnum == 6 and set([natom.GetAtomicNum() for ... | python | def hydrophobic_atoms(self, all_atoms):
"""Select all carbon atoms which have only carbons and/or hydrogens as direct neighbors."""
atom_set = []
data = namedtuple('hydrophobic', 'atom orig_atom orig_idx')
atm = [a for a in all_atoms if a.atomicnum == 6 and set([natom.GetAtomicNum() for ... | [
"def",
"hydrophobic_atoms",
"(",
"self",
",",
"all_atoms",
")",
":",
"atom_set",
"=",
"[",
"]",
"data",
"=",
"namedtuple",
"(",
"'hydrophobic'",
",",
"'atom orig_atom orig_idx'",
")",
"atm",
"=",
"[",
"a",
"for",
"a",
"in",
"all_atoms",
"if",
"a",
".",
"... | Select all carbon atoms which have only carbons and/or hydrogens as direct neighbors. | [
"Select",
"all",
"carbon",
"atoms",
"which",
"have",
"only",
"carbons",
"and",
"/",
"or",
"hydrogens",
"as",
"direct",
"neighbors",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L489-L501 |
ssalentin/plip | plip/modules/preparation.py | Mol.find_hba | def find_hba(self, all_atoms):
"""Find all possible hydrogen bond acceptors"""
data = namedtuple('hbondacceptor', 'a a_orig_atom a_orig_idx type')
a_set = []
for atom in filter(lambda at: at.OBAtom.IsHbondAcceptor(), all_atoms):
if atom.atomicnum not in [9, 17, 35, 53] and at... | python | def find_hba(self, all_atoms):
"""Find all possible hydrogen bond acceptors"""
data = namedtuple('hbondacceptor', 'a a_orig_atom a_orig_idx type')
a_set = []
for atom in filter(lambda at: at.OBAtom.IsHbondAcceptor(), all_atoms):
if atom.atomicnum not in [9, 17, 35, 53] and at... | [
"def",
"find_hba",
"(",
"self",
",",
"all_atoms",
")",
":",
"data",
"=",
"namedtuple",
"(",
"'hbondacceptor'",
",",
"'a a_orig_atom a_orig_idx type'",
")",
"a_set",
"=",
"[",
"]",
"for",
"atom",
"in",
"filter",
"(",
"lambda",
"at",
":",
"at",
".",
"OBAtom"... | Find all possible hydrogen bond acceptors | [
"Find",
"all",
"possible",
"hydrogen",
"bond",
"acceptors"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L503-L512 |
ssalentin/plip | plip/modules/preparation.py | Mol.find_hbd | def find_hbd(self, all_atoms, hydroph_atoms):
"""Find all possible strong and weak hydrogen bonds donors (all hydrophobic C-H pairings)"""
donor_pairs = []
data = namedtuple('hbonddonor', 'd d_orig_atom d_orig_idx h type')
for donor in [a for a in all_atoms if a.OBAtom.IsHbondDonor() and... | python | def find_hbd(self, all_atoms, hydroph_atoms):
"""Find all possible strong and weak hydrogen bonds donors (all hydrophobic C-H pairings)"""
donor_pairs = []
data = namedtuple('hbonddonor', 'd d_orig_atom d_orig_idx h type')
for donor in [a for a in all_atoms if a.OBAtom.IsHbondDonor() and... | [
"def",
"find_hbd",
"(",
"self",
",",
"all_atoms",
",",
"hydroph_atoms",
")",
":",
"donor_pairs",
"=",
"[",
"]",
"data",
"=",
"namedtuple",
"(",
"'hbonddonor'",
",",
"'d d_orig_atom d_orig_idx h type'",
")",
"for",
"donor",
"in",
"[",
"a",
"for",
"a",
"in",
... | Find all possible strong and weak hydrogen bonds donors (all hydrophobic C-H pairings) | [
"Find",
"all",
"possible",
"strong",
"and",
"weak",
"hydrogen",
"bonds",
"donors",
"(",
"all",
"hydrophobic",
"C",
"-",
"H",
"pairings",
")"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L514-L532 |
ssalentin/plip | plip/modules/preparation.py | Mol.find_rings | def find_rings(self, mol, all_atoms):
"""Find rings and return only aromatic.
Rings have to be sufficiently planar OR be detected by OpenBabel as aromatic."""
data = namedtuple('aromatic_ring', 'atoms orig_atoms atoms_orig_idx normal obj center type')
rings = []
aromatic_amino = ... | python | def find_rings(self, mol, all_atoms):
"""Find rings and return only aromatic.
Rings have to be sufficiently planar OR be detected by OpenBabel as aromatic."""
data = namedtuple('aromatic_ring', 'atoms orig_atoms atoms_orig_idx normal obj center type')
rings = []
aromatic_amino = ... | [
"def",
"find_rings",
"(",
"self",
",",
"mol",
",",
"all_atoms",
")",
":",
"data",
"=",
"namedtuple",
"(",
"'aromatic_ring'",
",",
"'atoms orig_atoms atoms_orig_idx normal obj center type'",
")",
"rings",
"=",
"[",
"]",
"aromatic_amino",
"=",
"[",
"'TYR'",
",",
"... | Find rings and return only aromatic.
Rings have to be sufficiently planar OR be detected by OpenBabel as aromatic. | [
"Find",
"rings",
"and",
"return",
"only",
"aromatic",
".",
"Rings",
"have",
"to",
"be",
"sufficiently",
"planar",
"OR",
"be",
"detected",
"by",
"OpenBabel",
"as",
"aromatic",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L534-L565 |
ssalentin/plip | plip/modules/preparation.py | PLInteraction.find_unpaired_ligand | def find_unpaired_ligand(self):
"""Identify unpaired functional in groups in ligands, involving H-Bond donors, acceptors, halogen bond donors.
"""
unpaired_hba, unpaired_hbd, unpaired_hal = [], [], []
# Unpaired hydrogen bond acceptors/donors in ligand (not used for hydrogen bonds/water,... | python | def find_unpaired_ligand(self):
"""Identify unpaired functional in groups in ligands, involving H-Bond donors, acceptors, halogen bond donors.
"""
unpaired_hba, unpaired_hbd, unpaired_hal = [], [], []
# Unpaired hydrogen bond acceptors/donors in ligand (not used for hydrogen bonds/water,... | [
"def",
"find_unpaired_ligand",
"(",
"self",
")",
":",
"unpaired_hba",
",",
"unpaired_hbd",
",",
"unpaired_hal",
"=",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",
"# Unpaired hydrogen bond acceptors/donors in ligand (not used for hydrogen bonds/water, salt bridges/mcomplex)",
"in... | Identify unpaired functional in groups in ligands, involving H-Bond donors, acceptors, halogen bond donors. | [
"Identify",
"unpaired",
"functional",
"in",
"groups",
"in",
"ligands",
"involving",
"H",
"-",
"Bond",
"donors",
"acceptors",
"halogen",
"bond",
"donors",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L683-L708 |
ssalentin/plip | plip/modules/preparation.py | PLInteraction.refine_hydrophobic | def refine_hydrophobic(self, all_h, pistacks):
"""Apply several rules to reduce the number of hydrophobic interactions."""
sel = {}
# 1. Rings interacting via stacking can't have additional hydrophobic contacts between each other.
for pistack, h in itertools.product(pistacks, all_h):
... | python | def refine_hydrophobic(self, all_h, pistacks):
"""Apply several rules to reduce the number of hydrophobic interactions."""
sel = {}
# 1. Rings interacting via stacking can't have additional hydrophobic contacts between each other.
for pistack, h in itertools.product(pistacks, all_h):
... | [
"def",
"refine_hydrophobic",
"(",
"self",
",",
"all_h",
",",
"pistacks",
")",
":",
"sel",
"=",
"{",
"}",
"# 1. Rings interacting via stacking can't have additional hydrophobic contacts between each other.",
"for",
"pistack",
",",
"h",
"in",
"itertools",
".",
"product",
... | Apply several rules to reduce the number of hydrophobic interactions. | [
"Apply",
"several",
"rules",
"to",
"reduce",
"the",
"number",
"of",
"hydrophobic",
"interactions",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L710-L775 |
ssalentin/plip | plip/modules/preparation.py | PLInteraction.refine_hbonds_ldon | def refine_hbonds_ldon(self, all_hbonds, salt_lneg, salt_pneg):
"""Refine selection of hydrogen bonds. Do not allow groups which already form salt bridges to form H-Bonds."""
i_set = {}
for hbond in all_hbonds:
i_set[hbond] = False
for salt in salt_pneg:
p... | python | def refine_hbonds_ldon(self, all_hbonds, salt_lneg, salt_pneg):
"""Refine selection of hydrogen bonds. Do not allow groups which already form salt bridges to form H-Bonds."""
i_set = {}
for hbond in all_hbonds:
i_set[hbond] = False
for salt in salt_pneg:
p... | [
"def",
"refine_hbonds_ldon",
"(",
"self",
",",
"all_hbonds",
",",
"salt_lneg",
",",
"salt_pneg",
")",
":",
"i_set",
"=",
"{",
"}",
"for",
"hbond",
"in",
"all_hbonds",
":",
"i_set",
"[",
"hbond",
"]",
"=",
"False",
"for",
"salt",
"in",
"salt_pneg",
":",
... | Refine selection of hydrogen bonds. Do not allow groups which already form salt bridges to form H-Bonds. | [
"Refine",
"selection",
"of",
"hydrogen",
"bonds",
".",
"Do",
"not",
"allow",
"groups",
"which",
"already",
"form",
"salt",
"bridges",
"to",
"form",
"H",
"-",
"Bonds",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L777-L800 |
ssalentin/plip | plip/modules/preparation.py | PLInteraction.refine_pi_cation_laro | def refine_pi_cation_laro(self, all_picat, stacks):
"""Just important for constellations with histidine involved. If the histidine ring is positioned in stacking
position to an aromatic ring in the ligand, there is in most cases stacking and pi-cation interaction reported
as histidine also carri... | python | def refine_pi_cation_laro(self, all_picat, stacks):
"""Just important for constellations with histidine involved. If the histidine ring is positioned in stacking
position to an aromatic ring in the ligand, there is in most cases stacking and pi-cation interaction reported
as histidine also carri... | [
"def",
"refine_pi_cation_laro",
"(",
"self",
",",
"all_picat",
",",
"stacks",
")",
":",
"i_set",
"=",
"[",
"]",
"for",
"picat",
"in",
"all_picat",
":",
"exclude",
"=",
"False",
"for",
"stack",
"in",
"stacks",
":",
"if",
"whichrestype",
"(",
"stack",
".",... | Just important for constellations with histidine involved. If the histidine ring is positioned in stacking
position to an aromatic ring in the ligand, there is in most cases stacking and pi-cation interaction reported
as histidine also carries a positive charge in the ring. For such cases, only report s... | [
"Just",
"important",
"for",
"constellations",
"with",
"histidine",
"involved",
".",
"If",
"the",
"histidine",
"ring",
"is",
"positioned",
"in",
"stacking",
"position",
"to",
"an",
"aromatic",
"ring",
"in",
"the",
"ligand",
"there",
"is",
"in",
"most",
"cases",... | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L829-L842 |
ssalentin/plip | plip/modules/preparation.py | PLInteraction.refine_water_bridges | def refine_water_bridges(self, wbridges, hbonds_ldon, hbonds_pdon):
"""A donor atom already forming a hydrogen bond is not allowed to form a water bridge. Each water molecule
can only be donor for two water bridges, selecting the constellation with the omega angle closest to 110 deg."""
donor_at... | python | def refine_water_bridges(self, wbridges, hbonds_ldon, hbonds_pdon):
"""A donor atom already forming a hydrogen bond is not allowed to form a water bridge. Each water molecule
can only be donor for two water bridges, selecting the constellation with the omega angle closest to 110 deg."""
donor_at... | [
"def",
"refine_water_bridges",
"(",
"self",
",",
"wbridges",
",",
"hbonds_ldon",
",",
"hbonds_pdon",
")",
":",
"donor_atoms_hbonds",
"=",
"[",
"hb",
".",
"d",
".",
"idx",
"for",
"hb",
"in",
"hbonds_ldon",
"+",
"hbonds_pdon",
"]",
"wb_dict",
"=",
"{",
"}",
... | A donor atom already forming a hydrogen bond is not allowed to form a water bridge. Each water molecule
can only be donor for two water bridges, selecting the constellation with the omega angle closest to 110 deg. | [
"A",
"donor",
"atom",
"already",
"forming",
"a",
"hydrogen",
"bond",
"is",
"not",
"allowed",
"to",
"form",
"a",
"water",
"bridge",
".",
"Each",
"water",
"molecule",
"can",
"only",
"be",
"donor",
"for",
"two",
"water",
"bridges",
"selecting",
"the",
"conste... | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L844-L873 |
ssalentin/plip | plip/modules/preparation.py | BindingSite.find_hal | def find_hal(self, atoms):
"""Look for halogen bond acceptors (Y-{O|P|N|S}, with Y=C,P,S)"""
data = namedtuple('hal_acceptor', 'o o_orig_idx y y_orig_idx')
a_set = []
# All oxygens, nitrogen, sulfurs with neighboring carbon, phosphor, nitrogen or sulfur
for a in [at for at in ato... | python | def find_hal(self, atoms):
"""Look for halogen bond acceptors (Y-{O|P|N|S}, with Y=C,P,S)"""
data = namedtuple('hal_acceptor', 'o o_orig_idx y y_orig_idx')
a_set = []
# All oxygens, nitrogen, sulfurs with neighboring carbon, phosphor, nitrogen or sulfur
for a in [at for at in ato... | [
"def",
"find_hal",
"(",
"self",
",",
"atoms",
")",
":",
"data",
"=",
"namedtuple",
"(",
"'hal_acceptor'",
",",
"'o o_orig_idx y y_orig_idx'",
")",
"a_set",
"=",
"[",
"]",
"# All oxygens, nitrogen, sulfurs with neighboring carbon, phosphor, nitrogen or sulfur",
"for",
"a",... | Look for halogen bond acceptors (Y-{O|P|N|S}, with Y=C,P,S) | [
"Look",
"for",
"halogen",
"bond",
"acceptors",
"(",
"Y",
"-",
"{",
"O|P|N|S",
"}",
"with",
"Y",
"=",
"C",
"P",
"S",
")"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L893-L904 |
ssalentin/plip | plip/modules/preparation.py | BindingSite.find_charged | def find_charged(self, mol):
"""Looks for positive charges in arginine, histidine or lysine, for negative in aspartic and glutamic acid."""
data = namedtuple('pcharge', 'atoms atoms_orig_idx type center restype resnr reschain')
a_set = []
# Iterate through all residue, exclude those in c... | python | def find_charged(self, mol):
"""Looks for positive charges in arginine, histidine or lysine, for negative in aspartic and glutamic acid."""
data = namedtuple('pcharge', 'atoms atoms_orig_idx type center restype resnr reschain')
a_set = []
# Iterate through all residue, exclude those in c... | [
"def",
"find_charged",
"(",
"self",
",",
"mol",
")",
":",
"data",
"=",
"namedtuple",
"(",
"'pcharge'",
",",
"'atoms atoms_orig_idx type center restype resnr reschain'",
")",
"a_set",
"=",
"[",
"]",
"# Iterate through all residue, exclude those in chains defined as peptides",
... | Looks for positive charges in arginine, histidine or lysine, for negative in aspartic and glutamic acid. | [
"Looks",
"for",
"positive",
"charges",
"in",
"arginine",
"histidine",
"or",
"lysine",
"for",
"negative",
"in",
"aspartic",
"and",
"glutamic",
"acid",
"."
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L906-L945 |
ssalentin/plip | plip/modules/preparation.py | BindingSite.find_metal_binding | def find_metal_binding(self, mol):
"""Looks for atoms that could possibly be involved in chelating a metal ion.
This can be any main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids"""
data = namedtuple('metal_binding', 'atom atom_orig_idx type restype resnr reschain lo... | python | def find_metal_binding(self, mol):
"""Looks for atoms that could possibly be involved in chelating a metal ion.
This can be any main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids"""
data = namedtuple('metal_binding', 'atom atom_orig_idx type restype resnr reschain lo... | [
"def",
"find_metal_binding",
"(",
"self",
",",
"mol",
")",
":",
"data",
"=",
"namedtuple",
"(",
"'metal_binding'",
",",
"'atom atom_orig_idx type restype resnr reschain location'",
")",
"a_set",
"=",
"[",
"]",
"for",
"res",
"in",
"pybel",
".",
"ob",
".",
"OBResi... | Looks for atoms that could possibly be involved in chelating a metal ion.
This can be any main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids | [
"Looks",
"for",
"atoms",
"that",
"could",
"possibly",
"be",
"involved",
"in",
"chelating",
"a",
"metal",
"ion",
".",
"This",
"can",
"be",
"any",
"main",
"chain",
"oxygen",
"atom",
"or",
"oxygen",
"nitrogen",
"and",
"sulfur",
"from",
"specific",
"amino",
"a... | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L947-L985 |
ssalentin/plip | plip/modules/preparation.py | Ligand.is_functional_group | def is_functional_group(self, atom, group):
"""Given a pybel atom, look up if it belongs to a function group"""
n_atoms = [a_neighbor.GetAtomicNum() for a_neighbor in pybel.ob.OBAtomAtomIter(atom.OBAtom)]
if group in ['quartamine', 'tertamine'] and atom.atomicnum == 7: # Nitrogen
#... | python | def is_functional_group(self, atom, group):
"""Given a pybel atom, look up if it belongs to a function group"""
n_atoms = [a_neighbor.GetAtomicNum() for a_neighbor in pybel.ob.OBAtomAtomIter(atom.OBAtom)]
if group in ['quartamine', 'tertamine'] and atom.atomicnum == 7: # Nitrogen
#... | [
"def",
"is_functional_group",
"(",
"self",
",",
"atom",
",",
"group",
")",
":",
"n_atoms",
"=",
"[",
"a_neighbor",
".",
"GetAtomicNum",
"(",
")",
"for",
"a_neighbor",
"in",
"pybel",
".",
"ob",
".",
"OBAtomAtomIter",
"(",
"atom",
".",
"OBAtom",
")",
"]",
... | Given a pybel atom, look up if it belongs to a function group | [
"Given",
"a",
"pybel",
"atom",
"look",
"up",
"if",
"it",
"belongs",
"to",
"a",
"function",
"group"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L1073-L1113 |
ssalentin/plip | plip/modules/preparation.py | Ligand.find_hal | def find_hal(self, atoms):
"""Look for halogen bond donors (X-C, with X=F, Cl, Br, I)"""
data = namedtuple('hal_donor', 'x orig_x x_orig_idx c c_orig_idx')
a_set = []
for a in atoms:
if self.is_functional_group(a, 'halocarbon'):
n_atoms = [na for na in pybel.o... | python | def find_hal(self, atoms):
"""Look for halogen bond donors (X-C, with X=F, Cl, Br, I)"""
data = namedtuple('hal_donor', 'x orig_x x_orig_idx c c_orig_idx')
a_set = []
for a in atoms:
if self.is_functional_group(a, 'halocarbon'):
n_atoms = [na for na in pybel.o... | [
"def",
"find_hal",
"(",
"self",
",",
"atoms",
")",
":",
"data",
"=",
"namedtuple",
"(",
"'hal_donor'",
",",
"'x orig_x x_orig_idx c c_orig_idx'",
")",
"a_set",
"=",
"[",
"]",
"for",
"a",
"in",
"atoms",
":",
"if",
"self",
".",
"is_functional_group",
"(",
"a... | Look for halogen bond donors (X-C, with X=F, Cl, Br, I) | [
"Look",
"for",
"halogen",
"bond",
"donors",
"(",
"X",
"-",
"C",
"with",
"X",
"=",
"F",
"Cl",
"Br",
"I",
")"
] | train | https://github.com/ssalentin/plip/blob/906c8d36463689779b403f6c2c9ed06174acaf9a/plip/modules/preparation.py#L1115-L1129 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.