public static TemplateReaction makeTemplateReaction( Structure p_structureSp, Kinetics[] p_kinetics, ReactionTemplate p_template, Structure p_structure) { double PT = System.currentTimeMillis(); // Look for pre-existing reaction in Template's reactionDictionaryByStructure. TemplateReaction reaction = p_template.getReactionFromStructure(p_structureSp); Global.getReacFromStruc = Global.getReacFromStruc + (System.currentTimeMillis() - PT) / 1000 / 60; if (reaction == null) { // Create a new reaction. reaction = new TemplateReaction(p_structureSp, p_kinetics, p_template); if (reaction.isBackward()) { Logger.info( "Created new reverse " + p_template.getName() + " reaction: " + reaction.toString()); TemplateReaction reverse = reaction.generateReverseForBackwardReaction(p_structure, p_structureSp); if (reverse == null) return null; reaction.setReverseReaction(reverse); } else { Logger.info( "Created new forwards " + p_template.getName() + " reaction: " + reaction.toString()); ReactionTemplate fRT = reaction.getReactionTemplate(); ReactionTemplate rRT = null; if (fRT.isNeutral()) rRT = fRT; else rRT = fRT.getReverseReactionTemplate(); if (rRT != null) { TemplateReaction reverse = new TemplateReaction(p_structureSp.generateReverseStructure(), p_kinetics, rRT); reaction.setReverseReaction(reverse); reverse.setReverseReaction(reaction); rRT.addReaction(reverse); } } if (!reaction.repOk()) { throw new InvalidTemplateReactionException(); } p_template.addReaction(reaction); } Global.makeTR += (System.currentTimeMillis() - PT) / 1000 / 60; if (!reaction.repOk()) { throw new InvalidTemplateReactionException(); } return reaction; }
// ## operation getType() public String getType() { // #[ operation getType() return reactionTemplate.getName(); // #] }