SAMSON Forum
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • SAMSON Connect
    • Get SAMSON

    Selection of bond locations

    Feature requests
    2
    2
    2735
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      Cyril last edited by

      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 !

      1 Reply Last reply Reply Quote 0
      • DmitriyMarin
        DmitriyMarin last edited by

        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
        

        Dmitriy,
        The SAMSON Team, https://s-c.io

        1 Reply Last reply Reply Quote 1
        • First post
          Last post