def __init__(self, filename, mode="wa", numterms=None, preamble=None, **kwargs): """Set up for writing to *filename*. :Arguments: *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 :meth:`write` """ self.filename = util.filename(filename, ext=self.ext) if not mode in ('a', 'w', 'wa'): raise ValueError("mode must be one of 'w', 'a', 'wa', not %r" % mode) self.mode = mode self._current_mode = mode[0] if numterms is None or numterms < 0: self.numterms = self.default_numterms elif numterms is False: self.numterms = 0 else: self.numterms = numterms self.preamble = preamble self.otherargs = kwargs # hack self.number = 0 self.write_preamble()
def testNamedStream(self): ns = util.NamedStream(cStringIO.StringIO(), self.filename) fn = util.filename(ns, ext=self.ext) # assert_equal replace by this if loop to avoid segfault on some systems if fn != ns: raise AssertionError("fn and ns are different") assert_equal(str(fn), self.filename2) assert_equal(ns.name, self.filename2)
def __init__(self, filename, convert_units=None, **kwargs): """Set up a GROWriter with a precision of 3 decimal places. :Arguments: *filename* output filename """ self.filename = util.filename(filename, ext='gro') if convert_units is None: convert_units = MDAnalysis.core.flags['convert_lengths'] self.convert_units = convert_units # convert length and time to base units
def __init__(self, filename, convert_units=None, **kwargs): """Set up a GROWriter with a precision of 3 decimal places. :Arguments: *filename* output filename """ self.filename = util.filename(filename, ext="gro") if convert_units is None: convert_units = MDAnalysis.core.flags["convert_lengths"] self.convert_units = convert_units # convert length and time to base units
def __init__(self, filename, convert_units=None, **kwargs): """Set up a PQRWriter with full whitespace separation. :Arguments: *filename* output filename *remarks* remark lines (list of strings) or single string to be added to the top of the PQR file """ self.filename = util.filename(filename, ext='pqr') if convert_units is None: convert_units = MDAnalysis.core.flags['convert_lengths'] self.convert_units = convert_units # convert length and time to base units self.remarks = kwargs.pop('remarks', "PQR file written by MDAnalysis")
def __init__(self, filename, **kwargs): self.filename = util.filename(filename, ext='crd') self.crd = None
def __init__(self, filename, **kwargs): self.filename = util.filename(filename, ext='pdbqt') self.pdb = util.anyopen(self.filename, 'w')
def testStringRootExtKeep(self): fn = util.filename(self.root, ext=self.ext, keep=True) assert_equal(fn, self.filename2)
def testStringRootExt(self): fn = util.filename(self.root, ext=self.ext) assert_equal(fn, self.filename2)
def testStringKeep(self): fn = util.filename(self.filename, ext=self.ext, keep=True) assert_equal(fn, self.filename)
def testStringNoExt(self): fn = util.filename(self.filename) assert_equal(fn, self.filename)