*/
protected void createGraph(BioPAXL3Graph root)
{
Map<String, NodeModel> map = new HashMap<String, NodeModel>();
Model model = root.getBiopaxModel();
// for (xref xr : model.getObjects(xref.class))
// {
// UniquePrinter.print("xref ["+xr.getID()+"] = ", xr.getDB());
// }
if (nestCompartments) createAndNestCompartments(model, map, root);
// Create actors
for (PhysicalEntity pe : model.getObjects(PhysicalEntity.class))
{
if (pe.getStandardName() == null)
{
if (pe.getDisplayName() != null)
{
pe.setStandardName(pe.getDisplayName());
}
else if (!pe.getName().isEmpty())
{
pe.setStandardName(pe.getName().iterator().next());
}
else if (pe instanceof SimplePhysicalEntity)
{
EntityReference er = ((SimplePhysicalEntity) pe).getEntityReference();
if (er != null)
{
pe.setStandardName(er.getStandardName());
if (pe.getStandardName() == null &&
er.getName() != null && !er.getName().isEmpty())
{
pe.setStandardName(er.getName().iterator().next());
}
}
}
}
if (pe.getStandardName() == null)
{
pe.setStandardName("noname");
}
// Complex will be processed later.
if (pe instanceof Complex) continue;
// Create simple states (Actors)
CompoundModel parent = extractCompartment(pe, map);
if (parent == null) parent = root;
if (!isUbique(pe))
{
if (pe.getComponentOf().isEmpty() || !pe.getParticipantOf().isEmpty())
{
Actor actor = new Actor(parent, pe, null);
map.put(pe.getRDFId(), actor);
}
}
else
{
for (Interaction inter : pe.getParticipantOf())
{
Actor actor = new Actor(parent, pe, inter);
map.put(pe.getRDFId() + inter.getRDFId(), actor);
}
}
}
// Create complexes
for (Complex cmp : model.getObjects(Complex.class))
{
if (cmp.getParticipantOf().isEmpty())
{
ChbComplex c = new ChbComplex(root, cmp);
createComplexContent(c, cmp, cmp, map);
}
else
{
CompoundModel compart = getCompartment(cmp, map, root);
if (compart == root)
{
String nm = ChbComplex.suggestCompartmentNameUsingMembers(cmp.getComponent());
if (nm != null)
{
if (nestCompartments) nm = CompartmentManager.getUnifiedName(nm);
compart = getCompartment(nm, map, root);
}
}
NodeModel nd;
if (cmp.getComponent().isEmpty())
{
nd = new Actor(compart, cmp, null);
}
else
{
ChbComplex c = new ChbComplex(compart, cmp);
createComplexContent(c, cmp, cmp, map);
nd = c;
}
map.put(cmp.getRDFId(), nd);
}
}
// Create events
for (Conversion conv : model.getObjects(Conversion.class))
{
String compName = ChbConversion.getPossibleCompartmentName(conv);
if (compName != null && nestCompartments)
compName = CompartmentManager.getUnifiedName(compName);
CompoundModel compart = compName == null ? root : (CompoundModel) map.get(compName);
// if (compart == null)
// {
// System.out.println("");
// }
assert compart != null;
ChbConversion forwd = null, rever = null;
if (evidenceExists(conv, ChbConversion.LEFT_TO_RIGHT))
{
forwd = new ChbConversion(compart, conv, ChbConversion.LEFT_TO_RIGHT, map);
forwd.selectBestCompartment();
}
if (evidenceExists(conv, ChbConversion.RIGHT_TO_LEFT))
{
rever = new ChbConversion(compart, conv, ChbConversion.RIGHT_TO_LEFT, map);
rever.selectBestCompartment();
}
if (forwd == null && rever == null)
{
forwd = new ChbConversion(compart, conv, ChbConversion.LEFT_TO_RIGHT, map);
forwd.selectBestCompartment();
}
}
// for (TemplateReaction reac : model.getObjects(TemplateReaction.class))
// {
// String compName = ChbConversion.getPossibleCompartmentName(reac);
//
// if (compName != null && nestCompartments)
// compName = CompartmentManager.getUnifiedName(compName);
//
// CompoundModel compart = compName == null ? root : (CompoundModel) map.get(compName);
//
// }
for (Interaction inter : model.getObjects(Interaction.class))
{
boolean drawPPI = true;
if (!drawPPI) break;
if (!(inter instanceof Conversion) && !(inter instanceof Control))