Esempio n. 1
0
    def __init__(self, filename, **kwargs):
        self.filename = util.filename(filename, ext=native_str("stream"))
        self._version = kwargs.get("charmm_version", 41)

        width = 4 if self._version < 36 else 8
        if self._version >= 36:
            self.fmt = ("""
                IC EDIT
                DIST %-{width}s %{width}d %-{width}s %-{width}s %{width}d %-{width}s%{width}.1f
                END
                """.format(width=width))
        else:
            self.fmt = ("""
                IC EDIT
                DIST BYNUM %{width}d BYNUM %{width}d %{width}.1f
                END
                """.format(width=width))

        date = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
        user = environ["USER"]
        self._title = kwargs.get(
            "title", (
                "* Created by fluctmatch on {date}".format(date=date),
                "* User: {user}".format(user=user),
            ))
        if not util.iterable(self._title):
            self._title = util.asiterable(self._title)
Esempio n. 2
0
 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)
Esempio n. 3
0
 def test_named_stream(self):
     ns = util.NamedStream(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:
         pytest.fail("fn and ns are different")
     assert str(fn) == self.filename2
     assert ns.name == self.filename2
Esempio n. 4
0
 def testNamedStream(self):
     ns = util.NamedStream(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)
Esempio n. 5
0
 def __init__(self, filename):
     self.filename = util.filename(filename, ext="prm")
     self._prmbuffers = dict(
         ATOMS=StringIO(),
         BONDS=StringIO(),
         ANGLES=StringIO(),
         DIHEDRALS=StringIO(),
         IMPROPER=StringIO(),
     )
Esempio n. 6
0
 def __init__(self, filename, **kwargs):
     """
     Parameters
     ----------
     filename : str or :class:`~MDAnalysis.lib.util.NamedStream`
          name of the output file or a stream
     """
     super().__init__(filename, **kwargs)
     self.filename = util.filename(filename, ext="cor")
     self.crd = None
Esempio n. 7
0
    def __init__(self, filename, **kwargs):
        self.filename = util.filename(filename, ext="prm")
        self._version = kwargs.get("charmm_version", 41)
        self._nonbonded = kwargs.get("nonbonded", False)

        date = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
        user = environ["USER"]
        self._title = kwargs.get("title", (
            "* Created by fluctmatch on {date}".format(date=date),
            "* User: {user}".format(user=user),
        ))
        if not util.iterable(self._title):
            self._title = util.asiterable(self._title)
Esempio n. 8
0
    def __init__(self, filename, **kwargs):
        self.filename = util.filename(filename, ext="ic")
        self._intcor = None
        self._extended = kwargs.get("extended", True)
        self._resid = kwargs.get("resid", True)
        self.key = "EXTENDED" if self._extended else "STANDARD"
        self.key += "_RESID" if self._resid else ""

        date = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
        user = environ["USER"]
        self._title = kwargs.get(
            "title", (
                "* Created by fluctmatch on {date}".format(date=date),
                "* User: {user}".format(user=user),
            ))
        if not util.iterable(self._title):
            self._title = util.asiterable(self._title)
Esempio n. 9
0
    def __init__(self, filename, convert_units=True, **kwargs):
        """Set up a DATAWriter

        Parameters
        ----------
        filename : str
            output filename
        convert_units : bool, optional
            units are converted to the MDAnalysis base format; [``True``]  
        """
        self.filename = util.filename(filename, ext='data')

        self.convert_units = convert_units

        self.units = {'time': 'fs', 'length': 'Angstrom'}
        self.units['length'] = kwargs.pop('lengthunit', self.units['length'])
        self.units['time'] = kwargs.pop('timeunit', self.units['time'])
        self.units['velocity'] = kwargs.pop('velocityunit',
                                 self.units['length']+'/'+self.units['time'])
Esempio n. 10
0
 def test_string(self, name, ext, keep, actual_name):
     file_name = util.filename(name, ext, keep)
     assert file_name == actual_name
Esempio n. 11
0
 def __init__(self, filename):
     self.filename = util.filename(filename, ext="ic")
Esempio n. 12
0
 def testStringRootExtKeep(self):
     fn = util.filename(self.root, ext=self.ext, keep=True)
     assert_equal(fn, self.filename2)
Esempio n. 13
0
 def testStringRootExt(self):
     fn = util.filename(self.root, ext=self.ext)
     assert_equal(fn, self.filename2)
Esempio n. 14
0
 def testStringKeep(self):
     fn = util.filename(self.filename, ext=self.ext, keep=True)
     assert_equal(fn, self.filename)
Esempio n. 15
0
 def testStringRootExtKeep(self):
     fn = util.filename(self.root, ext=self.ext, keep=True)
     assert_equal(fn, self.filename2)
Esempio n. 16
0
 def testStringRootExt(self):
     fn = util.filename(self.root, ext=self.ext)
     assert_equal(fn, self.filename2)
Esempio n. 17
0
 def testStringKeep(self):
     fn = util.filename(self.filename, ext=self.ext, keep=True)
     assert_equal(fn, self.filename)
Esempio n. 18
0
 def testStringNoExt(self):
     fn = util.filename(self.filename)
     assert_equal(fn, self.filename)
Esempio n. 19
0
 def __init__(self, filename, **kwargs):
     super().__init__(filename, **kwargs)
     self.filename = util.filename(filename, ext="par")
Esempio n. 20
0
def cli(data_dir, logfile, outdir, prefix, tbltype, ressep, verbose, start, end, trimmed, trimcut):
    pt = paramtable.ParamTable(
        prefix=prefix,
        tbltype=tbltype,
        ressep=ressep,
        datadir=data_dir,
        start=start,
        end=end,
        trimmed=trimmed,
        trimcut=trimcut
    )
    # Setup logger
    logging.config.dictConfig({
        "version": 1,
        "disable_existing_loggers": False,  # this fixes the problem
        "formatters": {
            "standard": {
                "class": "logging.Formatter",
                "format": "%(name)-12s %(levelname)-8s %(message)s",
            },
            "detailed": {
                "class": "logging.Formatter",
                "format":
                "%(asctime)s %(name)-15s %(levelname)-8s %(message)s",
                "datefmt": "%m-%d-%y %H:%M",
            },
        },
        "handlers": {
            "console": {
                "class": "logging.StreamHandler",
                "level": "INFO",
                "formatter": "standard",
            },
            "file": {
                "class": "logging.FileHandler",
                "filename": logfile,
                "level": "INFO",
                "mode": "w",
                "formatter": "detailed",
            }
        },
        "root": {
            "level": "INFO",
            "handlers": ["console", "file"]
        },
    })
    logger = logging.getLogger(__name__)

    pt.run(verbose=verbose)

    # Write the various tables to different files.
    fn = path.join(outdir, filename(tbltype.lower(), ext="txt", keep=True))
    pt.write(fn)

    if tbltype == "Kb":
        fn = path.join(outdir, filename("perres", ext="txt"))
        with open(fn, mode="wb") as output:
            logger.info("Writing per-residue data to {}.".format(fn))
            table = pt.per_residue.to_csv(
                header=True,
                index=True,
                sep=native_str(" "),
                float_format=native_str("%.4f"),
                encoding="utf-8",
            )
            output.write(table.encode())
            logger.info("Table successfully written.")

        fn = path.join(outdir, filename("interactions", ext="txt"))
        with open(fn, mode="wb") as output:
            logger.info("Writing interactions to {}.".format(fn))
            table = pt.interactions.to_csv(
                header=True,
                index=True,
                sep=native_str(" "),
                float_format=native_str("%.4f"),
                encoding="utf-8",
            )
            output.write(table.encode())
            logger.info("Table successfully written.")
Esempio n. 21
0
 def testStringNoExt(self):
     fn = util.filename(self.filename)
     assert_equal(fn, self.filename)