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:

˘&gt;˝‰‡&gt;™†≠&gt;I14&gt;)B=*À¢&lt;™ÅK=i§=‰≤Ñ=ê8ºO∑ææÑ¸ΩﬁZ
Ω2…=wÇ=œjÖ=ÿm=◊6=â(:ÿ◊ôΩl≥æ=sËΩ,vzºËm
&gt;dg&gt;ÄàG&gt;&gt;hº&amp;&gt;è,&gt;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!
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.