| 
0
 | 
     1 #!/bin/bash
 | 
| 
 | 
     2 
 | 
| 
 | 
     3 #########################################
 | 
| 
 | 
     4 ###     SPECIFY THE NUMBER OF CPU     ###
 | 
| 
 | 
     5 #########################################
 | 
| 
 | 
     6 cpu=1
 | 
| 
 | 
     7 
 | 
| 
 | 
     8 
 | 
| 
 | 
     9 
 | 
| 
 | 
    10 
 | 
| 
 | 
    11 
 | 
| 
 | 
    12 #########################################
 | 
| 
 | 
    13 ###        Recover the arguments      ###
 | 
| 
 | 
    14 #########################################
 | 
| 
 | 
    15 html=$1;shift
 | 
| 
 | 
    16 len_file_path=$1;shift
 | 
| 
 | 
    17 estimSign=$1;shift
 | 
| 
 | 
    18 parameters=$1;shift
 | 
| 
 | 
    19 working_dir=`pwd`
 | 
| 
 | 
    20 
 | 
| 
 | 
    21 
 | 
| 
 | 
    22 
 | 
| 
 | 
    23 mkdir in
 | 
| 
 | 
    24 cd in
 | 
| 
 | 
    25 
 | 
| 
 | 
    26 names=$(sed 's/\s/_/g' <<< $*)
 | 
| 
 | 
    27 names=$(sed 's/_\// \//g' <<< $names)
 | 
| 
 | 
    28 names=$(sed 's/_annotated//g' <<< $names)
 | 
| 
 | 
    29 names=$(sed 's/_filtered//g' <<< $names)
 | 
| 
 | 
    30 names=$(sed 's/\.txt_/_/' <<< $names)
 | 
| 
 | 
    31 
 | 
| 
 | 
    32 for name in ${names}
 | 
| 
 | 
    33 do
 | 
| 
 | 
    34   file=$(sed 's/=/ /' <<< $name);
 | 
| 
 | 
    35   echo $file
 | 
| 
 | 
    36   ln -s $file
 | 
| 
 | 
    37 done
 | 
| 
 | 
    38 cd ..
 | 
| 
 | 
    39 
 | 
| 
 | 
    40 output_dir=${html%%.*}_files
 | 
| 
 | 
    41 
 | 
| 
 | 
    42 
 | 
| 
 | 
    43 #########################################
 | 
| 
 | 
    44 ### Calculates the statistics         ###
 | 
| 
 | 
    45 #########################################
 | 
| 
 | 
    46 
 | 
| 
 | 
    47 perl $SCRIPT_PATH/mutspecStat.pl --outfile $output_dir \
 | 
| 
 | 
    48 	--temp "$working_dir/temp" \
 | 
| 
 | 
    49 	--pathRscript $SCRIPT_PATH \
 | 
| 
 | 
    50 	$parameters \
 | 
| 
 | 
    51 	$working_dir/in
 | 
| 
 | 
    52 
 | 
| 
 | 
    53 
 | 
| 
 | 
    54 #########################################
 | 
| 
 | 
    55 ### Estimate the number of signatures ###
 | 
| 
 | 
    56 #########################################
 | 
| 
 | 
    57 if [[ $estimSign > 0 ]]; then
 | 
| 
 | 
    58   Rscript $SCRIPT_PATH/R/estimateSign_Galaxy.r --input $output_dir/Mutational_Analysis/Figures/Input_NMF/Input_NMF_Count.txt --stop $estimSign --cpu $cpu --output $output_dir/Mutational_Analysis/Figures/Estimate_Number_Signatures.png 2>&1
 | 
| 
 | 
    59 fi
 | 
| 
 | 
    60 
 | 
| 
 | 
    61 
 | 
| 
 | 
    62 #########################################
 | 
| 
 | 
    63 ### Create css                          #
 | 
| 
 | 
    64 #########################################
 | 
| 
 | 
    65 css=$output_dir/Mutational_Analysis/style.css
 | 
| 
 | 
    66 echo ".legend{position:relative}.legend .legend-hidden{display:none;position:absolute;background-color:#fff;border:3px solid #03F;padding:3px;color:#000;font-size:1em;border-radius:10px;margin-top:-40px}.legend:hover .legend-hidden{display:block}" > $css
 | 
| 
 | 
    67 
 | 
| 
 | 
    68 
 | 
| 
 | 
    69 
 | 
| 
 | 
    70 # HMTL page for the result of the tool
 | 
| 
 | 
    71 echo "<html>" >> $html
 | 
| 
 | 
    72 echo "<body>" >> $html
 | 
| 
 | 
    73 
 | 
| 
 | 
    74 if [ -d $output_dir/Mutational_Analysis/Figures ]; then
 | 
| 
 | 
    75 
 | 
| 
 | 
    76 echo "<center> <h2>Mutational spectra report summary</h2> </center>" >> $html
 | 
| 
 | 
    77 
 | 
| 
 | 
    78 echo "<br/> Download the full report in Excel" >> $html
 | 
| 
 | 
    79 
 | 
| 
 | 
    80 ## One report with all the samples. Specify the full path
 | 
| 
 | 
    81 if [[ -e "$output_dir/Mutational_Analysis/Report_Mutation_Spectra.xls" ]]
 | 
| 
 | 
    82 then
 | 
| 
 | 
    83 	# Interpreted by Galaxy so don't need the full path
 | 
| 
 | 
    84 	echo "<br/><a href="Mutational_Analysis/Report_Mutation_Spectra.xls">Report_Mutation_Spectra.xls</a>" >> $html
 | 
| 
 | 
    85 fi
 | 
| 
 | 
    86 ## One report for each samples
 | 
| 
 | 
    87 for file in $names
 | 
| 
 | 
    88 do
 | 
| 
 | 
    89   name=$(echo ${file}| cut -d"=" -f2)
 | 
| 
 | 
    90   name=${name%.*}
 | 
| 
 | 
    91 
 | 
| 
 | 
    92   # One report for each samples
 | 
