How to use maker method in hypothesis

Best Python code snippet using hypothesis

makerbotHBP.py

Source:makerbotHBP.py Github

copy

Full Screen

1import nc2import makerbot_codes as maker3import datetime4import iso_modal5import math678now = datetime.datetime.now()910################################################################################11class CreatorMakerbotHBP(iso_modal.CreatorIsoModal):12 def __init__(self):13 iso_modal.CreatorIsoModal.__init__(self)1415 self.absolute_flag = True16 self.prev_g91 = ''171819################################################################################20# program begin and end2122 def program_begin(self, id, name=''):23 self.write((maker.codes.COMMENT(now)))24 self.write((maker.codes.EXTRUDER_TEMP('220')) + (maker.codes.COMMENT('Extruder Temp')) )25 self.write((maker.codes.BUILD_BED_TEMP('110'))+ (maker.codes.COMMENT('Build Bed Temp')) )26 self.write((maker.codes.FAN_OFF()) + (maker.codes.COMMENT('Fan Off')) )27 self.write((maker.codes.METRIC()) + (maker.codes.COMMENT('Metric units')) )28 self.write((maker.codes.ABSOLUTE()) + (maker.codes.COMMENT('Absolute units')) )29 self.write('G92 X0 Y0 Z0 (You are now at 0,0,0)\n')30 self.write('G0 Z15 (Move up for warmup)\n')31 self.write((maker.codes.EXTRUDER_SPEED_PWM('255')) + (maker.codes.COMMENT('Extruder Speed')) )32 self.write('M6 T0 (Wait for tool to heat up)\n')33 self.write('G04 P5000 (Wait 5 seconds)\n')34 self.write((maker.codes.EXTRUDER_ON_FWD()) + (maker.codes.COMMENT('Extruder On')) )35 self.write('G04 P5000 (Wait 5 seconds)\n')36 self.write((maker.codes.EXTRUDER_OFF()) + (maker.codes.COMMENT('Extruder Off')) )37 self.write('M01 (The heated build platform is heating up. Wait until after the lights have turned off for the first time, clear the test extrusion, and click yes.)\n')38 self.write('G0 Z0 (Go back to zero.)\n')3940 def program_end(self):41 self.write((maker.codes.COMMENT('End of the file. Begin cool-down')))42 self.write((maker.codes.EXTRUDER_TEMP('0')) + (maker.codes.COMMENT('Extruder Temp')) )43 self.write((maker.codes.BUILD_BED_TEMP('0')) + (maker.codes.COMMENT('Build Bed Temp')) )44 self.write((maker.codes.FAN_ON()) + (maker.codes.COMMENT('Fan On')) )45 self.write('G92 Z0 (zero our z axis - hack b/c skeinforge mangles gcodes in end.txt)\n')46 self.write('G1 Z10 (go up 10 b/c it was zeroed earlier.)\n')47 self.write('G1 X0 Y0 Z10 (go to 0,0,z)\n')48 self.write((maker.codes.STEPPERS_OFF()) + (maker.codes.COMMENT('Steppers Off')) )4950 def program_stop(self):51 self.write((maker.codes.EXTRUDER_TEMP('0')))52 self.write((maker.codes.BUILD_BED_TEMP('0')))53 self.write((maker.codes.STEPPERS_OFF()))54 55################################################################################56# general57 def write_blocknum(self):58 pass5960 def set_plane(self, plane):61 pass62 63 def workplane(self, id):64 pass65 66 def spindle(self, s, clockwise):67 pass68################################################################################69# Extruder Control70 71 def extruder_on(self):72 self.write((maker.codes.EXTRUDER_ON()) + ('\n'))73 74 def extruder_off(self):75 self.write((maker.codes.EXTRUDER_OFF()) + ('\n'))76 77 def set_extruder_flowrate(self, flowrate):78 self.write((maker.codes.EXTRUDER_SPEED_PWM(flowrate)) + ('\n'))7980 def extruder_temp(self, temp):81 self.write((maker.codes.EXTRUDER_TEMP(temp)) + ('\n'))82 83################################################################################84# Build Environment Control85 def build_bed_temp(self, temp):86 self.write((maker.codes.BUILD_BED_TEMP(temp)) + ('\n'))87 88 def chamber_temp(self, temp):89 self.write((maker.codes.CHAMBER_TEMP(temp)) + ('\n')) 90 91################################################################################92# Fan Control93 def fan_on(self):94 self.write((maker.codes.FAN_ON()) + ('\n'))95 96 def fan_off(self):97 self.write((maker.codes.FAN_OFF()) + ('\n'))98 99################################################################################100# Custom routines101102 def wipe(self):103 self.write(('(This would be a good place for a custom wipe routine)\n'))104105################################################################################106# APT style INSERT- insert anything into program107108 def insert(self, text):109 self.write((text + '\n'))110111################################################################################112# tool info113 def tool_change(self, id):114 pass115 # self.write_blocknum()116 # self.write((maker.codes.TOOL() % id) + '\n')117 # self.t = id118 119 def tool_defn(self, id, name='', params=None):120 pass121############################################################################122## Moves123124 def rapid(self, x=None, y=None, z=None, a=None, b=None, c=None ):125 self.write_blocknum()126 if self.g0123_modal:127 if self.prev_g0123 != maker.codes.RAPID():128 self.write(maker.codes.RAPID())129 self.prev_g0123 = maker.codes.RAPID()130 else:131 self.write(maker.codes.RAPID())132 self.write_preps()133 if (x != None):134 dx = x - self.x135 if (self.absolute_flag ):136 self.write(maker.codes.X() + (self.fmt % x))137 else:138 self.write(maker.codes.X() + (self.fmt % dx))139 self.x = x140 if (y != None):141 dy = y - self.y142 if (self.absolute_flag ):143 self.write(maker.codes.Y() + (self.fmt % y))144 else:145 self.write(maker.codes.Y() + (self.fmt % dy))146147 self.y = y148 if (z != None):149 dz = z - self.z150 if (self.absolute_flag ):151 self.write(maker.codes.Z() + (self.fmt % z))152 else:153 self.write(maker.codes.Z() + (self.fmt % dz))154155 self.z = z156157 if (a != None):158 da = a - self.a159 if (self.absolute_flag ):160 self.write(maker.codes.A() + (self.fmt % a))161 else:162 self.write(maker.codes.A() + (self.fmt % da))163 self.a = a164165 if (b != None):166 db = b - self.b167 if (self.absolute_flag ):168 self.write(maker.codes.B() + (self.fmt % b))169 else:170 self.write(maker.codes.B() + (self.fmt % db))171 self.b = b172173 if (c != None):174 dc = c - self.c175 if (self.absolute_flag ):176 self.write(maker.codes.C() + (self.fmt % c))177 else:178 self.write(maker.codes.C() + (self.fmt % dc))179 self.c = c180 self.write_spindle()181 self.write_misc()182 self.write('\n')183184 def feed(self, x=None, y=None, z=None, a = None, b = None, c = None):185 if self.same_xyz(x, y, z): return186 self.write_blocknum()187 if self.g0123_modal:188 if self.prev_g0123 != maker.codes.FEED():189 self.write(maker.codes.FEED())190 self.prev_g0123 = maker.codes.FEED()191 else:192 self.write(maker.codes.FEED())193 self.write_preps()194 dx = dy = dz = 0195 if (x != None):196 dx = x - self.x197 if (self.absolute_flag ):198 self.write(maker.codes.X() + (self.fmt % x))199 else:200 self.write(maker.codes.X() + (self.fmt % dx))201 self.x = x202 if (y != None):203 dy = y - self.y204 if (self.absolute_flag ):205 self.write(maker.codes.Y() + (self.fmt % y))206 else:207 self.write(maker.codes.Y() + (self.fmt % dy))208209 self.y = y210 if (z != None):211 dz = z - self.z212 if (self.absolute_flag ):213 self.write(maker.codes.Z() + (self.fmt % z))214 else:215 self.write(maker.codes.Z() + (self.fmt % dz))216217 self.z = z218 if (self.fhv) : self.calc_feedrate_hv(math.sqrt(dx*dx+dy*dy), math.fabs(dz))219 self.write_feedrate()220 self.write_spindle()221 self.write_misc()222 self.write('\n')223224 def same_xyz(self, x=None, y=None, z=None):225 if (x != None):226 if (self.fmt % x) != (self.fmt % self.x):227 return False228 if (y != None):229 if (self.fmt % y) != (self.fmt % self.y):230 return False231 if (z != None):232 if (self.fmt % z) != (self.fmt % self.z):233 return False234 235 return True236237 def arc(self, cw, x=None, y=None, z=None, i=None, j=None, k=None, r=None):238 if self.same_xyz(x, y, z): return239 self.write_blocknum()240 arc_g_code = ''241 if cw: arc_g_code = maker.codes.ARC_CW()242 else: arc_g_code = maker.codes.ARC_CCW()243 if self.g0123_modal:244 if self.prev_g0123 != arc_g_code:245 self.write(arc_g_code)246 self.prev_g0123 = arc_g_code247 else:248 self.write(arc_g_code)249 self.write_preps()250 if (x != None):251 dx = x - self.x252 if (self.absolute_flag ):253 self.write(maker.codes.X() + (self.fmt % x))254 else:255 self.write(maker.codes.X() + (self.fmt % dx))256 self.x = x257 if (y != None):258 dy = y - self.y259 if (self.absolute_flag ):260 self.write(maker.codes.Y() + (self.fmt % y))261 else:262 self.write(maker.codes.Y() + (self.fmt % dy))263 self.y = y264 if (z != None):265 dz = z - self.z266 if (self.absolute_flag ):267 self.write(maker.codes.Z() + (self.fmt % z))268 else:269 self.write(maker.codes.Z() + (self.fmt % dz))270 self.z = z271 if (i != None) : self.write(maker.codes.CENTRE_X() + (self.fmt % i))272 if (j != None) : self.write(maker.codes.CENTRE_Y() + (self.fmt % j))273 if (k != None) : self.write(maker.codes.CENTRE_Z() + (self.fmt % k))274 if (r != None) : self.write(maker.codes.RADIUS() + (self.fmt % r))275# use horizontal feed rate276 if (self.fhv) : self.calc_feedrate_hv(1, 0)277 self.write_feedrate()278 self.write_spindle()279 self.write_misc()280 self.write('\n')281282 def arc_cw(self, x=None, y=None, z=None, i=None, j=None, k=None, r=None):283 self.arc(True, x, y, z, i, j, k, r)284285 def arc_ccw(self, x=None, y=None, z=None, i=None, j=None, k=None, r=None):286 self.arc(False, x, y, z, i, j, k, r)287288 def dwell(self, t):289 self.write_blocknum()290 self.write_preps()291 self.write(maker.codes.DWELL() + (maker.codes.TIME() % t))292 self.write_misc()293 self.write('\n')294295 def rapid_home(self, x=None, y=None, z=None, a=None, b=None, c=None):296 pass297298 def rapid_unhome(self):299 pass300301 def set_machine_coordinates(self):302 self.write(maker.codes.MACHINE_COORDINATES())303 self.prev_g0123 = ''304305nc.creator = CreatorMakerbotHBP() ...

