How to use set_options method in Testify

Best Python code snippet using Testify_python

Snakefile

Source:Snakefile Github

copy

Full Screen

...92 M0_cml.alignment = input[1]93 M0_cml.tree = input[0]94 M0_cml.out_file = output[0]95 M0_cml.working_dir = output[0].split('/')[:-1][0] +'/'+output[0].split('/')[:-1][1]+'/'+output[0].split('/')[:-1][2]+'/'96 M0_cml.set_options(noisy = 9) # 0,1,2,3,9: how much rubbish on the screen97 M0_cml.set_options(verbose = 1) # 1: detailed output, 0: concise output98 M0_cml.set_options(runmode = 0) # 0: user tree; 1: semi-automatic; 2: automatic99 M0_cml.set_options(seqtype = 1) # 1:codons; 2:AAs; 3:codons-->AAs100 M0_cml.set_options(CodonFreq = 2) # 0:1/61 each, 1:F1X4, 2:F3X4, 3:codon table101 M0_cml.set_options(clock = 0) # 0: no clock, unrooted tree, 1: clock, rooted tree102 M0_cml.set_options(aaDist = 0) # 0:equal, +:geometric; -:linear, {1-5:G1974,Miyata,c,p,v}103 M0_cml.set_options(model = 0) # models for codons:104 M0_cml.set_options(NSsites = [0]) # 0:one w; 1:NearlyNeutral; 2:PositiveSelection; 3:discrete; Needs to be array105 M0_cml.set_options(icode = 0) # 0:standard genetic code; 1:mammalian mt; 2-10:see below106 M0_cml.set_options(Mgene = 0) # 0:rates, 1:separate; 2:pi, 3:kappa, 4:all107 M0_cml.set_options(fix_kappa = 0) # 1: kappa fixed, 0: kappa to be estimated108 M0_cml.set_options(kappa = 2) # initial or fixed kappa109 M0_cml.set_options(fix_omega = 0) # 1: omega or omega_1 fixed, 0: estimate110 M0_cml.set_options(omega = 1) # initial or fixed omega, for codons or codon-based AAs111 M0_cml.set_options(getSE = 0) # 0: don't want them, 1: want S.E.s of estimates112 M0_cml.set_options(RateAncestor = 0) # (0,1,2): rates (alpha>0) or ancestral states (1 or 2)113 M0_cml.set_options(Small_Diff = .45e-6) # Default value.114 M0_cml.set_options(cleandata = 0) # remove sites with ambiguity data (1:yes, 0:no)?115 M0_cml.set_options(fix_blength = 0) # 0: ignore, -1: random, 1: initial, 2: fixed116 M0_results = M0_cml.run(verbose=True)117 identifiers = re.search("Families/"+"(.*)"+"_dir",output[0])118 family=identifiers.groups()[0]119 try:120 M0_lnL = M0_results.get("NSsites").get(0).get("lnL")121 M0_np = len(M0_results.get("NSsites").get(0).get("parameters").get("parameter list").split())122 # print("@@@@@@@@@@@@@@@@@@@@")123 # print(M0_lnL,M0_np,M0_cml.working_dir)124 with open(M0_cml.working_dir+"statsfile.txt","w") as out:125 out.write(family+"\tM0\t"+str(M0_np)+"\t"+str(M0_lnL)+"\n")126 except:127 with open(M0_cml.working_dir+"statsfile.txt","w") as out:128 out.write(family+"\tM0\tNA\tNA\n")129rule M1:130 input:131 "Families/family_{fam}_dir/M1/family_{fam}.tree",132 "Families/family_{fam}_dir/M1/family_{fam}.codon.phylip"133 output:134 "Families/family_{fam}_dir/M1/family_{fam}.mcl"135 run:136 COUNTER.append(True)137 M1_cml = codeml.Codeml()138 M1_cml.alignment = input[1]139 M1_cml.tree = input[0]140 M1_cml.out_file = output[0]141 M1_cml.working_dir = output[0].split('/')[:-1][0] +'/'+output[0].split('/')[:-1][1]+'/'+output[0].split('/')[:-1][2]+'/'142 M1_cml.set_options(noisy = 9) # 0,1,2,3,9: how much rubbish on the screen143 M1_cml.set_options(verbose = 1) # 1: detailed output, 0: concise output144 M1_cml.set_options(runmode = 0) # 0: user tree; 1: semi-automatic; 2: automatic145 M1_cml.set_options(seqtype = 1) # 1:codons; 2:AAs; 3:codons-->AAs146 M1_cml.set_options(CodonFreq = 2) # 0:1/61 each, 1:F1X4, 2:F3X4, 3:codon table147 M1_cml.set_options(clock = 0) # 0: no clock, unrooted tree, 1: clock, rooted tree148 M1_cml.set_options(aaDist = 0) # 0:equal, +:geometric; -:linear, {1-5:G1974,Miyata,c,p,v}149 M1_cml.set_options(model = 0) # models for codons:150 M1_cml.set_options(NSsites = [1]) # 0:one w; 1:NearlyNeutral; 2:PositiveSelection; 3:discrete; Needs to be array151 M1_cml.set_options(icode = 0) # 0:standard genetic code; 1:mammalian mt; 2-10:see below152 M1_cml.set_options(Mgene = 0) # 0:rates, 1:separate; 2:pi, 3:kappa, 4:all153 M1_cml.set_options(fix_kappa = 0) # 1: kappa fixed, 0: kappa to be estimated154 M1_cml.set_options(kappa = 2) # initial or fixed kappa155 M1_cml.set_options(fix_omega = 0) # 1: omega or omega_1 fixed, 0: estimate156 M1_cml.set_options(omega = 1) # initial or fixed omega, for codons or codon-based AAs157 M1_cml.set_options(getSE = 0) # 0: don't want them, 1: want S.E.s of estimates158 M1_cml.set_options(RateAncestor = 0) # (0,1,2): rates (alpha>0) or ancestral states (1 or 2)159 M1_cml.set_options(Small_Diff = .45e-6) # Default value.160 M1_cml.set_options(cleandata = 0) # remove sites with ambiguity data (1:yes, 0:no)?161 M1_cml.set_options(fix_blength = 0) # 0: ignore, -1: random, 1: initial, 2: fixed162 M1_results = M1_cml.run(verbose=True)163 identifiers = re.search("Families/"+"(.*)"+"_dir",output[0])164 family=identifiers.groups()[0]165 try:166 M1_lnL = M1_results.get("NSsites").get(1).get("lnL")167 M1_np = len(M1_results.get("NSsites").get(1).get("parameters").get("parameter list").split())168 # print("@@@@@@@@@@@@@@@@@@@@")169 print(M1_lnL,M1_np,M1_cml.working_dir)170 with open(M1_cml.working_dir+"statsfile.txt","w") as out:171 out.write(family+"\tM1\t"+str(M1_np)+"\t"+str(M1_lnL)+"\n")172 except:173 with open(M1_cml.working_dir+"statsfile.txt","w") as out:174 out.write(family+"\tM1\tNA\tNA\n")175rule M2:176 input:177 "Families/family_{fam}_dir/M2/family_{fam}.tree",178 "Families/family_{fam}_dir/M2/family_{fam}.codon.phylip"179 output:180 "Families/family_{fam}_dir/M2/family_{fam}.mcl"181 run:182 COUNTER.append(True)183 M2_cml = codeml.Codeml()184 M2_cml.alignment = input[1]185 M2_cml.tree = input[0]186 M2_cml.out_file = output[0]187 M2_cml.working_dir = output[0].split('/')[:-1][0] +'/'+output[0].split('/')[:-1][1]+'/'+output[0].split('/')[:-1][2]+'/'188 M2_cml.set_options(noisy = 9) # 0,1,2,3,9: how much rubbish on the screen189 M2_cml.set_options(verbose = 1) # 1: detailed output, 0: concise output190 M2_cml.set_options(runmode = 0) # 0: user tree; 1: semi-automatic; 2: automatic191 M2_cml.set_options(seqtype = 1) # 1:codons; 2:AAs; 3:codons-->AAs192 M2_cml.set_options(CodonFreq = 2) # 0:1/61 each, 1:F1X4, 2:F3X4, 3:codon table193 M2_cml.set_options(clock = 0) # 0: no clock, unrooted tree, 1: clock, rooted tree194 M2_cml.set_options(aaDist = 0) # 0:equal, +:geometric; -:linear, {1-5:G1974,Miyata,c,p,v}195 M2_cml.set_options(model = 0) # models for codons:196 M2_cml.set_options(NSsites = [2]) # 0:one w; 1:NearlyNeutral; 2:PositiveSelection; 3:discrete; Needs to be array197 M2_cml.set_options(icode = 0) # 0:standard genetic code; 1:mammalian mt; 2-10:see below198 M2_cml.set_options(Mgene = 0) # 0:rates, 1:separate; 2:pi, 3:kappa, 4:all199 M2_cml.set_options(fix_kappa = 0) # 1: kappa fixed, 0: kappa to be estimated200 M2_cml.set_options(kappa = 2) # initial or fixed kappa201 M2_cml.set_options(fix_omega = 0) # 1: omega or omega_1 fixed, 0: estimate202 M2_cml.set_options(omega = 1) # initial or fixed omega, for codons or codon-based AAs203 M2_cml.set_options(getSE = 0) # 0: don't want them, 1: want S.E.s of estimates204 M2_cml.set_options(RateAncestor = 0) # (0,1,2): rates (alpha>0) or ancestral states (1 or 2)205 M2_cml.set_options(Small_Diff = .45e-6) # Default value.206 M2_cml.set_options(cleandata = 0) # remove sites with ambiguity data (1:yes, 0:no)?207 M2_cml.set_options(fix_blength = 0) # 0: ignore, -1: random, 1: initial, 2: fixed208 M2_results = M2_cml.run(verbose=True)209 identifiers = re.search("Families/"+"(.*)"+"_dir",output[0])210 family=identifiers.groups()[0]211 try:212 M2_lnL = M2_results.get("NSsites").get(2).get("lnL")213 M2_np = len(M2_results.get("NSsites").get(2).get("parameters").get("parameter list").split())214 # print("@@@@@@@@@@@@@@@@@@@@")215 # print(M2_lnL,M2_np,M2_cml.working_dir)216 with open(M2_cml.working_dir+"statsfile.txt","w") as out:217 out.write(family+"\tM2\t"+str(M2_np)+"\t"+str(M2_lnL)+"\n")218 except:219 with open(M2_cml.working_dir+"statsfile.txt","w") as out:220 out.write(family+"\tM2\tNA\tNA\n")221rule M3:222 input:223 "Families/family_{fam}_dir/M3/family_{fam}.tree",224 "Families/family_{fam}_dir/M3/family_{fam}.codon.phylip"225 output:226 "Families/family_{fam}_dir/M3/family_{fam}.mcl"227 run:228 COUNTER.append(True)229 M3_cml = codeml.Codeml()230 M3_cml.alignment = input[1]231 M3_cml.tree = input[0]232 M3_cml.out_file = output[0]233 M3_cml.working_dir = output[0].split('/')[:-1][0] +'/'+output[0].split('/')[:-1][1]+'/'+output[0].split('/')[:-1][2]+'/'234 M3_cml.set_options(noisy = 9) # 0,1,2,3,9: how much rubbish on the screen235 M3_cml.set_options(verbose = 1) # 1: detailed output, 0: concise output236 M3_cml.set_options(runmode = 0) # 0: user tree; 1: semi-automatic; 2: automatic237 M3_cml.set_options(seqtype = 1) # 1:codons; 2:AAs; 3:codons-->AAs238 M3_cml.set_options(CodonFreq = 2) # 0:1/61 each, 1:F1X4, 2:F3X4, 3:codon table239 M3_cml.set_options(clock = 0) # 0: no clock, unrooted tree, 1: clock, rooted tree240 M3_cml.set_options(aaDist = 0) # 0:equal, +:geometric; -:linear, {1-5:G1974,Miyata,c,p,v}241 M3_cml.set_options(model = 0) # models for codons:242 M3_cml.set_options(NSsites = [3]) # 0:one w; 1:NearlyNeutral; 2:PositiveSelection; 3:discrete; Needs to be array243 M3_cml.set_options(icode = 0) # 0:standard genetic code; 1:mammalian mt; 2-10:see below244 M3_cml.set_options(Mgene = 0) # 0:rates, 1:separate; 2:pi, 3:kappa, 4:all245 M3_cml.set_options(fix_kappa = 0) # 1: kappa fixed, 0: kappa to be estimated246 M3_cml.set_options(kappa = 2) # initial or fixed kappa247 M3_cml.set_options(fix_omega = 0) # 1: omega or omega_1 fixed, 0: estimate248 M3_cml.set_options(omega = 1) # initial or fixed omega, for codons or codon-based AAs249 M3_cml.set_options(getSE = 0) # 0: don't want them, 1: want S.E.s of estimates250 M3_cml.set_options(RateAncestor = 0) # (0,1,2): rates (alpha>0) or ancestral states (1 or 2)251 M3_cml.set_options(Small_Diff = .45e-6) # Default value.252 M3_cml.set_options(cleandata = 0) # remove sites with ambiguity data (1:yes, 0:no)?253 M3_cml.set_options(fix_blength = 0) # 0: ignore, -1: random, 1: initial, 2: fixed254 M3_results = M3_cml.run(verbose=True)255 identifiers = re.search("Families/"+"(.*)"+"_dir",output[0])256 family=identifiers.groups()[0]257 try:258 M3_lnL = M3_results.get("NSsites").get(3).get("lnL")259 M3_np = len(M3_results.get("NSsites").get(3).get("parameters").get("parameter list").split())260 # print("@@@@@@@@@@@@@@@@@@@@")261 # print(M3_lnL,M3_np,M3_cml.working_dir)262 with open(M3_cml.working_dir+"statsfile.txt","w") as out:263 out.write(family+"\tM3\t"+str(M3_np)+"\t"+str(M3_lnL)+"\n")264 except:265 with open(M3_cml.working_dir+"statsfile.txt","w") as out:266 out.write(family+"\tM3\tNA\tNA\n")267rule M7:268 input:269 "Families/family_{fam}_dir/M7/family_{fam}.tree",270 "Families/family_{fam}_dir/M7/family_{fam}.codon.phylip"271 output:272 "Families/family_{fam}_dir/M7/family_{fam}.mcl"273 run:274 COUNTER.append(True)275 M7_cml = codeml.Codeml()276 M7_cml.alignment = input[1]277 M7_cml.tree = input[0]278 M7_cml.out_file = output[0]279 M7_cml.working_dir = output[0].split('/')[:-1][0] +'/'+output[0].split('/')[:-1][1]+'/'+output[0].split('/')[:-1][2]+'/'280 M7_cml.set_options(noisy = 9) # 0,1,2,3,9: how much rubbish on the screen281 M7_cml.set_options(verbose = 1) # 1: detailed output, 0: concise output282 M7_cml.set_options(runmode = 0) # 0: user tree; 1: semi-automatic; 2: automatic283 M7_cml.set_options(seqtype = 1) # 1:codons; 2:AAs; 3:codons-->AAs284 M7_cml.set_options(CodonFreq = 2) # 0:1/61 each, 1:F1X4, 2:F3X4, 3:codon table285 M7_cml.set_options(clock = 0) # 0: no clock, unrooted tree, 1: clock, rooted tree286 M7_cml.set_options(aaDist = 0) # 0:equal, +:geometric; -:linear, {1-5:G1974,Miyata,c,p,v}287 M7_cml.set_options(model = 0) # models for codons:288 M7_cml.set_options(NSsites = [7]) # 0:one w; 1:NearlyNeutral; 2:PositiveSelection; 3:discrete; Needs to be array289 M7_cml.set_options(icode = 0) # 0:standard genetic code; 1:mammalian mt; 2-10:see below290 M7_cml.set_options(Mgene = 0) # 0:rates, 1:separate; 2:pi, 3:kappa, 4:all291 M7_cml.set_options(fix_kappa = 0) # 1: kappa fixed, 0: kappa to be estimated292 M7_cml.set_options(kappa = 2) # initial or fixed kappa293 M7_cml.set_options(fix_omega = 0) # 1: omega or omega_1 fixed, 0: estimate294 M7_cml.set_options(omega = 1) # initial or fixed omega, for codons or codon-based AAs295 M7_cml.set_options(getSE = 0) # 0: don't want them, 1: want S.E.s of estimates296 M7_cml.set_options(RateAncestor = 0) # (0,1,2): rates (alpha>0) or ancestral states (1 or 2)297 M7_cml.set_options(Small_Diff = .45e-6) # Default value.298 M7_cml.set_options(cleandata = 0) # remove sites with ambiguity data (1:yes, 0:no)?299 M7_cml.set_options(fix_blength = 0) # 0: ignore, -1: random, 1: initial, 2: fixed300 M7_results = M7_cml.run(verbose=True)301 identifiers = re.search("Families/"+"(.*)"+"_dir",output[0])302 family=identifiers.groups()[0]303 try:304 M7_lnL = M7_results.get("NSsites").get(7).get("lnL")305 M7_np = len(M7_results.get("NSsites").get(7).get("parameters").get("parameter list").split())306 # print("@@@@@@@@@@@@@@@@@@@@")307 # print(M7_lnL,M7_np,M7_cml.working_dir)308 with open(M7_cml.working_dir+"statsfile.txt","w") as out:309 out.write(family+"\tM7\t"+str(M7_np)+"\t"+str(M7_lnL)+"\n")310 except:311 with open(M7_cml.working_dir+"statsfile.txt","w") as out:312 out.write(family+"\tM7\tNA\tNA\n")313rule M8:314 input:315 "Families/family_{fam}_dir/M8/family_{fam}.tree",316 "Families/family_{fam}_dir/M8/family_{fam}.codon.phylip"317 output:318 "Families/family_{fam}_dir/M8/family_{fam}.mcl"319 run:320 COUNTER.append(True)321 M8_cml = codeml.Codeml()322 M8_cml.alignment = input[1]323 M8_cml.tree = input[0]324 M8_cml.out_file = output[0]325 M8_cml.working_dir = output[0].split('/')[:-1][0] +'/'+output[0].split('/')[:-1][1]+'/'+output[0].split('/')[:-1][2]+'/'326 M8_cml.set_options(noisy = 9) # 0,1,2,3,9: how much rubbish on the screen327 M8_cml.set_options(verbose = 1) # 1: detailed output, 0: concise output328 M8_cml.set_options(runmode = 0) # 0: user tree; 1: semi-automatic; 2: automatic329 M8_cml.set_options(seqtype = 1) # 1:codons; 2:AAs; 3:codons-->AAs330 M8_cml.set_options(CodonFreq = 2) # 0:1/61 each, 1:F1X4, 2:F3X4, 3:codon table331 M8_cml.set_options(clock = 0) # 0: no clock, unrooted tree, 1: clock, rooted tree332 M8_cml.set_options(aaDist = 0) # 0:equal, +:geometric; -:linear, {1-5:G1974,Miyata,c,p,v}333 M8_cml.set_options(model = 0) # models for codons:334 M8_cml.set_options(NSsites = [8]) # 0:one w; 1:NearlyNeutral; 2:PositiveSelection; 3:discrete; Needs to be array335 M8_cml.set_options(icode = 0) # 0:standard genetic code; 1:mammalian mt; 2-10:see below336 M8_cml.set_options(Mgene = 0) # 0:rates, 1:separate; 2:pi, 3:kappa, 4:all337 M8_cml.set_options(fix_kappa = 0) # 1: kappa fixed, 0: kappa to be estimated338 M8_cml.set_options(kappa = 2) # initial or fixed kappa339 M8_cml.set_options(fix_omega = 0) # 1: omega or omega_1 fixed, 0: estimate340 M8_cml.set_options(omega = 1) # initial or fixed omega, for codons or codon-based AAs341 M8_cml.set_options(getSE = 0) # 0: don't want them, 1: want S.E.s of estimates342 M8_cml.set_options(RateAncestor = 0) # (0,1,2): rates (alpha>0) or ancestral states (1 or 2)343 M8_cml.set_options(Small_Diff = .45e-6) # Default value.344 M8_cml.set_options(cleandata = 0) # remove sites with ambiguity data (1:yes, 0:no)?345 M8_cml.set_options(fix_blength = 0) # 0: ignore, -1: random, 1: initial, 2: fixed346 M8_results = M8_cml.run(verbose=True)347 identifiers = re.search("Families/"+"(.*)"+"_dir",output[0])348 family=identifiers.groups()[0]349 try:350 M8_lnL = M8_results.get("NSsites").get(8).get("lnL")351 M8_np = len(M8_results.get("NSsites").get(8).get("parameters").get("parameter list").split())352 # print("@@@@@@@@@@@@@@@@@@@@")353 # print(M8_lnL,M8_np,M8_cml.working_dir)354 with open(M8_cml.working_dir+"statsfile.txt","w") as out:355 out.write(family+"\tM8\t"+str(M8_np)+"\t"+str(M8_lnL)+"\n")356 except:357 with open(M8_cml.working_dir+"statsfile.txt","w") as out:358 out.write(family+"\tM8\tNA\tNA\n")359rule M8a:360 input:361 "Families/family_{fam}_dir/M8a/family_{fam}.tree",362 "Families/family_{fam}_dir/M8a/family_{fam}.codon.phylip"363 output:364 "Families/family_{fam}_dir/M8a/family_{fam}.mcl"365 run:366 COUNTER.append(True)367 M8a_cml = codeml.Codeml()368 M8a_cml.alignment = input[1]369 M8a_cml.tree = input[0]370 M8a_cml.out_file = output[0]371 M8a_cml.working_dir = output[0].split('/')[:-1][0] +'/'+output[0].split('/')[:-1][1]+'/'+output[0].split('/')[:-1][2]+'/'372 M8a_cml.set_options(noisy = 9) # 0,1,2,3,9: how much rubbish on the screen373 M8a_cml.set_options(verbose = 1) # 1: detailed output, 0: concise output374 M8a_cml.set_options(runmode = 0) # 0: user tree; 1: semi-automatic; 2: automatic375 M8a_cml.set_options(seqtype = 1) # 1:codons; 2:AAs; 3:codons-->AAs376 M8a_cml.set_options(CodonFreq = 2) # 0:1/61 each, 1:F1X4, 2:F3X4, 3:codon table377 M8a_cml.set_options(clock = 0) # 0: no clock, unrooted tree, 1: clock, rooted tree378 M8a_cml.set_options(aaDist = 0) # 0:equal, +:geometric; -:linear, {1-5:G1974,Miyata,c,p,v}379 M8a_cml.set_options(model = 0) # models for codons:380 M8a_cml.set_options(NSsites = [8]) # 0:one w; 1:NearlyNeutral; 2:PositiveSelection; 3:discrete; Needs to be array381 M8a_cml.set_options(icode = 0) # 0:standard genetic code; 1:mammalian mt; 2-10:see below382 M8a_cml.set_options(Mgene = 0) # 0:rates, 1:separate; 2:pi, 3:kappa, 4:all383 M8a_cml.set_options(fix_kappa = 0) # 1: kappa fixed, 0: kappa to be estimated384 M8a_cml.set_options(kappa = 2) # initial or fixed kappa385 M8a_cml.set_options(fix_omega = 1) # 1: omega or omega_1 fixed, 0: estimate386 M8a_cml.set_options(omega = 1) # initial or fixed omega, for codons or codon-based AAs387 M8a_cml.set_options(getSE = 0) # 0: don't want them, 1: want S.E.s of estimates388 M8a_cml.set_options(RateAncestor = 0) # (0,1,2): rates (alpha>0) or ancestral states (1 or 2)389 M8a_cml.set_options(Small_Diff = .45e-6) # Default value.390 M8a_cml.set_options(cleandata = 0) # remove sites with ambiguity data (1:yes, 0:no)?391 M8a_cml.set_options(fix_blength = 0) # 0: ignore, -1: random, 1: initial, 2: fixed392 M8a_results=M8a_cml.run(verbose=True)393 identifiers = re.search("Families/"+"(.*)"+"_dir",output[0])394 family=identifiers.groups()[0]395 try:396 M8a_lnL = M8a_results.get("NSsites").get(8).get("lnL")397 M8a_np = len(M8a_results.get("NSsites").get(8).get("parameters").get("parameter list").split())398 # print("@@@@@@@@@@@@@@@@@@@@")399 # print(M8a_lnL,M8a_np,M8a_cml.working_dir+"statsfile.txt")400 with open(M8a_cml.working_dir+"statsfile.txt","w") as out:401 out.write(family+"\tM8a\t"+str(M8a_np)+"\t"+str(M8a_lnL)+"\n")402 except:403 with open(M8a_cml.working_dir+"statsfile.txt","w") as out:404 out.write(family+"\tM8a\tNA\tNA\n")405rule codemlModels:...

