Skip to content

Instantly share code, notes, and snippets.

@chenyuxiang0425
Last active March 9, 2022 10:22
Show Gist options
  • Select an option

  • Save chenyuxiang0425/cf82e6168ae5e998eb42b39fd72de715 to your computer and use it in GitHub Desktop.

Select an option

Save chenyuxiang0425/cf82e6168ae5e998eb42b39fd72de715 to your computer and use it in GitHub Desktop.
Batch run Material Studio files on the server
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)
@chenyuxiang0425
Copy link
Author

chenyuxiang0425 commented Mar 9, 2022

python run_multi_ms_file_in_cloud.py directory_name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment