Skip to content

Commit

Permalink
fix: commands download, log generation, trjconv echo
Browse files Browse the repository at this point in the history
  • Loading branch information
ivopr committed Jan 2, 2023
1 parent ca5f540 commit 129015e
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 25 deletions.
2 changes: 1 addition & 1 deletion app/blueprints/download/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def commandsdownload(mode, protein, folder):
#move os arquivos .xvg para a pasta graficos.
for folder, subfolders, files in os.walk(folder_run_path):
for file in files:
if file.endswith('_PBC.xtc') or file.endswith('complx_pr.tpr'):
if file.endswith('_PBC.xtc') or file.endswith('_pr.tpr'):
zf.write(os.path.join(folder, file), file, compress_type=zipfile.ZIP_DEFLATED)

zf.close()
Expand Down
4 changes: 2 additions & 2 deletions app/blueprints/dynamic/executors/acpype.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def execute(folder, CommandsFileName, username, filename, itpname, groname, mol)

## comando 1
comando_gerar_molecula_complexada = 'cat {}_livre.top | sed \'/forcefield\.itp\"/a\#include "{}"\' >| {}1_complx.top'.format(mol,itpname,mol)
with open(os.path.join(folder, "run", "logs", f"dynamic-log.log"), 'a') as f:
with open(os.path.join(folder, "run", "logs", f"linux-commands.log"), 'a') as f:
subprocess.call(comando_gerar_molecula_complexada, shell=True, stdin=f, stdout=f, stderr=f)

with open(os.path.join(RunFolder, f"{mol}1_complx.top"), "r") as f:
Expand All @@ -104,7 +104,7 @@ def execute(folder, CommandsFileName, username, filename, itpname, groname, mol)

#aqui vai o echo ligand 1
comando_moleculetype = 'echo "{}" >> {}_complx.top'.format(molecula,mol)
with open(os.path.join(folder, "run", "logs", f"dynamic-log.log"), 'a') as f:
with open(os.path.join(folder, "run", "logs", f"linux-commands.log"), 'a') as f:
subprocess.call(comando_moleculetype, shell=True, stdin=f, stdout=f, stderr=f)

with open(os.path.join(folder, 'status'), 'w') as f:
Expand Down
4 changes: 2 additions & 2 deletions app/blueprints/dynamic/executors/apo.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def execute(folder, CommandsFileName, username, filename):
f.write(f"{folder}\n")

with open(os.path.join(Config.UPLOAD_FOLDER, username, "log_dir"), "w") as f:
f.write(os.path.join(folder, "run", "logs", f"dynamic-log.log"))
f.write(os.path.join(folder, "run", "logs", f"gmx-commands.log"))

#abrir arquivo
with open(CommandsFileName) as f: #CODIGO PARA A PRODUÇÃO
Expand All @@ -39,7 +39,7 @@ def execute(folder, CommandsFileName, username, filename):
WriteUserDynamics(l, username)
else:
os.chdir(RunFolder)
rcode = run_dynamics_command(l, os.path.join(folder, "run", "logs", f"dynamic-log.log"))
rcode = run_dynamics_command(l, os.path.join(folder, "run", "logs", f"gmx-commands.log"))

