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

    How to show Atomtype Labels from GROMACS .gro File in SAMSON

    SAMSON
    2
    6
    231
    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.
    • M
      Mattia Felice last edited by Mattia Felice

      Dear SAMSON Development Team,

      I'm currently working on a document in SAMSON where I aim to display a molecule with specific custom labels for each atom. I'd like to show the 'atomtype' for each atom as imported from a GROMACS .gro file, which I found stored in each atom 'comment' value.

      I've been using the Python scripting console in SAMSON for this task, but I haven't been able to achieve the desired result. Specifically, I tried creating SBLabel objects and adding them to the document: the label objects are recognized in the pane on the left, but I'm struggling to display the created labels on the molecule.

      I would be grateful for any guidance or assistance you can provide on this matter!

      Thank you for your support and the continuous development of SAMSON.

      Kind regards,

      Mattia

      DmitriyMarin 1 Reply Last reply Reply Quote 1
      • DmitriyMarin
        DmitriyMarin @Mattia Felice last edited by

        Dear @Mattia-Felice ,

        Currently, the exposed SBLabel does not have an API to change its position - the position is determined by the label class itself depending on the label type (e.g., based on the centroid of the structure to which it has been applied). We will see how we can improve it in the future release.

        For now, what you can do is temporarily set the atomtype from the comment as the atom name, add the label via the interface, and then reset the name when needed either via the undo mechanism or via a saved list/map. Below is an example.

        1. Add labels by "Atoms (names)"
        2. Set GRO atomtypes from atom's comment:
        # get an indexer of all atoms in the active document
        atom_indexer = SAMSON.getNodes('n.t a')
        # or only selected atoms: n.s == node.selected
        #atom_indexer = SAMSON.getNodes('n.t a and n.s')
        
        # holding: take care of undo/redo in SAMSON
        SAMSON.beginHolding('Change atom name')
        
        atom_name_map = {}
        for atom in atom_indexer:
        	atom_name_map[atom] = atom.name
        	atom.name = atom.getComment()
        
        # stop holding the undoable operation
        SAMSON.endHolding()
        
        1. Reset using the stored atom map:
        # holding: take care of undo/redo in SAMSON
        SAMSON.beginHolding('Change atom name')
        
        for atom, name in atom_name_map.items():
        	atom.name = name
        
        SAMSON.endHolding()
        

        Please let me know if you have questions.

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

        1 Reply Last reply Reply Quote 1
        • M
          Mattia Felice last edited by

          Hello Dmitriy,

          this worked like a charm! It's a very useful feature to be able to do this when working on a new forcefield.

          Thank you again for your prompt help!

          Mattia

          DmitriyMarin 1 Reply Last reply Reply Quote 0
          • DmitriyMarin
            DmitriyMarin @Mattia Felice last edited by

            Great!

            Do you often need to show the atomtypes that are stored in the comment record for atoms? And what else would you like to be able to show e.g. as labels or in some other way? This will help us to see what functionality is necessary to add.

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

            1 Reply Last reply Reply Quote 0
            • M
              Mattia Felice last edited by

              Hello Dmitriy,

              having the atom types shown during the development of a force field it's very handy, especially when you want to check if e.g. the molecular SMARTS pattern one's applying to match a certain atom are working properly. I guess in the future this kind of work might be taken over by AI (e.g. https://github.com/choderalab/espaloma ), but for the time being it would be a very valuable feature, together with showing the charge and LJ parameters from a .top file, or analogous formats.

              Regarding other information that would be useful to show, if you ever plan to support reading molecular structures from the output from ab-initio packages such as GAUSSIAN, ORCA, etc., an invaluable feature would be the possibility to show the values of charge and spin population in the labels, together with color mapping. This is a feature I've seen implemented only in ChemCraft so far.

              Thank you for the interest in the feedback :)

              Mattia

              DmitriyMarin 1 Reply Last reply Reply Quote 0
              • DmitriyMarin
                DmitriyMarin @Mattia Felice last edited by

                Dear @Mattia-Felice ,

                Thank you for the feedback! We will consider this for the next releases of SAMSON.

                We will surely add more labeling possibilities in the next release.

                As for formats from ab initio packages, SAMSON currently supports only Molden and it loads only the molecular structure from it. But we can add the possibility to load other data from it as well.

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

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