MetaNetwork

class MetaNetwork.MetaNetwork[source]

The MetaNetwork class is a container for a meta-network extracted from DyNetML. The base class stores network data in dictionaries; using a graphing library to store network data requires that you use one of the two SubClasses. Manipulating networks will not guarantee corresponding modifications of data contained in __node_tree; you will need to make any desired transformations to the nodes yourself.

Variables:
  • properties – A dictionary of the different properties associated with the meta-network.
  • propertyIdentities – A dictionary of the two defining traits of each property associated with the network
  • __node_tree – A three-layer dictionary laying out node sets grouped into classes, nodes with node sets, and properties associated with each node: self.nodesets[node class][node set][node][node property] = <property>. Note that node attributes are also stored in the dictionary. If an attribute and a property colide on some value, the property value will be retained. __node_tree is private in order to regulate how properties are added and to help insure that networks are valid. This may change in future updates.
  • networks – A dictionary of the different networks in the meta-network.
  • sources – A dictionary of source materials; it exists exclusively in networks generated by AutoMap, and is not yet fully handled.
convert_to_dynetml()[source]

Converts the graph to DyNetML and returns an lxml._Element

create_node(nodeclass_name, nodeset_name, node_name, property_dict=None)[source]

Create a node in a give nodeset in a give nodeclass. If a set of properties are specified, add the properties.

Parameters:
  • nodeclass_name (str|unicode) – name of the parent of nodeset_name
  • nodeset_name (str|unicode) – name of the parent of node_name
  • node_name (str|unicode) – name of the node to be created
  • property_dict (dict|None) – A dictionary of properties to assign the new node.
create_nodeset_property(nodeclass_name, nodeset_name, property_name, type_str, singlevalued_bool)[source]

Create a new nodeset property

Parameters:
  • nodeclass_name (str|unicode) – the name of the parent of nodeset_name
  • nodeset_name (str|unicode) – the name of the nodeset that should get the new property
  • property_name (str|unicode) – the name of the property to be added
  • type_str (str|unicode) – the type of the parameter
  • singlevalued_bool (bool) – whether or not the parameter should be single-valued
get_node(nodeclass_name, nodeset_name, node_name)[source]
Parameters:
  • nodeclass_name (str|unicode) – name of the parent of nodeset_name
  • nodeset_name (str|unicode) – name of the parent of node_name
  • node_name (str|unicode) – name of the node to be returned
Returns:

self.__node_tree[nodeclass_name][nodeset_name][node]

Return type:

dynetmlparsingutils.node_tuple

get_node_tree()[source]
Returns:__node_tree
Return type:dynetmlparsingutils.node_tree)
get_nodeclass(nodeclass_name)[source]
Returns:__node_tree[nodeclass_name]
Return type:dynetmlparsingutils.nodeclass_dict
get_nodeset(nodeclass_name, nodeset_name)[source]
Parameters:
  • nodeclass_name (str|unicode) – name of the parent of nodeset_name
  • nodeset_name (str|unicode) – name of the nodeset to be returned
Returns:

self.__node_tree[nodeclass_name][nodeset_name]

Return type:

dmlpu.nodeset_tuple

load_from_dynetml(mn_text, properties_to_include=None, properties_to_ignore=None, nodeclasses_to_include=None, nodeclasses_to_ignore=None, networks_to_include=None, networks_to_ignore=None)[source]

Parses XML containing a meta-network and loads the contents. If no properties, nodeclasses, or networks are specified to be included, all of them will be included. Lists of included and ignored elements are exclusive - only specify a set to include or a set to ignore for each category.

Parameters:
  • mn_text (str|unicode) – XML containing a meta-network
  • properties_to_include (list) – a list of nodeclass properties that should be included
  • properties_to_ignore (list) – a list of nodeclass properties that should be ignored
  • nodeclasses_to_include (list) – a list of nodeclasses that should be included
  • nodeclasses_to_ignore (list) – a list of nodeclasses that should be ignored
  • networks_to_include (list) – a list of networks that should be included
  • networks_to_ignore (list) – a list of networks that should be ignored
load_from_tag(mn_tag, properties_to_include=None, properties_to_ignore=None, nodeclasses_to_include=None, nodeclasses_to_ignore=None, networks_to_include=None, networks_to_ignore=None)[source]

Parses the content of an lxml._Element containing a meta-network and loads the contents. If no properties, nodeclasses, or networks are specified to be included, all of them will be included. Lists of included and ignored elements are exclusive - only specify a set to include or a set to ignore for each category.

Parameters:
  • mn_tag (lxml._Element) – A tag containing a dynamic meta-network
  • properties_to_include (list) – a list of nodeclass properties that should be included
  • properties_to_ignore (list) – a list of nodeclass properties that should be ignored
  • nodeclasses_to_include (list) – a list of nodeclasses that should be included
  • nodeclasses_to_ignore (list) – a list of nodeclasses that should be ignored
  • networks_to_include (list) – a list of networks that should be included
  • networks_to_ignore (list) – a list of networks that should be ignored
pretty_print()[source]

Pretty print the meta-network

rename_node(nodeclass_name, nodeset_name, node_name, new_node_name)[source]

Rename a particular node, both in the node tree and in the networks containing it.

Parameters:
  • nodeclass_name (str|unicode) – name of the parent of nodeset_name
  • nodeset_name (str|unicode) – name of the parent of node_name
  • node_name (str|unicode) – current node name
  • new_node_name (str|unicode) – new name for the node
set_node_property(nodeclass_name, nodeset_name, node_name, property_name, value)[source]

Set the value of a node property

Parameters:
  • nodeclass_name (str|unicode) – the name of the parent of nodeset_name
  • nodeset_name (str|unicode) – the name of the parent of node_name
  • node_name (str|unicode) – the name of the node whose property is being set
  • property_name (str|unicode) – the name of the property to be set
  • value (str|unicode|bool|float|datetime.datetime) – the value of the parameter
union_nodesets(nodeclass_name, *args)[source]

Takes two nodesets and combines them in a new nodeset. Properties and entries from the first nodeset override those from the second nodeset.

Parameters:
  • nodeclass_name (str|unicode) – The name of the parent nodeclass of nodeset_one_name and nodeset_two_name
  • nodeset_one_name (str|unicode) – The name of the first nodeset in the union.
  • nodset_two_name (str|unicode) – The name of the second ndeset in the union.
  • other_nodesets – union_nodesets takes a *args argument, so any number of nodesets is acceptable
  • new_nodeset_name (str|unicode) – The name of the new nodeset to be created
write_dynetml(out_file_path)[source]
Parameters:out_file_path (str|unicode) – Write the meta-network to this path.

Previous topic

DynamicMetaNetwork

Next topic

MetaNetworkNetworkX