@Test @Ignore public void testSimpleStatementProtoNetworkBuilding() { ProtoNetworkBuilder protoNetworkBuilder = new ProtoNetworkBuilder(document); ProtoNetwork protoNetwork = protoNetworkBuilder.buildProtoNetwork(); NamespaceTable namespaceTable = protoNetwork.getNamespaceTable(); ParameterTable parameterTable = protoNetwork.getParameterTable(); TermTable termTable = protoNetwork.getTermTable(); Namespace hgncNs = new Namespace( "HGNC", "http: assertEquals(3, namespaceTable.getNamespaces().size()); assertEquals(11, parameterTable.getTableParameters().size()); assertEquals(9, termTable.getTermValues().size()); assertTrue(parameterTable.getTableParameters().contains( new TableParameter(new TableNamespace(hgncNs), "AIFM1"))); assertTrue(termTable.getTermValues().contains("proteinAbundance(#)")); assertTrue(termTable.getTermValues().contains("geneAbundance(#)")); StatementTable statementTable = protoNetwork.getStatementTable(); assertEquals(6, statementTable.getStatements().size()); }
public ProtoNetwork buildProtoNetwork() { ProtoNetwork pn = new ProtoNetwork(); DocumentTable dt = pn.getDocumentTable(); dt.addDocumentHeader(new DocumentHeader(doc.getHeader())); NamespaceGroup nsg = doc.getNamespaceGroup(); if (nsg != null) { NamespaceTable nt = pn.getNamespaceTable(); if (nsg.getDefaultResourceLocation() != null) { org.openbel.framework.common.model.Namespace dns = new Namespace("", nsg.getDefaultResourceLocation()); nt.addNamespace(new TableNamespace(dns), 0); } final List<Namespace> nsl = nsg.getNamespaces(); if (hasItems(nsl)) { for (org.openbel.framework.common.model.Namespace ns : nsl) { nt.addNamespace(new TableNamespace(ns), 0); } } } if (hasItems(doc.getDefinitions())) { for (AnnotationDefinition ad : doc.getDefinitions()) { AnnotationDefinitionTable adt = pn.getAnnotationDefinitionTable(); adt.addAnnotationDefinition(new TableAnnotationDefinition(ad), 0); } } for (StatementGroup statementGroup : doc.getStatementGroups()) { buildProtoNetwork(pn, statementGroup, new HashMap<String, Annotation>()); } final TermTable tt = pn.getTermTable(); final ProtoNodeTable pnt = pn.getProtoNodeTable(); final List<String> labels = tt.getTermValues(); for (int i = 0, n = labels.size(); i < n; i++) { pnt.addNode(i, labels.get(i)); } final Map<Integer, Integer> termNodeMap = pnt.getTermNodeIndex(); final StatementTable st = pn.getStatementTable(); final ProtoEdgeTable pet = pn.getProtoEdgeTable(); final List<TableStatement> stmts = st.getStatements(); for (int i = 0, n = stmts.size(); i < n; i++) { final TableStatement ts = stmts.get(i); final int subjectTerm = ts.getSubjectTermId(); if (ts.getObjectTermId() != null) { final int objectTerm = ts.getObjectTermId(); final int source = termNodeMap.get(subjectTerm); final int target = termNodeMap.get(objectTerm); pet.addEdges(i, new ProtoEdgeTable.TableProtoEdge(source, ts .getRelationshipName(), target)); } } return pn; }
ProtoNetworkBuilder { public ProtoNetwork buildProtoNetwork() { ProtoNetwork pn = new ProtoNetwork(); DocumentTable dt = pn.getDocumentTable(); dt.addDocumentHeader(new DocumentHeader(doc.getHeader())); NamespaceGroup nsg = doc.getNamespaceGroup(); if (nsg != null) { NamespaceTable nt = pn.getNamespaceTable(); if (nsg.getDefaultResourceLocation() != null) { org.openbel.framework.common.model.Namespace dns = new Namespace("", nsg.getDefaultResourceLocation()); nt.addNamespace(new TableNamespace(dns), 0); } final List<Namespace> nsl = nsg.getNamespaces(); if (hasItems(nsl)) { for (org.openbel.framework.common.model.Namespace ns : nsl) { nt.addNamespace(new TableNamespace(ns), 0); } } } if (hasItems(doc.getDefinitions())) { for (AnnotationDefinition ad : doc.getDefinitions()) { AnnotationDefinitionTable adt = pn.getAnnotationDefinitionTable(); adt.addAnnotationDefinition(new TableAnnotationDefinition(ad), 0); } } for (StatementGroup statementGroup : doc.getStatementGroups()) { buildProtoNetwork(pn, statementGroup, new HashMap<String, Annotation>()); } final TermTable tt = pn.getTermTable(); final ProtoNodeTable pnt = pn.getProtoNodeTable(); final List<String> labels = tt.getTermValues(); for (int i = 0, n = labels.size(); i < n; i++) { pnt.addNode(i, labels.get(i)); } final Map<Integer, Integer> termNodeMap = pnt.getTermNodeIndex(); final StatementTable st = pn.getStatementTable(); final ProtoEdgeTable pet = pn.getProtoEdgeTable(); final List<TableStatement> stmts = st.getStatements(); for (int i = 0, n = stmts.size(); i < n; i++) { final TableStatement ts = stmts.get(i); final int subjectTerm = ts.getSubjectTermId(); if (ts.getObjectTermId() != null) { final int objectTerm = ts.getObjectTermId(); final int source = termNodeMap.get(subjectTerm); final int target = termNodeMap.get(objectTerm); pet.addEdges(i, new ProtoEdgeTable.TableProtoEdge(source, ts .getRelationshipName(), target)); } } return pn; } }
ProtoNetworkBuilder { public ProtoNetwork buildProtoNetwork() { ProtoNetwork pn = new ProtoNetwork(); DocumentTable dt = pn.getDocumentTable(); dt.addDocumentHeader(new DocumentHeader(doc.getHeader())); NamespaceGroup nsg = doc.getNamespaceGroup(); if (nsg != null) { NamespaceTable nt = pn.getNamespaceTable(); if (nsg.getDefaultResourceLocation() != null) { org.openbel.framework.common.model.Namespace dns = new Namespace("", nsg.getDefaultResourceLocation()); nt.addNamespace(new TableNamespace(dns), 0); } final List<Namespace> nsl = nsg.getNamespaces(); if (hasItems(nsl)) { for (org.openbel.framework.common.model.Namespace ns : nsl) { nt.addNamespace(new TableNamespace(ns), 0); } } } if (hasItems(doc.getDefinitions())) { for (AnnotationDefinition ad : doc.getDefinitions()) { AnnotationDefinitionTable adt = pn.getAnnotationDefinitionTable(); adt.addAnnotationDefinition(new TableAnnotationDefinition(ad), 0); } } for (StatementGroup statementGroup : doc.getStatementGroups()) { buildProtoNetwork(pn, statementGroup, new HashMap<String, Annotation>()); } final TermTable tt = pn.getTermTable(); final ProtoNodeTable pnt = pn.getProtoNodeTable(); final List<String> labels = tt.getTermValues(); for (int i = 0, n = labels.size(); i < n; i++) { pnt.addNode(i, labels.get(i)); } final Map<Integer, Integer> termNodeMap = pnt.getTermNodeIndex(); final StatementTable st = pn.getStatementTable(); final ProtoEdgeTable pet = pn.getProtoEdgeTable(); final List<TableStatement> stmts = st.getStatements(); for (int i = 0, n = stmts.size(); i < n; i++) { final TableStatement ts = stmts.get(i); final int subjectTerm = ts.getSubjectTermId(); if (ts.getObjectTermId() != null) { final int objectTerm = ts.getObjectTermId(); final int source = termNodeMap.get(subjectTerm); final int target = termNodeMap.get(objectTerm); pet.addEdges(i, new ProtoEdgeTable.TableProtoEdge(source, ts .getRelationshipName(), target)); } } return pn; } ProtoNetworkBuilder(Document doc); }
ProtoNetworkBuilder { public ProtoNetwork buildProtoNetwork() { ProtoNetwork pn = new ProtoNetwork(); DocumentTable dt = pn.getDocumentTable(); dt.addDocumentHeader(new DocumentHeader(doc.getHeader())); NamespaceGroup nsg = doc.getNamespaceGroup(); if (nsg != null) { NamespaceTable nt = pn.getNamespaceTable(); if (nsg.getDefaultResourceLocation() != null) { org.openbel.framework.common.model.Namespace dns = new Namespace("", nsg.getDefaultResourceLocation()); nt.addNamespace(new TableNamespace(dns), 0); } final List<Namespace> nsl = nsg.getNamespaces(); if (hasItems(nsl)) { for (org.openbel.framework.common.model.Namespace ns : nsl) { nt.addNamespace(new TableNamespace(ns), 0); } } } if (hasItems(doc.getDefinitions())) { for (AnnotationDefinition ad : doc.getDefinitions()) { AnnotationDefinitionTable adt = pn.getAnnotationDefinitionTable(); adt.addAnnotationDefinition(new TableAnnotationDefinition(ad), 0); } } for (StatementGroup statementGroup : doc.getStatementGroups()) { buildProtoNetwork(pn, statementGroup, new HashMap<String, Annotation>()); } final TermTable tt = pn.getTermTable(); final ProtoNodeTable pnt = pn.getProtoNodeTable(); final List<String> labels = tt.getTermValues(); for (int i = 0, n = labels.size(); i < n; i++) { pnt.addNode(i, labels.get(i)); } final Map<Integer, Integer> termNodeMap = pnt.getTermNodeIndex(); final StatementTable st = pn.getStatementTable(); final ProtoEdgeTable pet = pn.getProtoEdgeTable(); final List<TableStatement> stmts = st.getStatements(); for (int i = 0, n = stmts.size(); i < n; i++) { final TableStatement ts = stmts.get(i); final int subjectTerm = ts.getSubjectTermId(); if (ts.getObjectTermId() != null) { final int objectTerm = ts.getObjectTermId(); final int source = termNodeMap.get(subjectTerm); final int target = termNodeMap.get(objectTerm); pet.addEdges(i, new ProtoEdgeTable.TableProtoEdge(source, ts .getRelationshipName(), target)); } } return pn; } ProtoNetworkBuilder(Document doc); ProtoNetwork buildProtoNetwork(); int buildProtoNetwork(final ProtoNetwork pn, final Term term); }
ProtoNetworkBuilder { public ProtoNetwork buildProtoNetwork() { ProtoNetwork pn = new ProtoNetwork(); DocumentTable dt = pn.getDocumentTable(); dt.addDocumentHeader(new DocumentHeader(doc.getHeader())); NamespaceGroup nsg = doc.getNamespaceGroup(); if (nsg != null) { NamespaceTable nt = pn.getNamespaceTable(); if (nsg.getDefaultResourceLocation() != null) { org.openbel.framework.common.model.Namespace dns = new Namespace("", nsg.getDefaultResourceLocation()); nt.addNamespace(new TableNamespace(dns), 0); } final List<Namespace> nsl = nsg.getNamespaces(); if (hasItems(nsl)) { for (org.openbel.framework.common.model.Namespace ns : nsl) { nt.addNamespace(new TableNamespace(ns), 0); } } } if (hasItems(doc.getDefinitions())) { for (AnnotationDefinition ad : doc.getDefinitions()) { AnnotationDefinitionTable adt = pn.getAnnotationDefinitionTable(); adt.addAnnotationDefinition(new TableAnnotationDefinition(ad), 0); } } for (StatementGroup statementGroup : doc.getStatementGroups()) { buildProtoNetwork(pn, statementGroup, new HashMap<String, Annotation>()); } final TermTable tt = pn.getTermTable(); final ProtoNodeTable pnt = pn.getProtoNodeTable(); final List<String> labels = tt.getTermValues(); for (int i = 0, n = labels.size(); i < n; i++) { pnt.addNode(i, labels.get(i)); } final Map<Integer, Integer> termNodeMap = pnt.getTermNodeIndex(); final StatementTable st = pn.getStatementTable(); final ProtoEdgeTable pet = pn.getProtoEdgeTable(); final List<TableStatement> stmts = st.getStatements(); for (int i = 0, n = stmts.size(); i < n; i++) { final TableStatement ts = stmts.get(i); final int subjectTerm = ts.getSubjectTermId(); if (ts.getObjectTermId() != null) { final int objectTerm = ts.getObjectTermId(); final int source = termNodeMap.get(subjectTerm); final int target = termNodeMap.get(objectTerm); pet.addEdges(i, new ProtoEdgeTable.TableProtoEdge(source, ts .getRelationshipName(), target)); } } return pn; } ProtoNetworkBuilder(Document doc); ProtoNetwork buildProtoNetwork(); int buildProtoNetwork(final ProtoNetwork pn, final Term term);  }