<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -133,56 +133,25 @@ public class PathFingerprinter implements Fingerprinter
 
   public BitSet getFingerprint(Molecule molecule)
   {
-    paths.clear();
-    this.bloomFilter = new BloomFilter(1024);
-    this.writer = new PathWriter(bloomFilter);
     bloomFilter.clear();
-    findAromatics(molecule);
-
-    for (int i = 0; i &lt; molecule.countAtoms(); i++)
-    {
-      Atom atom = molecule.getAtom(i);
+    Collection&lt;List&lt;Atom&gt;&gt; rings = ringFinder.findRings(molecule);
+    findAromatics(molecule, rings);
 
-      walker.walk(atom, writer);
-    }
-
-    return bloomFilter.toBitSet();
-  }
-
-  private void findAromatics(Molecule molecule)
-  {
-    aromatics.clear();
-    filter.filterAtoms(molecule, aromatics);
-
-    for (Atom atom : aromatics)
-    {
-      aromatics.add(atom);
-    }
+    recordWalk(molecule);
+    
+    BitSet walkBits = bloomFilter.toBitSet();
+    BitSet result = new BitSet(getFingerprintLength());
+    
+    result.or(walkBits);
+    writeRingBits(result, rings);
 
-    writer.setAromatics(aromatics);
+    return result;
   }
-
-//  public BitSet getFingerprint(Molecule molecule)
-//  {
-//    bloomFilter.clear();
-//    Collection&lt;List&lt;Atom&gt;&gt; rings = ringFinder.findRings(molecule);
-//    findAromatics(molecule, rings);
-//
-//    recordWalk(molecule);
-//    
-//    BitSet walkBits = bloomFilter.toBitSet();
-//    BitSet result = new BitSet(getFingerprintLength());
-//    
-//    result.or(walkBits);
-////    writeRingBits(result, rings);
-//
-//    return bloomFilter.toBitSet();
-//  }
+  
   private void writeRingBits(BitSet bitset, Collection&lt;List&lt;Atom&gt;&gt; rings)
   {
     for (List&lt;Atom&gt; ring : rings)
     {
-//      System.out.println(&quot;ring: &quot; + (ring.size() - 1));
       if (ring.size() &lt; ringBitCount)
       {
         int index = bloomFilter.getBitArraySize() + (ring.size() - 4);
@@ -210,16 +179,5 @@ public class PathFingerprinter implements Fingerprinter
     aromatics.clear();
     filter.filterAtoms(molecule.countAtoms(), rings, aromatics);
     writer.setAromatics(aromatics);
-  }//  private void findAromatics(Molecule molecule)
-//  {
-//    aromatics.clear();
-//    filter.filterAtoms(molecule, aromatics);
-//
-//    for (Atom atom : aromatics)
-//    {
-//      aromatics.add(atom);
-//    }
-//
-//    writer.setAromatics(aromatics);
-//  }
+  }
 }</diff>
      <filename>src/com/metamolecular/mx/fingerprint/PathFingerprinter.java</filename>
    </modified>
    <modified>
      <diff>@@ -30,7 +30,6 @@ import com.metamolecular.mx.io.Molecules;
 import com.metamolecular.mx.model.Atom;
 import com.metamolecular.mx.model.DefaultMolecule;
 import com.metamolecular.mx.model.Molecule;
-import com.metamolecular.mx.model.MoleculeKit;
 import com.metamolecular.mx.ring.RingFilter;
 import java.util.BitSet;
 import junit.framework.TestCase;
@@ -285,63 +284,12 @@ public class PathFingerprinterTest extends TestCase
     assertTrue(match(propane, acetone));
   }
   