| 
 | 
    93   if [[ -e "$output_dir/Mutational_Analysis/Report_Mutation_Spectra-$name.xls" ]]
 | 
| 
 | 
    94   then
 | 
| 
 | 
    95     echo "<br/><a href="Mutational_Analysis/Report_Mutation_Spectra-$name.xls">Report_Mutation_Spectra-$name.xls</a>" >> $html
 | 
| 
 | 
    96   fi
 | 
| 
 | 
    97 done
 | 
| 
 | 
    98 ## One report for each samples: Pool_Data
 | 
| 
 | 
    99 if [[ $parameters =~ "--pooldata" ]]; then
 | 
| 
 | 
   100   if [[ -e "$output_dir/Mutational_Analysis/Report_Mutation_Spectra-Pool_Data.xls" ]]; then
 | 
| 
 | 
   101     echo "<br/><a href="Mutational_Analysis/Report_Mutation_Spectra-Pool_Data.xls">Report_Mutation_Spectra-Pool_Data.xls</a>" >> $html
 | 
| 
 | 
   102   fi
 | 
| 
 | 
   103 fi
 | 
| 
 | 
   104 
 | 
| 
 | 
   105 
 | 
| 
 | 
   106 ## Input file for NMF
 | 
| 
 | 
   107 if [[ -e "$output_dir/Mutational_Analysis/Figures/Input_NMF/Input_NMF_Count.txt" ]]
 | 
| 
 | 
   108 then
 | 
| 
 | 
   109   # Interpreted by Galaxy so don't need the full path
 | 
| 
 | 
   110   echo "<br/><br/> Download the input file for the tool mutSpec-NMF" >> $html
 | 
| 
 | 
   111   echo "<br/><a href="Mutational_Analysis/Figures/Input_NMF/Input_NMF_Count.txt">Input_NMF_Count.txt</a><br/>" >> $html
 | 
| 
 | 
   112 fi
 | 
| 
 | 
   113 
 | 
| 
 | 
   114 ## Computed statistics for estimating the number of signatures
 | 
| 
 | 
   115 if [[ $estimSign > 0 ]]; then
 | 
| 
 | 
   116   echo "<br/> Link to the computed statistics for estimating the number of signatures <br/>" >> $html
 | 
| 
 | 
   117   if [[ -e "$output_dir/Mutational_Analysis/Figures/Estimate_Number_Signatures.png" ]]; then
 | 
| 
 | 
   118     outEstimateSign="$output_dir/Mutational_Analysis/EstimatingSignatures.html"
 | 
| 
 | 
   119     touch $outEstimateSign
 | 
| 
 | 
   120     echo "<a href='Mutational_Analysis/EstimatingSignatures.html'>Estimating the number of signatures</a><br/>" >> $html
 | 
| 
 | 
   121     echo "<br/> <center> <h2>Computed statistics for estimating the number of signatures</h2> </center> <br/>" >> $outEstimateSign
 | 
| 
 | 
   122     echo "Several approaches have been proposed to choose the optimal number of signatures to extract with NMF. <br/>
 | 
| 
 | 
   123           Brunet et al. 2004, proposed to take the first number of signature for which the cophenetic coefficient starts decreasing, <br/>
 | 
| 
 | 
   124           Hutchins et al. 2008, suggested to choose the first value where the RSS curve presents an inflection point. <br/>
 | 
| 
 | 
   125           Frigyesi et al. 2008, considered the smallest value at which the decrease in the RSS is lower than the decrease of the RSS obtained from random data. <br/><br/>
 | 
| 
 | 
   126           The estimation are based on Brunet’s algorithm computed from 50 runs for each value of signature to estimate. <br/> <br/>
 | 
| 
 | 
   127           The original data are shuffled for comparing the quality measures obtained with our data (Data x) and from randomized data (Data y). The curves for the actual data are in solid line, those for the randomized data are in dashed line. <br/> <br/>" >> $outEstimateSign
 | 
| 
 | 
   128     echo "<img src="Figures/Estimate_Number_Signatures.png width="1000""/><br/></td>" >> $outEstimateSign
 | 
| 
 | 
   129   else
 | 
| 
 | 
   130     echo "<br/>There is not enough mutations for estimating the number of signatures <br/>" >> $html
 | 
| 
 | 
   131     echo "Read the tool standard output for more detail<br/>"  >> $html
 | 
| 
 | 
   132   fi
 | 
| 
 | 
   133 fi
 | 
| 
 | 
   134 
 | 
| 
 | 
   135 
 | 
| 
 | 
   136 ## HMTL Link to the samples
 | 
| 
 | 
   137 echo "<br/> Link to individual samples <br/>" >> $html
 | 
| 
 | 
   138 for file in $names
 | 
| 
 | 
   139 do
 | 
| 
 | 
   140   name=$(echo ${file}| cut -d"=" -f2)
 | 
| 
 | 
   141   name=${name%.*}
 | 
| 
 | 
   142   outfile="$output_dir/Mutational_Analysis/$name.html"
 | 
| 
 | 
   143   touch $outfile # Create an empty file named $outfile
 | 
| 
 | 
   144   echo "<a href='Mutational_Analysis/$name.html'>$name</a><br/>" >> $html
 | 
| 
 | 
   145 
 | 
| 
 | 
   146 #-------------------------------------------------------------------------------------------------------------------------------------------------------------------------#
 | 
| 
 | 
   147 #                                                                              INDIVIDUAL SAMPLES                                                                         #
 | 
| 
 | 
   148 #-------------------------------------------------------------------------------------------------------------------------------------------------------------------------#
 | 
| 
 | 
   149 echo "<br/> <center> <h2>Mutational Spectra report for $name</h2> </center> <br/>" >> $outfile
 | 
| 
 | 
   150 
 | 
| 
 | 
   151 echo "<html>" >> $outfile
 | 
| 
 | 
   152 
 | 
| 
 | 
   153 echo "<head>" >> $outfile
 | 