if rcode != 0:
with open(os.path.join(folder, 'status'), 'w') as f:
Expand Down
2 changes: 1 addition & 1 deletion app/blueprints/dynamic/generators/acpype.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def generate(folder, file_orig, file_itp_orig, file_gro_orig, force_field, water
f"{gmx} grompp -f md_pr.mdp -c \"{filename}_complx_npt.gro\" -p \"{filename}_complx.top\" -o \"{filename}_complx_pr.tpr\" -maxwarn 20\n",
f"{gmx} mdrun -v -s \"{filename}_complx_pr.tpr\" -deffnm \"{filename}_complx_pr\"\n\n",
"#analyzemd\n",
f"echo \"1 0\" | {gmx} trjconv -s \"{filename}_complx_pr.tpr\" -f \"{filename}_complx_pr.xtc\" -o \"{filename}_complx_pr_PBC.xtc\" -pbc mol -center\n",
f"echo \"1 17\" | {gmx} trjconv -s \"{filename}_complx_pr.tpr\" -f \"{filename}_complx_pr.xtc\" -o \"{filename}_complx_pr_PBC.xtc\" -pbc mol -center\n",
f"echo \"4 4\" | {gmx} rms -s \"{filename}_complx_pr.tpr\" -f \"{filename}_complx_pr_PBC.xtc\" -o \"{filename}_complx_rmsd_prod.xvg\" -tu ns\n",
f"{grace} -nxy \"{filename}_complx_rmsd_prod\".xvg -hdevice PNG -hardcopy -printfile \"../graficos/{filename}_complx_rmsd_prod.png\"\n",
f"echo \"4 4\" | {gmx} rms -s \"{filename}_complx_pr.tpr\" -f \"{filename}_complx_pr_PBC.xtc\" -o \"{filename}_complx_rmsd_cris.xvg\" -tu ns\n",
Expand Down
4 changes: 2 additions & 2 deletions app/blueprints/dynamic/generators/apo.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def generate(folder, file_orig, force_field, water_model, box_type, box_distance
if neutralize:
commands.extend([
f"echo 'SOL' | {gmx} genion -s \"{filename}_charged.tpr\" -o \"{filename}_charged\" -p \"{filename}.top\" -neutral\n\n",
"#minimizationsteepdesc\n\n",
"#minimizationsteepdesc\n",
f"{gmx} grompp -f PME_em.mdp -c \"{filename}_charged.gro\" -p \"{filename}.top\" -o \"{filename}_charged\" -maxwarn 2\n",
f"{gmx} mdrun -v -s \"{filename}_charged.tpr\" -deffnm \"{filename}_sd_em\"\n",
f"echo '10 0' | {gmx} energy -f \"{filename}_sd_em.edr\" -o \"{filename}_potentialsd.xvg\"\n",
Expand All @@ -67,7 +67,7 @@ def generate(folder, file_orig, force_field, water_model, box_type, box_distance
f"{gmx} grompp -f md_pr.mdp -c \"{filename}_npt.gro\" -p \"{filename}.top\" -o \"{filename}_pr\" -maxwarn 2\n",
f"{gmx} mdrun -v -s \"{filename}_pr.tpr\" -deffnm \"{filename}_pr\"\n\n",
"#analyzemd\n",
f"echo '1 0' | {gmx} trjconv -s \"{filename}_pr.tpr\" -f \"{filename}_pr.xtc\" -o \"{filename}_pr_PBC.xtc\" -pbc mol -center\n",
f"echo '1 16' | {gmx} trjconv -s \"{filename}_pr.tpr\" -f \"{filename}_pr.xtc\" -o \"{filename}_pr_PBC.xtc\" -pbc mol -center\n",
f"echo '4 4' | {gmx} rms -s \"{filename}_pr.tpr\" -f \"{filename}_pr_PBC.xtc\" -o \"{filename}_rmsd_prod.xvg\" -tu ns\n",
f"{grace} -nxy \"{filename}_rmsd_prod.xvg\" -hdevice PNG -hardcopy -printfile \"../graficos/{filename}_rmsd_prod.png\"\n",
f"echo '4 4' | {gmx} rms -s \"{filename}_charged.tpr\" -f \"{filename}_pr_PBC.xtc\" -o \"{filename}_rmsd_cris.xvg\" -tu ns\n",
Expand Down
4 changes: 2 additions & 2 deletions app/blueprints/dynamic/generators/prodrg.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def generate(folder, file_orig, file_itp_orig, file_gro_orig, force_field, water
commands = [
"#topology\n",
f"{gmx} pdb2gmx -f \"{filename}{ext}\" -o \"{filename}_livre.gro\" -p \"{filename}_livre.top\" -ff gromos53a6 -water {water_model} -ignh -missing\n\n",
"#break\n\n",
"#break\n",
f"{gmx} editconf -f \"{filename}_complx.gro\" -c -d 1 -bt {box_type} -o \"{filename}_complx.gro\"\n",
"#solvate\n",
f"{gmx} solvate -cp \"{filename}_complx.gro\" -cs spc216.gro -p \"{filename}_complx.top\" -o \"{filename}_complx_box.gro\"\n\n",
Expand Down Expand Up @@ -55,7 +55,7 @@ def generate(folder, file_orig, file_itp_orig, file_gro_orig, force_field, water
f"{gmx} grompp -f md_pr.mdp -c \"{filename}_complx_npt.gro\" -p \"{filename}_complx.top\" -o \"{filename}_complx_pr.tpr\" -maxwarn 2\n",
f"{gmx} mdrun -v -s \"{filename}_complx_pr.tpr\" -deffnm \"{filename}_complx_pr\"\n\n",
"#analyzemd\n",
f"echo \"1 0\" | {gmx} trjconv -s \"{filename}_complx_pr.tpr\" -f \"{filename}_complx_pr.xtc\" -o \"{filename}_complx_pr_PBC.xtc\" -pbc mol -center\n",
f"echo \"1 17\" | {gmx} trjconv -s \"{filename}_complx_pr.tpr\" -f \"{filename}_complx_pr.xtc\" -o \"{filename}_complx_pr_PBC.xtc\" -pbc mol -center\n",
f"echo \"4 4\" | {gmx} rms -s \"{filename}_complx_pr.tpr\" -f \"{filename}_complx_pr_PBC.xtc\" -o \"{filename}_complx_rmsd_prod.xvg\" -tu ns\n",
f"{grace} -nxy \"{filename}_complx_rmsd_prod.xvg\" -hdevice PNG -hardcopy -printfile \"../graficos/{filename}_complx_rmsd_prod.png\"\n",
f"echo \"4 4\" | {gmx} rms -s \"{filename}_complx_pr.tpr\" -f \"{filename}_complx_pr_PBC.xtc\" -o \"{filename}_complx_rmsd_cris.xvg\"\n",
Expand Down
27 changes: 12 additions & 15 deletions app/blueprints/dynamic/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ def apo():
if request.form.get('download') == 'Download':
return redirect(
url_for(
'DownloadRoutes.commandsdownload',
filename={
"complete": CompleteFileName,
"name": filename
}
'DownloadRoutes.dynamiccomandsdownload',
folder=f"{timestamp}",
mode="apo",
protein=filename
)
)

Expand Down Expand Up @@ -113,11 +112,10 @@ def prodrg():
if request.form.get('download') == 'Download':
return redirect(
url_for(
'DownloadRoutes.commandsdownload',
filename={
"complete": CompleteFileName,
"name": name
}
'DownloadRoutes.dynamiccomandsdownload',
folder=f"{timestamp}",
mode="prodrg",
protein=f"{filename}_{fileitpname}_{filegroname}"
)
)

Expand Down Expand Up @@ -189,11 +187,10 @@ def acpype():
if request.form.get('download') == 'Download':
return redirect(
url_for(
'DownloadRoutes.commandsdownload',
filename={
"complete": CompleteFileName,
"name": name
}
'DownloadRoutes.dynamiccomandsdownload',
folder=f"{timestamp}",
mode="acpype",
protein=f"{filename}_{fileitpname}_{filegroname}"
)
)

Expand Down

0 comments on commit 129015e

Please sign in to comment.