def process_serial(binary, input_file): """ Runs the apbs binary on a given input file """ # First extract the name of the input file's base name base_name = input_file.split(".")[0] # The output file should have the same basename output_name = f"{base_name}.out" # Ensure that there are sufficient permissions to write to the output file output_file = open(output_name, "w") # Construct the system command and make the call command = [r"{}".format(binary), input_file] print(f"BINARY: {binary}") print(f"INPUT: {input_file}") print(f"COMMAND: {command}") with subprocess.Popen( command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) as proc: line = str(proc.stdout.read(), "utf-8") sys.stdout.write(line) output_file.write(line) # Look for the results in the output file output_file = open(output_name, "r") output_text = output_file.read() # Look for intermidiate energy results output_results = check_energies(output_name) output_pattern = r"Global net (?:ELEC|APOL) energy \= " + FLOAT_PATTERN output_results2 = [ float(r) for r in re.findall(output_pattern, output_text) ] output_results += output_results2 # Return all the matched results as a list of floating point numbers return output_results
def process_serial(binary, input_file): """ Runs the apbs binary on a given input file """ # First extract the name of the input file's base name base_name = input_file.split('.')[0] # The output file should have the same basename output_name = '%s.out' % base_name # Ensure that there are sufficient permissions to write to the output file output_file = open(output_name, 'w') # Construct the system command and make the call command = [binary, input_file] proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) for line in proc.stdout: sys.stdout.write(line) output_file.write(line) proc.wait() # Look for the results in the output file output_file = open(output_name, 'r') output_text = output_file.read() # Look for intermidiate energy results output_results = check_energies(output_name) output_pattern = r'Global net (?:ELEC|APOL) energy \= ' + float_pattern output_results2 = [ float(r) for r in re.findall(output_pattern, output_text) ] output_results += output_results2 # Return all the matched results as a list of floating point numbers return output_results
def process_serial( binary, input_file ): """ Runs the apbs binary on a given input file """ # First extract the name of the input file's base name base_name = input_file.split('.')[0] # The output file should have the same basename output_name = '%s.out' % base_name # Ensure that there are sufficient permissions to write to the output file output_file = open( output_name, 'w' ) # Construct the system command and make the call command = [ binary, input_file ] proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) for line in proc.stdout: sys.stdout.write(line) output_file.write(line) proc.wait() # Look for the results in the output file output_file = open( output_name, 'r' ) output_text = output_file.read() # Look for intermidiate energy results output_results = check_energies(output_name) output_pattern = r'Global net (?:ELEC|APOL) energy \= ' + float_pattern output_results2 =[float( r ) for r in re.findall( output_pattern, output_text )] output_results += output_results2 # Return all the matched results as a list of floating point numbers return output_results