6.1. VMD selections

Write MDAnalysis.core.AtomGroup.AtomGroup selection to a VMD tcl file that defines atomselect macros. To be used in VMD like this:

source macros.vmd
set sel [atomselect top mdanalysis001]  # use macro 001
class MDAnalysis.selections.vmd.SelectionWriter(filename, mode='wa', numterms=None, preamble=None, **kwargs)[source]

Set up for writing to filename.

Parameters:
  • *filename* – output file
  • *mode* – overwrite (“w”) for every write, append (“a”) to existing file, or overwrite an existing file and then append (“wa”) [“wa”]
  • *numterms* – number of individual index numbers per line for output formats that write multiple entries in one line. If set to 0 or False then no special formatting is done [8]
  • *preamble* – string that is written as a comment at the top of the file []
  • *kwargs* – use as defaults for write()
__delattr__

x.__delattr__(‘name’) <==> del x.name

__format__()

default object formatter

__getattribute__

x.__getattribute__(‘name’) <==> x.name

__hash__
__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__
__setattr__

x.__setattr__(‘name’, value) <==> x.name = value

__sizeof__() → int

size of object in memory, in bytes

__str__
comment(s)[source]

Return string s interpolated into the comment format string.

If no SelectionWriter.commentfmt is defined (None) then the empty string is returned because presumably there is no way to enter comments into the file.

A newline is appended to non-empty strings.

write(selection, number=None, name=None, frame=None, mode=None)[source]

Write selection to the output file.

Parameters:
  • *selection* – a MDAnalysis.core.AtomGroup.AtomGroup
  • *number* – selection will be named “mdanalysis<number>” (None auto increments between writes; useful when appending) [None]
  • *name* – selection will be named name (instead of numbered) [None]
  • *frame* – write selection of this frame (or the current one if None [None]
write_preamble()[source]

Write a header, depending on the file format.