| 
 | 
   154 echo "<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">" >> $outfile
 | 
| 
 | 
   155 # Link to the css style file for having a legend when we pass the mouse on the figures
 | 
| 
 | 
   156 echo "<link rel="stylesheet" href="style.css" />" >> $outfile
 | 
| 
 | 
   157 echo "</head>" >> $outfile
 | 
| 
 | 
   158 
 | 
| 
 | 
   159 echo "<body>" >> $outfile
 | 
| 
 | 
   160 
 | 
| 
 | 
   161 echo "<table>" >> $outfile
 | 
| 
 | 
   162 echo "<tr>" >> $outfile
 | 
| 
 | 
   163 echo "<th><h3>Overall mutation distribution</h3></th>" >> $outfile
 | 
| 
 | 
   164 echo "<th><h3>Impact on protein sequence</h3></th>" >> $outfile
 | 
| 
 | 
   165 echo "</tr><tr>" >> $outfile
 | 
| 
 | 
   166 echo "<td> <center> <a href="Figures/Overall_mutation_distribution/$name/$name-OverallMutationDistribution.txt">$name-OverallMutationDistribution.txt</a> </center> </td>" >> $outfile
 | 
| 
 | 
   167 echo "<td> <center> <a href="Figures/Impact_protein_sequence/$name/$name-DistributionExoFunc.txt">$name-DistributionExoFunc.txt</a> </center> </td>" >> $outfile
 | 
| 
 | 
   168 echo "</tr><tr>" >> $outfile
 | 
| 
 | 
   169 
 | 
| 
 | 
   170 echo "<td>" >> $outfile
 | 
| 
 | 
   171 echo "<span class="legend"><img src="Figures/Overall_mutation_distribution/$name/$name-OverallMutationDistribution.png width="280""/>" >> $outfile
 | 
| 
 | 
   172 echo "<span class="legend-hidden">" >> $outfile
 | 
| 
 | 
   173 echo "<center><B>Overall Mutation Distribution</center></B><br/>Proportion of all mutation types (total count are indicated in parenthesis). For indels the counts are based on annotation retrieved from the database ExonicFunc.refGene<br/>" >> $outfile
 | 
| 
 | 
   174 echo "</td>" >> $outfile
 | 
| 
 | 
   175 echo "<td>" >> $outfile
 | 
| 
 | 
   176 echo "<span class="legend"><img src="Figures/Impact_protein_sequence/$name/$name-DistributionExoFunc.png width="400""/>" >> $outfile
 | 
| 
 | 
   177 echo "<span class="legend-hidden">" >> $outfile
 | 
| 
 | 
   178 echo "<center><B>Graph 1. Impact on protein sequence</center></B><br/>Impact of all mutations (SBS and Indel) on the protein sequence based on the ExonicFunc.refGene annotation<br/>" >> $outfile
 | 
| 
 | 
   179 echo "</td>" >> $outfile
 | 
| 
 | 
   180 
 | 
| 
 | 
   181 echo "</tr>" >> $outfile
 | 
| 
 | 
   182 echo "</table>" >> $outfile
 | 
| 
 | 
   183 
 | 
| 
 | 
   184 echo "<br/><br/>"  >> $outfile
 | 
| 
 | 
   185 
 | 
| 
 | 
   186 
 | 
| 
 | 
   187 echo "<table>" >> $outfile
 | 
| 
 | 
   188 echo "<tr>" >> $outfile
 | 
| 
 | 
   189 echo "<th><h3>SBS distribution</h3></th>" >> $outfile
 | 
| 
 | 
   190 echo "<th><h3>Stranded distribution of SBS</h3></th>" >> $outfile
 | 
| 
 | 
   191 echo "</tr><tr>" >> $outfile
 | 
| 
 | 
   192 echo "<td> <center> <a href="Figures/SBS_distribution/$name/$name-SBS_distribution.txt">$name-SBS_distribution.txt</a> </center> </td>" >> $outfile
 | 
| 
 | 
   193 echo "<td> <center> <a href="Figures/Stranded_Analysis/$name/$name-StrandBias.txt">$name-StrandBias.txt</a> </center> </td>" >> $outfile
 | 
| 
 | 
   194 echo "</tr><tr>" >> $outfile
 | 
| 
 | 
   195 
 | 
| 
 | 
   196 echo "<td>" >> $outfile
 | 
| 
 | 
   197 echo "<span class="legend"><img src="Figures/SBS_distribution/$name/$name-SBS_distribution.png width="550""/>" >> $outfile
 | 
| 
 | 
   198 echo "<span class="legend-hidden">" >> $outfile
 | 
| 
 | 
   199 echo "<center><B>Graph 2. SBS distribution</center></B><br/>Proportion of each type of single base substitution (SBS)<br/>" >> $outfile
 | 
| 
 | 
   200 echo "</td>" >> $outfile
 | 
| 
 | 
   201 echo "<td>" >> $outfile
 | 
| 
 | 
   202 echo "<span class="legend"><img src="Figures/Stranded_Analysis/$name/$name-StrandBias.png width="400""/>" >> $outfile
 | 
| 
 | 
   203 echo "<span class="legend-hidden">" >> $outfile
 | 
| 
 | 
   204 echo "<center><B>Graph 3. Stranded distribution of SBS</center></B><br/>Count of the six substitution types on the transcribed and non-transcribed strand<br/>" >> $outfile
 | 
| 
 | 
   205 echo "</td>" >> $outfile
 | 
| 
 | 
   206 
 | 
| 
 | 
   207 echo "</tr>" >> $outfile
 | 
| 
 | 
   208 echo "</table>" >> $outfile
 | 
| 
 | 
   209 
 | 
| 
 | 
   210 
 | 
| 
 | 
   211 echo "<br/><br/>"  >> $outfile
 | 
| 
 | 
   212 
 | 
| 
 | 
   213 
 | 
| 
 | 
   214 ######################################################
 | 
| 
 | 
   215 #	Trinucleotide sequence context of SBS on genomic #
 | 
