#!/bin/bash # Set the PBS info. #PBS -N PARTS_DIRECTORY_STRING #PBS -l nodes=1:ppn=4,walltime=24:00:00 #PBS -q long #PBS -j oe #cd $PBS_O_WORKDIR # Create the unique script variables necessary for this calculation. COMMAND="COMMAND_STRING" DIRECTORY=DIRECTORY_STRING EMAIL="EMAIL_STRING" HTMLCOMMAND="COMMAND_HTML_STRING" MODETYPE="MODE_TYPE_STRING" NUMSEQS=2 OUTPUTTYPE="" # Export the data path and run the main calculation command. source ../../../../Utilities/Scripts/RunScriptTools || echo 'Internal Server error. Please contact the website administrator.' > errors.txt #include common functions, including sendResultsEmail. calcStarted 'PARTS' 'PARTS' 'DIRECTORY_STRING' 'EMAIL_TO' runTool PARTS $COMMAND # Generate results files and create results pages depending on the calculation mode. if [[ "$MODETYPE" == "pp" ]]; then OUTPUTTYPE="Plot" PLOTBOUNDS="PLOT_BOUNDS_STRING" # For each input sequence, create its results files and individual HTML page in a separate subfolder. typeset -i i SEQS; let SEQS=NUMSEQS; let num=1; while (( num <= SEQS )); do # Make the next subfolder and move the relevant files into it. # Then move to the subfolder. mkdir seq${num}; mv PARTS${num}.fasta seq${num}/PARTS.fasta mv PARTS${num}.txt seq${num}/PARTS.txt cd seq${num} # Create the plot files. runTool ProbabilityPlot PARTS.txt PARTS.ps $PLOTBOUNDS --matrix runTool ps2pdf PARTS.ps PARTS.pdf runTool gs -dNOPAUSE -dBATCH -q -r300 -dJPEGQ=100 -sDEVICE=jpeg -sOutputFile=PARTS.jpeg PARTS.ps runTool ProbabilityPlot PARTS.txt PARTS.svg $PLOTBOUNDS --matrix --svg # If no errors occurred in results files generation, create a results page using a templated HTML file. if [[ ! -s errors.txt ]]; then copyTemplate ResultsPagePlots Results.html sed -i "s@FULL_RESULTS_DIRECTORY@ResultsPages/$DIRECTORY/seq${num}@g" Results.html sed -i "s@PFS@Text@g" Results.html sed -i "s@pfs@txt@g" Results.html fi # If an error did occur in results file generation, create an error page using a templated HTML file, break out of the loop. if [[ -s ../errors.txt ]]; then break fi # Move back to the main directory and increment the loop. cd .. let num++; done # Create the combined structure results page and set the alignment div invisible. copyTemplate ResultsPageManyAlignedStructures Results.html sed -i 's@id="alignment" class="centerClass"@id="alignment" class="centerClass" style="display: none"@g' Results.html else OUTPUTTYPE="Structures" # For each input sequence, create its results files and individual HTML page in a separate subfolder. typeset -i i SEQS; let SEQS=NUMSEQS; let num=1; while (( num <= SEQS )); do # Make the next subfolder and move the relevant files into it. # Then move to the subfolder. mkdir seq${num}; mv PARTS${num}.fasta seq${num}/PARTS.fasta mv PARTS${num}.ct seq${num}/PARTS.ct cd seq${num} # Create the comprehensive PS and PDF files. runTool draw PARTS.ct PARTS.ps if [[ ! -s ../errors.txt ]]; then ps2pdf PARTS.ps PARTS.pdf 1>/dev/null 2>>../errors.txt; fi # If only one structure is present, create a JPEG and SVG file to be available to the user. # Otherwise, split the CT file into individual structures and make CT, PS, PDF, and SVG files for each structure. # Individual JPEG files are not created because they take too long and occupy too much space; they are made only if and when the user requests them. NUMSTRUCTURES=0 if [[ ! -s ../errors.txt ]]; then NUMSTRUCTURES=`grep -r showpage PARTS.ps | wc -l` if (( $NUMSTRUCTURES == 1 )); then if [[ ! -s ../errors.txt ]]; then gs -dNOPAUSE -dBATCH -q -r300 -dJPEGQ=100 -sDEVICE=jpeg -sOutputFile=PARTS.jpeg PARTS.ps 1>/dev/null 2>>../errors.txt; fi runTool draw PARTS.ct PARTS.svg -n 1 --svg else if [[ ! -s ../errors.txt ]]; then SEQLENGTH=`head -n 1 PARTS.ct | awk '{print $1}'` let SEQLENGTH++; awk '{print > (NR%"'"$SEQLENGTH"'"?i:i++)".ct";}' i=1 PARTS.ct fi typeset -i i END; let END=$NUMSTRUCTURES; let i=1; while (( i <= END )); do runTool draw PARTS.ct ${i}.ps -n $i if [[ ! -s ../errors.txt ]]; then ps2pdf ${i}.ps ${i}.pdf 1>/dev/null 2>>../errors.txt; fi runTool draw PARTS.ct ${i}.svg -n $i --svg let i++; done fi fi # If no errors occurred in results files generation, create a results page using a templated HTML file. # If no structures were generated, use a static notification HTML page as the results page. # If only one structure was generated, place it in a specialized static HTML page. # If multiple structures were generated, place it in a dynamic, expandable HTML page. # If one or more structures were made, place the proper interface name, results directory, and command line in the results page. if [[ ! -s ../errors.txt ]]; then if grep -Fqs "contains no pairs" PARTS.svg then cp ../../../../Utilities/Pages/NoStructures.html Results.html rm -f PARTS* else if (( $NUMSTRUCTURES == 1 )); then copyTemplate ResultsPageSingleCTSingleStructure Results.html else copyTemplate ResultsPageSingleCTManyStructures Results.html sed -i "s@STRUCTURE_NUMBER@$END@g" Results.html awk '/download structure 1 links/,/structure 1 links end here -->/{print}' ../../../../../Utilities/Templates/ResultsPageSingleCTManyStructures.html > individualDiv.txt typeset -i i END; let END=$NUMSTRUCTURES; let i=1; while (( i <= END )); do sed "s/1/$i/g" individualDiv.txt >> extendedDivs.txt let i++; done sed -i '/download structure 1 links/,/structure 1 links end here -->/d' Results.html sed -i "N;/Download Individual Structures/r extendedDivs.txt" Results.html fi fi sed -i "s@FULL_RESULTS_DIRECTORY@ResultsPages/$DIRECTORY/seq${num}@g" Results.html fi # If an error did occur in results file generation, create an error page using a templated HTML file, break out of the loop. if [[ -s ../errors.txt ]]; then break fi # Move back to the main directory and increment the loop. cd .. let num++; done # Create the combined structure results page and set the alignment root in it. copyTemplate ResultsPageManyAlignedStructures Results.html sed -i 's@ALIGNMENT_ROOT@PARTS@g' Results.html fi # If an error results page was not already made, build the combined results page. if [[ ! -s ../errors.txt ]]; then sed -i '/image box starts/,/command line ends/d' Results.html let num=1; while (( num <= SEQS )); do echo "