From: Vermaas, Josh (vermaasj_at_msu.edu)
Date: Tue Mar 08 2022 - 14:58:18 CST

Hi Adam,

Rather than rolling your own, is there a good reason you couldn't use MDAnalysis or MDTraj to load your dcd files? That would seem to be much simpler.

-Josh

On 3/8/22, 1:21 PM, "owner-vmd-l_at_ks.uiuc.edu on behalf of Adam Gross" <owner-vmd-l_at_ks.uiuc.edu on behalf of asgross37_at_gmail.com> wrote:

    Thanks

    I just tried with v1.9.3 and got the same problem. I’ll try some more things on the Python side to see if I can get it working

> On Mar 8, 2022, at 1:16 PM, John Stone <johns_at_ks.uiuc.edu> wrote:
>
> 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://urldefense.com/v3/__https://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html__;!!HXCxUKc!mPvfs3d2ekBhne7JiL-feVGNmiB1skuyBZoYNCTlhmH31ufMuMRQw6Hp1qQvysY$ ).
>> 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://urldefense.com/v3/__https://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html__;!!HXCxUKc!mPvfs3d2ekBhne7JiL-feVGNmiB1skuyBZoYNCTlhmH31ufMuMRQw6Hp1qQvysY$
>
> --
> NIH Center for Macromolecular Modeling and Bioinformatics
> Beckman Institute for Advanced Science and Technology
> University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
> https://urldefense.com/v3/__http://www.ks.uiuc.edu/*johns/__;fg!!HXCxUKc!mPvfs3d2ekBhne7JiL-feVGNmiB1skuyBZoYNCTlhmH31ufMuMRQw6HpfljRXis$ Phone: 217-244-3349
> https://urldefense.com/v3/__http://www.ks.uiuc.edu/Research/vmd/__;!!HXCxUKc!mPvfs3d2ekBhne7JiL-feVGNmiB1skuyBZoYNCTlhmH31ufMuMRQw6Hp9CkB7wo$