I am trying to isolate certain pieces of information within a dsn6 file. Specifically, I want to find the electron density around two atoms within a protein. I want to then run a python code to determine if there is positive electron density between the two of them. In order to do so, I believe I need to convert the dsn6 file, which is stored in a very compressed format, into a format I can understand.

I have searched around found ways to view dsn6 files (such as through PyMOL or COOT in CCP4) as a model. However, I do not know a way to view this decompressed file as text. I have tried, but have been completely unsuccessful in trying to figure out how these programs decompress/read the files.

This is what a piece of a dsn6 file currently looks like:


I hope that the decompressed dsn6 file will look similar to what a pdb file looks like. For example,

ATOM    228  OG1 THR A  58       7.843  45.672  59.760  1.00 15.56   O        
ATOM    229  CG2 THR A  58       6.672  44.132  61.223  1.00 14.90   C        
ATOM    230  N   PRO A  59       9.292  42.373  62.754  1.00 13.16   N         
ATOM    231  CA  PRO A  59       9.409  40.982  63.160  1.00 13.07   C        

I asked this question in Stack Overflow, but thought that it might be better suited here. Thank you for the help!

  • 2
    $\begingroup$ I commented under your SO question: stackoverflow.com/questions/56987505/… $\endgroup$
    – marcin
    Commented Jul 11, 2019 at 12:10
  • $\begingroup$ It looks like your file is saved in a binary file file format. It is possible to decode is, particularly if you have an idea of what is in the file, but this is a challenge. Can you save the file in any other format? $\endgroup$
    – Comos
    Commented Jul 11, 2019 at 13:11
  • $\begingroup$ I tried to save it as a .pdb file, but this was unsuccessful. I am unfamiliar with the binary file format. If you want to download one of the files to see, here is a link: edmaps.rcsb.org/maps/5x22_2fofc.dsn6 $\endgroup$
    – Ben
    Commented Jul 11, 2019 at 13:18
  • $\begingroup$ There is a software called xtal.js , referred to at github.com/uglymol/uglymol/wiki/ccp4-dsn6-mtz , that may do what you need $\endgroup$
    – Buck Thorn
    Commented Jul 11, 2019 at 14:22
  • $\begingroup$ can you provide some metadata of the measurment that you shared e.g. x start, y start, sampling step, listed in marcin comment maybe we can create a script for opening the files $\endgroup$
    – G M
    Commented Jul 11, 2019 at 16:54

1 Answer 1


There is a program called mapman that can convert between different formats. The .xplor format is a text-based one, the others are all binary, so that's the one you need. The program runs on linux and mac platforms.

Other crystallographic software suites (ccp4, etc) might have similar capabilities, but this one might be the easiest to install (standalone program).

I want to find the electron density around two atoms within a protein.

This is much easier with a molecular browser. You could just set the contour levels to the ones your are interested in, and take a look. If you need to do this programmatically for thousands of structures though, that will not help you.

It will be kind of tricky to find the right spot in the density, though, because they use fractional coordinates (makes generation of symmetry much easier) and your coordinates are in orthogonal coordinates. If this is a problem, just ask another question.

Here is the description of how data is organized in an .xplor map:

Following the map header, the density matrix is then written section-by-section with c moving slowest (in z-sections). Each section of the density map is preceded by a section number.

Thus, for the formatted map file each section of the density map is written using FORTRAN statements of the type



and the resulting map is written with six pixels on each line. The binary format is identical except the format statements are missing, so that each line that is written contains the entire length of map along the `fast' (a-axis) direction.

  • $\begingroup$ Indeed, I have thousands of proteins I need to run through. What you've given here is a great boost though, and I will make much use of it. Thank you! $\endgroup$
    – Ben
    Commented Jul 11, 2019 at 15:26
  • $\begingroup$ @Ben - If you are programming in python anyway, you could try the Computational Crystallography Toolbox. It calls github.com/cctbx/ccp4io/blob/master/libccp4/ccp4/cmap_data.c to read the binary map files. $\endgroup$
    – Karsten
    Commented Jul 12, 2019 at 0:03
  • $\begingroup$ Here are the docs: cci.lbl.gov/cctbx_docs/index.html $\endgroup$
    – Karsten
    Commented Jul 12, 2019 at 0:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.