Full Screen

Full Screen

maker.smk

Source:maker.smk Github

copy

Full Screen

1# split the maker.gff base on the 2nd column2rule generate_output:3 input: "maker/maker_annotation.gff"4 output: "maker.gff"5 run:6 maker = open("maker.gff", "w")7 abinit = open("abinit.gff", "w")8 other = open("other.gff", "w")9 with open(input[0]) as f:10 for line in f:11 rec = line.strip().split('\t')12 if len(rec) < 9:13 continue14 if rec[1] == 'maker':15 maker.write(line)16 elif "masked" in rec[1]:17 abinit.write(line)18 else:19 other.write(line)20 maker.close()21 abinit.close()22 other.close()23# rule to generate maker.gff24rule maker_annotation_output:25 input: "status/maker_annotation.done"26 params:27 base_name = "maker/maker_annotation",28 dsindex = "{ds}.maker.output/{ds}_master_datastore_index.log".format(ds=specie_name)29 output: 30 gff = "maker/maker_annotation.gff",31 protein = "maker/maker_annotation.all.maker.proteins.fasta",32 transcript = "maker/maker_annotation.all.maker.transcripts.fasta" 33 shell:"""34 fasta_merge -o {params.base_name} -d {params.dsindex} && 35 gff3_merge -o {output} -d {params.dsindex}36 """37# CTL file rules38def add_param_to_setting(settings, params):39 if len(params) == 0:40 return settings41 for param in params:42 key,value = param.split("=")43 settings[key] = value44 return settings45def get_maker_config(wildcards):46 maker_ctl = wildcards.ctl47 maker_type = wildcards.type48 json_file = ".maker_{}_{}_parameter.json".format(maker_ctl, maker_type)49 settings = dict()50 51 # maker round52 if maker_type.find("round") >= 0:53 round = int(maker_type[5:])54 elif maker_type == "base":55 round = 156 else:57 round = -1 # prediction58 # get the params59 if round > 0:60 params = config['round'+str(round)].get(maker_ctl,"")61 else:62 params = config['prediciton'].get(maker_ctl,"")63 64 if maker_ctl == "bopts" or maker_ctl == "exe": # bopts and exe65 settings = add_param_to_setting(settings, params)66 else: # opts setting67 # default settings68 settings['genome'] = reference69 if protein is not None:70 settings['protein'] = protein71 if transcript_fasta is not None:72 settings['est'] = ','.join(transcript_fasta) 73 # set the gff3 in est_gff74 if transcript_assemble:75 settings['est_gff'] = ','.join(all_gff3)76 else:77 settings['est_gff'] = gtf 78 if maker_type == "annotation":79 # training model: setting snap, hmm 80 if training_model:81 if snap_rounds != '0':82 settings['snaphmm'] = "gene_model/snap_round{}.hmm".format(snap_rounds[-1])83 if augustus_rounds != '0':84 settings["augustus_species"] = specie_name85 else: 86 settings['snaphmm'] = snaphmm87 settings['augustus_species'] = augustus_species88 if maker_type == "base": # train round = 189 if snaphmm or augustus_species:90 settings['snaphmm'] = snaphmm91 settings['augustus_species'] = augustus_species92 else:93 settings['est2genome'] = '1'94 if protein is not None:95 settings['protein2genome'] = '1'96 97 if maker_type.find("round") >= 0: # train round > 198 if str(round-1) in snap_rounds :99 settings['snaphmm'] = "gene_model/snap_round{}.hmm".format(round-1)100 if str(round-1) in augustus_rounds :101 settings["augustus_species"] = specie_name102 settings = add_param_to_setting(settings, params)103 # dump the settings to json104 with open(json_file, "w") as f:105 json.dump(settings, f)106 return os.path.abspath(json_file)107# return the input base on the training_model and transcript_assemble108def get_maker_ctl_input(wildcards):109 maker_ctl = wildcards.ctl110 maker_type = wildcards.type111 112 input_dict = {113 "ctl" : "maker_{ctl}.ctl".format(ctl=maker_ctl)114 }115 if maker_ctl == "bopts" or maker_ctl == "exe":116 return input_dict117 if maker_type == "annotation":118 if training_model:119 input_dict['train'] = "status/model_training_round{round}.done".format(round=max_round)120 #print(input_dict)121 return input_dict122 elif transcript_assemble:123 input_dict['gtf'] = "status/transcript_assemble.done"124 #print(input_dict)125 return input_dict126 elif check_gff(gtf):127 return input_dict128 else:129 log_exception("gtf not exists")130 if maker_type == "base":131 #print(input_dict)132 if transcript_assemble:133 input_dict['gtf'] = "status/transcript_assemble.done"134 return input_dict135 elif check_gff(gtf):136 return input_dict137 else:138 log_exception("gtf not exists")139 if maker_type.find("round") >= 0:140 round = int(maker_type[5:])141 input_dict['train'] = "status/model_training_round{round}.done".format(round=round-1)142 #print(input_dict)143 return input_dict144rule init_maker_ctl:145 output: "maker_opts.ctl", "maker_bopts.ctl", "maker_exe.ctl"146 shell:"maker -CTL"147rule update_maker_ctl:148 input: unpack(get_maker_ctl_input)149 params:150 script_dir = script_dir,151 opts_settings = get_maker_config152 output: "ctl/maker_{ctl}_{type}.ctl"153 shell:"""154 python {params.script_dir}/maker_ctl_updator.py {input.ctl} {output} {params.opts_settings}155 """156# annotation step157if MPI:158 rule run_maker_annotation:159 input: 160 opts = "ctl/maker_opts_annotation.ctl",161 bopts = "ctl/maker_bopts_annotation.ctl",162 exe = "ctl/maker_exe_annotation.ctl"163 output: touch("status/maker_annotation.done")164 params:165 dsname = specie_name166 threads: 40167 log: "log/maker_annotation.log"168 shell:"""169 mpiexec -n {threads} maker -quiet -base {params.dsname} {input.opts} {input.bopts} {input.exe} &> {log} 170 """171else: 172 rule run_maker_annotation:173 input: 174 opts = "ctl/maker_opts_annotation.ctl",175 bopts = "ctl/maker_bopts_annotation.ctl",176 exe = "ctl/maker_exe_annotation.ctl"177 output: touch("status/maker_annotation.done")178 params:179 dsname = specie_name,180 threads: 1181 log: "log/maker_annotation.log"182 shell:"""183 maker -quiet -base {params.dsname} {input.opts} {input.bopts} {input.exe} &> {log} 184 """185# train step: maker_loop: maker_round{2...n}.gff186rule maker_loop_output:187 input: "status/maker_round{round}.done"188 params:189 base_name = lambda wildcards: "maker/maker_round{round}".format(round=wildcards.round),190 dsindex = "{ds}.maker.output/{ds}_master_datastore_index.log".format(ds=specie_name)191 output: 192 gff = "maker/maker_round{round}.gff",193 protein = "maker/maker_round{round}.all.maker.proteins.fasta",194 transcript = "maker/maker_round{round}.all.maker.transcripts.fasta"195 shell:"""196 fasta_merge -o {params.base_name} -d {params.dsindex} && 197 gff3_merge -o {output.gff} -d {params.dsindex} 198 """199if MPI:200 rule run_maker_loop:201 input: 202 opts = "ctl/maker_opts_round{round}.ctl",203 bopts = "ctl/maker_bopts_round{round}.ctl",204 exe = "ctl/maker_exe_round{round}.ctl"205 output: touch("status/maker_round{round}.done")206 params:207 dsname = specie_name,208 threads: 40209 log: "log/maker_round{round}.log"210 shell:"""211 mpiexec -n {threads} maker -quiet -base {params.dsname} {input.opts} {input.bopts} {input.exe} &> {log} 212 """213else:214 rule run_maker_loop:215 input: 216 opts = "ctl/maker_opts_round{round}.ctl",217 bopts = "ctl/maker_bopts_round{round}.ctl",218 exe = "ctl/maker_exe_round{round}.ctl"219 output: touch("status/maker_round{round}.done")220 params:221 dsname = specie_name,222 threads: 1223 log: "log/maker_round{round}.log"224 shell:"""225 maker -quiet -base {params.dsname} {input.opts} {input.bopts} {input.exe} &> {log} 226 """227# maker_base.gff228if MPI:229 rule run_maker_base:230 input: 231 opts = "ctl/maker_opts_base.ctl",232 bopts = "ctl/maker_bopts_base.ctl",233 exe = "ctl/maker_exe_base.ctl"234 output: touch("status/maker_base.done")235 params:236 dsname = specie_name,237 threads: 40238 log: "log/maker_base.log"239 shell:"""240 mpiexec -n {threads} maker -quiet -base {params.dsname} {input.opts} {input.bopts} {input.exe} &> {log} 241 """242else:243 rule run_maker_base:244 input: 245 opts = "ctl/maker_opts_base.ctl",246 bopts = "ctl/maker_bopts_base.ctl",247 exe = "ctl/maker_exe_base.ctl"248 output: touch("status/maker_base.done")249 params:250 dsname = specie_name,251 threads: 1252 log: "log/maker_base.log"253 shell:"""254 maker -quiet -base {params.dsname} {input.opts} {input.bopts} {input.exe} &> {log} 255 """256rule maker_base_output:257 input: "status/maker_base.done"258 params:259 base_name = "maker/maker_base",260 dsindex = "{ds}.maker.output/{ds}_master_datastore_index.log".format(ds=specie_name)261 output: 262 gff = "maker/maker_base.gff",263 protein = "maker/maker_base.all.maker.proteins.fasta",264 transcript = "maker/maker_base.all.maker.transcripts.fasta"265 shell:"""266 fasta_merge -o {params.base_name} -d {params.dsindex} &&267 gff3_merge -o {output.gff} -d {params.dsindex} ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run hypothesis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful