How to use copy_dir method in localstack

Best Python code snippet using localstack_python

srna_result.py

Source:srna_result.py Github

copy

Full Screen

...102 self.diff_analy()103 self.miRNA_target_norefanimal() 104 def SuppFiles(self):105 SuppFilesdir = self.make_dir('SuppFiles')106 self.copy_dir(os.path.join(107 self.projpath,'11.edit_family','edit_analy','known_novel_hairpin.fa'108 ),os.path.join(SuppFilesdir,'hairpin.fa')109 )110 assert not os.system('cat {known_mature} {novel_mature} > {total_mature}'.format(111 known_mature = os.path.join(self.result,'*Known_miRNA','mature.fa'),112 novel_mature = os.path.join(self.result,'*Novel_miRNA','mature.fa'),113 total_mature = os.path.join(SuppFilesdir,'mature.fa'))114 )115 116 assert not os.system('{perlExec} {BioScripts}/Release/GO_class.pl {go} {GOseq} {outfile}'.format(117 perlExec = self.perlExec, BioScripts = self.BioScripts,go = self.go,118 GOseq = self.GOseq,outfile = os.path.join(SuppFilesdir,'gene.goannot.xls'))119 )120 121 self.copy_dir(os.path.join(122 self.projpath,'*.diff','diffAnalysisResult','{meanscount.txt,meanstpm.txt}'123 ),SuppFilesdir124 )125 self.copy_dir(self.geneAnn,os.path.join(SuppFilesdir,'gene.description.xls'))126 self.copy_dir(os.path.join(127 self.readme,'0.SuppFiles.Readme.txt'128 ),SuppFilesdir129 )130 131 assert not os.system(132 '{perlExec} {BioScripts}/Release/known_haipin_mature_result.pl \\\n'133 ' -readcount {readcount} \\\n'134 ' -h {hairpin} \\\n'135 ' -m {mature} \\\n'136 ' -pairs {hairpin_mature_pairs} \\\n'137 ' -o {outfile} '.format(138 perlExec = self.perlExec,BioScripts = self.BioScripts,139 readcount = os.path.join(self.projpath,'3.known/known_miRNAs/mature.readcount'),140 hairpin = os.path.join(self.projpath,'3.known/known_miRNAs/hairpin.fa'),141 mature = os.path.join(self.projpath,'3.known/known_miRNAs/mature.fa'),142 hairpin_mature_pairs = os.path.join(self.projpath,'3.known/known_miRNAs/hairpin_mature.pairs'),143 outfile = os.path.join(SuppFilesdir,'known_hairpin_mature.xls')144 )145 )146 assert not os.system(147 '{perlExec} {BioScripts}/Release/novel_haipin_mature_result.pl \\\n'148 ' -readcount {readcount} \\\n'149 ' -h {hairpin} \\\n'150 ' -m {mature} \\\n'151 ' -str {hairpin_str} \\\n'152 ' -pos {hairpin_pos} \\\n'153 ' -o {outfile} '.format(154 perlExec = self.perlExec,BioScripts = self.BioScripts,155 readcount = os.path.join(self.projpath,'8.novel/novel_miRNAs/mature.readcount'),156 hairpin = os.path.join(self.projpath,'8.novel/novel_miRNAs/hairpin.fa'),157 mature = os.path.join(self.projpath,'8.novel/novel_miRNAs/mature.fa'),158 hairpin_str = os.path.join(self.projpath,'8.novel/novel_miRNAs/hairpin.str'),159 hairpin_pos = os.path.join(self.projpath,'8.novel/novel_miRNAs/hairpin.pos'),160 outfile = os.path.join(SuppFilesdir,'novel_hairpin_mature.xls')161 )162 )163 if 'refanimal' in self.org:164 assert not os.system('{perlExec} {BioScripts}/Release/targets_pairs.transfer.v3.pl {inf} {ouf}'.format(165 perlExec = self.perlExec,BioScripts = self.BioScripts,166 inf = os.path.join(self.result,'*miRNA_target/all_target_gene.xls'),167 ouf = os.path.join(SuppFilesdir,'targets.pairs.allcom')168 )169 )170 else:171 assert not os.system('{perlExec} {BioScripts}/Release/targets_pairs.transfer.v3.pl {inf} {ouf}'.format(172 perlExec = self.perlExec,BioScripts = self.BioScripts,173 inf = os.path.join(self.result,'*miRNA_target/*_targets.pairs'),174 ouf = os.path.join(SuppFilesdir,'targets.pairs.allcom')175 )176 )177 178 assert not os.system("sed -e 's/,/\\t/g' {inf} > {ouf}".format(179 inf = os.path.join(SuppFilesdir,'targets.pairs.allcom'),180 ouf = os.path.join(SuppFilesdir,'targets.pairs.alltab')181 )182 )183 184 if 'noref' not in self.org:185 if 'refplant' in self.org:186 self.copy_dir(self.gene,os.path.join(SuppFilesdir,'gene.fa'))187 else:188 self.copy_dir(self.utr3,os.path.join(SuppFilesdir,'3_utr.fa'))189 190 def Example_data(self):191 192 #RawDatadir,CleanDatadir,order = self.make_dir('Example_data',['1.RawData','2.CleanData'])193 CleanDatadir,order = self.make_dir('Example_data',['1.CleanData']) 194 ''' 195 for eachsample in self.samples:196 files = glob.glob(self.projpath+'/raw_data/'+eachsample+'/'+eachsample+'.fq.gz')[0]197 f_in = gzip.open(files,'rb')198 f_out = [f_in.readline() for num in range(20)]199 f_out_name = os.path.join(RawDatadir,eachsample+'.example.raw.fastq')200 open(f_out_name,'w').writelines(f_out)201 f_in.close()202 shutil.copy('{}/1.1RawData.txt'.format(self.readme),os.path.join(RawDatadir,order+'.1.RawData.Readme.txt'))203 ''' 204 for eachsample in self.samples:205 files=glob.glob(self.projpath+'/1.QC/'+eachsample+'/clean_data/'+eachsample+'_remain_total.fa')[0]206 f_in=open(files,'rb')207 f_out=[f_in.readline() for num in range(20)]208 f_out_name = os.path.join(CleanDatadir,eachsample+'.example.clean.fastq')209 open(f_out_name,'w').writelines(f_out)210 f_in.close()211 #shutil.copy('{}/1.2CleanData.txt'.format(self.readme),os.path.join(CleanDatadir,order+'.2.CleanData.Readme.txt'))212 shutil.copy('{}/1.2CleanData.txt'.format(self.readme),os.path.join(CleanDatadir,order+'.1.CleanData.Readme.txt'))213 def qc(self):214 #RawData_ErrorRate,RawData_Stat,ReadsClassification,Length_Filter,order = self.make_dir(215 # 'QualityControl',['1.RawData_ErrorRate','2.RawData_Stat','3.ReadsClassification','4.Length_Filter']216 #)217 218 Length_Filter,order = self.make_dir('QualityControl',['1.Length_Filter'])219 #qc_report = os.path.join(self.projpath,self.project+'_QC_results','results')220 #dirname = os.path.dirname(RawData_ErrorRate)221 #self.copy_dir(os.path.join(qc_report,'1RawData_ErrorRate/*'),RawData_ErrorRate)222 #self.copy_dir(os.path.join(qc_report,'2RawData_Stat/*'),RawData_Stat)223 #self.copy_dir(os.path.join(qc_report,'3ReadsClassification/*'),ReadsClassification)224 self.copy_dir(os.path.join(self.projpath,'1.QC/*/clean_data/*len_distribution.p*'),Length_Filter)225 #shutil.copy(226 # '{}/2.1RawData_ErrorRate.txt'.format(self.readme),227 # os.path.join(RawData_ErrorRate,order+'.1.RawData_ErrorRate.txt')228 # )229 #shutil.copy(230 # '{}/2.2RawData_Stat.txt'.format(self.readme),231 # os.path.join(RawData_Stat,order+'.2.RawData_Stat.txt')232 # )233 #shutil.copy(234 # '{}/2.3ReadsClassification.txt'.format(self.readme),235 # os.path.join(ReadsClassification,order+'.3.ReadsClassification.txt')236 # )237 shutil.copy(238 '{}/2.4Length_Filter.txt'.format(self.readme),239 os.path.join(Length_Filter,order+'.1.Length_Filter.txt')240 )241 #shutil.copy(242 # '{}/2QC_2.txt'.format(self.readme),243 # os.path.join(dirname,order+'.QC.Readme.txt')244 # ) 245 if 'y' in self.common :246 assert not os.system('mkdir -p {}'.format(os.path.join(dirname,order+'.5.Common_Specific_sRNA')))247 self.copy_dir(os.path.join(self.projpath,'1.QC','*_vs_*/*venn*'),dirname)248 shutil.copy(249 '{}/2.5Common-Specific_sRNA.txt'.format(self.readme),250 os.path.join(dirname,order+'.5.Common_Specific_sRNA',order+'.5.Common_Specific_sRNA.Readme.txt')251 )252 def mapping(self):253 Mapping_Stat,order = self.make_dir('Mapping_Stat')254 analydir = os.path.join(self.projpath,'2.map')255 shutil.copy(256 os.path.join(analydir,'reference.mapping.stat'),257 Mapping_Stat258 )259 for eachsample in self.samples:260 shutil.copy(261 os.path.join(analydir,eachsample,eachsample+'.mapping.stat'),262 Mapping_Stat263 )264 if 'noref' not in self.org:265 shutil.copy(266 os.path.join(analydir,eachsample,'Circos',eachsample+'_circos.png'),267 os.path.join(Mapping_Stat,eachsample+'.circos.png')268 )269 shutil.copy(270 os.path.join(analydir,eachsample,'Circos',eachsample+'_circos.svg'),271 os.path.join(Mapping_Stat,eachsample+'.circos.svg')272 ) 273 self.copy_dir(os.path.join(274 self.readme,'3Mapping_Stat.txt'275 ),os.path.join(Mapping_Stat,order+'.Mapping_Stat.Readme.txt')276 )277 def known_miRNA(self):278 279 known_miRNA,order = self.make_dir('Known_miRNA')280 analydir = os.path.join(self.projpath,'3.known') 281 assert not os.system('mkdir -p {}'.format(282 os.path.join(known_miRNA,'Structure_plot_example'))283 )284 assert not os.system('tar -zcf {tardir} -C {rawdir} {file}'.format(285 tardir = os.path.join(known_miRNA,'Structure_plot.tar.gz'),286 rawdir = os.path.join(analydir,'known_miRNAs'),287 file = 'image')288 )289 assert not os.system('ls {} 2>&1 | head -n 10 | xargs -n1 -i cp {{}} {}'.format(290 os.path.join(analydir,'known_miRNAs','image/*jpg'),291 os.path.join(known_miRNA,'Structure_plot_example'))292 )293 self.copy_dir(os.path.join(294 analydir,'known_miRNAs','{hairpin*,mature*,known*.map.*,miRBase.mrd}'295 ),known_miRNA296 )297 298 for eachsample in self.samples: 299 shutil.copy(300 os.path.join(analydir,eachsample+'.firstbase.png'),301 known_miRNA302 )303 shutil.copy(304 os.path.join(analydir,eachsample+'.position.png'),305 known_miRNA306 )307 self.copy_dir(os.path.join(308 self.readme,'4Known_miRNA.txt'309 ),os.path.join(known_miRNA,order+'.Known_miRNA.Readme.txt')310 )311 312 def ncRNA(self):313 ncRNA,order = self.make_dir('ncRNA')314 analydir = os.path.join(self.projpath,'4.ncRNA')315 self.copy_dir(os.path.join(316 analydir,'output','{*.map.fas,rc.stat,uc.stat}'317 ),ncRNA318 )319 self.copy_dir(os.path.join(320 self.readme,'5ncRNA.txt'321 ),os.path.join(ncRNA,order+'.ncRNA.Readme.txt')322 ) 323 def repeat(self):324 repeat,order = self.make_dir('Repeat')325 analydir = os.path.join(self.projpath,'5.repeat')326 self.copy_dir(os.path.join(327 analydir,'{repeat.map.fas,repeat.rc.stat,repeat.uc.stat,*bar.png,*bar.pdf}'328 ),repeat329 )330 self.copy_dir(os.path.join(331 self.readme,'6Repeats.txt'332 ),os.path.join(repeat,order+'.Repeats.Readme.txt')333 )334 def NAT(self):335 NAT,order = self.make_dir('NAT')336 analydir = os.path.join(self.projpath,'6.NAT')337 self.copy_dir(os.path.join(338 analydir,'output','{*.map.fas,rc.stat,uc.stat,NAT.rc.stat,NAT.uc.stat}'339 ),NAT340 )341 self.copy_dir(os.path.join(342 self.readme,'7NAT.txt'343 ),os.path.join(NAT,order+'.NAT.Readme.txt')344 )345 def geneAnalysis(self):346 gene,order = self.make_dir('gene')347 analydir = os.path.join(self.projpath,'7.gene')348 self.copy_dir(os.path.join(349 analydir,'output','{*.map.fas,rc.stat,uc.stat}'350 ),gene351 )352 self.copy_dir(os.path.join(353 self.readme,'8gene.txt'354 ),os.path.join(gene,order+'.gene.Readme.txt')355 )356 def novel_miRNA(self):357 Novel_miRNA,order = self.make_dir('Novel_miRNA')358 analydir = os.path.join(self.projpath,'8.novel') 359 assert not os.system('mkdir -p {}'.format(360 os.path.join(Novel_miRNA,'Structure_plot_example'))361 )362 assert not os.system('tar -zcf {tardir} -C {rawdir} {file}'.format(363 tardir = os.path.join(Novel_miRNA,'Structure_plot.tar.gz'),364 rawdir = os.path.join(analydir,'novel_miRNAs'),365 file = 'image')366 )367 assert not os.system('ls {} 2>&1 | head -n 10 | xargs -n1 -i cp {{}} {}'.format(368 os.path.join(analydir,'novel_miRNAs','image/*jpg'),369 os.path.join(Novel_miRNA,'Structure_plot_example'))370 )371 self.copy_dir(os.path.join(372 analydir,'novel_miRNAs','{hairpin*,mature*,novel*.map.*,miRBase.mrd,star*}'373 ),Novel_miRNA374 )375 376 for eachsample in self.samples: 377 shutil.copy(378 os.path.join(analydir,eachsample+'.firstbase.png'),379 Novel_miRNA380 )381 shutil.copy(382 os.path.join(analydir,eachsample+'.position.png'),383 Novel_miRNA384 )385 self.copy_dir(os.path.join(386 self.readme,'9Novel_miRNA.txt'387 ),os.path.join(Novel_miRNA,order+'.Novel_miRNA.Readme.txt')388 )389 390 def TAS(self):391 392 tas,order = self.make_dir('TAS')393 analydir = os.path.join(self.projpath,'9.TAS')394 self.copy_dir(os.path.join(395 analydir,'output','{TAS.map.fas,TAS.rc.stat,TAS.uc.stat}'396 ),tas397 )398 self.copy_dir(os.path.join(399 self.readme,'10TAS.txt'400 ),os.path.join(tas,order+'.TAS.Readme.txt')401 )402 403 def Category(self):404 category,order = self.make_dir('Category')405 analydir = os.path.join(self.projpath,'10.Category')406 self.copy_dir(os.path.join(407 analydir,'{*_full.txt,*pie.png,*pie.pdf}'408 ),category409 )410 self.copy_dir(os.path.join(411 self.readme,'11Category.txt'412 ),os.path.join(category,order+'.Category.Readme.txt')413 )414 def miRNA_editing(self):415 miRNA_editing,order = self.make_dir('miRNA_editing')416 analydir = os.path.join(self.projpath,'11.edit_family')417 self.copy_dir(os.path.join(418 analydir,'edit_analy','*editing_stats*.txt'419 ),miRNA_editing420 )421 self.copy_dir(os.path.join(422 self.readme,'12miRNA_editing.txt'423 ),os.path.join(miRNA_editing,order+'.miRNA_editing.Readme.txt')424 )425 426 427 def miRNA_family(self):428 miRNA_family,order = self.make_dir('miRNA_family')429 analydir = os.path.join(self.projpath,'11.edit_family')430 self.copy_dir(os.path.join(431 analydir,'family_analy','*_family.*.txt'432 ),miRNA_family433 )434 self.copy_dir(os.path.join(435 self.readme,'13miRNA_family.txt'436 ),os.path.join(miRNA_family,order+'.miRNA_family.Readme.txt')437 )438 def diff_analy(self):439 analydir = os.path.join(self.projpath,'13.diff')440 if len(self.samples) == 1:441 miRNAExp,miRNAExpdensity,order = self.make_dir('DiffExprAnalysis',442 ['1.miRNAExp','2.miRNAExpdensity'])443 else:444 if self.venn_cluster:445 (miRNAExp,miRNAExpdensity,CorAnalysis,DiffExprAnalysis,446 DEsFilter,DEcluster,DEvenn,order) = self.make_dir('DiffExprAnalysis',[447 '1.miRNAExp','2.miRNAExpdensity','3.CorAnalysis','4.DiffExprAnalysis',448 '5.DEsFilter','6.DEcluster','7.DEvenn'449 ])450 else:451 (miRNAExp,miRNAExpdensity,CorAnalysis,DiffExprAnalysis,452 DEsFilter,DEcluster,order) = self.make_dir('DiffExprAnalysis',[453 '1.miRNAExp','2.miRNAExpdensity','3.CorAnalysis',454 '4.DiffExprAnalysis','5.DEsFilter','6.DEcluster'455 ])456 self.copy_dir(os.path.join(457 analydir,'diffAnalysisResult','{Readcount_TPM.xls,TPM_interval.xls}'458 ),miRNAExp459 )460 self.copy_dir(os.path.join(461 self.readme,'14.1miRNAExp.txt'462 ),os.path.join(miRNAExp,order+'.1.miRNAExp.Readme.txt')463 )464 465 self.copy_dir(os.path.join(466 analydir,'diffAnalysisResult','{TPM_density_distribution.*,TPM_boxplot.*}'467 ),miRNAExpdensity468 )469 self.copy_dir(os.path.join(470 self.readme,'14.2miRNAExpdensity.txt'471 ),os.path.join(miRNAExpdensity,order+'.2.miRNAExpdensity.Readme.txt')472 )473 474 if len(self.samples) != 1:475 476 self.copy_dir(os.path.join(477 analydir,'diffAnalysisResult','corr_plot/*'478 ),CorAnalysis479 )480 self.copy_dir(os.path.join(481 self.readme,'14.3CorAnalysis.txt'482 ),os.path.join(CorAnalysis,order+'.3.CorAnalysis.Readme.txt')483 )484 485 for each_compare in self.comparename.replace(':','vs').split(','):486 assert not os.system('mkdir -p {}'.format(os.path.join(DiffExprAnalysis,each_compare))) 487 self.copy_dir(os.path.join(488 analydir,'diffAnalysisResult',each_compare,'{*vs*xls,*vs*txt}'489 ),os.path.join(DiffExprAnalysis,each_compare)490 )491 self.copy_dir(os.path.join(492 analydir,'diffAnalysisResult',each_compare,'*Volcanoplot*'493 ),DEsFilter494 ) 495 self.copy_dir(os.path.join(496 self.readme,'14.4DiffExprAnalysis.txt'497 ),os.path.join(DiffExprAnalysis,order+'.4.DiffExprAnalysis.Readme.txt')498 )499 500 self.copy_dir(os.path.join(501 self.readme,'14.5DEsFilter.txt'502 ),os.path.join(DEsFilter,order+'.5.DEsFilter.Readme.txt')503 )504 505 #self.copy_dir(os.path.join(506 # analydir,'diffAnalysisResult',507 # '{*heatmap.png,*heatmap.pdf,DE_union_for_cluster,SOM_cluster,K_means_cluster}'508 # ),DEcluster509 # )510 #self.copy_dir(os.path.join(511 # self.readme,'14.6DEcluster.txt'512 # ),os.path.join(DEcluster,order+'.6.DEcluster.Readme.txt')513 # )514 if self.venn_cluster:515 516 self.copy_dir(os.path.join(517 analydir,'diffAnalysisResult','venn'518 ),DEvenn519 )520 assert not os.system('rm -rf {}'.format(os.path.join(521 DEvenn,'venn','{type.txt,Signature.xls,plot_venn.R}'))522 )523 self.copy_dir(os.path.join(524 self.readme,'14.7DEvenn.txt'525 ),os.path.join(DEvenn,order+'.7.DEvenn.Readme.txt')526 )527 if len(self.groupname.split(','))==2:528 529 tmpdir = os.path.dirname(os.path.abspath(miRNAExp))530 DEvenn = os.path.join(tmpdir,order+'.7.DEvenn')531 assert not os.system('mkdir -p {}'.format(DEvenn))532 533 self.copy_dir(os.path.join(534 analydir,'diffAnalysisResult','venn'535 ),DEvenn536 )537 self.copy_dir(os.path.join(538 self.readme,'14.8DEvenn.txt'539 ),os.path.join(DEvenn,order+'.7.DEvenn.Readme.txt') )540 541 542 def miRNA_target_refanimal(self):543 544 miRNA_target,order = self.make_dir('miRNA_target')545 analydir = os.path.join(self.projpath,'12.target')546 self.copy_dir(os.path.join(547 analydir,'Common','{commom_target.xls,all_target_gene.xls,commom_target_example.xls,all_target_gene.xls.annotate}'548 ),miRNA_target549 )550 assert not os.system('gzip -c {}/miRanda/miranda_targets_out.fmt > {}/miranda_targets_out.fmt.gz'.format(analydir,miRNA_target))551 assert not os.system('gzip -c {}/RNAhybrid/RNAhybrid_miRNA_target_pairs > {}/RNAhybrid_miRNA_target_pairs.gz'.format(analydir,miRNA_target)) 552 assert not os.system('gzip -c {}/PITA/PITA_pita_results_targets.tab > {}/PITA_pita_results_targets.tab.gz'.format(analydir,miRNA_target)) 553 self.copy_dir(os.path.join(554 self.readme,'15miRNA_target.txt'555 ),os.path.join(miRNA_target,order+'.miRNA_target.Readme.txt')556 )557 def miRNA_target_plant(self):558 559 miRNA_target,order = self.make_dir('miRNA_target')560 analydir = os.path.join(self.projpath,'12.target')561 self.copy_dir(os.path.join(562 analydir,'{*targets.txt,*_example.xls,*targets.pairs.annotate,*targets.pairs}'563 ),miRNA_target564 )565 self.copy_dir(os.path.join(566 self.readme,'15miRNA_target.txt'567 ),os.path.join(miRNA_target,order+'.miRNA_target.Readme.txt')568 ) 569 570 571 def miRNA_target_norefanimal(self):572 573 miRNA_target,order = self.make_dir('miRNA_target')574 analydir = os.path.join(self.projpath,'12.target')575 self.copy_dir(os.path.join(576 analydir,'{*targets,*_example.xls,*targets.pairs.annotate,*targets.pairs}'577 ),miRNA_target578 )579 assert not os.system('gzip -c {}/mature.miranda_targets_out.fmt > {}/mature.miranda_targets_out.fmt.gz'.format(analydir,miRNA_target))580 self.copy_dir(os.path.join(581 self.readme,'15miRNA_target.txt'582 ),os.path.join(miRNA_target,order+'.miRNA_target.Readme.txt')583 )584 def single_sample_Enrichment(self):585 586 Enrichment,order = self.make_dir('Enrichment')587 analydir = os.path.join(self.projpath,'14.enrich')588 godir = os.path.join(Enrichment,self.samples[0],'GOenrichment') 589 keggdir = os.path.join(Enrichment,self.samples[0],'KEGGenrichment')590 assert not os.system('mkdir -p {}'.format(godir))591 assert not os.system('mkdir -p {}'.format(keggdir))592 self.copy_dir(os.path.join(593 analydir,'GO_enrichment','{*DEG*,*png,*pdf}'594 ),godir595 )596 self.copy_dir(os.path.join(597 analydir,'Pathway','{*scatterplot.png,*scatterplot.pdf,src}'598 ),keggdir599 )600 self.copy_dir(os.path.join(601 analydir,self.samples[0],'Pathway','*html'),602 os.path.join(603 keggdir,self.samples[0]+'.DEG_enriched_KEGG_pathway_API.html')604 )605 self.copy_dir(os.path.join(606 analydir,'Pathway',self.samples[0]+'.identify.xls'),607 os.path.join(608 keggdir,self.samples[0]+'.DEG_KEGG_pathway_enrichment_result.xls')609 )610 self.copy_dir(os.path.join(611 analydir,'Pathway','top*.xls'),612 os.path.join(613 keggdir,self.samples[0]+'.DEG_enriched_KEGG_pathway_top20.xls')614 )615 self.copy_dir(os.path.join(616 self.readme,'16Enrichment.txt'617 ),os.path.join(os.path.dirname(GOenrichment),order+'.Enrichment.Readme.txt')618 )619 def multi_sample_Enrichment(self):620 Enrichment,order = self.make_dir('Enrichment')621 analydir = os.path.join(self.projpath,'14.enrich')622 self.copy_dir(os.path.join(623 self.readme,'16Enrichment.txt'624 ),os.path.join(Enrichment,order+'.Enrichment.Readme.txt')625 )626 for each_compare in self.comparename.replace(':','vs').split(','):627 temdir = os.path.join(Enrichment,each_compare)628 assert not os.system('mkdir -p {}'.format(temdir))629 self.copy_dir(os.path.join(630 analydir,each_compare,'{*diffmiRNA-geneid,*diffmiRNAID,*diffmiRNA-gene.pairs}'631 ),temdir632 )633 tmpgodir = os.path.join(temdir,'GOenrichment')634 assert not os.system('mkdir -p {}'.format(tmpgodir))635 self.copy_dir(os.path.join(636 analydir,each_compare,'GO2','*DEG*'637 ),tmpgodir638 )639 os.system('rm -rf {}'.format(os.path.join(tmpgodir,640 '{*classification2_gene_count.txt,*classification2.pdf,*classification2.png}')641 )642 )643 tmpkeggdir = os.path.join(temdir,'KEGGenrichment')644 assert not os.system('mkdir -p {}'.format(tmpkeggdir))645 self.copy_dir(os.path.join(646 analydir,each_compare,'Pathway','{*scatterplot.pdf,*scatterplot.png,src}'647 ),tmpkeggdir648 )649 650 self.copy_dir(os.path.join(651 analydir,each_compare,'Pathway','*html'),652 os.path.join(653 tmpkeggdir,each_compare+'.DEG_enriched_KEGG_pathway_API.html')654 )655 if 'noref' not in self.org:656 657 self.copy_dir(os.path.join(658 analydir,each_compare,'Pathway',each_compare+'.identify.xls'),659 os.path.join(660 tmpkeggdir,each_compare+'.DEG_KEGG_pathway_enrichment_result.xls')661 )662 self.copy_dir(os.path.join(663 analydir,each_compare,'Pathway','top*.xls'),664 os.path.join(665 tmpkeggdir,each_compare+'.DEG_enriched_KEGG_pathway_top20.xls')666 )667 668 else:669 670 self.copy_dir(os.path.join(671 analydir,each_compare,'Pathway',each_compare+'*result.xls'),672 os.path.join(673 tmpkeggdir,each_compare+'.DEG_KEGG_pathway_enrichment_result.xls')674 )675 self.copy_dir(os.path.join(676 analydir,each_compare,'Pathway','*_top20.xls'),677 os.path.join(678 tmpkeggdir,each_compare+'.DEG_enriched_KEGG_pathway_top20.xls')679 )680 def make_dir(self,analysis,subdirs=None):681 subdirL = list()682 order = self.order683 analydir = os.path.join(self.result,order + '.' + analysis)684 if 'SuppFiles' in analysis:685 SupFdir = os.path.join(self.result,'0.SuppFiles')686 assert not os.system(687 'mkdir -p {}'.format(SupFdir)688 )689 return SupFdir690 else:691 if subdirs:692 for subdir in subdirs:693 absubdir = os.path.join(analydir,order + '.' + subdir)694 assert not os.system('mkdir -p {}'.format(absubdir))695 subdirL.append(absubdir)696 subdirL.append(order)697 return subdirL698 else:699 assert not os.system('mkdir -p {}'.format(analydir))700 return analydir,order701 @staticmethod702 def copy_dir(rawdir,newdir):703 if os.path.isfile(rawdir):704 assert not os.system(705 'cp -f {rawdir} {newdir}'.format(706 rawdir = rawdir, newdir = newdir)707 )708 else:709 ## assert not os.system(710 os.system(711 'cp -rf {rawdir} {newdir}'.format(712 rawdir = rawdir, newdir = newdir)713 )714def Argument():715 parser = argparse.ArgumentParser(716 description = 'srna pipline result v1.0',...

