Last active
March 9, 2022 10:22
-
-
Save chenyuxiang0425/cf82e6168ae5e998eb42b39fd72de715 to your computer and use it in GitHub Desktop.
Batch run Material Studio files on the server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import sys | |
| def get_qstat_length(): | |
| result=os.popen('qstat') | |
| context = result.read() | |
| length=len(context) | |
| result.close() | |
| return length | |
| def add_transferred_meaning(string,keywords_lst): | |
| new_string = "" | |
| for c in string: | |
| if c in keywords_lst: | |
| new_string = new_string + "\\" | |
| new_string = new_string + c | |
| return new_string | |
| def runner(file_dir): | |
| qstat_length=get_qstat_length() | |
| filename_list=os.listdir(file_dir) | |
| i=0 | |
| # If there are already a lot of running files, do not run | |
| if qstat_length > 5000: | |
| return | |
| for index,file in enumerate(filename_list): | |
| # If more than 400 molecules has runned in this file list, stop running | |
| if i > 400: | |
| print(qstat_length) | |
| break | |
| filename = file.split('.car')[0] | |
| filename_transferred = add_transferred_meaning(filename,["(",")","="]) | |
| path=file_dir+filename | |
| command='qsub dmol3.pbs -v case='+str(filename_transferred) | |
| os.chdir(path) | |
| os.system(command) | |
| os.chdir('../../') | |
| i=i+1 | |
| if __name__ == "__main__": | |
| file_dir = './'+sys.argv[1]+'/' | |
| runner(file_dir) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python run_multi_ms_file_in_cloud.py directory_name