forked from sbgn/libsbgn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadExample.java
More file actions
53 lines (40 loc) · 1.24 KB
/
ReadExample.java
File metadata and controls
53 lines (40 loc) · 1.24 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
package org.sbgn;
import java.io.File;
import javax.xml.bind.JAXBException;
import org.sbgn.SbgnUtil;
import org.sbgn.bindings.Arc;
import org.sbgn.bindings.Glyph;
import org.sbgn.bindings.Map;
import org.sbgn.bindings.Sbgn;
public class ReadExample
{
public static void main(String[] args) throws JAXBException
{
// our sbgnml file goes in "f"
String fileName = "../test-files/PD/adh.sbgn";
if (args.length > 0)
fileName = args[0];
File f = new File (fileName);
// Now read from "f" and put the result in "sbgn"
Sbgn sbgn = SbgnUtil.readFromFile(f);
// map is a container for the glyphs and arcs
Map map = sbgn.getMap().get(0);
// we can get a list of glyphs (nodes) in this map with getGlyph()
for (Glyph g : map.getGlyph())
{
// print the sbgn class of this glyph
System.out.print (" Glyph with class " + g.getId());
// if there is a label, print it as well
if (g.getLabel() != null)
System.out.println (", and label " + g.getLabel().getText());
else
System.out.println (", without label");
}
// we can get a list of arcs (edges) in this map with getArc()
for (Arc a : map.getArc())
{
// print the class of this arc
System.out.println (" Arc with class " + a.getClazz());
}
}
}