-//  public void testItDoesntMatchCyclooctaneToOctane()
-//  {
-//    BitSet cyclooctane = fingerprinter.getFingerprint(createCyclooctane());
-//    BitSet octane = fingerprinter.getFingerprint(createOctane());
-//    
-//    assertFalse(match(cyclooctane, octane));
-//  }
-  
-//  public void testItWorks()
-//  {
-//    fingerprinter.setMaximumPathDepth(8);
-//    BitSet query = fingerprinter.getFingerprint(query());
-//    
-//    Set&lt;String&gt; queryPaths = new HashSet(fingerprinter.paths());
-//    
-//    System.out.println(&quot;query&quot;);
-//    System.out.println(query);
-//    System.out.println(&quot;target&quot;);
-//    BitSet target = fingerprinter.getFingerprint(target());
-//    System.out.println(target);
-//    
-//    Set&lt;String&gt; targetPaths = new HashSet(fingerprinter.paths());
-//    
-//    for (String path : queryPaths)
-//    {
-//      if (!targetPaths.contains(path))
-//      {
-//        System.out.println(&quot;missing; &quot; + path);
-//      }
-//    }
-//    
-//    for (int i = 0; i &lt; query.size(); i++)
-//    {
-//      if (query.get(i) == true &amp;&amp; !target.get(i) == true)
-//      {
-//        System.out.println(&quot;missing: &quot; + i);
-//      }
-//    }
-//  }
-  
-  private Molecule target()
+  public void testItDoesntMatchCyclooctaneToOctane()
   {
-    String m = &quot;[NO NAME]\n  CHEMWRIT          2D\nCreated with ChemWriter - http://metamolecular.com/chemwriter\n 10 11  0  0  0  0  0  0  0  0  0 V2000\n    1.0607    2.5607    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    1.5000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    1.0607   -1.0607    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n    2.5095   -0.6724    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.5000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.9266   -0.4635    0.0000 S   0  0  0  0  0  0  0  0  0  0  0  0\n   -3.8083    0.7500    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.9266    1.9635    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.5000    1.5000    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n  2  1  2  0  0  0  0\n  3  2  1  0  0  0  0\n  4  3  1  0  0  0  0\n  5  4  2  0  0  0  0\n  6  3  1  0  0  0  0\n  7  6  1  0  0  0  0\n  8  7  1  0  0  0  0\n  9  8  1  0  0  0  0\n 10  9  1  0  0  0  0\n 10  2  1  0  0  0  0\n 10  6  1  0  0  0  0\nM  END&quot;;
-//    String m = &quot;[NO NAME]\n  CHEMWRIT          2D\nCreated with ChemWriter - http://metamolecular.com/chemwriter\n 12 13  0  0  0  0  0  0  0  0  0 V2000\n    1.0607    2.5607    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    1.5000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    1.0607   -1.0607    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n    2.5095   -0.6724    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.5000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.9266   -0.4635    0.0000 S   0  0  0  0  0  0  0  0  0  0  0  0\n   -3.8083    0.7500    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -4.9230    1.7537    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -4.9230   -0.2537    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.9266    1.9635    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.5000    1.5000    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n  2  1  2  0  0  0  0\n  3  2  1  0  0  0  0\n  4  3  1  0  0  0  0\n  5  4  2  0  0  0  0\n  6  3  1  0  0  0  0\n  7  6  1  0  0  0  0\n  8  7  1  0  0  0  0\n  9  8  1  0  0  0  0\n 10  8  1  0  0  0  0\n 11  8  1  0  0  0  0\n 12 11  1  0  0  0  0\n 12  2  1  0  0  0  0\n 12  6  1  0  0  0  0\nM  END&quot;;
-//    String m = &quot;[NO NAME]\n  CHEMWRIT          2D\nCreated with ChemWriter - http://metamolecular.com/chemwriter\n 19 21  0  0  0  0  0  0  0  0  0 V2000\n    1.0607    2.5607    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    1.5000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    1.0607   -1.0607    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n    2.5095   -0.6724    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    3.5702   -1.7331    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n    4.9860   -1.2377    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    6.2561   -2.0357    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    6.4241   -3.5263    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    5.3634   -4.5869    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    3.8728   -4.4190    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    3.0748   -3.1489    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.5000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.9266   -0.4635    0.0000 S   0  0  0  0  0  0  0  0  0  0  0  0\n   -3.8083    0.7500    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -4.9230    1.7537    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -4.9230   -0.2537    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.9266    1.9635    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.5000    1.5000    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n  2  1  2  0  0  0  0\n  3  2  1  0  0  0  0\n  4  3  1  0  0  0  0\n  5  4  2  0  0  0  0\n  6  5  1  0  0  0  0\n  7  6  1  0  0  0  0\n  8  7  1  0  0  0  0\n  9  8  1  0  0  0  0\n 10  9  1  0  0  0  0\n 11 10  1  0  0  0  0\n 12 11  1  0  0  0  0\n 12  6  1  0  0  0  0\n 13  3  1  0  0  0  0\n 14 13  1  0  0  0  0\n 15 14  1  0  0  0  0\n 16 15  1  0  0  0  0\n 17 15  1  0  0  0  0\n 18 15  1  0  0  0  0\n 19 18  1  0  0  0  0\n 19  2  1  0  0  0  0\n 19 13  1  0  0  0  0\nM  END&quot;;
-//    String m = &quot;[NO NAME]\n  CHEMWRIT          2D\nCreated with ChemWriter - http://metamolecular.com/chemwriter\n 30 32  0  0  0  0  0  0  0  0  0 V2000\n    1.0607    2.5607    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    1.5000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    1.0607   -1.0607    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n    2.5095   -0.6724    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    3.5702   -1.7331    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n    4.9860   -1.2377    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    6.2561   -2.0357    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    6.4241   -3.5263    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    5.3634   -4.5869    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    3.8728   -4.4190    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    3.0748   -3.1489    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.5000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.9266   -0.4635    0.0000 S   0  0  0  0  0  0  0  0  0  0  0  0\n   -3.8083    0.7500    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -4.9230    1.7537    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -4.9230   -0.2537    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.9266    1.9635    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -3.3901    3.3901    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.3864    4.5048    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n   -4.8573    3.7020    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n   -5.3209    5.1286    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -6.7881    5.4404    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n   -7.2516    6.8670    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -6.2479    7.9817    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n   -8.7188    7.1789    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -9.1824    8.6055    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n  -10.2042    6.9701    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -8.7712    5.6798    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.5000    1.5000    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n  2  1  2  0  0  0  0\n  3  2  1  0  0  0  0\n  4  3  1  0  0  0  0\n  5  4  2  0  0  0  0\n  6  5  1  0  0  0  0\n  7  6  1  0  0  0  0\n  8  7  1  0  0  0  0\n  9  8  1  0  0  0  0\n 10  9  1  0  0  0  0\n 11 10  1  0  0  0  0\n 12 11  1  0  0  0  0\n 12  6  1  0  0  0  0\n 13  3  1  0  0  0  0\n 14 13  1  0  0  0  0\n 15 14  1  0  0  0  0\n 16 15  1  0  0  0  0\n 17 15  1  0  0  0  0\n 18 15  1  0  0  0  0\n 19 18  1  0  0  0  0\n 20 19  2  0  0  0  0\n 21 19  1  0  0  0  0\n 22 21  1  0  0  0  0\n 23 22  1  0  0  0  0\n 24 23  1  0  0  0  0\n 25 24  2  0  0  0  0\n 26 24  1  0  0  0  0\n 27 26  1  0  0  0  0\n 28 26  1  0  0  0  0\n 29 26  1  0  0  0  0\n 30 18  1  0  0  0  0\n 30  2  1  0  0  0  0\n 30 13  1  0  0  0  0\nM  END&quot;;
+    BitSet cyclooctane = fingerprinter.getFingerprint(createCyclooctane());
+    BitSet octane = fingerprinter.getFingerprint(createOctane());
     
-    return MoleculeKit.readMolfile(m);
-  }
-  
-  private Molecule query()
-  {
-    String m = &quot;[NO NAME]\n  CHEMWRIT          2D\nCreated with ChemWriter - http://metamolecular.com/chemwriter\n  9 10  0  0  0  0  0  0  0  0  0 V2000\n    0.9900    4.9544    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.9900    3.5544    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    2.3900    3.5544    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n    2.3900    4.9544    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    5.9443    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n    3.3799    5.9443    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n    0.5573    2.2229    0.0000 S   0  0  0  0  0  0  0  0  0  0  0  0\n    1.6900    1.4000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    2.8226    2.2229    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  1  0  0  0  0\n  2  3  1  0  0  0  0\n  3  4  1  0  0  0  0\n  4  1  1  0  0  0  0\n  1  5  1  0  0  0  0\n  4  6  2  0  0  0  0\n  2  7  1  0  0  0  0\n  7  8  1  0  0  0  0\n  8  9  1  0  0  0  0\n  9  3  1  0  0  0  0\nM  END&quot;;
-//    String m = &quot;[NO NAME]\n  CHEMWRIT          2D\nCreated with ChemWriter - http://metamolecular.com/chemwriter\n 11 12  0  0  0  0  0  0  0  0  0 V2000\n    0.9900    4.9544    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.9900    3.5544    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    2.3900    3.5544    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n    2.3900    4.9544    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    5.9443    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n    3.3799    5.9443    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n    0.5573    2.2229    0.0000 S   0  0  0  0  0  0  0  0  0  0  0  0\n    1.6900    1.4000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    2.8226    2.2229    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    1.6900    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    2.9374    0.7644    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  1  0  0  0  0\n  2  3  1  0  0  0  0\n  3  4  1  0  0  0  0\n  4  1  1  0  0  0  0\n  1  5  1  0  0  0  0\n  4  6  2  0  0  0  0\n  2  7  1  0  0  0  0\n  7  8  1  0  0  0  0\n  8  9  1  0  0  0  0\n  9  3  1  0  0  0  0\n  8 10  1  0  0  0  0\n  8 11  1  0  0  0  0\nM  END&quot;;
-//    String m = &quot;[NO NAME]\n  CHEMWRIT          2D\nCreated with ChemWriter - http://metamolecular.com/chemwriter\n 11 12  0  0  0  0  0  0  0  0  0 V2000\n    0.9900    4.9544    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.9900    3.5544    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    2.3900    3.5544    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n    2.3900    4.9544    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    5.9443    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0\n    3.3799    5.9443    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n    0.5573    2.2229    0.0000 S   0  0  0  0  0  0  0  0  0  0  0  0\n    1.6900    1.4000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    2.8226    2.2229    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    1.6900    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    2.9374    0.7644    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  1  0  0  0  0\n  2  3  1  0  0  0  0\n  3  4  1  0  0  0  0\n  4  1  1  0  0  0  0\n  1  5  1  0  0  0  0\n  4  6  2  0  0  0  0\n  2  7  1  0  0  0  0\n  7  8  1  0  0  0  0\n  8  9  1  0  0  0  0\n  9  3  1  0  0  0  0\n  8 10  1  0  0  0  0\n  8 11  1  0  0  0  0\nM  END&quot;;
-
-    return MoleculeKit.readMolfile(m);
+    assertFalse(match(cyclooctane, octane));
   }
 
   private boolean match(BitSet bitset, BitSet other)</diff>
      <filename>src/com/metamolecular/mx/test/PathFingerprinterTest.java</filename>
    </modified>
    <modified>
      <diff>@@ -124,6 +124,7 @@ public class PathWriterTest extends TestCase
       });
 
     Atom atom1 = mockAtom(&quot;.&quot;);
