Difference between revisions of "Removealt"

From PyMOLWiki
Jump to navigation Jump to search
(obj=all, comma)
Line 4: Line 4:
 
= The Code =
 
= The Code =
 
<source lang="python">
 
<source lang="python">
def removeAlt(obj="", keep="A"):
+
def removeAlt(obj="(all)", keep="A"):
 
         """
 
         """
 
         removeAlt -- remove all alternate location-atoms not of altloc "keep" from object.
 
         removeAlt -- remove all alternate location-atoms not of altloc "keep" from object.
Line 16: Line 16:
 
         examples:
 
         examples:
 
                 removeAlt # remove all altLocations that aren't altloc A
 
                 removeAlt # remove all altLocations that aren't altloc A
                 removeAlt pdbID C  # remove all but C altlocations from pdbID
+
                 removeAlt pdbID, C  # remove all but C altlocations from pdbID
 
         """
 
         """
        if ( obj == "" ):
 
                obj="(all)"
 
 
 
         # select & remove all non A altlocs
 
         # select & remove all non A altlocs
 
         remStr = "%s and not (alt ''+%s)" % (obj, keep);
 
         remStr = "%s and not (alt ''+%s)" % (obj, keep);

Revision as of 03:06, 21 April 2011

Overview

removeAlt removes all atoms from obj that have alternate locations but aren't altloc keep.

The Code

def removeAlt(obj="(all)", keep="A"):
        """
        removeAlt -- remove all alternate location-atoms not of altloc "keep" from object.

        input:
                obj -- the object(s) to remove the atoms frmo
                keep -- which type of alt loc to keep

        output: none -- removes atoms

        examples:
                removeAlt # remove all altLocations that aren't altloc A
                removeAlt pdbID, C  # remove all but C altlocations from pdbID
        """
        # select & remove all non A altlocs
        remStr = "%s and not (alt ''+%s)" % (obj, keep);
        cmd.remove(remStr);
        # reset the PDB information
        cmd.alter( obj, "alt=''")

cmd.extend("removeAlt", removeAlt)

See Also

Handling Alternate Locations and alter