Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何将DSN6文件解压缩为可读格式?_Python_Pymol - Fatal编程技术网

Python 如何将DSN6文件解压缩为可读格式?

Python 如何将DSN6文件解压缩为可读格式?,python,pymol,Python,Pymol,我试图隔离dsn6文件中的某些信息。具体来说,我想找到蛋白质中两个原子周围的电子密度。然后我想运行一个python代码来确定它们之间是否存在正电子密度。为了做到这一点,我相信我需要将dsn6文件转换成我能理解的格式,该文件以非常压缩的格式存储 我四处搜索,找到了将dsn6文件作为模型查看的方法(例如通过CCP4中的PyMOL或COOT)。但是,我不知道如何将此解压缩文件视为文本。我已经试过了,但是在试图弄清楚这些程序是如何解压/读取文件方面完全失败了 这就是dsn6文件的当前外观: ˘>˝

我试图隔离dsn6文件中的某些信息。具体来说,我想找到蛋白质中两个原子周围的电子密度。然后我想运行一个python代码来确定它们之间是否存在正电子密度。为了做到这一点,我相信我需要将dsn6文件转换成我能理解的格式,该文件以非常压缩的格式存储

我四处搜索,找到了将dsn6文件作为模型查看的方法(例如通过CCP4中的PyMOL或COOT)。但是,我不知道如何将此解压缩文件视为文本。我已经试过了,但是在试图弄清楚这些程序是如何解压/读取文件方面完全失败了

这就是dsn6文件的当前外观:

˘>˝‰‡>™†≠>I14>)B=*À¢<™ÅK=i§=‰≤Ñ=ê8ºO∑ææѸΩfiZ
Ω2…=wÇ=œjÖ=ÿm=◊6=â(:ÿ◊ôΩl≥æ=sËΩ,vzºËm
>dg>ÄàG>>hº&>è,>SªÂ=
从@marcin提供的数据格式中,您可以了解数据格式,我提取了标题,但为了重新塑造数组,我得到了错误的值数:

import struct
import numpy as np
file_path = r'5x22_2fofc.dsn6'
with open(file_path,'rb') as f:
    brick = f.read(512)

header = brick # the firs brick is our header
n = 2 # number of bytes per entry
entries = [header[i:i + n] for i in range(0, len(header), n)]
header_desc = [
        'x start', # 1
        'y start', # 2
        'z start', # 3
        'x extent', # 4
        'y extent', # 5
        'z extent', # 6
        'x sampling rate', # 7
        'y sampling rate', # 8
        'z sampling rate', # 9
        'Header(18) * A Cell Edge', # 10
        'Header(18) * B Cell Edge', # 11
        'Header(18) * C Cell Edge', # 12
        'Header(18) * alfa', # 13
        'Header(18) * beta', # 14
        'Header(18) * gamma', # 15
        'Header(19) (253 -3) /(rmax -rmin)', # 16
        '(3rmax - 253rmin)/(rmax -rmin)]', # 17
        'Cell Constant Scaling Factor', # 18
        '100'] # 19

header_conv = [struct.unpack('>h',i)[0] for i in entries]
# we now extract the data afte the header(using an offset)
data = np.memmap(file_path,dtype='uint8',offset=512,mode='r')
for i in zip(header_desc,header_conv):
    print(i)
这是我提取的标题:

('x start', -20)
('y start', -56)
('z start', -135)
('x extent', 126)
('y extent', 118)
('z extent', 272)
('x sampling rate', 170)
('y sampling rate', 96)
('z sampling rate', 266)
('Header(18) * A Cell Edge', 14912)
('Header(18) * B Cell Edge', 8345)
('Header(18) * C Cell Edge', 23783)
('Header(18) * alfa', 7200)
('Header(18) * beta', 7868)
('Header(18) * gamma', 7200)
('Header(19) (253 -3) /(rmax -rmin)', 1375)
('(3rmax - 253rmin)/(rmax -rmin)]', 80)
('Cell Constant Scaling Factor', 80)
('100', 100)

不能将DSN6文件视为模型,因为它不是模型,而是体积数据(电子密度)。有关格式的详细信息,请参阅将其转换为文本不会有多大帮助。如果您从RCSB下载了此文件,您也可以下载更广泛支持的CCP4格式的相同数据。那么有没有办法将其转换为文本,而不是隔离特定区域并确定其是否为正电子密度(这将特别适用于fo fc图)?我想您可以检查(插值)使用cctbx在指定位置映射值。也许还可以用PyMOL。或者你可以自己编写代码。
('x start', -20)
('y start', -56)
('z start', -135)
('x extent', 126)
('y extent', 118)
('z extent', 272)
('x sampling rate', 170)
('y sampling rate', 96)
('z sampling rate', 266)
('Header(18) * A Cell Edge', 14912)
('Header(18) * B Cell Edge', 8345)
('Header(18) * C Cell Edge', 23783)
('Header(18) * alfa', 7200)
('Header(18) * beta', 7868)
('Header(18) * gamma', 7200)
('Header(19) (253 -3) /(rmax -rmin)', 1375)
('(3rmax - 253rmin)/(rmax -rmin)]', 80)
('Cell Constant Scaling Factor', 80)
('100', 100)