pstansfeld / MemProtMD

31 stars 5 forks source link

Here is an error emerging when running “MemProtMD_Insane.ipynb” #1

Open zhenwilliam opened 1 year ago

zhenwilliam commented 1 year ago
截屏2023-03-01 22 05 06 截屏2023-03-01 22 05 19

The error is entitled "FileNotFoundError: [Errno 2] No such file or directory: 'topol.top'"

The error happened in cell 6 and the who script was :

@title Set-up Coarse-Grained Membrane Protein System

%%capture os.chdir(working_dir)

for file in glob.glob(r'/content/martini*.itp'): print(file) shutil.copy(file, working_dir)

gromacs.make_ndx(f='memembed.pdb', o='index.ndx', input=('del 0', 'del 1-100','rDUM','q'),backup=False) gromacs.editconf(f='memembed.pdb',o='centered.pdb',n='index.ndx',c=True,d=3,input=(0,0),backup=False)

u = MDAnalysis.Universe('centered.pdb') x = round(u.dimensions[0]/10) y = round(u.dimensions[1]/10) z = round(u.dimensions[2]/10)

gromacs.confrms(f2='memembed.pdb', f1='centered.pdb', one=True, o='aligned.gro', input=(3,3),backup=False) gromacs.editconf(f='aligned.gro', o='protein.pdb',label='A',resnr=1,n=True,input=(0,0),backup=False)

v = MDAnalysis.Universe('aligned.gro') dum = v.select_atoms('resname DUM')

dm = (z/2) - (round(dum.center_of_mass()[2]/10))

with open('protein.pdb', 'r') as file : filedata = file.read() filedata = filedata.replace('HSE', 'HIS') filedata = filedata.replace('HSD', 'HIS') filedata = filedata.replace('MSE', 'MET') filedata = filedata.replace(' SE ', ' SD ') with open('protein.pdb', 'w') as file: file.write(filedata)

!martinize2 -f protein.pdb -dssp mkdssp -ff martini3001 -x protein-cg.pdb -o protein-cg.top -elastic -ef 500 -eu 1.0 -el 0.5 -ea 0 -ep 0 -merge A -maxwarn 100000 -scfix

!sed -e 's/^molecule./Protein 1/g' molecule.itp > protein-cg.itp

os.system('python2.7 /content/insane3.py ' + lipid + ' -salt 0.15 -sol W -o CG-system.gro -p topol.top -f protein-cg.pdb -center -x %s -y %s -z %s -dm %s' % (x, y, z, dm))

replacements = {'NA+':'NA', 'CL-':'CL', '#include "martini_v3.itp"':'#include "martini_v3.0.0.itp"\n#include "martini_v3.0.0_ions_v1.itp"\n#include "martini_v3.0.0_solvents_v1.itp"\n#include "martini_v3.0.0_phospholipids_v1.itp"\n'} lines = [] with open('topol.top') as infile: for line in infile: for src, target in replacements.items(): line = line.replace(src, target) lines.append(line) with open('topol.top', 'w') as outfile: for line in lines: outfile.write(line) with open('em.mdp','w') as em: em.write('integrator = steep\nnsteps = 5000\nemtol = 1000\nemstep = 0.001')

gromacs.grompp(f='em.mdp',o='em.tpr',c='CG-system.gro',maxwarn='-1',backup=False,v=True)

gromacs.mdrun(deffnm='em', c='CG-system.pdb',backup=False)

gromacs.trjconv(f='CG-system.pdb', o='CG-system.pdb', pbc='res', s='em.tpr', conect=True, input='0',backup=False)

%mkdir MD

gromacs.make_ndx(f='CG-system.pdb', o='index.ndx', input=('del 0', 'del 1-40', '0|rPOP*','1&!0','!1','del 1','name 1 Lipid','name 2 SOL_ION','q'),backup=False)

with open('cgmd.mdp','w') as md: md.write('integrator = md\ntinit = 0.0\ndt = 0.02\nnsteps = 10000\nnstxout = 0\nnstvout = 0\nnstfout = 0\nnstlog = 50000\nnstenergy = 50000\nnstxout-compressed = 50000\ncompressed-x-precision = 10000\nnstlist = 10\nns_type = grid\npbc = xyz\ncoulombtype = Reaction_field\nrcoulomb_switch = 0.0\nrcoulomb = 1.1\nepsilon_r = 15\nvdw_type = cutoff\nrvdw_switch = 0.9\nrvdw = 1.1\ncutoff-scheme = verlet\ncoulomb-modifier = Potential-shift\nvdw-modifier = Potential-shift\nepsilon_rf = 0\nverlet-buffer-tolerance = 0.005\ntcoupl = v-rescale\ntc-grps = PROTEIN LIPID SOL_ION\ntau_t = 1.0 1.0 1.0\nref_t = 310 310 310\nPcoupl = c-rescale\nPcoupltype = semiisotropic\ntau_p = 12.0\ncompressibility = 3e-4 3e-4\nref_p = 1.0 1.0\ngen_vel = yes\ngen_temp = 310\ngen_seed = -1\nconstraints = none\nconstraint_algorithm = Lincs\ncontinuation = no\nlincs_order = 4\nlincs_warnangle = 30\n')

gromacs.grompp(f='cgmd.mdp',o='MD/md',c='CG-system.pdb',maxwarn=-1, n='index.ndx',backup=False)

zhenwilliam commented 1 year ago

Dear Dr. @pstansfeld, Do you know what happened herein and how to fix this bug? Although I am not a computer science student, I am hopeful that this bug can be fixed to make this wonderful Colab Notebook more accessible to others.

I am eager to resolve this issue and was wondering if you could provide any insights on how to fix it. If it would be helpful, I would be happy to provide additional information or assist with troubleshooting.

Thank you for your help, and please let me know if there is anything else I can provide to assist.

Best regards, zhenwilliam

zhenwilliam commented 1 year ago

I have found a solution or workaround to the problem. Instead of using the "NA+" and "CL-" symbols in the script of cell 6, it appears that "SOD" and "CLA" are currently the adopted symbols for sodium and chloride ions, respectively. Therefore, I suggest replacing the symbols for representations of "NA" and "CL" with "SOD" and "CLA" respectively. This change will ensure that the correct symbols are used and that the issue is resolved.

This solution/workaround was inspired by a discussion thread on the Gromacs Forum, which I found at 🔗 https://gromacs.bioexcel.eu/t/error-1-file-topol-top-line-62-no-such-moleculetype-cl/4504/2.