| 
 | 
   216 ######################################################
 | 
| 
 | 
   217 echo "<table>" >> $outfile
 | 
| 
 | 
   218 echo "<h3>Trinucleotide sequence context of SBS on the genomic sequence</h3>" >> $outfile
 | 
| 
 | 
   219 echo "<tr>" >> $outfile
 | 
| 
 | 
   220 echo "<td> <center> <a href="Figures/Trinucleotide_Sequence_Context/$name/$name-MutationSpectraPercent-Genomic.txt">$name-MutationSpectraPercent.txt</a> </center> </td>" >> $outfile
 | 
| 
 | 
   221 echo "<td> <center> <a href="Figures/Trinucleotide_Sequence_Context/$name/$name-HeatmapPercent-Genomic.txt">$name-HeatmapPercent-Genomic.txt</a> </center> </td>" >> $outfile
 | 
| 
 | 
   222 echo "</tr><tr>" >> $outfile
 | 
| 
 | 
   223 
 | 
| 
 | 
   224 echo "<td>" >> $outfile
 | 
| 
 | 
   225 echo "<span class="legend"><img src="Figures/Trinucleotide_Sequence_Context/$name/$name-MutationSpectraPercent-Genomic.png width="1000""/>" >> $outfile
 | 
| 
 | 
   226 echo "<span class="legend-hidden">" >> $outfile
 | 
| 
 | 
   227 echo "<center><B>Panel 1. Trinucleotide sequence context of SBS on the genomic sequence</center></B><br/>Proportion of the six substitution types with their trinucleotide sequence context (total number of mutation is shown in parenthesis)<br/>" >> $outfile
 | 
| 
 | 
   228 echo "</td>" >> $outfile
 | 
| 
 | 
   229 echo "<td>" >> $outfile
 | 
| 
 | 
   230 echo "<span class="legend"><img src="Figures/Trinucleotide_Sequence_Context/$name/$name-HeatmapPercent-Genomic.png width="250""/>" >> $outfile
 | 
| 
 | 
   231 echo "<span class="legend-hidden">" >> $outfile
 | 
| 
 | 
   232 echo "<center><B>Panel 1. Trinucleotide sequence context of SBS on the genomic sequence</center></B><br/>Proportion of the six substitution types with their trinucleotide sequence context<br/>" >> $outfile
 | 
| 
 | 
   233 echo "</td>" >> $outfile
 | 
| 
 | 
   234 
 | 
| 
 | 
   235 echo "</tr>" >> $outfile
 | 
| 
 | 
   236 echo "</table>" >> $outfile
 | 
| 
 | 
   237 
 | 
| 
 | 
   238 
 | 
| 
 | 
   239 echo "<br/><br/>"  >> $outfile
 | 
| 
 | 
   240 
 | 
| 
 | 
   241 
 | 
| 
 | 
   242 ##############################################################
 | 
| 
 | 
   243 #	Trinucleotide sequence context of SBS on coding sequence #
 | 
| 
 | 
   244 ##############################################################
 | 
| 
 | 
   245 echo "<table>" >> $outfile
 | 
| 
 | 
   246 echo "<h3>Stranded analysis of trinucleotide sequence context of SBS</h3>" >> $outfile
 | 
| 
 | 
   247 echo "<tr>" >> $outfile
 | 
| 
 | 
   248 echo "<td> <center> <a href="Figures/Stranded_Analysis/$name/$name-StrandedSignaturePercent.txt">$name-StrandedSignaturePercent.txt</a> </center> </td>" >> $outfile
 | 
| 
 | 
   249 echo "</tr><tr>" >> $outfile
 | 
| 
 | 
   250 
 | 
| 
 | 
   251 echo "<td>" >> $outfile
 | 
| 
 | 
   252 echo "<span class="legend"><img src="Figures/Stranded_Analysis/$name/$name-StrandedSignaturePercent.png width="1300""/>" >> $outfile
 | 
| 
 | 
   253 echo "<span class="legend-hidden">" >> $outfile
 | 
| 
 | 
   254 echo "<center><B>Panel 2. Stranded analysis of trinucleotide sequence context of SBS</center></B><br/>Proportion of SBS with their trinucleotide context considering the non-transcribed and transcribed strand<br/>" >> $outfile
 | 
| 
 | 
   255 echo "</td>" >> $outfile
 | 
| 
 | 
   256 echo "</tr>" >> $outfile
 | 
| 
 | 
   257 echo "</table>" >> $outfile
 | 
| 
 | 
   258 
 | 
| 
 | 
   259 echo "<br/><br/>"  >> $outfile
 | 
| 
 | 
   260 
 | 
| 
 | 
   261 
 | 
| 
 | 
   262 #############################################
 | 
| 
 | 
   263 #	Sequence logo generated with Weblogo3 	#
 | 
| 
 | 
   264 #############################################
 | 
| 
 | 
   265 echo "<table>" >> $outfile
 | 
| 
 | 
   266 echo "<h3>Wider sequence context with Weblogo3</h3>" >> $outfile
 | 
| 
 | 
   267 # Legende de la figure : Panel 3. Wider sequence context on genomic strand generated with Weblogo3
 | 
| 
 | 
   268 
 | 
| 
 | 
   269 # C>A
 | 
| 
 | 
   270 echo "<tr>" >> $outfile
 | 
| 
 | 
   271 if [[ ! -e "$output_dir/Mutational_Analysis/Figures/WebLogo/$name/$name-CA-Probability.png" ]]; then
 | 
| 
 | 
   272   echo "<td>WARNING: No sequence for C>A </br> </td>" >> $outfile
 | 
| 
 | 
   273 else
 | 
| 
 | 
   274   echo "<td><a href="Figures/WebLogo/$name/$name-CA.fa">$name-CA.fa</a><br/>" >> $outfile
 | 
| 
 | 
   275   echo "<img src="Figures/WebLogo/$name/$name-CA-Probability.png"/><br/></td>" >> $outfile
 | 
