Removealt: Difference between revisions

From PyMOLWiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Overview =
{{Infobox script-repo
|type      = script
|filename  = removealt.py
|author    = [[User:Inchoate|Jason Vertrees]]
|license  = Free
}}
 
[[removeAlt]] removes all atoms from '''obj''' that have alternate locations but aren't altloc '''keep'''.
[[removeAlt]] removes all atoms from '''obj''' that have alternate locations but aren't altloc '''keep'''.


= The Code =
== Usage ==
<source lang="python">
 
def removeAlt(obj="", keep="A"):
removealt [ obj [, keep ]]
        """
 
        removeAlt -- remove all alternate location-atoms not of altloc "keep" from object.
== Example ==
 
<syntaxhighlight lang="python">
import removealt


        input:
fetch 1hxb, async=0
                obj -- the object(s) to remove the atoms frmo
                keep -- which type of alt loc to keep


        output: none -- removes atoms
select ligA, alt a
select ligB, alt b


        examples:
count_atoms ligA    # 49 atoms
                removeAlt # remove all altLocations that aren't altloc A
count_atoms ligB    # 49 atoms
                removeAlt pdbID C  # remove all but C altlocations from pdbID
        """
        if ( obj == "" ):
                obj="(all)"


        # select & remove all non A altlocs
removealt 1hxb, b
        remStr = "%s and not (alt ''+%s)" % (obj, keep);
        cmd.remove(remStr);
        # reset the PDB information
        cmd.alter( obj, "alt=''")


cmd.extend("removeAlt", removeAlt)
count_atoms ligA    # 0 atoms
</source>
count_atoms ligB    # 49 atoms
</syntaxhighlight>


= See Also =
== See Also ==
[[Property_Selectors#Alternate_Locations|Handling Alternate Locations]] and [[alter]]
[[Property_Selectors#Alternate_Locations|Handling Alternate Locations]] and [[alter]]


[[Category:Script_Library]]
[[Category:Script_Library]]
[[Category:ObjSel_Scripts]]
[[Category:ObjSel_Scripts]]
[[Category:Pymol-script-repo]]

Latest revision as of 10:04, 15 January 2012

Type Python Script
Download removealt.py
Author(s) Jason Vertrees
License Free
This code has been put under version control in the project Pymol-script-repo

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

Usage

removealt [ obj [, keep ]]

Example

import removealt

fetch 1hxb, async=0

select ligA, alt a
select ligB, alt b

count_atoms ligA    # 49 atoms
count_atoms ligB    # 49 atoms

removealt 1hxb, b

count_atoms ligA    # 0 atoms
count_atoms ligB    # 49 atoms

See Also

Handling Alternate Locations and alter