@@ -32,6 +32,7 @@ process report {
3232 path contigPlots
3333 path annStats
3434 path alnstats
35+ path readsToRefReports
3536
3637 output:
3738 path " *"
@@ -49,26 +50,27 @@ process report {
4950 my \$ ont_flag = ("${ platform != null ? platform.trim(): ""} " =~ /NANOPORE/)? 1 : 0;
5051 my \$ pacbio_flag = ("${ platform != null ? platform.trim(): ""} " =~ /PACBIO/)? 1 : 0;
5152 my \$ mergeFiles="\$ InputLogPDF,";
52- \$ mergeFiles.="$qcReport "."," if ( -e "$qcReport ");
53+ \$ mergeFiles.="$qcReport "."," if ( -s "$qcReport ");
5354 my \$ imagesDir = "./HTML_Report/images";
5455 my \$ final_pdf= "./final_report.pdf";
5556
5657
58+
59+
5760 my \$ taxonomyPDFfiles="";
58- \$ taxonomyPDFfiles .= "$readsTaxonomyReports " if("$readsTaxonomyReports " ne "DNE4 ");
61+ \$ taxonomyPDFfiles .= "$readsTaxonomyReports " if("$readsTaxonomyReports " ne "NO_FILE4 ");
5962 \$ taxonomyPDFfiles =~ s/\\ s/,/g;
60- \$ taxonomyPDFfiles .= "$contigTaxonomyReport "."," if( -e "$contigTaxonomyReport ");
63+ \$ taxonomyPDFfiles .= "$contigTaxonomyReport "."," if( -s "$contigTaxonomyReport ");
6164
6265
6366 my \$ qc_flag = (${ settings['faqcs']} )?"V":"";
6467 my \$ assembly_flag = (${ settings["runAssembly"]} )?"V":"";
6568 my \$ annotation_flag = (${ settings["annotation"]} )?"V":"";
6669 my \$ taxonomy_flag = (${ settings["readsTaxonomyAssignment"]} )?"V":"";
6770
68- my \$ features_parameters = "qc<-c(\\ "\$ qc_flag\\ ",\\ "QC\\ ")\\ nhost<-c( \\ " \$ host_removal_flag \\ ", \\ "Host Removal \\ ") \\ n
71+ my \$ features_parameters = "qc<-c(\\ "\$ qc_flag\\ ",\\ "QC\\ ")\\ n
6972 assembly<-c(\\ "\$ assembly_flag\\ ",\\ "Assembly\\ ")\\ nannotation<-c(\\ "\$ assembly_flag\\ ",\\ "Annotation\\ ")\\ n
70- taxonomy<-c(\\ "\$ taxonomy_flag\\ ",\\ "Taxonomy Classification\\ ")\\ n
71- primer<-c(\\ "\$ primer_flag\\ ",\\ "Primer Design\\ ")\\ n";
73+ taxonomy<-c(\\ "\$ taxonomy_flag\\ ",\\ "Taxonomy Classification\\ ")\\ n";
7274
7375 open (my \$ Rfh, ">\$ Rscript") or die "\$ Rscript \$ !";
7476 print \$ Rfh <<Rscript;
@@ -85,10 +87,22 @@ process report {
8587 input_pos<-nextPos-0.28
8688 Rscript
8789
90+
91+ if(${ settings['refBasedAnalysis']} ){
92+ print \$ Rfh <<Rscript;
93+
94+ text(0,nextPos,paste("Reference:",\" ${ settings["selectGenomes"].plus(settings["referenceGenomes"]).join(", ")} \" ),adj=0,font=2)
95+ nextPos<-nextPos-0.08
96+ parameters_pos<-nextPos-0.12
97+ input_pos<-nextPos-0.26
98+ Rscript
99+ }
100+
101+
88102 print \$ Rfh <<Rscript;
89103 text(0,nextPos,"Features:",adj=0,font=2)
90104 \$ features_parameters
91- parameters<-rbind(qc,host, assembly,annotation,taxonomy,primer )
105+ parameters<-rbind(qc,assembly,annotation,taxonomy)
92106 rownames(parameters)<-parameters[,2]
93107 parameters<-t(parameters)
94108 parameters[2,]<-\\ "\\ "
@@ -113,11 +127,41 @@ process report {
113127 Rscript
114128 }
115129
130+ if ((\$ ont_flag or \$ pacbio_flag)&& -s "$qcStats " ){
131+ print \$ Rfh <<Rscript;
132+ def.par <- par(no.readonly = TRUE)
133+ pdf(file = \" $qcReport \" ,width=10,height=8)
134+ par(family="mono")
135+ SummaryStats<-readLines("$qcStats ")
136+ plot(0:1,0:1,type=\' n\' ,xlab=\"\" ,ylab=\"\" ,xaxt=\' n\' ,yaxt=\' n\' ,bty=\' n\' )
137+ adjust<-11
138+ abline(h=0.85,lty=2)
139+ for (i in 1:length(SummaryStats)){
140+ if (i>5 && i<adjust){
141+ text(0.45,1-0.035*(i-6),SummaryStats[i],adj=0,font=2,cex=0.9)
142+ }else if(i >=adjust){
143+ text(0.05,1-0.035*(i-6),SummaryStats[i],adj=0,font=2,cex=0.9)
144+ }else{
145+ text(0.05,1-0.035*(i-1),SummaryStats[i],adj=0,font=2,cex=0.9)
146+ }
147+ }
148+
149+ title("QC stats")
150+ par(def.par)#- reset to default
151+ tmp<-dev.off()
152+ Rscript
116153
117- if (-e "$contigStatsReport "){
154+ #TODO: nanoplot plots
155+
156+
157+ }
158+
159+
160+
161+ if (-s "$contigStatsReport "){
118162 \$ mergeFiles .= '$contigStatsReport '.",";
119163 }
120- if ( -e "$alnstats "){
164+ if ( -s "$alnstats "){
121165 \$ mergeFiles .= "alnstats.pdf".",".'$contigPlots '.",";
122166 print \$ Rfh <<Rscript;
123167 pdf(file = "alnstats.pdf",width = 10, height = 8)
@@ -135,7 +179,26 @@ process report {
135179
136180 }
137181
138- \$ mergeFiles .= '$annStats '."," if ( -e '$annStats ');
182+ \$ mergeFiles .= '$annStats '."," if ( -s '$annStats ');
183+
184+ if (${ settings['refBasedAnalysis']} ) {
185+ if ( -s "${ readsToRefReports[0]} "){
186+ \$ mergeFiles .= "${ readsToRefReports[1]} ".","."${ readsToRefReports[0]} ".",";
187+ print \$ Rfh <<Rscript;
188+ pdf(file = "${ readsToRefReports[1]} ",width = 10, height = 8)
189+
190+ readsMappingToRefStats<-readLines("${ readsToRefReports[0]} ",n=11)
191+ readsMappingToRefStats<-gsub("-?nan","0",readsMappingToRefStats,ignore.case = TRUE)
192+ plot(0:1,0:1,type='n',xlab="",ylab="",xaxt='n',yaxt='n')
193+ for (i in 1:length(readsMappingToRefStats)){
194+ text(0,1-0.07*i,readsMappingToRefStats[i],adj=0,font=2)
195+ }
196+ title("Mapping Reads to Reference")
197+ tmp<-dev.off()
198+ Rscript
199+ }
200+ }
201+
139202
140203 \$ mergeFiles .= \$ taxonomyPDFfiles if (\$ taxonomyPDFfiles);
141204
@@ -152,7 +215,7 @@ process report {
152215
153216
154217 my @conversions;
155- if ( -e "$qcReport ")
218+ if ( -s "$qcReport ")
156219 {
157220 my \$ page_count = `pdfPageCount.pl "$qcReport "`;
158221 chomp \$ page_count;
@@ -165,19 +228,19 @@ process report {
165228 push @conversions, "convert -strip -density 120 -flatten $qcReport [\$ qc_boxplot_page] ./QC_quality_boxplot.png";
166229 }
167230
168- push @conversions, "convert -strip -density 120 -flatten $contigStatsReport [0] ./Assembly_length.png" if (-e "$contigStatsReport ");
169- push @conversions, "convert -strip -density 120 -flatten $contigStatsReport [1] ./Assembly_GC_content.png" if (-e "$contigStatsReport ");
170- push @conversions, "convert -strip -density 120 -flatten $contigPlots [0] ./Assembly_CovDepth_vs_Len.png" if (-e "$contigPlots ");
171- push @conversions, "convert -strip -density 120 -flatten $contigPlots [1] ./Assembly_Cov_vs_Len.png" if (-e "$contigPlots ");
172- push @conversions, "convert -strip -density 120 -flatten $contigPlots [2] ./Assembly_GC_vs_CovDepth.png" if (-e "$contigPlots ");
173- push @conversions, "convert -strip -density 120 -flatten $annStats ./annotation_stats_plots.png" if (-e "$annStats ");
231+ push @conversions, "convert -strip -density 120 -flatten $contigStatsReport [0] ./Assembly_length.png" if (-s "$contigStatsReport ");
232+ push @conversions, "convert -strip -density 120 -flatten $contigStatsReport [1] ./Assembly_GC_content.png" if (-s "$contigStatsReport ");
233+ push @conversions, "convert -strip -density 120 -flatten $contigPlots [0] ./Assembly_CovDepth_vs_Len.png" if (-s "$contigPlots ");
234+ push @conversions, "convert -strip -density 120 -flatten $contigPlots [1] ./Assembly_Cov_vs_Len.png" if (-s "$contigPlots ");
235+ push @conversions, "convert -strip -density 120 -flatten $contigPlots [2] ./Assembly_GC_vs_CovDepth.png" if (-s "$contigPlots ");
236+ push @conversions, "convert -strip -density 120 -flatten $annStats ./annotation_stats_plots.png" if (-s "$annStats ");
174237
175238 foreach my \$ file(split /,/, \$ taxonomyPDFfiles)
176239 {
177240 next if (\$ file eq "$contigTaxonomyReport ");
178241 my (\$ file_name, \$ file_path, \$ file_suffix)=fileparse("\$ file", qr/\\ .[^.]*/);
179242 my \$ size_opt = (\$ file_name =~ /tree/)? "-resize 240":"-density 120";
180- push @conversions, "convert \$ size_opt -colorspace RGB -flatten \$ file ./\$ file_name.png" if (-e \$ file);
243+ push @conversions, "convert \$ size_opt -colorspace RGB -flatten \$ file ./\$ file_name.png" if (-s \$ file);
181244 }
182245
183246 eval {system(\$ _)} foreach (@conversions);
@@ -199,6 +262,7 @@ workflow REPORT {
199262 contigPlots
200263 annStats
201264 alnStats
265+ readsToRefReports
202266
203267 main :
204268 report(settings,
@@ -211,6 +275,7 @@ workflow REPORT {
211275 contigStatsReport,
212276 contigPlots,
213277 annStats,
214- alnStats)
278+ alnStats,
279+ readsToRefReports)
215280
216281}
0 commit comments