| 
 | 
   276 fi
 | 
| 
 | 
   277 # C>G
 | 
| 
 | 
   278 if [[ ! -e "$output_dir/Mutational_Analysis/Figures/WebLogo/$name/$name-CG-Probability.png" ]]; then
 | 
| 
 | 
   279   echo "<td> WARNING: No sequence for C>G </br> </td>" >> $outfile
 | 
| 
 | 
   280 else
 | 
| 
 | 
   281   echo "<td><a href="Figures/WebLogo/$name/$name-CG.fa">$name-CG.fa</a><br/>" >> $outfile
 | 
| 
 | 
   282   echo "<img src="Figures/WebLogo/$name/$name-CG-Probability.png"/><br/></td>" >> $outfile
 | 
| 
 | 
   283 fi
 | 
| 
 | 
   284 # C>T
 | 
| 
 | 
   285 if [[ ! -e "$output_dir/Mutational_Analysis/Figures/WebLogo/$name/$name-CT-Probability.png" ]]; then
 | 
| 
 | 
   286   echo "<td> WARNING: No sequence for C>T </br> </td>" >> $outfile
 | 
| 
 | 
   287 else
 | 
| 
 | 
   288  echo "<td><a href="Figures/WebLogo/$name/$name-CT.fa">$name-CT.fa</a><br/>" >> $outfile
 | 
| 
 | 
   289  echo "<img src="Figures/WebLogo/$name/$name-CT-Probability.png"/><br/></td>" >> $outfile
 | 
| 
 | 
   290 fi
 | 
| 
 | 
   291 echo "</tr>" >> $outfile
 | 
| 
 | 
   292 
 | 
| 
 | 
   293 # T>A
 | 
| 
 | 
   294 echo "<tr>" >> $outfile
 | 
| 
 | 
   295 if [[ ! -e "$output_dir/Mutational_Analysis/Figures/WebLogo/$name/$name-TA-Probability.png" ]]; then
 | 
| 
 | 
   296   echo "<td>WARNING: No sequence for T>A </br> </td>" >> $outfile
 | 
| 
 | 
   297 else
 | 
| 
 | 
   298   echo "<td><a href="Figures/WebLogo/$name/$name-TA.fa">$name-TA.fa</a><br/>" >> $outfile
 | 
| 
 | 
   299   echo "<img src="Figures/WebLogo/$name/$name-TA-Probability.png"/><br/></td>" >> $outfile
 | 
| 
 | 
   300 fi
 | 
| 
 | 
   301 # T>C
 | 
| 
 | 
   302 if [[ ! -e "$output_dir/Mutational_Analysis/Figures/WebLogo/$name/$name-TC-Probability.png" ]]; then
 | 
| 
 | 
   303   echo "<td>WARNING: No sequence for T>C </br> </td>" >> $outfile
 | 
| 
 | 
   304 else
 | 
| 
 | 
   305   echo "<td><a href="Figures/WebLogo/$name/$name-TC.fa">$name-TC.fa</a><br/>" >> $outfile
 | 
| 
 | 
   306   echo "<img src="Figures/WebLogo/$name/$name-TC-Probability.png"/><br/></td>" >> $outfile
 | 
| 
 | 
   307 fi
 | 
| 
 | 
   308 # T>G
 | 
| 
 | 
   309 if [[ ! -e "$output_dir/Mutational_Analysis/Figures/WebLogo/$name/$name-TG-Probability.png" ]]; then
 | 
| 
 | 
   310   echo "<td>WARNING: No sequence for T>G </br> </td>" >> $outfile
 | 
| 
 | 
   311 else
 | 
| 
 | 
   312   echo "<td><a href="Figures/WebLogo/$name/$name-TG.fa">$name-TG.fa</a><br/>" >> $outfile
 | 
| 
 | 
   313   echo "<img src="Figures/WebLogo/$name/$name-TG-Probability.png"/><br/></td>" >> $outfile
 | 
| 
 | 
   314 fi
 | 
| 
 | 
   315 echo "</tr>" >> $outfile
 | 
| 
 | 
   316 
 | 
| 
 | 
   317 echo "</table>" >> $outfile
 | 
| 
 | 
   318 
 | 
| 
 | 
   319 echo "</body></html>" >> $outfile
 | 
| 
 | 
   320 
 | 
| 
 | 
   321 done
 | 
| 
 | 
   322 
 | 
| 
 | 
   323 #-------------------------------------------------------------------------------------------------------------------------------------------------------------------------#
 | 
| 
 | 
   324 #                                                                                     POOL DATA                                                                           #
 | 
| 
 | 
   325 #-------------------------------------------------------------------------------------------------------------------------------------------------------------------------#
 | 
| 
 | 
   326 ## HMTL Link to Pool_Data
 | 
| 
 | 
   327 if [[ $parameters =~ "--pooldata" ]]; then
 | 
| 
 | 
   328   outfilePoolData="$output_dir/Mutational_Analysis/Pool_Data.html"
 | 
| 
 | 
   329   touch $outfilePoolData # Create an empty file named $outfile
 | 
| 
 | 
   330   echo "<a href='Mutational_Analysis/Pool_Data.html'>Pool_Data</a><br/>" >> $html
 | 
| 
 | 
   331 
 | 
| 
 | 
   332 
 | 
| 
 | 
   333   echo "<br/> <center> <h2>Mutational Spectra report for Pool_Data</h2> </center> <br/>" >> $outfilePoolData
 | 
| 
 | 
   334   echo "<html>" >> $outfilePoolData
 | 
| 
 | 
   335 
 | 
| 
 | 
   336   echo "<head>" >> $outfilePoolData
 | 
| 
 | 
   337   echo "<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">" >> $outfilePoolData
 | 
| 
 | 
   338   # Link to the css style file for having a legend when we pass the mouse on the figures
 | 
| 
 | 
   339   echo "<link rel="stylesheet" href="style.css" />" >> $outfilePoolData
 | 
| 
 | 
   340   echo "</head>" >> $outfilePoolData
 | 
