Пример #1
0
'''
Created on 2015/06/03
@author: Naoto Hori
'''
import sys
import math
import numpy as np
from cafysis.lib_f2py import py_distance2_hist
from cafysis.file_io.dcd import DcdFile
from cafysis.file_io.psf import PsfFile

if len(sys.argv) != 4:
    print ('\n Usage: SCRIPT [input DCD] [input PSF] [output]\n')
    sys.exit(2)
    
psffile = PsfFile(sys.argv[2])
psffile.open_to_read()
psf = psffile.read_all()

dcd = DcdFile(sys.argv[1])

id0_Mg = []
id0_P  = []
id0_K  = []
id0_Cl = []
for i,a in enumerate(psf.atoms):
    if a.atom_name.strip() == 'P':
        id0_P.append(i)
    elif a.atom_name.strip() == 'Mg':
        id0_Mg.append(i)
    elif a.atom_name.strip() == 'K':
Пример #2
0
            a.atom_type = 'P'
            a.charge = -1.0
        a.res_id = ires
        a.res_name = 'R'
        psfdata.atoms.append(a)

    for i in range(2, nmp + 1):
        if i % 3 == 1:  #S
            psfdata.bonds.append((i - 1, i))
        elif i % 3 == 2:  #B
            psfdata.bonds.append((i - 1, i))
        elif i % 3 == 0:  #P
            psfdata.bonds.append((i - 2, i))

    # Write to file
    fpsf = PsfFile(filepath_psf)
    fpsf.open_to_write()
    fpsf.write_all(psfdata)
    fpsf.close()

# Calculate number of steps from file sieze
crdsize = os.path.getsize(filepath_crd)
num_step = crdsize / 8 / 3 / (nmp + 1)

crd = CoordFile(filepath_crd, nmp)
crd.open_to_read()

header = DcdHeader()
header.nset = num_step
header.istart = 1
header.nstep_save = 1