+        when(bond.getMate(atom)).thenReturn(atom1);
     when(atom1.getBonds()).thenReturn(new Bond[]
       {
         bond
@@ -140,7 +141,6 @@ public class PathWriterTest extends TestCase
     sequence.verify(paths).add(&quot;.%&quot;);
     sequence.verify(paths).add(&quot;.%.%&quot;);
   }
-
   public void testItWritesSaturatedAtomForFirstAtomOfDoubleBond()
   {
     doNew();
@@ -153,6 +153,7 @@ public class PathWriterTest extends TestCase
 
     when(bond1.getType()).thenReturn(1);
     when(bond2.getType()).thenReturn(2);
+    when(bond2.getMate(atom2)).thenReturn(atom3);
     when(atom1.getBonds()).thenReturn(new Bond[]
       {
         bond1
@@ -161,6 +162,10 @@ public class PathWriterTest extends TestCase
       {
         bond1, bond2
       });
+    when(atom3.getBonds()).thenReturn(new Bond[]
+      {
+        bond2
+      });
 
     writer.walkStart(atom1);
     writer.atomFound(atom1);
@@ -176,9 +181,11 @@ public class PathWriterTest extends TestCase
     sequence.verify(paths, times(1)).add(&quot;12&quot;);
     sequence.verify(paths, times(1)).add(&quot;12%&quot;);
     sequence.verify(paths, times(1)).add(&quot;12%3%&quot;);
+
+    verify(paths, times(4)).add(any(String.class));
   }
 
-  public void testItClearsBondPathWhenBranchStarted()
+  public void testItWritesDoubleBondForRingClosure()
   {
     doNew();
 
@@ -187,32 +194,86 @@ public class PathWriterTest extends TestCase
     Atom atom3 = mockAtom(&quot;3&quot;);
     Bond bond1 = mock(Bond.class);
     Bond bond2 = mock(Bond.class);
+    Bond bond3 = mock(Bond.class);
 
-    when(bond1.getType()).thenReturn(2);
+    when(bond1.getType()).thenReturn(1);
+    when(bond2.getType()).thenReturn(1);
+    when(bond3.getType()).thenReturn(2);
+    when(bond3.getMate(atom3)).thenReturn(atom1);
     when(atom1.getBonds()).thenReturn(new Bond[]
       {
-        bond1
+        bond1, bond3
       });
     when(atom2.getBonds()).thenReturn(new Bond[]
       {
         bond1, bond2
       });
+    when(atom3.getBonds()).thenReturn(new Bond[]
+      {
+        bond2, bond3
+      });
 
     writer.walkStart(atom1);
     writer.atomFound(atom1);
     writer.bondFound(bond1);
     writer.atomFound(atom2);
-    writer.branchStart(atom1);
     writer.bondFound(bond2);
     writer.atomFound(atom3);
-    writer.branchEnd(atom1);
+    writer.bondFound(bond3);
+    writer.ringClosed(bond3);
     writer.walkEnd(atom1);
 
     InOrder sequence = inOrder(paths);
 
     sequence.verify(paths, times(1)).add(&quot;1%&quot;);
-    sequence.verify(paths, times(1)).add(&quot;1%2%&quot;);
-    sequence.verify(paths, times(1)).add(&quot;13&quot;);
+    sequence.verify(paths, times(1)).add(&quot;1%2&quot;);
+    sequence.verify(paths, times(1)).add(&quot;1%23%&quot;);
+    sequence.verify(paths, times(1)).add(&quot;1%23%-3&quot;);
+
+    verify(paths, times(4)).add(any(String.class));
+  }
+  public void testItClearsBondPathWhenBranchStarted()
+  {
+    doNew();
+
+    Atom atom1 = mockAtom(&quot;1&quot;);
+    Atom atom2 = mockAtom(&quot;2&quot;);
+    Atom atom3 = mockAtom(&quot;3&quot;);
+    Bond bond1 = mock(Bond.class);
+    Bond bond2 = mock(Bond.class);
+
+    when(bond1.getType()).thenReturn(1);
+    when(atom1.getBonds()).thenReturn(new Bond[]
+      {
+        bond1
+      });
+    when(atom2.getBonds()).thenReturn(new Bond[]
+      {
+        bond1, bond2
+      });
+    when(atom3.getBonds()).thenReturn(new Bond[]
+      {
+        bond2
+      });
+
+    writer.walkStart(atom2);
+    writer.atomFound(atom2);
+    writer.bondFound(bond1);
+    writer.atomFound(atom1);
+    writer.branchStart(atom2);
+    writer.bondFound(bond2);
+    writer.atomFound(atom3);
+    writer.branchEnd(atom2);
+    writer.walkEnd(atom2);
+
+    InOrder sequence = inOrder(paths);
+
+    sequence.verify(paths, times(1)).add(&quot;2&quot;);
+    sequence.verify(paths, times(1)).add(&quot;21&quot;);
+    sequence.verify(paths, times(1)).add(&quot;2&quot;);
+    sequence.verify(paths, times(1)).add(&quot;23&quot;);
+
+    verify(paths, times(4)).add(any(String.class));
   }
 
   public void testItBacktracksWhenBranchStarted()
@@ -371,7 +432,7 @@ public class PathWriterTest extends TestCase
     }
   }
 