| 
 | 
   341 
 | 
| 
 | 
   342   echo "<body>" >> $outfilePoolData
 | 
| 
 | 
   343 
 | 
| 
 | 
   344   echo "<table>" >> $outfilePoolData
 | 
| 
 | 
   345   echo "<tr>" >> $outfilePoolData
 | 
| 
 | 
   346   echo "<th><h3>Overall mutation distribution</h3></th>" >> $outfilePoolData
 | 
| 
 | 
   347   echo "<th><h3>Impact on protein sequence</h3></th>" >> $outfilePoolData
 | 
| 
 | 
   348   echo "</tr><tr>" >> $outfilePoolData
 | 
| 
 | 
   349   echo "<td> <center> <a href="Figures/Overall_mutation_distribution/Pool_Data/Pool_Data-OverallMutationDistribution.txt">Pool_Data-OverallMutationDistribution.txt</a> </center> </td>" >> $outfilePoolData
 | 
| 
 | 
   350   echo "<td> <center> <a href="Figures/Impact_protein_sequence/Pool_Data/Pool_Data-DistributionExoFunc.txt">Pool_Data-DistributionExoFunc.txt</a> </center> </td>" >> $outfilePoolData
 | 
| 
 | 
   351   echo "</tr><tr>" >> $outfilePoolData
 | 
| 
 | 
   352 
 | 
| 
 | 
   353   echo "<td>" >> $outfilePoolData
 | 
| 
 | 
   354   echo "<span class="legend"><img src="Figures/Overall_mutation_distribution/Pool_Data/Pool_Data-OverallMutationDistribution.png width="280""/>" >> $outfilePoolData
 | 
| 
 | 
   355   echo "<span class="legend-hidden">" >> $outfilePoolData
 | 
| 
 | 
   356   echo "<center><B>Overall Mutation Distribution</center></B><br/>Proportion of all mutation types (total count are indicated in parenthesis). For indels the counts are based on annotation retrieved from the database ExonicFunc.refGene<br/>" >> $outfilePoolData
 | 
| 
 | 
   357   echo "</td>" >> $outfilePoolData
 | 
| 
 | 
   358   echo "<td>" >> $outfilePoolData
 | 
| 
 | 
   359   echo "<span class="legend"><img src="Figures/Impact_protein_sequence/Pool_Data/Pool_Data-DistributionExoFunc.png width="400""/>" >> $outfilePoolData
 | 
| 
 | 
   360   echo "<span class="legend-hidden">" >> $outfilePoolData
 | 
| 
 | 
   361   echo "<center><B>Graph 1. Impact on protein sequence</center></B><br/>Impact of all mutations (SBS and Indel) on the protein sequence based on the ExonicFunc.refGene annotation<br/>" >> $outfilePoolData
 | 
| 
 | 
   362   echo "</td>" >> $outfilePoolData
 | 
| 
 | 
   363 
 | 
| 
 | 
   364   echo "</tr>" >> $outfilePoolData
 | 
| 
 | 
   365   echo "</table>" >> $outfilePoolData
 | 
| 
 | 
   366 
 | 
| 
 | 
   367   echo "<br/><br/>"  >> $outfilePoolData
 | 
| 
 | 
   368 
 | 
| 
 | 
   369 
 | 
| 
 | 
   370   echo "<table>" >> $outfilePoolData
 | 
| 
 | 
   371   echo "<tr>" >> $outfilePoolData
 | 
| 
 | 
   372   echo "<th><h3>SBS distribution</h3></th>" >> $outfilePoolData
 | 
| 
 | 
   373   echo "<th><h3>Stranded distribution of SBS</h3></th>" >> $outfilePoolData
 | 
| 
 | 
   374   echo "</tr><tr>" >> $outfilePoolData
 | 
| 
 | 
   375   echo "<td> <center> <a href="Figures/SBS_distribution/Pool_Data/Pool_Data-SBS_distribution.txt">Pool_Data-SBS_distribution.txt</a> </center> </td>" >> $outfilePoolData
 | 
| 
 | 
   376   echo "<td> <center> <a href="Figures/Stranded_Analysis/Pool_Data/Pool_Data-StrandBias.txt">Pool_Data-StrandBias.txt</a> </center> </td>" >> $outfilePoolData
 | 
| 
 | 
   377   echo "</tr><tr>" >> $outfilePoolData
 | 
| 
 | 
   378 
 | 
| 
 | 
   379   echo "<td>" >> $outfilePoolData
 | 
| 
 | 
   380   echo "<span class="legend"><img src="Figures/SBS_distribution/Pool_Data/Pool_Data-SBS_distribution.png width="550""/>" >> $outfilePoolData
 | 
| 
 | 
   381   echo "<span class="legend-hidden">" >> $outfilePoolData
 | 
| 
 | 
   382   echo "<center><B>Graph 2. SBS distribution</center></B><br/>Proportion of each type of single base substitution (SBS)<br/>" >> $outfilePoolData
 | 
| 
 | 
   383   echo "</td>" >> $outfilePoolData
 | 
| 
 | 
   384   echo "<td>" >> $outfilePoolData
 | 
| 
 | 
   385   echo "<span class="legend"><img src="Figures/Stranded_Analysis/Pool_Data/Pool_Data-StrandBias.png width="400""/>" >> $outfilePoolData
 | 
| 
 | 
   386   echo "<span class="legend-hidden">" >> $outfilePoolData
 | 
| 
 | 
   387   echo "<center><B>Graph 3. Stranded distribution of SBS</center></B><br/>Count of the six substitution types on the transcribed and non-transcribed strand<br/>" >> $outfilePoolData
 | 
| 
 | 
   388   echo "</td>" >> $outfilePoolData
 | 
| 
 | 
   389 
 | 
| 
 | 
   390   echo "</tr>" >> $outfilePoolData
 | 
| 
 | 
   391   echo "</table>" >> $outfilePoolData
 | 
| 
 | 
   392 
 | 