Full Screen

Full Screen

test_options.py

Source:test_options.py Github

copy

Full Screen

...5from xarray.core.options import OPTIONS, _get_keep_attrs6from xarray.tests.test_dataset import create_test_data7def test_invalid_option_raises():8 with pytest.raises(ValueError):9 xarray.set_options(not_a_valid_options=True)10def test_display_width():11 with pytest.raises(ValueError):12 xarray.set_options(display_width=0)13 with pytest.raises(ValueError):14 xarray.set_options(display_width=-10)15 with pytest.raises(ValueError):16 xarray.set_options(display_width=3.5)17def test_arithmetic_join():18 with pytest.raises(ValueError):19 xarray.set_options(arithmetic_join="invalid")20 with xarray.set_options(arithmetic_join="exact"):21 assert OPTIONS["arithmetic_join"] == "exact"22def test_enable_cftimeindex():23 with pytest.raises(ValueError):24 xarray.set_options(enable_cftimeindex=None)25 with pytest.warns(FutureWarning, match="no-op"):26 with xarray.set_options(enable_cftimeindex=True):27 assert OPTIONS["enable_cftimeindex"]28def test_file_cache_maxsize():29 with pytest.raises(ValueError):30 xarray.set_options(file_cache_maxsize=0)31 original_size = FILE_CACHE.maxsize32 with xarray.set_options(file_cache_maxsize=123):33 assert FILE_CACHE.maxsize == 12334 assert FILE_CACHE.maxsize == original_size35def test_keep_attrs():36 with pytest.raises(ValueError):37 xarray.set_options(keep_attrs="invalid_str")38 with xarray.set_options(keep_attrs=True):39 assert OPTIONS["keep_attrs"]40 with xarray.set_options(keep_attrs=False):41 assert not OPTIONS["keep_attrs"]42 with xarray.set_options(keep_attrs="default"):43 assert _get_keep_attrs(default=True)44 assert not _get_keep_attrs(default=False)45def test_nested_options():46 original = OPTIONS["display_width"]47 with xarray.set_options(display_width=1):48 assert OPTIONS["display_width"] == 149 with xarray.set_options(display_width=2):50 assert OPTIONS["display_width"] == 251 assert OPTIONS["display_width"] == 152 assert OPTIONS["display_width"] == original53def test_display_style():54 original = "text"55 assert OPTIONS["display_style"] == original56 with pytest.raises(ValueError):57 xarray.set_options(display_style="invalid_str")58 with xarray.set_options(display_style="html"):59 assert OPTIONS["display_style"] == "html"60 assert OPTIONS["display_style"] == original61def create_test_dataset_attrs(seed=0):62 ds = create_test_data(seed)63 ds.attrs = {"attr1": 5, "attr2": "history", "attr3": {"nested": "more_info"}}64 return ds65def create_test_dataarray_attrs(seed=0, var="var1"):66 da = create_test_data(seed)[var]67 da.attrs = {"attr1": 5, "attr2": "history", "attr3": {"nested": "more_info"}}68 return da69class TestAttrRetention:70 def test_dataset_attr_retention(self):71 # Use .mean() for all tests: a typical reduction operation72 ds = create_test_dataset_attrs()73 original_attrs = ds.attrs74 # Test default behaviour75 result = ds.mean()76 assert result.attrs == {}77 with xarray.set_options(keep_attrs="default"):78 result = ds.mean()79 assert result.attrs == {}80 with xarray.set_options(keep_attrs=True):81 result = ds.mean()82 assert result.attrs == original_attrs83 with xarray.set_options(keep_attrs=False):84 result = ds.mean()85 assert result.attrs == {}86 def test_dataarray_attr_retention(self):87 # Use .mean() for all tests: a typical reduction operation88 da = create_test_dataarray_attrs()89 original_attrs = da.attrs90 # Test default behaviour91 result = da.mean()92 assert result.attrs == {}93 with xarray.set_options(keep_attrs="default"):94 result = da.mean()95 assert result.attrs == {}96 with xarray.set_options(keep_attrs=True):97 result = da.mean()98 assert result.attrs == original_attrs99 with xarray.set_options(keep_attrs=False):100 result = da.mean()101 assert result.attrs == {}102 def test_groupby_attr_retention(self):103 da = xarray.DataArray([1, 2, 3], [("x", [1, 1, 2])])104 da.attrs = {"attr1": 5, "attr2": "history", "attr3": {"nested": "more_info"}}105 original_attrs = da.attrs106 # Test default behaviour107 result = da.groupby("x").sum(keep_attrs=True)108 assert result.attrs == original_attrs109 with xarray.set_options(keep_attrs="default"):110 result = da.groupby("x").sum(keep_attrs=True)111 assert result.attrs == original_attrs112 with xarray.set_options(keep_attrs=True):113 result1 = da.groupby("x")114 result = result1.sum()115 assert result.attrs == original_attrs116 with xarray.set_options(keep_attrs=False):117 result = da.groupby("x").sum()118 assert result.attrs == {}119 def test_concat_attr_retention(self):120 ds1 = create_test_dataset_attrs()121 ds2 = create_test_dataset_attrs()122 ds2.attrs = {"wrong": "attributes"}123 original_attrs = ds1.attrs124 # Test default behaviour of keeping the attrs of the first125 # dataset in the supplied list126 # global keep_attrs option current doesn't affect concat127 result = concat([ds1, ds2], dim="dim1")128 assert result.attrs == original_attrs129 @pytest.mark.xfail130 def test_merge_attr_retention(self):131 da1 = create_test_dataarray_attrs(var="var1")132 da2 = create_test_dataarray_attrs(var="var2")133 da2.attrs = {"wrong": "attributes"}134 original_attrs = da1.attrs135 # merge currently discards attrs, and the global keep_attrs136 # option doesn't affect this137 result = merge([da1, da2])138 assert result.attrs == original_attrs139 def test_display_style_text(self):140 ds = create_test_dataset_attrs()141 text = ds._repr_html_()142 assert text.startswith("<pre>")143 assert "&#x27;nested&#x27;" in text144 assert "&lt;xarray.Dataset&gt;" in text145 def test_display_style_html(self):146 ds = create_test_dataset_attrs()147 with xarray.set_options(display_style="html"):148 html = ds._repr_html_()149 assert html.startswith("<div>")150 assert "&#x27;nested&#x27;" in html151 def test_display_dataarray_style_text(self):152 da = create_test_dataarray_attrs()153 text = da._repr_html_()154 assert text.startswith("<pre>")155 assert "&lt;xarray.DataArray &#x27;var1&#x27;" in text156 def test_display_dataarray_style_html(self):157 da = create_test_dataarray_attrs()158 with xarray.set_options(display_style="html"):159 html = da._repr_html_()160 assert html.startswith("<div>")...