-  public void testItRaisesWhenClosingToNonexistantAtom()
+  public void testItThrowsWhenClosingToNonexistantAtom()
   {
     doNew();
 
@@ -422,7 +483,6 @@ public class PathWriterTest extends TestCase
       assertEquals(&quot;Atom closes rings with size less than three &quot; + shorty, e.getMessage());
     }
   }
-
   private void doNew()
   {
     writer = new PathWriter(paths);</diff>
      <filename>src/com/metamolecular/mx/test/PathWriterTest.java</filename>
    </modified>
    <modified>
      <diff>@@ -74,19 +74,12 @@ public class PathWriter implements Reporter
 
   public void atomFound(Atom atom)
   {
-//    System.out.println(&quot;atomFound: &quot; + atom.getIndex());
     if (atomPath.size() &gt; 0 &amp;&amp; (atomPath.size() != bondPath.size()))
     {
       throw new RuntimeException(&quot;Attempt to add Atom without first adding Bond&quot;);
     }
-    atomPath.add(atom);
     
-//    for (Atom inpath : atomPath)
-//    {
-//      System.out.print(inpath.getIndex() + &quot;-&quot;);
-//    }
-//    
-//    System.out.println();
+    atomPath.add(atom);
 
     pathDirty = true;
   }
@@ -111,7 +104,7 @@ public class PathWriter implements Reporter
       throw new RuntimeException(&quot;Attempt to branch from nonexistant atom &quot; + atom);
     }
 