| 
 | 
   393 
 | 
| 
 | 
   394   echo "<br/><br/>"  >> $outfilePoolData
 | 
| 
 | 
   395 
 | 
| 
 | 
   396 
 | 
| 
 | 
   397   ##########################################################
 | 
| 
 | 
   398   # Trinucleotide sequence context of SBS on genomic: Pool #
 | 
| 
 | 
   399   ##########################################################
 | 
| 
 | 
   400   echo "<table>" >> $outfilePoolData
 | 
| 
 | 
   401   echo "<h3>Trinucleotide sequence context of SBS on the genomic sequence</h3>" >> $outfilePoolData
 | 
| 
 | 
   402   echo "<tr>" >> $outfilePoolData
 | 
| 
 | 
   403   echo "<td> <center> <a href="Figures/Trinucleotide_Sequence_Context/Pool_Data/Pool_Data-MutationSpectraPercent-Genomic.txt">Pool_Data-MutationSpectraPercent.txt</a> </center> </td>" >> $outfilePoolData
 | 
| 
 | 
   404   echo "<td> <center> <a href="Figures/Trinucleotide_Sequence_Context/Pool_Data/Pool_Data-HeatmapPercent-Genomic.txt">Pool_Data-HeatmapPercent-Genomic.txt</a> </center> </td>" >> $outfilePoolData
 | 
| 
 | 
   405   echo "</tr><tr>" >> $outfilePoolData
 | 
| 
 | 
   406 
 | 
| 
 | 
   407   echo "<td>" >> $outfilePoolData
 | 
| 
 | 
   408   echo "<span class="legend"><img src="Figures/Trinucleotide_Sequence_Context/Pool_Data/Pool_Data-MutationSpectraPercent-Genomic.png width="1000""/>" >> $outfilePoolData
 | 
| 
 | 
   409   echo "<span class="legend-hidden">" >> $outfilePoolData
 | 
| 
 | 
   410   echo "<center><B>Panel 1. Trinucleotide sequence context of SBS on the genomic sequence</center></B><br/>Proportion of the six substitution types with their trinucleotide sequence context (total number of mutation is shown in parenthesis)<br/>" >> $outfilePoolData
 | 
| 
 | 
   411   echo "</td>" >> $outfilePoolData
 | 
| 
 | 
   412   echo "<td>" >> $outfilePoolData
 | 
| 
 | 
   413   echo "<span class="legend"><img src="Figures/Trinucleotide_Sequence_Context/Pool_Data/Pool_Data-HeatmapPercent-Genomic.png width="250""/>" >> $outfilePoolData
 | 
| 
 | 
   414   echo "<span class="legend-hidden">" >> $outfilePoolData
 | 
| 
 | 
   415   echo "<center><B>Panel 1. Trinucleotide sequence context of SBS on the genomic sequence</center></B><br/>Proportion of the six substitution types with their trinucleotide sequence context<br/>" >> $outfilePoolData
 | 
| 
 | 
   416   echo "</td>" >> $outfilePoolData
 | 
| 
 | 
   417 
 | 
| 
 | 
   418   echo "</tr>" >> $outfilePoolData
 | 
| 
 | 
   419   echo "</table>" >> $outfilePoolData
 | 
| 
 | 
   420 
 | 
| 
 | 
   421 
 | 
| 
 | 
   422   echo "<br/><br/>"  >> $outfilePoolData
 | 
| 
 | 
   423 
 | 
| 
 | 
   424 
 | 
| 
 | 
   425   ##################################################################
 | 
| 
 | 
   426   # Trinucleotide sequence context of SBS on coding sequence: Pool #
 | 
| 
 | 
   427   ##################################################################
 | 
| 
 | 
   428   echo "<table>" >> $outfilePoolData
 | 
| 
 | 
   429   echo "<h3>Stranded analysis of trinucleotide sequence context of SBS</h3>" >> $outfilePoolData
 | 
| 
 | 
   430   echo "<tr>" >> $outfilePoolData
 | 
| 
 | 
   431   echo "<td> <center> <a href="Figures/Stranded_Analysis/Pool_Data/Pool_Data-StrandedSignaturePercent.txt">Pool_Data-StrandedSignaturePercent.txt</a> </center> </td>" >> $outfilePoolData
 | 
| 
 | 
   432   echo "</tr><tr>" >> $outfilePoolData
 | 
| 
 | 
   433 
 | 
| 
 | 
   434   echo "<td>" >> $outfilePoolData
 | 
| 
 | 
   435   echo "<span class="legend"><img src="Figures/Stranded_Analysis/Pool_Data/Pool_Data-StrandedSignaturePercent.png width="1300""/>" >> $outfilePoolData
 | 
| 
 | 
   436   echo "<span class="legend-hidden">" >> $outfilePoolData
 | 
| 
 | 
   437   echo "<center><B>Panel 2. Stranded analysis of trinucleotide sequence context of SBS</center></B><br/>Proportion of SBS with their trinucleotide context considering the non-transcribed and transcribed strand<br/>" >> $outfilePoolData
 | 
| 
 | 
   438   echo "</td>" >> $outfilePoolData
 | 
| 
 | 
   439   echo "</tr>" >> $outfilePoolData
 | 
| 
 | 
   440   echo "</table>" >> $outfilePoolData
 | 
| 
 | 
   441 
 | 
| 
 | 
   442   echo "<br/><br/>"  >> $outfilePoolData
 | 
| 
 | 
   443 
 | 
| 
 | 
   444   #####################################################
 | 
| 
 | 
   445   # Sequence logo generated with Weblogo3: Pool   #
 | 
| 
 | 
   446   #####################################################
 | 
| 
 | 
   447   echo "<table>" >> $outfilePoolData
 | 
| 
 | 
   448   echo "<h3>Sequence logo generated with Weblogo3</h3>" >> $outfilePoolData
 | 
| 
 | 
   449   # C>A
 | 
| 
 | 
   450   echo "<tr>" >> $outfilePoolData
 | 
