def main(): '''main method.''' filename = os.path.realpath(__file__) with open(filename) as protocol_file: runlog, _ = simulate.simulate(protocol_file, filename) print(simulate.format_runlog(runlog))
def simulate_program(self): """ This will run an Opentrons simulation on the program. """ # If we have a critical error then don't do anything else. if self.critical_error: return # Select program file if not located where we think it is. if not os.path.isfile(self.path_to_program): self.path_to_program, _ = \ QtWidgets.QFileDialog.getOpenFileName(self, self.tr("Select Program File"), self.tr("C:{0}Users{0}{1}{0}Documents{0}" .format(os.sep, os.getlogin()))) self.info_report('If you do not get a "Success" notice then the simulation failed.\nSee the terminal window ' 'for the reason') protocol_file = open(self.path_to_program) labware_location = "{}{}custom_labware".format(os.path.dirname(self.path_to_program), os.sep) run_log, __bundle__ = simulate(protocol_file, custom_labware_paths=[labware_location], propagate_logs=False) # Write the simulation steps to a file simulation_date = datetime.datetime.today().strftime("%a %b %d %H:%M %Y") outfile = open("C:{0}Users{0}{1}{0}Documents{0}{2}_Simulation.txt" .format(os.sep, os.getlogin(), self.selected_program), 'w', encoding="UTF-16") step_number = 1 t = format_runlog(run_log).split("\n") outstring = "Opentrons OT-2 Steps.\nDate: {}\nProgram File: {}\nTSV File: {}\n\nStep\tCommand\n"\ .format(simulation_date, self.selected_program, self.path_to_tsv) for line in t: outstring += "{}\t{}\n".format(step_number, line) step_number += 1 outfile.write(outstring) outfile.close() # Write the simulation steps to the GUI self.run_simulation_output.insertPlainText(format_runlog(run_log)) protocol_file.close()
water_aspirated += right_dispensed_vol water_tip_height = res_tip_height(initial_water_volume-water_aspirated, water_res_well_dia, cone_vol) count += 1 left_pipette.drop_tip() right_pipette.drop_tip() if __name__ == "__main__": protocol_file = open('Dispensing_Test.py') labware_path = "{}{}custom_labware".format(os.getcwd(), os.sep) run_log, __bundle__ = simulate(protocol_file, custom_labware_paths=[labware_path]) run_date = datetime.datetime.today().strftime("%a %b %d %H:%M %Y") i = 1 t = format_runlog(run_log).split("\n") outstring = "Opentrons OT-2 Steps for {}.\nDate: {}\nProgram File: Dispensing_Test.py\n\nStep\tCommand\n" \ .format(metadata['protocolName'], run_date) for l in t: outstring += "{}\t{}\n".format(i, l) i += 1 if platform.system() == "Windows": outfile = open("C:{0}Users{0}{1}{0}Documents{0}Dispensing_Simulation.txt" .format(os.sep, os.getlogin()), 'w', encoding="UTF-16") outfile.write(outstring) outfile.close() protocol_file.close()
#SV200907 - module for simulating opentrons protocols # Import statements from opentrons.simulate import simulate, format_runlog # Read file protocol_file = open( "C:/Users/svreugdenhil/Documents/GitHub/OT2/mollab_protocols/primer_aliquots/illu_primer.py" ) # Simulate protocol runlog, _bundle = simulate(protocol_file) # Print runlog print(format_runlog(runlog))
# -*- coding: utf-8 -*- """ Created on Mon May 25 18:43:58 2020 @author: Trevor Ho """ #%% Simulation from opentrons.simulate import simulate, format_runlog protocol_filename = 'Test_script.py' # TODO: change this for a new file protocol_file = open(protocol_filename) runlog = simulate(protocol_file, file_name='') print(format_runlog(runlog[0])) # Line modified compared to Opentrons Doc #%% Export simulated log file for documentation simulated_log_filename = protocol_filename.split('.py')[0] + '_log.txt' simulated_log = open(simulated_log_filename, 'w+') simulated_log.write(format_runlog(runlog[0])) simulated_log.close()
from opentrons import simulate, robot filepath = "tpeng/OneDrive/OD__Universität/BA__Axmann/PlateScripts/" outpath = "tpeng/OneDrive/OD__Universität/BA__Axmann/protocol_simulations/" filename = "P03_OTV1_GlcGradientONECELL_BigFalconRack" PC = False print_output = False if PC: header = "D:/" else: header = "C:/Users/" protocol_file = open(header + filepath + filename + ".py") robot.reset() runlog = simulate.simulate(protocol_file, file_name=filename + ".py") protocol_file.close() if print_output: print(simulate.format_runlog(runlog[0])) else: file = open(header + outpath + filename + "_out.txt", "w") file.write(simulate.format_runlog(runlog[0])) file.close() robot.reset()