示例#1
0
 // ## operation getMatchedFunctionalGroup(LinkedList)
 public LinkedList getMatchedFunctionalGroup(LinkedList p_reactants) {
   // #[ operation getMatchedFunctionalGroup(LinkedList)
   LinkedList fgCollection = new LinkedList();
   boolean found = false;
   Iterator r_iter = p_reactants.iterator();
   while (r_iter.hasNext()) {
     found = false;
     Object o = r_iter.next();
     ChemGraph cg = null;
     if (o instanceof Species) cg = ((Species) r_iter.next()).getChemGraph();
     else cg = (ChemGraph) o;
     Iterator t_iter = reactantTree.iterator();
     while (t_iter.hasNext()) {
       HierarchyTree t = (HierarchyTree) t_iter.next();
       Stack s = t.findMatchedPath(cg);
       if (s != null && !s.isEmpty()) {
         found = true;
         fgCollection.add(s);
       }
     }
     if (!found) {
       // System.out.println("can't find matched path: " + cg.toString());
       // System.exit(0);
       return null;
     }
   }
   return fgCollection;
   // #]
 }
示例#2
0
 // Constructors
 // ## operation StructureTemplate(Matchable,Matchable)
 public StructureTemplate(Matchable p_reactant1, Matchable p_reactant2) {
   {
     reactantTree = new ArrayList();
   }
   // #[ operation StructureTemplate(Matchable,Matchable)
   reactants.add(p_reactant1);
   if (p_reactant2 != null) reactants.add(p_reactant2);
   // #]
 }
示例#3
0
 // ## operation getAllowedFunctionalGroupAt(int)
 public Matchable getAllowedFunctionalGroupAt(int p_index) {
   // #[ operation getAllowedFunctionalGroupAt(int)
   Matchable t = (Matchable) (reactants.get(p_index - 1));
   if (t == null) return null;
   return t;
   // #]
 }
示例#4
0
 // ## operation generateReverse(ReactionAdjList)
 public StructureTemplate generateReverse(ReactionAdjList p_reactionAdjList) {
   // #[ operation generateReverse(ReactionAdjList)
   int r_num = getReactantNumber();
   Matchable r1 = getAllowedFunctionalGroupAt(1);
   LinkedList reactant = new LinkedList();
   reactant.add(r1);
   if (r_num == 2) {
     Matchable r2 = getAllowedFunctionalGroupAt(2);
     reactant.add(r2);
   }
   LinkedList reverse = p_reactionAdjList.reactFunctionalGroup(reactant);
   StructureTemplate reverseRT = new StructureTemplate(reverse);
   reverseRT.reactantTree = this.reactantTree;
   return reverseRT;
   // #]
 }
示例#5
0
 // ## operation StructureTemplate(Matchable)
 public StructureTemplate(Matchable p_reactant) {
   {
     reactantTree = new ArrayList();
   }
   // #[ operation StructureTemplate(Matchable)
   reactants.add(p_reactant);
   // #]
 }
示例#6
0
 // ## operation setReactant(int,LinkedHashSet)
 public void setReactant(int p_position, LinkedHashSet p_reactantFGSet) {
   // #[ operation setReactant(int,LinkedHashSet)
   reactants.add(p_position, p_reactantFGSet);
   // #]
 }
示例#7
0
 // ## operation getReactants()
 public Iterator getReactants() {
   // #[ operation getReactants()
   Iterator iter = reactants.iterator();
   return iter;
   // #]
 }
示例#8
0
 // ## operation getReactantNumber()
 public int getReactantNumber() {
   // #[ operation getReactantNumber()
   return reactants.size();
   // #]
 }