| 
 | 
   451   if [[ ! -e "$output_dir/Mutational_Analysis/Figures/WebLogo/Pool_Data/Pool_Data-CA-Probability.png" ]]; then
 | 
| 
 | 
   452     echo "<td>WARNING: No sequence for C>A </br> </td>" >> $outfilePoolData
 | 
| 
 | 
   453   else
 | 
| 
 | 
   454     echo "<td><a href="Figures/WebLogo/Pool_Data/Pool_Data-CA.fa">Pool_Data-CA.fa</a><br/>" >> $outfilePoolData
 | 
| 
 | 
   455     echo "<img src="Figures/WebLogo/Pool_Data/Pool_Data-CA-Probability.png"/><br/></td>" >> $outfilePoolData
 | 
| 
 | 
   456   fi
 | 
| 
 | 
   457   # C>G
 | 
| 
 | 
   458   if [[ ! -e "$output_dir/Mutational_Analysis/Figures/WebLogo/Pool_Data/Pool_Data-CG-Probability.png" ]]; then
 | 
| 
 | 
   459     echo "<td>WARNING: No sequence for C>G </br> </td>" >> $outfilePoolData
 | 
| 
 | 
   460   else
 | 
| 
 | 
   461     echo "<td><a href="Figures/WebLogo/Pool_Data/Pool_Data-CG.fa">Pool_Data-CG.fa</a><br/>" >> $outfilePoolData
 | 
| 
 | 
   462     echo "<img src="Figures/WebLogo/Pool_Data/Pool_Data-CG-Probability.png"/><br/></td>" >> $outfilePoolData
 | 
| 
 | 
   463   fi
 | 
| 
 | 
   464   # C>T
 | 
| 
 | 
   465   if [[ ! -e "$output_dir/Mutational_Analysis/Figures/WebLogo/Pool_Data/Pool_Data-CT-Probability.png" ]]; then
 | 
| 
 | 
   466     echo "<td>WARNING: No sequence for C>T </br> </td>" >> $outfilePoolData
 | 
| 
 | 
   467   else
 | 
| 
 | 
   468     echo "<td><a href="Figures/WebLogo/Pool_Data/Pool_Data-CT.fa">Pool_Data-CT.fa</a><br/>" >> $outfilePoolData
 | 
| 
 | 
   469     echo "<img src="Figures/WebLogo/Pool_Data/Pool_Data-CT-Probability.png"/><br/></td>" >> $outfilePoolData
 | 
| 
 | 
   470   fi
 | 
| 
 | 
   471   echo "</tr>" >> $outfilePoolData
 | 
| 
 | 
   472 
 | 
| 
 | 
   473   # T>A
 | 
| 
 | 
   474   echo "<tr>" >> $outfilePoolData
 | 
| 
 | 
   475   if [[ ! -e "$output_dir/Mutational_Analysis/Figures/WebLogo/Pool_Data/Pool_Data-TA-Probability.png" ]]; then
 | 
| 
 | 
   476     echo "<td>WARNING: No sequence for T>A </br> </td>" >> $outfilePoolData
 | 
| 
 | 
   477   else
 | 
| 
 | 
   478     echo "<td><a href="Figures/WebLogo/Pool_Data/Pool_Data-TA.fa">Pool_Data-TA.fa</a><br/>" >> $outfilePoolData
 | 
| 
 | 
   479     echo "<img src="Figures/WebLogo/Pool_Data/Pool_Data-TA-Probability.png"/><br/></td>" >> $outfilePoolData
 | 
| 
 | 
   480   fi
 | 
| 
 | 
   481   # T>C
 | 
| 
 | 
   482   if [[ ! -e "$output_dir/Mutational_Analysis/Figures/WebLogo/Pool_Data/Pool_Data-TC-Probability.png" ]]; then
 | 
| 
 | 
   483     echo "<td>WARNING: No sequence for T>C </br> </td>" >> $outfilePoolData
 | 
| 
 | 
   484   else
 | 
| 
 | 
   485     echo "<td><a href="Figures/WebLogo/Pool_Data/Pool_Data-TC.fa">Pool_Data-TC.fa</a><br/>" >> $outfilePoolData
 | 
| 
 | 
   486     echo "<img src="Figures/WebLogo/Pool_Data/Pool_Data-TC-Probability.png"/><br/></td>" >> $outfilePoolData
 | 
| 
 | 
   487   fi
 | 
| 
 | 
   488   # T>G
 | 
| 
 | 
   489   if [[ ! -e "$output_dir/Mutational_Analysis/Figures/WebLogo/Pool_Data/Pool_Data-TG-Probability.png" ]]; then
 | 
| 
 | 
   490     echo "<td>WARNING: No sequence for T>G </br> </td>" >> $outfilePoolData
 | 
| 
 | 
   491   else
 | 
| 
 | 
   492     echo "<td><a href="Figures/WebLogo/Pool_Data/Pool_Data-TG.fa">Pool_Data-TG.fa</a><br/>" >> $outfilePoolData
 | 
| 
 | 
   493     echo "<img src="Figures/WebLogo/Pool_Data/Pool_Data-TG-Probability.png"/><br/></td>" >> $outfilePoolData
 | 
| 
 | 
   494   fi
 | 
| 
 | 
   495   echo "</tr>" >> $outfilePoolData
 | 
| 
 | 
   496   echo "</table>" >> $outfilePoolData
 | 
| 
 | 
   497 
 | 
| 
 | 
   498   echo "</body></html>" >> $outfilePoolData
 | 
| 
 | 
   499 
 | 
| 
 | 
   500 fi # End if --poolData
 | 
| 
 | 
   501 
 | 
| 
 | 
   502 fi # End if [ -d $output_dir/Mutational_Analysis/Figures ]
 | 
| 
 | 
   503 
 | 
| 
 | 
   504 echo "</body></html>" >> $html
 | 
| 
 | 
   505 
 | 
| 
 | 
   506 exit 0
 | 
| 
 | 
   507 
 |