Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust the tmp file directory in the script #5

Open
conchaeloko opened this issue May 3, 2023 · 0 comments
Open

Adjust the tmp file directory in the script #5

conchaeloko opened this issue May 3, 2023 · 0 comments

Comments

@conchaeloko
Copy link

conchaeloko commented May 3, 2023

Hi all,

Thanks for the tool, I find it very helpful for my research. I may have a question though. I tried running the program in parallel using multiprocess in python but it does not work well, I assume because of the tmp files (file_ca_coo.pdb ,file_proba_contact.mat,file_matrix_pu_contact.mtx and file_pu_delineation.mtx ) overwriting themselves and not allowing a single thread to go through. I have not looked into the script deeply yet but how simple would it be to add the option --tmp that would indicate where the tmp files would be created ?

In case my question is unclear, here is the script I submit on a cluster :

import os 
import subprocess
from multiprocessing.pool import ThreadPool

path_work = "/home/user/"
path_pdb = f"{path_work}/ficheros_28032023/out_minibatch"
path_out = f"{path_work}/ficheros_28032023/sword2_Minibatch"


def sword2_pred(pdb_file) :
    """
    This function makes a sword prediction from a pdb_file.
    It takes as an input a pdb file, and outputs swords2 files.     
    The path_out is to be adjusted to the context.
    """
    with open(f"{path_out}/sword2.log" ,"a+") as outfile :
        path_sword = "/home/user/software/SWORD2"
        name = pdb_file.split("/")[-1].split(".pdb")[0]
        sword_command = f" {path_sword}/SWORD2.py -i {pdb_file} -o {path_out}/{name} -x 5"
        sword_subprocess = subprocess.Popen (sword_command , shell = True, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
        hmm_out, hmm_err = sword_subprocess.communicate()
        print(hmm_out)
        outfile.write(f"{name} is done.")
    
paths = [f"{path_pdb}/{file}" for file in os.listdir(path_pdb) if os.path.isdir(f"{path_out}/{file.split('.pdb')[0]}")==False]
    
if __name__ == '__main__':
    with ThreadPool(8) as p:
        p.map(sword2_pred, paths)

Thanks again !
Best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant