def __init__(self, sequence_name, sequence, vectorizer, structure): self.sequence_name = sequence_name self.sequence = sequence self.vectorizer = vectorizer self.structure = structure # create a base_graph , expand base_graph = conv.sequence_dotbracket_to_graph(seq_info=sequence, seq_struct=structure) self.base_graph = vectorizer._edge_to_vertex_transform(base_graph) # get an expanded abstract graph abstract_graph = forgi.get_abstr_graph(structure) abstract_graph = vectorizer._edge_to_vertex_transform(abstract_graph) # connect edges to nodes in the abstract graph self.abstract_graph = edge_parent_finder(abstract_graph, self.base_graph) # we are forced to set a label .. for eden reasons def name_edges(graph, what=''): for n, d in graph.nodes(data=True): if 'edge' in d: d['label'] = what # in the abstract graph , all the edge nodes need to have a contracted attribute. # originaly this happens naturally but since we make multiloops into one loop there are some left out def setset(graph): for n, d in graph.nodes(data=True): if 'contracted' not in d: d['contracted'] = set() name_edges(self.abstract_graph) setset(self.abstract_graph)
def abstract_graph(self): ''' we need to make an abstraction Ooo ''' if self._abstract_graph is None: # create the abstract graph and populate the contracted set abstract_graph = forgi.get_abstr_graph( self.structure, ignore_inserts=self.ignore_inserts) abstract_graph = self.vectorizer._edge_to_vertex_transform( abstract_graph) self._abstract_graph = forgi.edge_parent_finder( abstract_graph, self._base_graph) # eden is forcing us to set a label and a contracted attribute.. lets do this for n, d in self._abstract_graph.nodes(data=True): if 'edge' in d: d['label'] = 'e' # in the abstract graph , all the edge nodes need to have a contracted attribute. # originaly this happens naturally but since we make multiloops into one loop # there are some left out for n, d in self._abstract_graph.nodes(data=True): if 'contracted' not in d: d['contracted'] = set() return self._abstract_graph
def abstract_graph(self): ''' we need to make an abstraction Ooo ''' # create the abstract graph and populate the contracted set abstract_graph = forgi.get_abstr_graph(self.structure, ignore_inserts=self.ignore_inserts) abstract_graph = self.vectorizer._edge_to_vertex_transform(abstract_graph) completed_abstract_graph = forgi.edge_parent_finder(abstract_graph, self._base_graph) # eden is forcing us to set a label and a contracted attribute.. lets do this for n, d in completed_abstract_graph.nodes(data=True): if 'edge' in d: d['label'] = 'e' # in the abstract graph , all the edge nodes need to have a contracted attribute. # originaly this happens naturally but since we make multiloops into one loop # there are some left out for n, d in completed_abstract_graph.nodes(data=True): if 'contracted' not in d: d['contracted'] = set() return completed_abstract_graph