Selection of bond locations



  • I suggest to implement the possibility to select bonds (without atoms) by location (for instance all bonds centered at z=2 A). Is it possible ? Thank you very much indeed !



  • Thank you @Cyril for the suggestion. We will see whether to add it as a feature in the next version of SAMSON or implement it as a SAMSON Element.

    For now, you can use Python Scripting in SAMSON. To use the Python Scripting SAMSON Element you will need to have a specific version of Python installed. Please, check the Python Scripting installation instructions for SAMSON. You can also check the SAMSON Python Scripting tutorials and documentation.

    The sample script for this task can be found below. You can either copy it inside of the Python Scripting console in SAMSON, or save it as a .py file and open this file in SAMSON when you need to execute this script.

    '''
    This example shows how to select bonds which center lies in between of two planes: z_min and z_max
    
    If you want to select bonds which center lies on a specific plane, just set z_min=z_max
    '''
    
    # Get an indexer of all bonds in the active document. Here we use SAMSON Node Specification Language to get only bonds
    allBondsIndexer = SAMSON.getNodes('node.type bond')
    
    # two planes: 1.7A and 2.3A
    z_min = Quantity.angstrom(1.7)
    z_max = Quantity.angstrom(2.3)
    
    for bond in allBondsIndexer:		# a loop over an indexer
    	# compute the z-axis center of the bond 
    	bondCenterZ = (bond.leftAtom.getZ() + bond.rightAtom.getZ()) / 2.0
    	# check whether the bond lies in between of desired planes
    	if bondCenterZ >= z_min and bondCenterZ <= z_max:
    		# select the bond by setting the selectionFlag to True
    		bond.selectionFlag = True
    
    allBondsIndexer.clear()		# clear an indexer
    

Log in to reply
 















Web
Analytics

Looks like your connection to SAMSON Connect - Forum was lost, please wait while we try to reconnect.