From: John Stone (johns_at_ks.uiuc.edu)
Date: Thu Oct 02 2003 - 16:49:14 CDT

Dear Tyler,
  The DCD reader plugin already has code in it for reading the
periodic cell information from Charmm format DCD files, so it should
be working already. Can you send me an example DCD file that doesn't
correctly load periodic cell information into VMD? Here's the actual
C code that reads in the unit cell info, its possible that your DCD
file is missing the '48' sentinel integer that the reader is looking
for, or has some other number there in its place. In any case, if
you can provide me with a reasonably sized example, we can fix whatever
it is that's preventing it from loading the PBC data. The code is below...

Thanks,
  John Stone
  vmd_at_ks.uiuc.edu

static int read_charmm_extrablock(FILE *fd, int charmm, int reverseEndian,
                                  float *unitcell) {
  int input_integer;
  int i;
  if ((charmm & DCD_IS_CHARMM) &&
      (charmm & DCD_HAS_EXTRA_BLOCK)) {
    /* Leading integer must be 48 */
    if (fread(&input_integer, sizeof(int), 1, fd) != 1) {
      return DCD_BADREAD;
    }
    if (reverseEndian) reverseFourByteWord(&input_integer);
    if (input_integer == 48) {
      double tmp[6];
      if (fread(tmp, 48, 1, fd) != 1) return DCD_BADREAD;
      if (reverseEndian)
        for (i=0; i<6; i++)
          reverseEightByteWord(tmp+i);
      for (i=0; i<6; i++) unitcell[i] = (float)tmp[i];
    } else {
      /* just skip it */
      if (fseek(fd, input_integer, SEEK_CUR)) return DCD_BADREAD;
    }
    if (fread(&input_integer, sizeof(int), 1, fd) != 1) return DCD_BADREAD;
  }

  return 0;
}

On Thu, Oct 02, 2003 at 12:08:27PM -0600, Tyler Luchko wrote:
> Hello,
>
> since VMD now supports PBC it would be very helpful if it could read in
> the unit cell information for each frame of a CHARMM DCD. This
> information is currently stored for each frame in the CHARMM DCD file if
> the simulation used PBC. Would such a feature be possible?
>
> Thank you,
>
> Tyler
>
>
> ________TyLer_LuchKo__::__MaSters_StuDent__->>__DePartMent_Of_PhysIcs_________
> _______UnIVerSiTy_Of_AlBerTa__->>__EdMonTon__->>__AlBerTa__->>__CanADa________
> ____http://Phys.UAlBerTa.Ca/______________________tluchko@Phys.UAlBerTa.Ca____
> _______________________780-492-5519__(But_SomeTimes_3552)_____________________

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