def test_06_MSMS(): # test the MSMS node net = ed.currentNetwork net.runOnNewData.value = True node1 = ReadMolecule(library=molkitlib) net.addNode(node1, 20, 20) node1.inputPorts[0].widget.set(os.path.abspath("1crn.pdb")) # assign radii node2 = AssignRadii(library=molkitlib) net.addNode(node2, 275, 62) net.connectNodes(node1, node2, "MolSets", "molecules") node2.toggleNodeExpand_cb() # select nodes node3 = NodeSelector(library=molkitlib) net.addNode(node3, 14, 153) net.connectNodes(node2, node3, "molecules", "nodes") node3.toggleNodeExpand_cb() # msms node4 = AtomsAsMSMS(library=molkitlib) net.addNode(node4, 263, 267) net.connectNodes(node3, node4, "nodes", "atoms") net.connectNodes(node2, node4, "radii", "radii") pause() # check data from mslib import MSMS assert isinstance(node4.outputPorts[0].data, MSMS),\ "Expected %s, got %s"%(MSMS, node4.outputPorts[0].data.__class__) assert len(node4.outputPorts[0].data.coords) == 327,\ "Expected 327, got %s"%len(node4.outputPorts[0].data.coords) # just for the fun of it, click the united radii checkbutton a couple times node2.inputPorts[1].widget.set(1) node2.inputPorts[1].widget.set(0) node2.inputPorts[1].widget.set(1) node2.inputPorts[1].widget.set(0)
def test_03_AssignRadii(): # test the Assign Radii node net = ed.currentNetwork net.runOnNewData.value = True node1 = ReadMolecule(library=molkitlib) net.addNode(node1, 20, 20) node1.inputPorts[0].widget.set(os.path.abspath("1crn.pdb")) node2 = AssignRadii(library=molkitlib) net.addNode(node2, 30, 100) net.connectNodes(node1, node2, "MolSets", "molecules") node2.toggleNodeExpand_cb() pause() # both output ports should have data # a molecule: data = node2.outputPorts[0].data from MolKit.protein import ProteinSet assert isinstance(data, ProteinSet), "Expected %s, got %s"%( ProteinSet, data.__class__) # list of radii: data = node2.outputPorts[1].data assert len(data) == 327, "Expected 327, got %s"%len(data) # check if united Radii works node2.inputPorts[1].widget.set(1)
def test_03_AssignRadii(): # test the Assign Radii node net = ed.currentNetwork net.runOnNewData.value = True node1 = ReadMolecule(library=molkitlib) net.addNode(node1, 20, 20) node1.inputPorts[0].widget.set(os.path.abspath("1crn.pdb")) node2 = AssignRadii(library=molkitlib) net.addNode(node2, 30, 100) net.connectNodes(node1, node2, "MolSets", "molecules") node2.toggleNodeExpand_cb() pause() # both output ports should have data # a molecule: data = node2.outputPorts[0].data from MolKit.protein import ProteinSet assert isinstance( data, ProteinSet), "Expected %s, got %s" % (ProteinSet, data.__class__) # list of radii: data = node2.outputPorts[1].data assert len(data) == 327, "Expected 327, got %s" % len(data) # check if united Radii works node2.inputPorts[1].widget.set(1)
def test_07_MSMSWithAtomSubset(): # test if we can pass an atom set (C,CA,N) to compute an MSMS masterNet = ed.currentNetwork ## saving node Read Molecule ## node0 = ReadMolecule(library=molkitlib) masterNet.addNode(node0, 20, 20) node0.inputPorts[0].widget.set(os.path.abspath("1crn.pdb"), 0) # do not run yet ## saving node MSMS ## node2 = AtomsAsMSMS(library=molkitlib) masterNet.addNode(node2, 250, 275) ## saving node Select Nodes ## node4 = NodeSelector(library=molkitlib) masterNet.addNode(node4, 14, 153) node4.inputPorts[2].widget.set("C,CA,N") apply(node4.configure, (), {'expanded': True}) ## saving node Assign Radii ## node5 = AssignRadii(library=molkitlib) masterNet.addNode(node5, 275, 62) apply(node5.configure, (), {'expanded': True}) ## saving node Extract Atom Property ## node7 = AtomsProperty(library=molkitlib) masterNet.addNode(node7, 302, 169) node7.inputPorts[1].widget.set("radius") apply(node7.configure, (), {'expanded': True}) ## saving connections for network Network 0 ## masterNet.connectNodes(node0, node5, "MolSets", "molecules") masterNet.connectNodes(node5, node4, "molecules", "nodes") masterNet.connectNodes(node4, node2, "nodes", "atoms") masterNet.connectNodes(node4, node7, "nodes", "atoms") masterNet.connectNodes(node7, node2, "propertyValues", "radii") pause() masterNet.run() # check if the data is correct # (compare to above: the entire AtomSet would be 237) assert node2.outputPorts[0].data is not None,\ "Expected data, got %s"%node2.outputPorts[0].data assert len(node2.outputPorts[0].data.coords) == 138,\ "Expected 128, got %s"%len(node2.outputPorts[0].data.coords)
## saving node Read Molecule ## from MolKit.VisionInterface.MolKitNodes import ReadMolecule node0 = ReadMolecule(constrkw={}, name='Read Molecule', library=molkitlib) masterNet.addNode(node0, 94, 50) widget = node0.inputPorts[0].widget widget.set("cv.pdb", 0) except: print "WARNING: failed to restore node ReadMolecule called Read Molecule in network masterNet" print_exc() node0 = None try: ## saving node Assign Radii ## from MolKit.VisionInterface.MolKitNodes import AssignRadii node1 = AssignRadii(constrkw={}, name='Assign Radii', library=molkitlib) masterNet.addNode(node1, 86, 114) widget = node1.inputPorts[1].widget widget.set(0, 0) except: print "WARNING: failed to restore node AssignRadii called Assign Radii in network masterNet" print_exc() node1 = None try: ## saving node Select Nodes ## from MolKit.VisionInterface.MolKitNodes import NodeSelector node2 = NodeSelector(constrkw={}, name='Select Nodes', library=molkitlib) masterNet.addNode(node2, 89, 177) widget = node2.inputPorts[1].widget widget.set("Atom", 0)
def afterAddingToNetwork(self): from NetworkEditor.macros import MacroNode MacroNode.afterAddingToNetwork(self) ## loading libraries ## from MolKit.VisionInterface.MolKitNodes import molkitlib from DejaVu.VisionInterface.DejaVuNodes import vizlib from Vision.StandardNodes import stdlib ## building macro network ## WebMSMS = self from traceback import print_exc ## loading libraries ## from MolKit.VisionInterface.MolKitNodes import molkitlib self.macroNetwork.getEditor().addLibraryInstance(molkitlib,"MolKit.VisionInterface.MolKitNodes", "molkitlib") from DejaVu.VisionInterface.DejaVuNodes import vizlib self.macroNetwork.getEditor().addLibraryInstance(vizlib,"DejaVu.VisionInterface.DejaVuNodes", "vizlib") from Vision.StandardNodes import stdlib self.macroNetwork.getEditor().addLibraryInstance(stdlib,"Vision.StandardNodes", "stdlib") try: ## saving node input Ports ## input_Ports = self.macroNetwork.ipNode input_Ports.move(13, 4) except: print "WARNING: failed to restore MacroInputNode named input Ports in network self.macroNetwork" print_exc() input_Ports=None try: ## saving node output Ports ## output_Ports = self.macroNetwork.opNode output_Ports.move(256, 220) except: print "WARNING: failed to restore MacroOutputNode named output Ports in network self.macroNetwork" print_exc() output_Ports=None try: ## saving node Assign Radii ## from MolKit.VisionInterface.MolKitNodes import AssignRadii Assign_Radii = AssignRadii(constrkw = {}, name='Assign Radii', library=molkitlib) self.macroNetwork.addNode(Assign_Radii,30,68) apply(Assign_Radii.getInputPortByName('molecules').configure, (), {'color': '#c64e70', 'cast': True, 'shape': 'oval'}) apply(Assign_Radii.getInputPortByName('united').configure, (), {'color': 'yellow', 'cast': True, 'shape': 'circle'}) apply(Assign_Radii.getOutputPortByName('molecules').configure, (), {'color': '#c64e70', 'shape': 'oval'}) apply(Assign_Radii.getOutputPortByName('radii').configure, (), {'color': 'cyan', 'shape': 'oval'}) except: print "WARNING: failed to restore AssignRadii named Assign Radii in network self.macroNetwork" print_exc() Assign_Radii=None try: ## saving node Select Nodes ## from MolKit.VisionInterface.MolKitNodes import NodeSelector Select_Nodes = NodeSelector(constrkw = {}, name='Select Nodes', library=molkitlib) self.macroNetwork.addNode(Select_Nodes,29,135) apply(Select_Nodes.getInputPortByName('nodes').configure, (), {'color': '#c64e70', 'cast': True, 'shape': 'oval'}) apply(Select_Nodes.getInputPortByName('nodeType').configure, (), {'color': 'white', 'cast': True, 'shape': 'oval'}) apply(Select_Nodes.getInputPortByName('selectionString').configure, (), {'color': 'white', 'cast': True, 'shape': 'oval'}) apply(Select_Nodes.getOutputPortByName('nodes').configure, (), {'color': '#fe92a0', 'shape': 'oval'}) Select_Nodes.getInputPortByName("selectionString").widget.set(".*") except: print "WARNING: failed to restore NodeSelector named Select Nodes in network self.macroNetwork" print_exc() Select_Nodes=None try: ## saving node Get xyzr ## from Vision.StandardNodes import Generic Get_xyzr = Generic(constrkw = {}, name='Get xyzr', library=stdlib) self.macroNetwork.addNode(Get_xyzr,30,194) apply(Get_xyzr.addInputPort, (), {'name': 'atoms', 'cast': True, 'datatype': 'AtomSet', 'height': 8, 'width': 12, 'shape': 'oval', 'color': '#fe92a0'}) apply(Get_xyzr.addOutputPort, (), {'name': 'output', 'datatype': 'string', 'height': 12, 'width': 12, 'shape': 'oval', 'color': 'white'}) code = """def doit(self, atoms): lines = '' for atom in atoms: lines += str(atom.coords[0]) + ' ' + str(atom.coords[1]) + ' ' + str(atom.coords[2]) + ' '+ str(atom.radius) lines += "\\n" self.outputData(output=lines) """ Get_xyzr.configure(function=code) except: print "WARNING: failed to restore Generic named Get xyzr in network self.macroNetwork" print_exc() Get_xyzr=None try: ## saving node IndexedPolygons ## from DejaVu.VisionInterface.GeometryNode import IndexedPolygonsNE IndexedPolygons = IndexedPolygonsNE(constrkw = {}, name='IndexedPolygons', library=vizlib) self.macroNetwork.addNode(IndexedPolygons,273,147) apply(IndexedPolygons.getInputPortByName('coords').configure, (), {'color': 'purple', 'cast': True, 'shape': 'circle'}) apply(IndexedPolygons.getInputPortByName('indices').configure, (), {'color': 'yellow', 'cast': True, 'shape': 'circle'}) apply(IndexedPolygons.getInputPortByName('vnormals').configure, (), {'cast': True, 'shape': 'circle'}) apply(IndexedPolygons.getInputPortByName('colors').configure, (), {'cast': True, 'shape': 'circle'}) apply(IndexedPolygons.getInputPortByName('name').configure, (), {'color': 'white', 'cast': True, 'shape': 'oval'}) apply(IndexedPolygons.getInputPortByName('instanceMatrices').configure, (), {'cast': True}) apply(IndexedPolygons.getInputPortByName('geomOptions').configure, (), {'color': 'cyan', 'cast': True, 'shape': 'oval'}) apply(IndexedPolygons.getInputPortByName('parent').configure, (), {'color': 'red', 'cast': True, 'shape': 'rect'}) apply(IndexedPolygons.getOutputPortByName('indexedPolygons').configure, (), {'color': 'red', 'shape': 'rect'}) apply(IndexedPolygons.getOutputPortByName('allGeometries').configure, (), {'color': 'red', 'shape': 'rect'}) except: print "WARNING: failed to restore IndexedPolygonsNE named IndexedPolygons in network self.macroNetwork" print_exc() IndexedPolygons=None try: ## saving node MSMS WS ## from Vision.StandardNodes import Generic MSMS_WS = Generic(constrkw = {}, name='MSMS WS', library=stdlib) self.macroNetwork.addNode(MSMS_WS,273,37) apply(MSMS_WS.addInputPort, (), {'name': 'input_str', 'cast': True, 'datatype': 'string', 'height': 12, 'width': 12, 'shape': 'oval', 'color': 'white'}) apply(MSMS_WS.addInputPort, (), {'name': 'density', 'datatype': 'float', 'required':False}) apply(MSMS_WS.getInputPortByName('density').createWidget, (), {'descr':{'initialValue': 1.0, 'increment':0.1, 'type':'float', 'master': 'ParamPanel', 'oneTurn':10, 'min':1.0, 'labelCfg': {'text': 'density'}, 'class': 'NEDial'}}) apply(MSMS_WS.addInputPort, (), {'name': 'probe_radius', 'datatype': 'float', 'required':False}) apply(MSMS_WS.getInputPortByName('probe_radius').createWidget, (), {'descr':{'initialValue': 1.5, 'increment':0.1, 'type':'float', 'master': 'ParamPanel', 'oneTurn':10, 'min':0.5, 'labelCfg': {'text': 'probe radius'}, 'class': 'NEDial'}}) apply(MSMS_WS.addInputPort, (), {'name': 'allComp', 'datatype': 'int', 'required':False}) apply(MSMS_WS.getInputPortByName('allComp').createWidget, (), {'descr':{'initialValue': 0, 'master': 'ParamPanel', 'labelCfg': {'text': 'all components'}, 'class': 'NECheckButton'}}) apply(MSMS_WS.addInputPort, (), {'name': 'getfile', 'datatype': 'boolean'}) apply(MSMS_WS.getInputPortByName('getfile').createWidget, (), {'descr':{'master': 'ParamPanel', 'labelCfg': {'text': 'upload output'}, 'class': 'NECheckButton', 'initialValue':True }}) apply(MSMS_WS.addOutputPort, (), {'name': 'vertices', 'datatype': 'coordinates3D', 'height': 8, 'width': 12, 'shape': 'rect', 'color': 'green'}) apply(MSMS_WS.addOutputPort, (), {'name': 'indices', 'datatype': 'faceIndices', 'height': 8, 'width': 12, 'shape': 'rect', 'color': 'purple'}) apply(MSMS_WS.addOutputPort, (), {'name': 'vnormals', 'datatype': 'normals3D', 'height': 8, 'width': 12, 'shape': 'rect', 'color': 'blue'}) MSMS_WS.host = self.host MSMS_WS.opal_service = self.opal_service code = """def doit(self, input_str, probe_radius, density, allComp, getfile): self.opal_service.inputFile.Set_name('msms.xyzr') self.opal_service.inputFile.Set_contents(input_str) options = '-if msms.xyzr -of ws_out ' options += '-probe_radius ' + str(probe_radius) options += ' -density ' + str(density) if allComp: options += ' -all_components' self.opal_service.req._argList = options inputFiles = [] inputFiles.append(self.opal_service.inputFile) self.opal_service.req._inputFile = inputFiles resp = self.opal_service.run('msmsServicePort') if resp: for files in resp._outputFile: if files._url.split('/')[-1] == 'ws_out.face': face_file = files._url if files._url.split('/')[-1] == 'ws_out.vert': vert_file = files._url if getfile: from Pmv.msmsParser import MSMSParser msmsParser = MSMSParser() import urllib opener = urllib.FancyURLopener({}) in_file = opener.open(face_file) msmsParser.getFaces(in_file.readlines()) in_file = opener.open(vert_file) msmsParser.getVert(in_file.readlines()) self.outputData(vertices = msmsParser.vertices, indices = msmsParser.faces, vnormals = msmsParser.normals) else: self.outputData(vertices = vert_file, indices = face_file, vnormals = None) """ MSMS_WS.configure(function=code) except: print "WARNING: failed to restore Generic named MSMS WS in network self.macroNetwork" print_exc() MSMS_WS=None self.macroNetwork.freeze() ## saving connections for network WebMSMS ## if Assign_Radii is not None and Select_Nodes is not None: self.macroNetwork.connectNodes( Assign_Radii, Select_Nodes, "molecules", "nodes", blocking=True) if Select_Nodes is not None and Get_xyzr is not None: self.macroNetwork.connectNodes( Select_Nodes, Get_xyzr, "nodes", "atoms", blocking=True) if Get_xyzr is not None and MSMS_WS is not None: self.macroNetwork.connectNodes( Get_xyzr, MSMS_WS, "output", "input_str", blocking=True) if MSMS_WS is not None and IndexedPolygons is not None: self.macroNetwork.connectNodes( MSMS_WS, IndexedPolygons, "vertices", "coords", blocking=True) if MSMS_WS is not None and IndexedPolygons is not None: self.macroNetwork.connectNodes( MSMS_WS, IndexedPolygons, "indices", "indices", blocking=True) if MSMS_WS is not None and IndexedPolygons is not None: self.macroNetwork.connectNodes( MSMS_WS, IndexedPolygons, "vnormals", "vnormals", blocking=True) output_Ports = self.macroNetwork.opNode if IndexedPolygons is not None and output_Ports is not None: self.macroNetwork.connectNodes( IndexedPolygons, output_Ports, "indexedPolygons", "new", blocking=True) input_Ports = self.macroNetwork.ipNode if input_Ports is not None and Assign_Radii is not None: self.macroNetwork.connectNodes( input_Ports, Assign_Radii, "new", "molecules", blocking=True) self.macroNetwork.unfreeze() WebMSMS.shrink() ## reset modifications ## WebMSMS.resetTags() WebMSMS.buildOriginalList()
def afterAddingToNetwork(self): from NetworkEditor.macros import MacroNode MacroNode.afterAddingToNetwork(self) ## loading libraries ## from MolKit.VisionInterface.MolKitNodes import molkitlib from DejaVu.VisionInterface.DejaVuNodes import vizlib from Vision.StandardNodes import stdlib ## building macro network ## WebMSMS = self from traceback import print_exc ## loading libraries ## from MolKit.VisionInterface.MolKitNodes import molkitlib self.macroNetwork.getEditor().addLibraryInstance( molkitlib, "MolKit.VisionInterface.MolKitNodes", "molkitlib") from DejaVu.VisionInterface.DejaVuNodes import vizlib self.macroNetwork.getEditor().addLibraryInstance( vizlib, "DejaVu.VisionInterface.DejaVuNodes", "vizlib") from Vision.StandardNodes import stdlib self.macroNetwork.getEditor().addLibraryInstance( stdlib, "Vision.StandardNodes", "stdlib") try: ## saving node input Ports ## input_Ports = self.macroNetwork.ipNode input_Ports.move(13, 4) except: print "WARNING: failed to restore MacroInputNode named input Ports in network self.macroNetwork" print_exc() input_Ports = None try: ## saving node output Ports ## output_Ports = self.macroNetwork.opNode output_Ports.move(256, 220) except: print "WARNING: failed to restore MacroOutputNode named output Ports in network self.macroNetwork" print_exc() output_Ports = None try: ## saving node Assign Radii ## from MolKit.VisionInterface.MolKitNodes import AssignRadii Assign_Radii = AssignRadii(constrkw={}, name='Assign Radii', library=molkitlib) self.macroNetwork.addNode(Assign_Radii, 30, 68) apply( Assign_Radii.getInputPortByName('molecules').configure, (), { 'color': '#c64e70', 'cast': True, 'shape': 'oval' }) apply( Assign_Radii.getInputPortByName('united').configure, (), { 'color': 'yellow', 'cast': True, 'shape': 'circle' }) apply( Assign_Radii.getOutputPortByName('molecules').configure, (), { 'color': '#c64e70', 'shape': 'oval' }) apply( Assign_Radii.getOutputPortByName('radii').configure, (), { 'color': 'cyan', 'shape': 'oval' }) except: print "WARNING: failed to restore AssignRadii named Assign Radii in network self.macroNetwork" print_exc() Assign_Radii = None try: ## saving node Select Nodes ## from MolKit.VisionInterface.MolKitNodes import NodeSelector Select_Nodes = NodeSelector(constrkw={}, name='Select Nodes', library=molkitlib) self.macroNetwork.addNode(Select_Nodes, 29, 135) apply( Select_Nodes.getInputPortByName('nodes').configure, (), { 'color': '#c64e70', 'cast': True, 'shape': 'oval' }) apply( Select_Nodes.getInputPortByName('nodeType').configure, (), { 'color': 'white', 'cast': True, 'shape': 'oval' }) apply( Select_Nodes.getInputPortByName('selectionString').configure, (), { 'color': 'white', 'cast': True, 'shape': 'oval' }) apply( Select_Nodes.getOutputPortByName('nodes').configure, (), { 'color': '#fe92a0', 'shape': 'oval' }) Select_Nodes.getInputPortByName("selectionString").widget.set(".*") except: print "WARNING: failed to restore NodeSelector named Select Nodes in network self.macroNetwork" print_exc() Select_Nodes = None try: ## saving node Get xyzr ## from Vision.StandardNodes import Generic Get_xyzr = Generic(constrkw={}, name='Get xyzr', library=stdlib) self.macroNetwork.addNode(Get_xyzr, 30, 194) apply( Get_xyzr.addInputPort, (), { 'name': 'atoms', 'cast': True, 'datatype': 'AtomSet', 'height': 8, 'width': 12, 'shape': 'oval', 'color': '#fe92a0' }) apply( Get_xyzr.addOutputPort, (), { 'name': 'output', 'datatype': 'string', 'height': 12, 'width': 12, 'shape': 'oval', 'color': 'white' }) code = """def doit(self, atoms): lines = '' for atom in atoms: lines += str(atom.coords[0]) + ' ' + str(atom.coords[1]) + ' ' + str(atom.coords[2]) + ' '+ str(atom.radius) lines += "\\n" self.outputData(output=lines) """ Get_xyzr.configure(function=code) except: print "WARNING: failed to restore Generic named Get xyzr in network self.macroNetwork" print_exc() Get_xyzr = None try: ## saving node IndexedPolygons ## from DejaVu.VisionInterface.GeometryNode import IndexedPolygonsNE IndexedPolygons = IndexedPolygonsNE(constrkw={}, name='IndexedPolygons', library=vizlib) self.macroNetwork.addNode(IndexedPolygons, 273, 147) apply( IndexedPolygons.getInputPortByName('coords').configure, (), { 'color': 'purple', 'cast': True, 'shape': 'circle' }) apply( IndexedPolygons.getInputPortByName('indices').configure, (), { 'color': 'yellow', 'cast': True, 'shape': 'circle' }) apply( IndexedPolygons.getInputPortByName('vnormals').configure, (), { 'cast': True, 'shape': 'circle' }) apply( IndexedPolygons.getInputPortByName('colors').configure, (), { 'cast': True, 'shape': 'circle' }) apply( IndexedPolygons.getInputPortByName('name').configure, (), { 'color': 'white', 'cast': True, 'shape': 'oval' }) apply( IndexedPolygons.getInputPortByName( 'instanceMatrices').configure, (), {'cast': True}) apply( IndexedPolygons.getInputPortByName('geomOptions').configure, (), { 'color': 'cyan', 'cast': True, 'shape': 'oval' }) apply( IndexedPolygons.getInputPortByName('parent').configure, (), { 'color': 'red', 'cast': True, 'shape': 'rect' }) apply( IndexedPolygons.getOutputPortByName( 'indexedPolygons').configure, (), { 'color': 'red', 'shape': 'rect' }) apply( IndexedPolygons.getOutputPortByName('allGeometries').configure, (), { 'color': 'red', 'shape': 'rect' }) except: print "WARNING: failed to restore IndexedPolygonsNE named IndexedPolygons in network self.macroNetwork" print_exc() IndexedPolygons = None try: ## saving node MSMS WS ## from Vision.StandardNodes import Generic MSMS_WS = Generic(constrkw={}, name='MSMS WS', library=stdlib) self.macroNetwork.addNode(MSMS_WS, 273, 37) apply( MSMS_WS.addInputPort, (), { 'name': 'input_str', 'cast': True, 'datatype': 'string', 'height': 12, 'width': 12, 'shape': 'oval', 'color': 'white' }) apply(MSMS_WS.addInputPort, (), { 'name': 'density', 'datatype': 'float', 'required': False }) apply( MSMS_WS.getInputPortByName('density').createWidget, (), { 'descr': { 'initialValue': 1.0, 'increment': 0.1, 'type': 'float', 'master': 'ParamPanel', 'oneTurn': 10, 'min': 1.0, 'labelCfg': { 'text': 'density' }, 'class': 'NEDial' } }) apply(MSMS_WS.addInputPort, (), { 'name': 'probe_radius', 'datatype': 'float', 'required': False }) apply( MSMS_WS.getInputPortByName('probe_radius').createWidget, (), { 'descr': { 'initialValue': 1.5, 'increment': 0.1, 'type': 'float', 'master': 'ParamPanel', 'oneTurn': 10, 'min': 0.5, 'labelCfg': { 'text': 'probe radius' }, 'class': 'NEDial' } }) apply(MSMS_WS.addInputPort, (), { 'name': 'allComp', 'datatype': 'int', 'required': False }) apply( MSMS_WS.getInputPortByName('allComp').createWidget, (), { 'descr': { 'initialValue': 0, 'master': 'ParamPanel', 'labelCfg': { 'text': 'all components' }, 'class': 'NECheckButton' } }) apply(MSMS_WS.addInputPort, (), { 'name': 'getfile', 'datatype': 'boolean' }) apply( MSMS_WS.getInputPortByName('getfile').createWidget, (), { 'descr': { 'master': 'ParamPanel', 'labelCfg': { 'text': 'upload output' }, 'class': 'NECheckButton', 'initialValue': True } }) apply( MSMS_WS.addOutputPort, (), { 'name': 'vertices', 'datatype': 'coordinates3D', 'height': 8, 'width': 12, 'shape': 'rect', 'color': 'green' }) apply( MSMS_WS.addOutputPort, (), { 'name': 'indices', 'datatype': 'faceIndices', 'height': 8, 'width': 12, 'shape': 'rect', 'color': 'purple' }) apply( MSMS_WS.addOutputPort, (), { 'name': 'vnormals', 'datatype': 'normals3D', 'height': 8, 'width': 12, 'shape': 'rect', 'color': 'blue' }) MSMS_WS.host = self.host MSMS_WS.opal_service = self.opal_service code = """def doit(self, input_str, probe_radius, density, allComp, getfile): self.opal_service.inputFile.Set_name('msms.xyzr') self.opal_service.inputFile.Set_contents(input_str) options = '-if msms.xyzr -of ws_out ' options += '-probe_radius ' + str(probe_radius) options += ' -density ' + str(density) if allComp: options += ' -all_components' self.opal_service.req._argList = options inputFiles = [] inputFiles.append(self.opal_service.inputFile) self.opal_service.req._inputFile = inputFiles resp = self.opal_service.run('msmsServicePort') if resp: for files in resp._outputFile: if files._url.split('/')[-1] == 'ws_out.face': face_file = files._url if files._url.split('/')[-1] == 'ws_out.vert': vert_file = files._url if getfile: from Pmv.msmsParser import MSMSParser msmsParser = MSMSParser() import urllib opener = urllib.FancyURLopener({}) in_file = opener.open(face_file) msmsParser.getFaces(in_file.readlines()) in_file = opener.open(vert_file) msmsParser.getVert(in_file.readlines()) self.outputData(vertices = msmsParser.vertices, indices = msmsParser.faces, vnormals = msmsParser.normals) else: self.outputData(vertices = vert_file, indices = face_file, vnormals = None) """ MSMS_WS.configure(function=code) except: print "WARNING: failed to restore Generic named MSMS WS in network self.macroNetwork" print_exc() MSMS_WS = None self.macroNetwork.freeze() ## saving connections for network WebMSMS ## if Assign_Radii is not None and Select_Nodes is not None: self.macroNetwork.connectNodes(Assign_Radii, Select_Nodes, "molecules", "nodes", blocking=True) if Select_Nodes is not None and Get_xyzr is not None: self.macroNetwork.connectNodes(Select_Nodes, Get_xyzr, "nodes", "atoms", blocking=True) if Get_xyzr is not None and MSMS_WS is not None: self.macroNetwork.connectNodes(Get_xyzr, MSMS_WS, "output", "input_str", blocking=True) if MSMS_WS is not None and IndexedPolygons is not None: self.macroNetwork.connectNodes(MSMS_WS, IndexedPolygons, "vertices", "coords", blocking=True) if MSMS_WS is not None and IndexedPolygons is not None: self.macroNetwork.connectNodes(MSMS_WS, IndexedPolygons, "indices", "indices", blocking=True) if MSMS_WS is not None and IndexedPolygons is not None: self.macroNetwork.connectNodes(MSMS_WS, IndexedPolygons, "vnormals", "vnormals", blocking=True) output_Ports = self.macroNetwork.opNode if IndexedPolygons is not None and output_Ports is not None: self.macroNetwork.connectNodes(IndexedPolygons, output_Ports, "indexedPolygons", "new", blocking=True) input_Ports = self.macroNetwork.ipNode if input_Ports is not None and Assign_Radii is not None: self.macroNetwork.connectNodes(input_Ports, Assign_Radii, "new", "molecules", blocking=True) self.macroNetwork.unfreeze() WebMSMS.shrink() ## reset modifications ## WebMSMS.resetTags() WebMSMS.buildOriginalList()