Skip to content

Commit

Permalink
pathwriter now writes ring closure paths in which branch has ring clo…
Browse files Browse the repository at this point in the history
…sure only and no atoms beyond branch
  • Loading branch information
Rich Apodaca committed Jul 18, 2009
1 parent 3eca88c commit 4bf4b4d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/com/metamolecular/mx/test/PathFingerprinterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
import com.metamolecular.mx.io.Molecules;
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;

import static org.mockito.Mockito.*;

/**
Expand Down
29 changes: 28 additions & 1 deletion src/com/metamolecular/mx/test/PathWriterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package com.metamolecular.mx.test;

import com.metamolecular.mx.walk.PathWriter;
Expand Down Expand Up @@ -266,6 +265,34 @@ public void testItWritesRingClosure()
sequence.verify(paths, times(1)).add("123-3");
}

public void testItWritesRingClosureWhenNoAtomsInBranch()
{
doNew();

Atom atom1 = mockAtom("1");
Atom atom2 = mockAtom("2");
Atom atom3 = mockAtom("3");
Atom atom4 = mockAtom("4");
Bond closure = mock(Bond.class);

when(closure.getMate(atom3)).thenReturn(atom1);

writer.walkStart(atom1);
writer.atomFound(atom1);
writer.bondFound(bond);
writer.atomFound(atom2);
writer.bondFound(bond);
writer.atomFound(atom3);
writer.bondFound(bond);
writer.atomFound(atom4);
writer.branchStart(atom3);
writer.ringClosed(closure);
writer.branchEnd(atom3);
writer.walkEnd(atom1);

verify(paths, times(1)).add("123-3");
}

public void testItWritesLongestLinearPathOnceWhenRingClosed()
{
doNew();
Expand Down
2 changes: 2 additions & 0 deletions src/com/metamolecular/mx/walk/PathWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public void ringClosed(Bond bond)
{
throw new RuntimeException("Atom closes rings with size less than three " + inPath);
}

pathDirty = true;

writePaths(ringSize);
}
Expand Down

0 comments on commit 4bf4b4d

Please sign in to comment.