-    chop(index);
+    chopPaths(index);
   }
 
   public void ringClosed(Bond bond)
@@ -136,15 +129,13 @@ public class PathWriter implements Reporter
     {
       throw new RuntimeException(&quot;Atom closes rings with size less than three &quot; + inPath);
     }
-    
-//    System.out.println(&quot;ringClosed: &quot; + ringSize);
-    
+
     pathDirty = true;
 
     writePaths(ringSize);
   }
 
-  private void chop(int index)
+  private void chopPaths(int index)
   {
     int atomChopCount = atomPath.size() - index - 1;
 
@@ -172,54 +163,75 @@ public class PathWriter implements Reporter
 
     for (Atom atom : atomPath)
     {
-      write(atom, buffer);
-
-      if (aromatics.contains(atom))
-      {
-        buffer.append(&quot;%&quot;);
-      }
-      else
-      {
-        for (Bond bond : atom.getBonds())
-        {
-          if (bond.getType() == 2 &amp;&amp; bondPath.contains(bond))
-          {
-            buffer.append(&quot;%&quot;);
-
-            break;
-          }
-
-          if (bond.getType() == 3 &amp;&amp; bondPath.contains(bond))
-          {
-            buffer.append(&quot;#&quot;);
+      writeAtom(atom, buffer);
 
-            break;
-          }
-        }
-      }
-      
-//      System.out.println(buffer);
       output.add(buffer.toString());
     }
 
     if (ringSize != 0)
     {
-//      System.out.println(buffer);
       output.add(buffer.toString() + &quot;-&quot; + ringSize);
     }
-    
-    else
-    {
-//      System.out.println(&quot;ring size 0: &quot; +buffer);
-    }
 
     pathDirty = false;
   }
 
-  private void write(Atom atom, StringBuffer buffer)
+  private void writeAtom(Atom atom, StringBuffer buffer)
+  {
+    buffer.append(atom.getSymbol());
+    writeAtomModifier(atom, buffer);
+  }
+
+  private void writeAtomModifier(Atom atom, StringBuffer buffer)
   {
-    String type = atom.getSymbol();
+    if (aromatics.contains(atom))
+    {
+      buffer.append(&quot;%&quot;);
+    }
+    else
+    {
+      for (Bond bond : atom.getBonds())
+      {
+        if (bond.getType() == 1)
+        {
+          continue;
+        }
+
+        int bondIndex = bondPath.indexOf(bond);
+
+        if (bondIndex == -1)
+        {
+          continue;
+        }
+
+        if (bond.getType() == 3)
+        {
+          buffer.append(&quot;#&quot;);
+          break;
+        }
 
-    buffer.append(type);
+        if (bond.getType() == 2)
+        {
+          int atomIndex = atomPath.indexOf(atom);
+
+          if (bondIndex == atomIndex)
+          {
+            if (!bond.getMate(atom).equals(atomPath.get(0)))
+            {
+              output.add(buffer.toString());
+            }
+            
+            buffer.append(&quot;%&quot;);
+            break;
+          }
+
+          if (bondIndex == atomIndex - 1 || bondIndex == bondPath.size() - 1)
+          {
+            buffer.append(&quot;%&quot;);
+            break;
+          }
+        }
+      }
+    }
   }
 }</diff>
      <filename>src/com/metamolecular/mx/walk/PathWriter.java</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f371b5f803406c593409aa1df7444d917c76c343</id>
    </parent>
  </parents>
  <author>
    <name>Rich Apodaca</name>
    <email>rapodaca@metamolecular.com</email>
  </author>
  <url>http://github.com/metamolecular/mx/commit/2aa0e27ae9b1012eb3b6fca55d36dc33794c654c</url>
  <id>2aa0e27ae9b1012eb3b6fca55d36dc33794c654c</id>
  <committed-date>2009-07-20T13:28:24-07:00</committed-date>
  <authored-date>2009-07-20T13:28:24-07:00</authored-date>
  <message>pathwriter uses C and C% for leading alkene carbon</message>
  <tree>729c851198dc513eabbb91f6fd805eb6f1b5cd28</tree>
  <committer>
    <name>Rich Apodaca</name>
    <email>rapodaca@metamolecular.com</email>
  </committer>
</commit>
