-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvis_trace.py
More file actions
72 lines (58 loc) · 2.16 KB
/
vis_trace.py
File metadata and controls
72 lines (58 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (C) 2022-2023 Dyne.org foundation <foundation@dyne.org>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import plotly.graph_objects as go
import json
from if_dpp import convert_bedpp, differentiate_resources
from if_graphics import make_sankey, vis_dpp, consol_trace
def main(trace_file):
with open(trace_file, 'r') as f:
a_dpp = json.loads(f.read())
if 'node' in a_dpp:
tot_dpp = convert_bedpp(a_dpp)
else:
tot_dpp = a_dpp[0]
# make resource ids unique in the flow
# differentiate_resources(tot_dpp)
labels = []
sources = []
targets = []
values = []
color_nodes = []
color_links = []
assigned = {}
vis_dpp(tot_dpp, count=0, assigned=assigned, labels=labels, targets=targets,
sources=sources, values=values, color_nodes=color_nodes, color_links=color_links)
sources, targets = consol_trace(assigned, sources, targets)
make_sankey(sources, targets, labels, values, color_nodes, color_links)
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument(
'-f', '--filename',
dest='filename',
action='store',
required=True,
help='specifies the name of the dpp file',
)
args, unknown = parser.parse_known_args()
if len(unknown) > 0:
print(f'Unknown options {unknown}')
parser.print_help()
exit(-1)
main(args.filename)