Full Screen

Full Screen

test_executers.py

Source:test_executers.py Github

copy

Full Screen

1import shutil2import os3import _executers4import _config5from .sample_data import SAMPLE_DIR, none_dir, copy_dir, move_dir6def _clean_sample_data_dir():7 if os.path.isdir(SAMPLE_DIR):8 shutil.rmtree(SAMPLE_DIR)9 assert not os.path.isdir(SAMPLE_DIR)10def _create_folders_if_dont_exist(sample_data: _config.UserDir):11 _executers._create_folders_if_dont_exists(12 [sample_data.in_, sample_data.out]13 )14def _fill_with_sample_files_with_extension(15 directory: str, num_files: int, extension: str16) -> None:17 for filename in [f"sample{x}.{extension}" for x in range(0, num_files)]:18 with open(os.path.join(directory, filename), "w") as f:19 f.write("sample data")20def test_none_executer_creates_directory():21 _clean_sample_data_dir()22 executer = _executers.NoneExecuter(23 none_dir.in_, none_dir.out, none_dir.filter_24 )25 executer.run()26 assert os.path.isdir(SAMPLE_DIR)27def test_copy_executer_copy_all_files():28 _clean_sample_data_dir()29 _create_folders_if_dont_exist(copy_dir)30 _fill_with_sample_files_with_extension(copy_dir.in_, 3, "jpg")31 _fill_with_sample_files_with_extension(copy_dir.in_, 2, "txt")32 assert len(os.listdir(copy_dir.in_)) == 533 assert len(os.listdir(copy_dir.out)) == 034 executer = _executers.CopyExecuter(35 copy_dir.in_, copy_dir.out, copy_dir.filter_36 )37 executer.run()38 assert len(os.listdir(copy_dir.in_)) == 539 assert len(os.listdir(copy_dir.out)) == 340def test_copy_executer_copy_existing_files():41 _clean_sample_data_dir()42 _create_folders_if_dont_exist(copy_dir)43 _fill_with_sample_files_with_extension(copy_dir.in_, 3, "jpg")44 _fill_with_sample_files_with_extension(copy_dir.out, 1, "jpg")45 _fill_with_sample_files_with_extension(copy_dir.in_, 2, "txt")46 assert len(os.listdir(copy_dir.in_)) == 547 assert len(os.listdir(copy_dir.out)) == 148 executer = _executers.CopyExecuter(49 copy_dir.in_, copy_dir.out, copy_dir.filter_50 )51 executer.run()52 assert len(os.listdir(copy_dir.in_)) == 553 assert len(os.listdir(copy_dir.out)) == 354def test_move_executer_all_files():55 _clean_sample_data_dir()56 _create_folders_if_dont_exist(move_dir)57 _fill_with_sample_files_with_extension(move_dir.in_, 3, "jpg")58 _fill_with_sample_files_with_extension(move_dir.in_, 2, "txt")59 assert len(os.listdir(move_dir.in_)) == 560 assert len(os.listdir(move_dir.out)) == 061 executer = _executers.MoveExecuter(62 move_dir.in_, move_dir.out, move_dir.filter_63 )64 executer.run()65 assert len(os.listdir(move_dir.in_)) == 266 assert len(os.listdir(move_dir.out)) == 367def test_copy_executer_move_existing_files():68 _clean_sample_data_dir()69 _create_folders_if_dont_exist(move_dir)70 _fill_with_sample_files_with_extension(move_dir.in_, 3, "jpg")71 _fill_with_sample_files_with_extension(move_dir.in_, 2, "txt")72 _fill_with_sample_files_with_extension(move_dir.out, 1, "jpg")73 assert len(os.listdir(move_dir.in_)) == 574 assert len(os.listdir(move_dir.out)) == 175 executer = _executers.MoveExecuter(76 move_dir.in_, move_dir.out, move_dir.filter_77 )78 executer.run()79 assert len(os.listdir(move_dir.in_)) == 280 assert len(os.listdir(move_dir.out)) == 381def test_copy_over_same_out_path():82 _clean_sample_data_dir()83 _create_folders_if_dont_exist(copy_dir)84 _fill_with_sample_files_with_extension(copy_dir.out, 3, "jpg")85 _fill_with_sample_files_with_extension(copy_dir.out, 2, "txt")86 assert len(os.listdir(copy_dir.out)) == 587 executer = _executers.CopyExecuter(88 copy_dir.out, copy_dir.out, copy_dir.filter_89 )90 executer.run()91 assert len(os.listdir(copy_dir.out)) == 592def test_move_executer_same_out_path():93 _clean_sample_data_dir()94 _create_folders_if_dont_exist(move_dir)95 _fill_with_sample_files_with_extension(move_dir.out, 3, "jpg")96 _fill_with_sample_files_with_extension(move_dir.out, 2, "txt")97 assert len(os.listdir(move_dir.out)) == 598 executer = _executers.MoveExecuter(99 move_dir.out, move_dir.out, move_dir.filter_100 )101 executer.run()...

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