src/main/java/de/unirostock/sems/bives/cellml/algorithm/CellMLGraphProducer.java
protected void processRnB () throws BivesUnsupportedException
	{
		CellMLModel modelB = cellmlDocB.getModel ();
		wholeCompartment.setDocB (modelB.getDocumentNode ());
		//rn.setCompartment (modelB.getDocumentNode (), wholeCompartment);

		LOGGER.info ("looping through components in B");
		HashMap<String, CellMLComponent> components = modelB.getComponents ();
		for (CellMLComponent component : components.values ())
		{
			List<CellMLReaction> reactions = component.getReactions ();
			for (CellMLReaction reaction : reactions)
			{
				DocumentNode rNode = reaction.getDocumentNode ();
				Connection con = conMgmt.getConnectionForNode (rNode);
				ReactionNetworkReaction rnReaction = null;
				if (con == null)
				{
					// no equivalent in doc a
					rnReaction = new ReactionNetworkReaction (rn, null, reaction.getComponent ().getName (), null, reaction.getDocumentNode (), null, wholeCompartment, reaction.isReversible ());
					rn.setReaction (rNode, rnReaction);
				}
				else
				{
					rnReaction = rn.getReaction (con.getPartnerOf (rNode));
					rn.setReaction (rNode, rnReaction);
					rnReaction.setDocB (rNode);
					rnReaction.setCompartmentB (wholeCompartment);
				}
				List<CellMLReactionSubstance> substances = reaction.getSubstances ();
				for (CellMLReactionSubstance substance : substances)
				{
					CellMLVariable var = substance.getVariable ();
					CellMLVariable rootvar = var.getRootVariable ();
					List<CellMLReactionSubstance.Role> roles = substance.getRoles ();

					//DocumentNode varDoc = var.getDocumentNode ();
					DocumentNode varRootDoc = rootvar.getDocumentNode ();

					ReactionNetworkSubstance subst = null;
					
					// species already defined?
					Connection c = conMgmt.getConnectionForNode (varRootDoc);
					if (c == null || rn.getSubstance (c.getPartnerOf (varRootDoc)) == null)
					{
						// no equivalent in doc a
						subst = new ReactionNetworkSubstance (rn, null, rootvar.getName (), null, rootvar.getDocumentNode (), null, wholeCompartment);
						//rn.setSubstance (varRootDoc, subst);
					}
					else
					{
						//System.out.println (varRootDoc);
						//System.out.println (c.getPartnerOf (varRootDoc));
						subst = rn.getSubstance (c.getPartnerOf (varRootDoc));
						//System.out.println (subst);
						subst.setDocB (varRootDoc);
						subst.setLabelB (rootvar.getName ());
						subst.setCompartmentB (wholeCompartment);
						//rn.setSubstance (varRootDoc, subst);
					}
					
					// set up of reaction
					for (CellMLReactionSubstance.Role role : roles)
					{
						switch (role.role)
						{
							case CellMLReactionSubstance.ROLE_REACTANT:
								rnReaction.addInputB (subst, null, null);
								break;
							case CellMLReactionSubstance.ROLE_PRODUCT:
								rnReaction.addOutputB (subst, null, null);
								break;
							case CellMLReactionSubstance.ROLE_MODIFIER:
								rnReaction.addModB (subst, null, null);
								break;
							case CellMLReactionSubstance.ROLE_ACTIVATOR:
							case CellMLReactionSubstance.ROLE_CATALYST:
								rnReaction.addModB (subst, SBOTerm.createStimulator (), null);
								break;
							case CellMLReactionSubstance.ROLE_INHIBITOR:
								rnReaction.addModB (subst, SBOTerm.createInhibitor (), null);
								break;
							case CellMLReactionSubstance.ROLE_RATE:
								continue;
						}
						rn.setSubstance (rootvar.getDocumentNode (), subst);
					}
				}
			}
		}
	}
/**
	 * Process Reaction Network of the modified document.
	 * @throws BivesUnsupportedException 
	 */
