50typedef std::pair<Index, BeadMotif>
IdMotif;
65 unordered_map<Edge, bool>& remove_edges) {
67 vector<Edge> neigh_edges = full_graph.
getNeighEdges(junction);
68 for (
Edge& edge : neigh_edges) {
69 remove_edges[edge] =
true;
80 unordered_map<Edge, bool>& remove_edges,
81 unordered_map<
Index, vector<Edge>>
82 contracted_branch_edges_connected_to_junction) {
84 Index number_branches_with_more_than_one_bond = 0;
86 for (pair<
Index, vector<Edge>> branch_and_contracted_edges :
87 contracted_branch_edges_connected_to_junction) {
88 bool edge_is_single_connection_to_junction =
false;
89 if (branch_and_contracted_edges.second.size() == 1) {
91 Edge contracted_edge = branch_and_contracted_edges.second.at(0);
92 if (contracted_edge.
loop() ==
false) {
93 vector<vector<Edge>> expanded_edges =
96 if (expanded_edges.size() == 1) {
97 for (
Edge& edge : expanded_edges.at(0)) {
98 if (edge.contains(junction)) {
99 remove_edges[edge] =
true;
100 edge_is_single_connection_to_junction =
true;
107 if (edge_is_single_connection_to_junction ==
false) {
108 ++number_branches_with_more_than_one_bond;
112 return number_branches_with_more_than_one_bond;
123 unordered_map<Edge, bool>& remove_edges) {
129 for (
Index& junction : junctions) {
130 vector<Edge> neighboring_edges = reduced_graph.
getNeighEdges(junction);
131 unordered_map<Edge, bool> contracted_edge_explored;
132 for (
Edge& edge : neighboring_edges) {
133 contracted_edge_explored[edge] =
false;
136 Index branch_index = 0;
137 unordered_map<Index, vector<Edge>>
138 contracted_branch_edges_connected_to_junction;
139 for (
Edge& branch_starting_edge : neighboring_edges) {
140 if (contracted_edge_explored[branch_starting_edge] ==
false) {
143 set<Edge> branch_edges =
144 exploreBranch(reduced_graph, junction, branch_starting_edge);
146 vector<Edge> starting_edges_explored_by_branch;
147 for (
Edge& branch_starting_edge2 : neighboring_edges) {
148 if (branch_edges.count(branch_starting_edge2)) {
149 contracted_edge_explored[branch_starting_edge2] =
true;
150 starting_edges_explored_by_branch.push_back(branch_starting_edge2);
153 contracted_branch_edges_connected_to_junction[branch_index] =
154 starting_edges_explored_by_branch;
160 if (branch_index > 1) {
165 Index number_branches_with_more_than_one_bond =
167 junction, reduced_graph, remove_edges,
168 contracted_branch_edges_connected_to_junction);
173 if (number_branches_with_more_than_one_bond > 1) {
277 unordered_map<Index, BeadMotif> simple_motifs;
279 simple_motifs.insert(id_and_motif);
281 return simple_motifs;
290 if (id_and_motif.second.getType() ==
293 }
else if (id_and_motif.second.getType() ==
296 }
else if (id_and_motif.second.isMotifSimple()) {
299 assert(
false &&
"Error the motif type must be a simple or complex type.");
305 list<BeadMotif> split_motifs;
307 Graph full_graph = id_and_bead_motif.second.getGraph();
308 vector<Edge> all_edges = full_graph.
getEdges();
309 unordered_map<Edge, bool> remove_edges;
310 for (
Edge& edge : all_edges) {
311 remove_edges[edge] =
false;
316 vector<Index> all_vertices = full_graph.
getVertices();
318 std::vector<Edge> new_beadstructure_edges;
319 for (pair<const Edge, bool>& edge_and_remove : remove_edges) {
320 if (edge_and_remove.second ==
false) {
322 new_beadstructure_edges.push_back(edge_and_remove.first);
328 all_vertices, new_beadstructure_edges);
330 list<BeadMotif> split_motifs_temp =
333 split_motifs.splice(split_motifs.end(), split_motifs_temp);
347 assert(edge_iterator->loop() ==
false);
348 Index bead_id1 = edge_iterator->getEndPoint1();
349 Index bead_id2 = edge_iterator->getEndPoint2();
351 list<IdMotif>::iterator motif_bead1_iterator;
353 motif_bead1_iterator !=
motifs_simple_.end(); ++motif_bead1_iterator) {
355 if (motif_bead1_iterator->second.BeadExist(bead_id1)) {
360 list<IdMotif>::iterator motif_bead2_iterator;
362 motif_bead2_iterator !=
motifs_simple_.end(); ++motif_bead2_iterator) {
364 if (motif_bead2_iterator->second.BeadExist(bead_id2)) {
372 Edge motif_edge(motif_bead1_iterator->first, motif_bead2_iterator->first);
382 list<BeadMotif>& bead_motifs) {
384 list<BeadMotif>::iterator bead_motif_iter = bead_motifs.begin();
385 while (bead_motif_iter != bead_motifs.end()) {
388 if (bead_motif_iter->isMotifSimple()) {
392 pair<Index, BeadMotif> id_and_motif(new_motif_id,
393 std::move(*bead_motif_iter));
395 bead_motif_iter = bead_motifs.erase(bead_motif_iter);
416 unordered_map<Index, BeadMotif> motifs_simple_map =
418 auto simple_motifs_and_connector =
420 motifs_simple_map, connector);
421 return simple_motifs_and_connector;
Simple class for storing the connections between motifs and the underlying beads that are part of the...
void AddMotifAndBeadEdge(const tools::Edge &motif_edge, const tools::Edge &bead_edge)
Designed determine what kind of structure a beadstructure has.
Designed to determine if the structure beads passed in.
BeadStructure getSubStructure(const std::vector< Index > &idx, const std::vector< tools::Edge > &edges) const
Given indices and edges that exist are a subset of beadstructure, return the sub-beadstructure.
This is an internal class meant to deconstruct bead motifs into their simple forms.
list< Edge > bead_edges_removed_
unordered_map< Index, BeadMotif > getSimpleMotifs()
Returns a map of all the simple motifs with their ids.
size_t CountComplexMotifs() const
void sortMotifsAndAssignIdsToSimpleMotifs_(list< BeadMotif > &bead_motifs)
void AddMotif(IdMotif id_and_motif)
Adds a motif with its corresponding id.
void deconstructComplexSingleStructures(BeadMotifConnector &connector)
Takes a bead motif of type single structure and deconstructs it into smaller components.
list< IdMotif > motifs_simple_
void determineMotifConnections_(BeadMotifConnector &connector)
list< IdMotif > motifs_complex_single_structure_
list< IdMotif > motifs_multiple_structures_
bool ConnectionsCompleted() const
const Index unassigned_id
T breakIntoMotifs(BeadStructure &beadstructure)
breaks a beadstructure into individual motifs.
std::pair< Index, BeadMotif > IdMotif
void calculateEdgesToRemove_(Graph &full_graph, unordered_map< Edge, bool > &remove_edges)
Calculates which edges to remove from a graph, in order to split it up correctly into simple motif ty...
void removeAllEdgesConnectedToVertex_(Index junction, Graph &full_graph, unordered_map< Edge, bool > &remove_edges)
Determines which edges are connected to the junction and stored them in the remove_edges map.
Index determineEdgesOfBranchesWithSingleConnectionToJunction_(Index junction, ReducedGraph &reduced_graph, unordered_map< Edge, bool > &remove_edges, unordered_map< Index, vector< Edge > > contracted_branch_edges_connected_to_junction)
std::pair< std::unordered_map< Index, BeadMotif >, BeadMotifConnector > breakIntoSimpleMotifs(BeadMotif bead_motif)
This function will take a beadmotif and break it into its simple motifs.
base class for all analysis tools