# How do I view a DSN6 file as text?

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:

˘>˝‰‡>™†≠>I14>)B=*À¢<™ÅK=i§=‰≤Ñ=ê8ºO∑ææÑ¸ΩﬁZ
Ω2…=wÇ=œjÖ=ÿm=◊6=â(:ÿ◊ôΩl≥æ=sËΩ,vzºËm
>dg>ÄàG>>hº&>è,>SªÂ=


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!

• I commented under your SO question: stackoverflow.com/questions/56987505/… – marcin Jul 11 at 12:10
• 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? – Comos Jul 11 at 13:11
• 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 – Ben Jul 11 at 13:18
• There is a software called xtal.js , referred to at github.com/uglymol/uglymol/wiki/ccp4-dsn6-mtz , that may do what you need – Buck Thorn Jul 11 at 14:22
• 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 – G M Jul 11 at 16:54

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

WRITE(OUNIT,'(I8)') KSECT

WRITE(OUNIT,'(6E12.5)') ((SECTON(I,J),I=1,ISECT),J=1,JSECT)

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.