Process Reaction Network of the modified document.
Process Reaction Network of the modified document .
protected void processRnB () throws BivesUnsupportedException
	{
		CellMLModel modelB = cellmlDocB.getModel ();
		wholeCompartment.setDocB (modelB.getDocumentNode ());
		LOGGER.info ("looping through components in B");
		HashMap<String, CellMLComponent> components = modelB.getComponents ();
		for (CellMLComponent component : components.values ())
		{
			List<CellMLReaction> reactions = component.getReactions ();
			for (CellMLReaction reaction : reactions)
			{
				DocumentNode rNode = reaction.getDocumentNode ();
				Connection con = conMgmt.getConnectionForNode (rNode);
				ReactionNetworkReaction rnReaction = null;
				if (con == null)
				{
					rnReaction = new ReactionNetworkReaction (rn, null, reaction.getComponent ().getName (), null, reaction.getDocumentNode (), null, wholeCompartment, reaction.isReversible ());
					rn.setReaction (rNode, rnReaction);
				}
				else
				{
					rnReaction = rn.getReaction (con.getPartnerOf (rNode));
					rn.setReaction (rNode, rnReaction);
					rnReaction.setDocB (rNode);
					rnReaction.setCompartmentB (wholeCompartment);
				}
				List<CellMLReactionSubstance> substances = reaction.getSubstances ();
				for (CellMLReactionSubstance substance : substances)
				{
					CellMLVariable var = substance.getVariable ();
					CellMLVariable rootvar = var.getRootVariable ();
					List<CellMLReactionSubstance.Role> roles = substance.getRoles ();
					DocumentNode varRootDoc = rootvar.getDocumentNode ();
					ReactionNetworkSubstance subst = null;
					Connection c = conMgmt.getConnectionForNode (varRootDoc);
					if (c == null || rn.getSubstance (c.getPartnerOf (varRootDoc)) == null)
					{
						subst = new ReactionNetworkSubstance (rn, null, rootvar.getName (), null, rootvar.getDocumentNode (), null, wholeCompartment);
					}
					else
					{
						subst = rn.getSubstance (c.getPartnerOf (varRootDoc));
						subst.setDocB (varRootDoc);
						subst.setLabelB (rootvar.getName ());
						subst.setCompartmentB (wholeCompartment);
					}
					for (CellMLReactionSubstance.Role role : roles)
					{
						switch (role.role)
						{
							case CellMLReactionSubstance.ROLE_REACTANT:
								rnReaction.addInputB (subst, null, null);
								break;
							case CellMLReactionSubstance.ROLE_PRODUCT:
								rnReaction.addOutputB (subst, null, null);
								break;
							case CellMLReactionSubstance.ROLE_MODIFIER:
								rnReaction.addModB (subst, null, null);
								break;
							case CellMLReactionSubstance.ROLE_ACTIVATOR:
							case CellMLReactionSubstance.ROLE_CATALYST:
								rnReaction.addModB (subst, SBOTerm.createStimulator (), null);
								break;
							case CellMLReactionSubstance.ROLE_INHIBITOR:
								rnReaction.addModB (subst, SBOTerm.createInhibitor (), null);
								break;
							case CellMLReactionSubstance.ROLE_RATE:
								continue;
						}
						rn.setSubstance (rootvar.getDocumentNode (), subst);
					}
				}
			}
		}
	}
protected void processRnB ( ) throws BivesUnsupportedException { CellMLModel modelB = cellmlDocB . getModel ( ) ; wholeCompartment . setDocB ( modelB . getDocumentNode ( ) ) ; LOGGER . info ( "looping through components in B" ) ; HashMap < String , CellMLComponent > components = modelB . getComponents ( ) ; for ( CellMLComponent component : components . values ( ) ) { List < CellMLReaction > reactions = component . getReactions ( ) ; for ( CellMLReaction reaction : reactions ) { DocumentNode rNode = reaction . getDocumentNode ( ) ; Connection con = conMgmt . getConnectionForNode ( rNode ) ; ReactionNetworkReaction rnReaction = null ; if ( con == null ) { rnReaction = new ReactionNetworkReaction ( rn , null , reaction . getComponent ( ) . getName ( ) , null , reaction . getDocumentNode ( ) , null , wholeCompartment , reaction . isReversible ( ) ) ; rn . setReaction ( rNode , rnReaction ) ; } else { rnReaction = rn . getReaction ( con . getPartnerOf ( rNode ) ) ; rn . setReaction ( rNode , rnReaction ) ; rnReaction . setDocB ( rNode ) ; rnReaction . setCompartmentB ( wholeCompartment ) ; } List < CellMLReactionSubstance > substances = reaction . getSubstances ( ) ; for ( CellMLReactionSubstance substance : substances ) { CellMLVariable var = substance . getVariable ( ) ; CellMLVariable rootvar = var . getRootVariable ( ) ; List < CellMLReactionSubstance . Role > roles = substance . getRoles ( ) ; DocumentNode varRootDoc = rootvar . getDocumentNode ( ) ; ReactionNetworkSubstance subst = null ; Connection c = conMgmt . getConnectionForNode ( varRootDoc ) ; if ( c == null || rn . getSubstance ( c . getPartnerOf ( varRootDoc ) ) == null ) { subst = new ReactionNetworkSubstance ( rn , null , rootvar . getName ( ) , null , rootvar . getDocumentNode ( ) , null , wholeCompartment ) ; } else { subst = rn . getSubstance ( c . getPartnerOf ( varRootDoc ) ) ; subst . setDocB ( varRootDoc ) ; subst . setLabelB ( rootvar . getName ( ) ) ; subst . setCompartmentB ( wholeCompartment ) ; } for ( CellMLReactionSubstance . Role role : roles ) { switch ( role . role ) { case CellMLReactionSubstance . ROLE_REACTANT : rnReaction . addInputB ( subst , null , null ) ; break ; case CellMLReactionSubstance . ROLE_PRODUCT : rnReaction . addOutputB ( subst , null , null ) ; break ; case CellMLReactionSubstance . ROLE_MODIFIER : rnReaction . addModB ( subst , null , null ) ; break ; case CellMLReactionSubstance . ROLE_ACTIVATOR : case CellMLReactionSubstance . ROLE_CATALYST : rnReaction . addModB ( subst , SBOTerm . createStimulator ( ) , null ) ; break ; case CellMLReactionSubstance . ROLE_INHIBITOR : rnReaction . addModB ( subst , SBOTerm . createInhibitor ( ) , null ) ; break ; case CellMLReactionSubstance . ROLE_RATE : continue ; } rn . setSubstance ( rootvar . getDocumentNode ( ) , subst ) ; } } } } }
Process Reaction Network of the modified document.
Process Reaction Network of the modified document .
//rn.setCompartment (modelB.getDocumentNode (), wholeCompartment); // no equivalent in doc a //DocumentNode varDoc = var.getDocumentNode (); // species already defined? // no equivalent in doc a //rn.setSubstance (varRootDoc, subst); //System.out.println (varRootDoc); //System.out.println (c.getPartnerOf (varRootDoc)); //System.out.println (subst); //rn.setSubstance (varRootDoc, subst); // set up of reaction