def testAutoDragToBoundary(self): """docstring for testDrag""" vh0 = VirtualHelix(numBases=42, idnum=0) vh0.connectStrand(StrandType.Scaffold, 20, 22) str0 = "0 Scaffold: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,> <,> <,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_\n0 Staple: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_" self.assertEqual(repr(vh0), str0) vh0.autoDragToBoundary(StrandType.Scaffold, 20) str1 = "0 Scaffold: _,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_\n0 Staple: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_" self.assertEqual(repr(vh0), str1) vh0.autoDragToBoundary(StrandType.Scaffold, 22) str2 = "0 Scaffold: _,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,> <,_\n0 Staple: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_" self.assertEqual(repr(vh0), str2)
def createOrAddBasesToVirtualHelix(self, addBases=False,\ addToScaffold=False): coord = (self._row, self._col) vh = self.virtualHelix() index = self.part().activeSlice() if not vh: vh = VirtualHelix() self.part().setVirtualHelixAt(coord, vh) vh.basesModified.connect(self.update) if addBases and addToScaffold: vh.connectStrand(StrandType.Scaffold, index - 1, index + 1) elif addBases and not addToScaffold: vh.connectStrand(StrandType.Staple, index - 1, index + 1)
def createOrAddBasesToVirtualHelix(self, addBases=False,\ addToScaffold=False): coord = (self._row, self._col) vh = self.virtualHelix() index = self.part().activeSlice() undoStack = self.part().undoStack() if not vh: undoStack.beginMacro("Add helix") vh = VirtualHelix(numBases=self.part().crossSectionStep()) self.part().addVirtualHelixAt(coord, vh) vh.basesModified.connect(self.update) else: undoStack.beginMacro("Connect segment") if addBases and addToScaffold: vh.connectStrand(StrandType.Scaffold, index - 1, index + 1) elif addBases and not addToScaffold: vh.connectStrand(StrandType.Staple, index - 1, index + 1) self.undoStack().endMacro()
def testFractionalClearStrandCommand(self): """ The new API for clearStrand allows fractional values for base indices (see docs/virtualhelix.pdf). This tets them. """ vh = VirtualHelix(numBases=8, idnum=0) self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_\n0 Staple: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_') vh.connectStrand(StrandType.Scaffold, 2, 6) vh.connectStrand(StrandType.Staple, 0, 7) self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,> <,> <,> <,> <,_ _,_\n0 Staple: _,> <,> <,> <,> <,> <,> <,> <,_') vh.clearStrand(StrandType.Scaffold, 4, 4) vh.clearStrand(StrandType.Staple, 3, 5) self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,> <,> <,> <,> <,_ _,_\n0 Staple: _,> <,> <,_ _,_ _,_ _,> <,> <,_') vh.undoStack().undo() vh.undoStack().undo() self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,> <,> <,> <,> <,_ _,_\n0 Staple: _,> <,> <,> <,> <,> <,> <,> <,_') vh.undoStack().undo()
def testClearCrossovers(self): vh = VirtualHelix(numBases=8, idnum=0) vh.connectStrand(StrandType.Staple, 0, 7) vh1 = VirtualHelix(numBases=5, idnum=1) vh1.connectStrand(StrandType.Staple, 0, 5) vh1.installXoverFrom3To5(StrandType.Staple, 3, vh, 2) self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_\n0 Staple: _,> <,> <,1:3 _,> <,> <,> <,> <,_') self.assertEqual(repr(vh1), '1 Scaffold: _,_ _,_ _,_ _,_ _,_\n1 Staple: _,> <,> <,> <,0:2 _,_') vh1.clearStrand(StrandType.Staple, 0, 5) self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_\n0 Staple: _,> <,> <,_ _,> <,> <,> <,> <,_') self.assertEqual(repr(vh1), '1 Scaffold: _,_ _,_ _,_ _,_ _,_\n1 Staple: _,_ _,_ _,_ _,_ _,_') vh1.undoStack().undo() vh1.undoStack().undo() self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_\n0 Staple: _,> <,> <,> <,> <,> <,> <,> <,_') self.assertEqual(repr(vh1), '1 Scaffold: _,_ _,_ _,_ _,_ _,_\n1 Staple: _,> <,> <,> <,> <,_') vh.installXoverFrom3To5(StrandType.Staple, 2, vh1, 3) self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_\n0 Staple: _,> <,_ 1:3,> <,> <,> <,> <,> <,_') self.assertEqual(repr(vh1), '1 Scaffold: _,_ _,_ _,_ _,_ _,_\n1 Staple: _,> <,> <,_ 0:2,> <,_') vh1.clearStrand(StrandType.Staple, 0, 5) self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_\n0 Staple: _,> <,_ _,> <,> <,> <,> <,> <,_') self.assertEqual(repr(vh1), '1 Scaffold: _,_ _,_ _,_ _,_ _,_\n1 Staple: _,_ _,_ _,_ _,_ _,_')
def testVH(self): """ Perform the VirtualHelix tutorial and make sure that the expected changes occur to the sample VirtualHelix """ vh = VirtualHelix(numBases=8, idnum=0) self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_\n0 Staple: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_') vh.connectStrand(StrandType.Scaffold, 2, 6) vh.connectStrand(StrandType.Staple, 0, 7) self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,> <,> <,> <,> <,_ _,_\n0 Staple: _,> <,> <,> <,> <,> <,> <,> <,_') vh.clearStrand(StrandType.Scaffold, 3.5, 4.5) vh.clearStrand(StrandType.Staple, 2.5, 5.5) self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,> <,_ _,> <,> <,_ _,_\n0 Staple: _,> <,> <,_ _,_ _,_ _,> <,> <,_') vh1 = VirtualHelix(numBases=5, idnum=1) vh1.connectStrand(StrandType.Staple, 0, 4) self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,> <,_ _,> <,> <,_ _,_\n0 Staple: _,> <,> <,_ _,_ _,_ _,> <,> <,_') self.assertEqual(repr(vh1), '1 Scaffold: _,_ _,_ _,_ _,_ _,_\n1 Staple: _,> <,> <,> <,> <,_') vh.installXoverFrom3To5(StrandType.Staple, 2, vh1, 2) self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,> <,_ _,> <,> <,_ _,_\n0 Staple: _,> <,_ 1:2,> <,_ _,_ _,> <,> <,_') self.assertEqual(repr(vh1), '1 Scaffold: _,_ _,_ _,_ _,_ _,_\n1 Staple: _,> <,_ 0:2,> <,> <,_') vh.undoStack().undo() self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,> <,_ _,> <,> <,_ _,_\n0 Staple: _,> <,> <,_ _,_ _,_ _,> <,> <,_') self.assertEqual(repr(vh1), '1 Scaffold: _,_ _,_ _,_ _,_ _,_\n1 Staple: _,> <,> <,> <,> <,_') vh1.undoStack().undo() self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,> <,_ _,> <,> <,_ _,_\n0 Staple: _,> <,> <,_ _,_ _,_ _,> <,> <,_') self.assertEqual(repr(vh1), '1 Scaffold: _,_ _,_ _,_ _,_ _,_\n1 Staple: _,_ _,_ _,_ _,_ _,_') vh.undoStack().undo() self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,> <,_ _,> <,> <,_ _,_\n0 Staple: _,> <,> <,> <,> <,> <,> <,> <,_') vh.undoStack().undo() self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,> <,> <,> <,> <,_ _,_\n0 Staple: _,> <,> <,> <,> <,> <,> <,> <,_') vh.undoStack().undo() self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,> <,> <,> <,> <,_ _,_\n0 Staple: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_') vh.undoStack().undo() self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_\n0 Staple: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_') vh.connectStrand(StrandType.Scaffold, 2, 4) vh.connectStrand(StrandType.Scaffold, 0, 7) vh.undoStack().undo() self.assertEqual(repr(vh), '0 Scaffold: _,_ _,_ _,> <,> <,_ _,_ _,_ _,_\n0 Staple: _,_ _,_ _,_ _,_ _,_ _,_ _,_ _,_')
#!/usr/bin/python from model.virtualhelix import VirtualHelix from model.enum import StrandType from code import interact print "vh = VirtualHelix(numBases=8, idnum=0)" vh = VirtualHelix(numBases=8, idnum=0) print str(vh) + "\n\n" print "vh.connectStrand(StrandType.Scaffold,2,6)" print "vh.connectStrand(StrandType.Staple,0,7)" vh.connectStrand(StrandType.Scaffold,2,6) vh.connectStrand(StrandType.Staple,0,7) print str(vh) + "\n\n" print "vh.clearStrand(StrandType.Scaffold,4,4)" print "vh.clearStrand(StrandType.Staple,3,5)" vh.clearStrand(StrandType.Scaffold,4,4) vh.clearStrand(StrandType.Staple,3,5) print str(vh) + "\n\n" print "vh1 = VirtualHelix(numBases=5, idnum=1)" print "vh1.connectStrand(StrandType.Staple, 0, 4)" vh1 = VirtualHelix(numBases=5, idnum=1) vh1.connectStrand(StrandType.Staple, 0, 4) print str(vh) print str(vh1) + "\n\n" print "vh.connect3To5(StrandType.Staple, 2, vh1, 3)" vh.connect3To5(StrandType.Staple, 2, vh1, 2) print str(vh)