From: John Stone (johns_at_ks.uiuc.edu)
Date: Tue Mar 08 2022 - 12:16:36 CST

Hi,
  DCD files are binary files made to be compatible with
Fortran I/O used by CHARMM and don't have a text string "encoding"
in the modern sense at all. The Python parser shouldn't be attempting
to interpret any particular encoding and should instead likely just
accept any/all valid ASCII alphanumeric characters and ignore anything
non-printable. VMD 1.9.2 is very old now, but according to the revision
history on dcdplugin.c, nothing significant has changed in the last
decade, and nothing that would indicate an impact on how the trajectory
header is written. From what I see, it looks like the header writing
code hasn't been changed since 2005. I don't see anything obvious
that would indicate why there would be any difference in header content
whether VMD was used via the GUI or via 'animate write', since neither
have any direct input to the write_dcdheader() routine.

Best,
  John Stone

On Tue, Mar 08, 2022 at 12:39:05PM -0500, Adam Gross wrote:
> Hi,
> Running into a challenge when trying to automate saving DCD files from VMD
> for further analysis with custom-built python codes. When I save the DCDs
> via the GUI, everything works fine, and I can read the DCDs no issue.
> However, when I try to save using "animate write ...' I run into problems
> (animate write dcd filename.dcd waitfor all). When loading the DCD with my
> python code, I get an error when trying to read the "title" section of the
> Header (the second block of data in the DCD, as shown here
> [1]https://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html).
> It occurs on the second entry of the title section. The first says
> 'Created by DCD plugin', but when trying to read the second, Python gives
> me an error of 'utf-8 codec can't decode byte 0xe9 in position 76: invalid
> continuation byte'. When reading what should be the same DCD, except saved
> from VMD via the GUI instead, that title entry contains the date ('REMARKS
> Created XX Month, Year at HH:MM')
> VMD itself is able to read/load both saved DCD types correctly and without
> error. Running v1.9.2.
> Any ideas to fix? Why is the DCD title block being saved differently when
> saved via GUI vs the animate write command? And/or what type of encoding
> is being used in the second line of the title section of the DCD header
> when it is saved via the 'animate write' command?
> Thanks
>
> References
>
> Visible links
> 1. https://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html

-- 
NIH Center for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
http://www.ks.uiuc.edu/~johns/           Phone: 217-244-3349
http://www.ks.uiuc.edu/Research/vmd/