@@ -14,7 +14,7 @@ const RN_attrs = string.(propertynames(ReactionNetwork().subparts))
1414
1515function get_attrs (object)
1616 object = object isa Symbol ? objects_aliases[object] : object
17-
17+
1818 filter (x -> occursin (object, x), RN_attrs)
1919end
2020
@@ -67,12 +67,15 @@ function load_network(dict::Dict)
6767end
6868
6969function import_network_csv (pathmap)
70- dict = Dict (); for (key, paths) in pathmap
70+ dict = Dict ()
71+ for (key, paths) in pathmap
7172 push! (dict, key => [])
7273 for path in paths
73- data = DataFrame (CSV. File (path; delim= " ;;" , types= String, stripwhitespace= true , comment= " #" ))
74+ data = DataFrame (CSV. File (path; delim = " ;;" , types = String,
75+ stripwhitespace = true , comment = " #" ))
7476 for row in eachrow (data)
75- object = Dict (); for (attr, val) in Iterators. zip (keys (row), values (row))
77+ object = Dict ()
78+ for (attr, val) in Iterators. zip (keys (row), values (row))
7679 ! ismissing (val) && push! (object, string (attr) => val)
7780 end
7881 push! (dict[key], object)
8588
8689function import_network (path:: AbstractString )
8790 if splitext (path)[2 ] == " .csv"
88- pathmap = Dict (val => [] for val in [collect (values (objects_aliases)); " registered" ])
89- for row in CSV. File (path; delim= " ;;" , stripwhitespace= true , comment= " #" )
91+ pathmap = Dict (val => []
92+ for val in [collect (values (objects_aliases)); " registered" ])
93+ for row in CSV. File (path; delim = " ;;" , stripwhitespace = true , comment = " #" )
9094 push! (pathmap[row. type], joinpath (dirname (path), row. path))
9195 end
9296
@@ -96,7 +100,6 @@ function import_network(path::AbstractString)
96100 end
97101end
98102
99-
100103function export_network (acs:: ReactionNetwork , path:: AbstractString )
101104 if splitext (path)[2 ] == " .csv"
102105 exported_network = export_network (acs)
@@ -105,18 +108,19 @@ function export_network(acs::ReactionNetwork, path::AbstractString)
105108 push! (paths, (key, " export-$key .csv" ))
106109 objs_exported = DataFrame (Dict (attr => [] for attr in get_attrs (key)))
107110 for obj in objs
108- push! (objs_exported, [get (obj, key, missing ) for key in names (objs_exported)])
111+ push! (objs_exported,
112+ [get (obj, key, missing ) for key in names (objs_exported)])
109113 end
110114
111- CSV. write (joinpath (dirname (path), " export-$key .csv" ), objs_exported, delim= " ;;" )
115+ CSV. write (joinpath (dirname (path), " export-$key .csv" ), objs_exported,
116+ delim = " ;;" )
112117 end
113- CSV. write (path, paths, delim= " ;;" )
118+ CSV. write (path, paths, delim = " ;;" )
114119 else
115120 open (io -> TOML. print (io, export_network (acs)), path, " w+" )
116121 end
117122end
118123
119-
120124"""
121125Export model to a file: this can be either a single TOML file encoding the entire model,
122126or a batch of CSV files (a root file and a number of files, each per a class of objects).
0 commit comments