Full Screen

Full Screen

PAML_codeml_dnds.py

Source:PAML_codeml_dnds.py Github

copy

Full Screen

...3334 cml = codeml.Codeml(alignment = alignment, tree = tree,35 out_file = out_file1, working_dir = dataDir)3637 cml.set_options(verbose=1)38 cml.set_options(CodonFreq=2)39 cml.set_options(cleandata=0)40 cml.set_options(fix_blength=0)41 cml.set_options(model=1)42 cml.set_options(NSsites=[0])43 cml.set_options(fix_omega=0)44 cml.set_options(omega=0)45 cml.set_options(clock=0)46 cml.set_options(ncatG=10)47 cml.set_options(runmode=0)48 cml.set_options(fix_kappa=0)49 cml.set_options(kappa=0.4)50 cml.set_options(fix_alpha=1)51 cml.set_options(alpha=0)52 cml.set_options(Malpha=0)53 cml.set_options(Small_Diff=1e-6)54 cml.set_options(method=1)55 cml.set_options(aaDist=0)56 cml.set_options(RateAncestor=0)57 cml.set_options(aaRatefile="wag.dat")58 cml.set_options(icode=0)59 cml.set_options(seqtype=1)60 cml.set_options(getSE=0)61 cml.set_options(noisy=9)62 cml.set_options(Mgene=0)63 64 run1 = cml.run(command="C:\\Program Files (x86)\\paml4.9j\\bin\\codeml",verbose = True)65 66 results = run1.get('NSsites')67 results_1 = results.get(0)68 w_branch = results_1.get('omega tree')69 w = results_1.get('parameters').get('omega')70 PP = w[4]71 PV = w[5]7273 writer.writerow([gene,w_branch,PP,PV])7475 except:76 pass77 78# For single file7980outputfile = os.path.join(outDir, "all_loci_PAML.csv")81with open(outputfile, 'wb') as f:82 writer = csv.writer(f, delimiter=',')83 writer.writerow(["Gene","Omega_for_each_branch","Downy","Hairy"])84 85 filename= "all_loci.phy"86 filepath= "all_loci.phy"87 gene = filename.split(".")[0]88 alignment = filepath89 out_file1 = os.path.join(outDir,gene+"_model1.results")90 91 try:92 # model 1 (Null Model)9394 cml = codeml.Codeml(alignment = alignment, tree = tree,95 out_file = out_file1, working_dir = dataDir)9697 cml.set_options(verbose=1)98 cml.set_options(CodonFreq=2)99 cml.set_options(cleandata=0)100 cml.set_options(fix_blength=0)101 cml.set_options(model=1)102 cml.set_options(NSsites=[0])103 cml.set_options(fix_omega=0)104 cml.set_options(omega=0)105 cml.set_options(clock=0)106 cml.set_options(ncatG=10)107 cml.set_options(runmode=0)108 cml.set_options(fix_kappa=0)109 cml.set_options(kappa=0.4)110 cml.set_options(fix_alpha=1)111 cml.set_options(alpha=0)112 cml.set_options(Malpha=0)113 cml.set_options(Small_Diff=1e-6)114 cml.set_options(method=1)115 cml.set_options(aaDist=0)116 cml.set_options(RateAncestor=0)117 cml.set_options(aaRatefile="wag.dat")118 cml.set_options(icode=0)119 cml.set_options(seqtype=1)120 cml.set_options(getSE=0)121 cml.set_options(noisy=9)122 cml.set_options(Mgene=0)123 124 run1 = cml.run(command="C:\\Program Files (x86)\\paml4.9j\\bin\\codeml",verbose = True)125126 results = run1.get('NSsites')127 results_1 = results.get(0)128 w_branch = results_1.get('omega tree')129 w = results_1.get('parameters').get('omega')130 PP = w[4]131 PV = w[5]132133 writer.writerow([gene,w_branch,PP,PV])134135 except:136 pass

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 Testify 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