Difference between revisions of "User:Sbliven/Sandbox"

From PyMOLWiki
Jump to navigation Jump to search
Line 1: Line 1:
 
== Pymol Inclusion ==
 
== Pymol Inclusion ==
 +
Conclusion: the include plugin doesn't work as a template.
 +
 
Through Template:
 
Through Template:
{{Template:PymolScriptRepoInclude|removealt.py}}
+
{{Template:PymolScriptRepoInclude/Test|removealt.py}}
 
 
Direct:
 
<include src="https://raw.github.com/Pymol-Scripts/Pymol-script-repo/master/removealt.py" highlight="python" />
 
  
 
Subst:
 
Subst:
<include src="https://raw.github.com/Pymol-Scripts/Pymol-script-repo/master/{{{1}}}" highlight="{{{2|python}}}" />
+
<nowiki><include src="https://raw.github.com/Pymol-Scripts/Pymol-script-repo/master/{{{1}}}" highlight="{{{2|python}}}" /></nowiki>
  
 
This code has been put under version control in the project [http://www.pymolwiki.org/index.php/Git_intro Pymol-script-repo].
 
This code has been put under version control in the project [http://www.pymolwiki.org/index.php/Git_intro Pymol-script-repo].
 +
 +
Direct:
 +
<include src="https://raw.github.com/Pymol-Scripts/Pymol-script-repo/master/removealt.py" highlight="python" />

Revision as of 09:48, 30 October 2015

Pymol Inclusion

Conclusion: the include plugin doesn't work as a template.

Through Template: {{{lt|<}}}include src="https://raw.github.com/Pymol-Scripts/Pymol-script-repo/master/{{{1}}}" highlight="{{{2|python}}}" /{{{gt|>}}}

This code has been put under version control in the project Pymol-script-repo.

Subst: <include src="https://raw.github.com/Pymol-Scripts/Pymol-script-repo/master/{{{1}}}" highlight="{{{2|python}}}" />

This code has been put under version control in the project Pymol-script-repo.

Direct:

from pymol import cmd


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)