GlycoCT¶
A GlycoCT (Condensed) parser. Supports RES, LIN, and un-nested REP sections.
>>>from glypy.io import glycoct
>>>glycoct.loads("""RES
1b:o-dman-HEX-0:0|1:aldi
2b:a-lido-HEX-1:5|6:a
3s:sulfate
LIN
1:1o(3+1)2d
2:2o(2+1)3n
3:2o(4+1)4d
""")
>>>
-
glypy.io.glycoct.
GlycoCT
¶ alias of
GlycoCTReader
-
class
glypy.io.glycoct.
GlycoCTReader
(stream, structure_class=<class 'glypy.structure.glycan.Glycan'>, allow_repeats=True)[source]¶ Bases:
object
Simple State-Machine parser for condensed GlycoCT representations. Yields
Glycan
instances.-
__init__
(stream, structure_class=<class 'glypy.structure.glycan.Glycan'>, allow_repeats=True)[source]¶ Creates a parser of condensed GlycoCT.
Parameters: stream: basestring or file-like
A path to a file or a file-like object to be processed
-
__iter__
()[source]¶ Calls
parse()
and stores it for reuse with__next__()
-
__next__
()¶ Alias for next. Supports Py3 Iterator interface
-
handle_linkage
(line)[source]¶ Handle a linkage line, creates an instance of
Link
and attaches it to the two referenced nodes ingraph
. The parent node is always an instance ofMonosaccharide
, and the child node may either be an instance ofMonosaccharide
orSubstituent
orMonosaccharide
.Called by
parse()
See also
Link
for more information on the impact of instantiating aLink
object.
-
handle_residue_line
(line)[source]¶ Handle a base line, creates an instance of
Monosaccharide
and adds it tograph
at the given index.Called by
parse()
-
handle_residue_substituent
(line)[source]¶ Handle a substituent line, creates an instance of
Substituent
and adds it tograph
at the given index. TheSubstituent
object is not yet linked to aMonosaccharide
instance.Called by
parse()
-
classmethod
loads
(glycoct_str, structure_class=<class 'glypy.structure.glycan.Glycan'>, allow_repeats=True)[source]¶ Parse results from
str
-
-
class
glypy.io.glycoct.
StructurePrecisionEnum
[source]¶ Bases:
glypy.utils.enum.Enum
EnumType
-
glypy.io.glycoct.
conf_stem_pattern
= <_sre.SRE_Pattern object at 0x00000000082D37B0>¶ Pattern for parsing the potentially repeated
Configuration
andStem
regions of the lines of the RES section.
-
glypy.io.glycoct.
decorate_tree
(tree, decorate_value)[source]¶ Transform each node in the tree’s id value into a tuple of
(decorate_value, node.id)
to use common ids across identical graphs but discriminable between attached copies.Parameters: tree: Glycan
decorate_value: int
Returns: Glycan
-
glypy.io.glycoct.
decorated_value
(tree)[source]¶ Get the decorating value from a tree’s root node.id.
Returns
None
if the tree is undecoratedParameters: tree: Glycan Returns: int or None
-
glypy.io.glycoct.
dump
(structure, buffer=None)[source]¶ Serialize the
Glycan
graph object into condensed GlycoCT, usingbuffer
to store the result. Ifbuffer
isNone
, then the function will operate on a newly createdStringIO
object.Parameters: structure: |Glycan|
The structure to serialize
buffer: file-like or None
The stream to write the serialized structure to. If
None
, uses an instance ofStringIO
Returns: file-like or str if
buffer
isNone
-
glypy.io.glycoct.
get_decorated
(tree, id)[source]¶ As
Glycan.get()
, but with awareness of decorated node.id attributes. Will fall back to the normal get method if the tree is undecorated.Parameters: tree: Glycan
id: int
Returns: Monosaccharide
-
glypy.io.glycoct.
internal_link_pattern
= <_sre.SRE_Pattern object at 0x00000000076076E0>¶ Special truncation of the
link_pattern
which is used on REP header sections
-
glypy.io.glycoct.
link_pattern
= <_sre.SRE_Pattern object at 0x0000000006F59D10>¶ Pattern for parsing
Link
lines found in the LIN section
-
glypy.io.glycoct.
loads
(glycoct_str, structure_class=<class 'glypy.structure.glycan.Glycan'>, allow_repeats=True)[source]¶ A convenience wrapper for
GlycoCTReader.loads()
As additional convenience, this function does not return an iterator over glycans, and returns a single instance if only one is present, or a list of instances otherwise.
-
glypy.io.glycoct.
modification_pattern
= <_sre.SRE_Pattern object at 0x000000000829BE10>¶ Pattern for parsing modifications found on monosaccharide residue lines in the RES section
-
glypy.io.glycoct.
read
(stream, structure_class=<class 'glypy.structure.glycan.Glycan'>, allow_repeats=True)[source]¶ A convenience wrapper for
GlycoCTReader
-
glypy.io.glycoct.
rep_header_pattern
= <_sre.SRE_Pattern object>¶ Pattern for interpreting the REP# instance header section
-
glypy.io.glycoct.
res_pattern
= <_sre.SRE_Pattern object at 0x000000000613F470>¶ Pattern for parsing the lines of the RES section corresponding to individual
Monosaccharide
residues