#!/bin/bash # Set the PBS info. #PBS -N Predict1_DIRECTORY_STRING #PBS -l nodes=1,walltime=24:00:00 #PBS -q batch #PBS -j oe cd $PBS_O_WORKDIR source ../../../../Utilities/Scripts/RunScriptTools || echo 'Internal Server error. Please contact the website administrator.' > errors.txt #include common functions, including sendResultsEmail. calcStarted 'Predict1' 'Predict a Secondary Structure' 'DIRECTORY_STRING' 'EMAIL_TO' DIRECTORY="DIRECTORY_STRING" FULLCOMMAND="COMMAND_STRING" FULLHTML="COMMAND_HTML_STRING" PLOTBOUNDS="PLOT_BOUNDS_STRING" SHAPEFILE="SHAPE_FILE_STRING" ###################################################################### # Do the partition function calculation. ###################################################################### COMMAND=`echo $FULLCOMMAND | cut -d ';' -f '1'` HTMLCOMMAND=`echo $FULLHTML | cut -d ';' -f '1'` # Run the commands that create plot files. writeStatus "Running partition..." runTool partition $COMMAND writeStatus -d "Running ProbabilityPlot..." runTool ProbabilityPlot partition.pfs partition.ps $PLOTBOUNDS runTool ProbabilityPlot partition.pfs partition.svg $PLOTBOUNDS --svg #writeStatus -d "Generating pdf..." #runTool ps2pdf partition.ps partition.pdf #runTool gs -dNOPAUSE -dBATCH -q -r300 -dJPEGQ=100 -sDEVICE=jpeg -sOutputFile=partition.jpeg partition.ps writeStatus -d # If no errors occurred in results files generation, create a results page using a templated HTML file. # Place the proper interface name, results directory, and command line in the results page. if [[ ! -s errors.txt ]]; then copyTemplate ResultsPagePlots Results.html INTERFACEDESC=`grep -r --after-context=1 partition/partition.html ../../../../index.html | tail -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1` sed -i "s@Results@Results
($INTERFACEDESC)@g" Results.html sed -i 's@INTERFACE_PAGE@partition/partition.html@g' Results.html sed -i 's@INTERFACE_NAME@partition@g' Results.html sed -i "s@FULL_RESULTS_DIRECTORY@ResultsPages/$DIRECTORY/partition@g" Results.html sed -i "s@COMMAND_LINE@partition $HTMLCOMMAND@g" Results.html sed -i 's@partition/ResultsPages@Predict1/ResultsPages@g' Results.html sed -i 's@src="partition.svg"@src="partition/partition.svg"@g' Results.html sed -i "s@getFile=Predict1/ResultsPages/$DIRECTORY/partition.pfs@getFile=Predict1/ResultsPages/$DIRECTORY/partition/partition.pfs@g" Results.html fi # Move all files created for this section into the partition directory. mkdir partition; mv partition.* partition/; mv Results.html partition/; ###################################################################### # Do the Fold calculation and annotate results with probability data. ###################################################################### # Create the unique script variables necessary for this calculation. COMMAND=`echo $FULLCOMMAND | cut -d ';' -f '2'` HTMLCOMMAND=`echo $FULLHTML | cut -d ';' -f '2'` # Run the commands that create comprehensive CT, PS, and PDF files. writeStatus "Running Fold..." runTool Fold $COMMAND writeStatus -d "Drawing Structures (Combined)..." runTool draw Fold.ct Fold.ps -p partition/partition.pfs runTool ps2pdf Fold.ps Fold.pdf writeStatus -d # 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 Fold.ps | wc -l` writeStatus "Drawing Structures (Individual)..." if (( $NUMSTRUCTURES == 1 )); then #runTool gs -dNOPAUSE -dBATCH -q -r300 -dJPEGQ=100 -sDEVICE=jpeg -sOutputFile=Fold.jpeg Fold.ps runTool draw Fold.ct Fold.svg -p partition/partition.pfs -n 1 --svg else if [[ ! -s errors.txt ]]; then SEQLENGTH=`head -n 1 Fold.ct | awk '{print $1}'` let SEQLENGTH++; awk '{print > (NR%"'"$SEQLENGTH"'"?i:i++)".ct";}' i=1 Fold.ct fi typeset -i i END; let END=$NUMSTRUCTURES; let i=1; while (( i <= END )); do runTool draw Fold.ct ${i}.ps -n $i -p partition/partition.pfs runTool ps2pdf ${i}.ps ${i}.pdf runTool draw Fold.ct ${i}.svg -n $i -p partition/partition.pfs --svg let i++; done fi writeStatus -d 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" Fold.svg then cp ../../../../Utilities/Pages/NoStructures.html Results.html rm -f Fold* else if (( $NUMSTRUCTURES == 1 )); then copyTemplate ResultsPageSingleCTSingleStructure Results.html else copyTemplate ResultsPageSingleCTManyStructures Results.html sed -i "s@STRUCTURE_NUMBER@$END@g" Results.html rm -f extendedDivs.txt 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 INTERFACEDESC=`grep -r --after-context=1 Fold/Fold.html ../../../../index.html | tail -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1` sed -i "s@Results@Results
($INTERFACEDESC)@g" Results.html sed -i 's@INTERFACE_PAGE@Fold/Fold.html@g' Results.html sed -i 's@INTERFACE_NAME@Fold@g' Results.html sed -i "s@FULL_RESULTS_DIRECTORY@ResultsPages/$DIRECTORY/Fold@g" Results.html sed -i "s@COMMAND_LINE@Fold $HTMLCOMMAND@g" Results.html sed -i 's@Fold/ResultsPages@Predict1/ResultsPages@g' Results.html sed -i 's@src="Fold.svg"@src="Fold/Fold.svg"@g' Results.html sed -i "s@getFile=Predict1/ResultsPages/$DIRECTORY/Fold.ct@getFile=Predict1/ResultsPages/$DIRECTORY/Fold/Fold.ct@g" Results.html fi # Move all files created for this section into the Fold directory. mkdir Fold; mv *.ct Fold/; mv *.ps Fold/; mv *.pdf Fold/; if (( $NUMSTRUCTURES == 1 )); then mv Fold.jpeg Fold/; fi mv *.svg Fold/; mv Results.html Fold/; ###################################################################### # If necessary, create another page of Fold results annotated with SHAPE data. ###################################################################### if [[ "$SHAPEFILE" != "false" ]]; then writeStatus "Annotating structures with SHAPE data..." # Run the commands that create comprehensive PS and PDF files. runTool draw Fold/Fold.ct Fold.ps -s $SHAPEFILE runTool ps2pdf Fold.ps Fold.pdf # If only one structure is present, create a JPEG and SVG file to be available to the user. # Otherwise, make 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 Fold.ps | wc -l` if (( $NUMSTRUCTURES == 1 )); then runTool gs -dNOPAUSE -dBATCH -q -r300 -dJPEGQ=100 -sDEVICE=jpeg -sOutputFile=Fold.jpeg Fold.ps runTool draw Fold/Fold.ct Fold.svg -n 1 -s $SHAPEFILE --svg else typeset -i i END; let END=$NUMSTRUCTURES; let i=1; while (( i <= END )); do runTool draw Fold/Fold.ct ${i}.ps -n $i -s $SHAPEFILE runTool ps2pdf ${i}.ps ${i}.pdf runTool draw Fold/Fold.ct ${i}.svg -n $i -s $SHAPEFILE --svg let i++; done fi fi writeStatus -d # 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" Fold.svg then cp ../../../../Utilities/Pages/NoStructures.html Results.html rm -f Fold* else if (( $NUMSTRUCTURES == 1 )); then copyTemplate ResultsPageSingleCTSingleStructure Results.html else copyTemplate ResultsPageSingleCTManyStructures Results.html sed -i "s@STRUCTURE_NUMBER@$END@g" Results.html rm -f extendedDivs.txt 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@INTERFACE_NAME@Fold@g' Results.html sed -i "s@FULL_RESULTS_DIRECTORY@ResultsPages/$DIRECTORY/Fold/SHAPE@g" Results.html sed -i "s@COMMAND_LINE@Fold $HTMLCOMMAND@g" Results.html sed -i 's@Fold/ResultsPages@Predict1/ResultsPages@g' Results.html sed -i 's@src="Fold.svg"@src="Fold/SHAPE/Fold.svg"@g' Results.html sed -i "s@getFile=Predict1/ResultsPages/$DIRECTORY/Fold.ct@getFile=Predict1/ResultsPages/$DIRECTORY/Fold/SHAPE/Fold.ct@g" Results.html # Move all SHAPE-annotated files into the SHAPE directory. mkdir Fold/SHAPE; mv *.ps Fold/SHAPE/; mv *.pdf Fold/SHAPE/; if (( $NUMSTRUCTURES == 1 )); then mv Fold.jpeg Fold/SHAPE/; fi mv *.svg Fold/SHAPE/; mv Results.html Fold/SHAPE/; # Then, move all probability annotated files into the PFS directory and edit directory names accordingly. sed -i 's@Fold/@Fold/PFS/@g' Fold/Results.html sed -i 's@Fold"@Fold/PFS"@g' Fold/Results.html sed -i 's@Fold\&@Fold/PFS\&@g' Fold/Results.html mkdir Fold/PFS; mv Fold/*.ps Fold/PFS/; mv Fold/*.pdf Fold/PFS/; if (( $NUMSTRUCTURES == 1 )); then mv Fold/Fold.jpeg Fold/PFS/; fi mv Fold/*.svg Fold/PFS/; mv Fold/Results.html Fold/PFS/; # Correct any subdirectory assignments for files that weren't actually moved. awk '/CT/ { gsub(/PFS\//, "") }; { print }' Fold/PFS/Results.html > temp.out; mv temp.out Fold/PFS/Results.html; awk '/Fold.html/ { gsub(/PFS\//, "") }; { print }' Fold/PFS/Results.html > temp.out; mv temp.out Fold/PFS/Results.html; awk '/CT/ { gsub(/SHAPE\//, "") }; { print }' Fold/SHAPE/Results.html > temp.out; mv temp.out Fold/SHAPE/Results.html; awk '/Fold.html/ { gsub(/SHAPE\//, "") }; { print }' Fold/SHAPE/Results.html > temp.out; mv temp.out Fold/SHAPE/Results.html; # Put the two annotation results pages together into one big one reflecting the entire Fold section. copyTemplate ResultsPageManyAlignedStructures Results.html sed -i '/results header starts/,/command line ends/d' Results.html sed -n "/results header starts/,/download links end/p" Fold/PFS/Results.html > combinedTemp.txt echo "
" >> combinedTemp.txt sed "s@id=\"@id=\"1@g" combinedTemp.txt >> combined.txt sed -n "/image box starts/,/command line ends/p" Fold/SHAPE/Results.html > combinedTemp.txt echo "
" >> combinedTemp.txt sed "s@id=\"@id=\"2@g" combinedTemp.txt >> combined.txt sed -i 'N;/id="main"/r combined.txt' Results.html rm -f combined*.txt mv Results.html Fold/; fi fi ###################################################################### # Do the MaxExpect calculation. ###################################################################### # Create the unique script variables necessary for this calculation. COMMAND=`echo $FULLCOMMAND | cut -d ';' -f '3'` HTMLCOMMAND=`echo $FULLHTML | cut -d ';' -f '3'` if [[ ! -s errors.txt ]]; then # Run the commands that create comprehensive CT, PS, and PDF files. writeStatus "Running MaxExpect..." runTool MaxExpect $COMMAND writeStatus -d "Drawing MaxExpect Structures (Combined)..." runTool draw MaxExpect.ct MaxExpect.ps -p partition/partition.pfs runTool ps2pdf MaxExpect.ps MaxExpect.pdf writeStatus -d # 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 MaxExpect.ps | wc -l` writeStatus "Drawing MaxExpect structures (Individual)..." if (( $NUMSTRUCTURES == 1 )); then #runTool gs -dNOPAUSE -dBATCH -q -r300 -dJPEGQ=100 -sDEVICE=jpeg -sOutputFile=MaxExpect.jpeg MaxExpect.ps runTool draw MaxExpect.ct MaxExpect.svg -n 1 -p partition/partition.pfs --svg else if [[ ! -s errors.txt ]]; then SEQLENGTH=`head -n 1 MaxExpect.ct | awk '{print $1}'` let SEQLENGTH++; awk '{print > (NR%"'"$SEQLENGTH"'"?i:i++)".ct";}' i=1 MaxExpect.ct fi typeset -i i END; let END=$NUMSTRUCTURES; let i=1; while (( i <= END )); do runTool draw MaxExpect.ct ${i}.ps -n $i -p partition/partition.pfs #runTool ps2pdf ${i}.ps ${i}.pdf runTool draw MaxExpect.ct ${i}.svg -n $i -p partition/partition.pfs --svg let i++; done fi writeStatus -d 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" MaxExpect.svg then cp ../../../../Utilities/Pages/NoStructures.html Results.html rm -f MaxExpect* else if (( $NUMSTRUCTURES == 1 )); then copyTemplate ResultsPageSingleCTSingleStructure Results.html else copyTemplate ResultsPageSingleCTManyStructures Results.html sed -i "s@STRUCTURE_NUMBER@$END@g" Results.html rm -f extendedDivs.txt 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 INTERFACEDESC=`grep -r --after-context=1 MaxExpect.html ../../../../index.html | tail -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1` sed -i "s@Results@Results
($INTERFACEDESC)@g" Results.html sed -i 's@INTERFACE_PAGE@MaxExpect/MaxExpect.html@g' Results.html sed -i 's@INTERFACE_NAME@MaxExpect@g' Results.html sed -i "s@FULL_RESULTS_DIRECTORY@ResultsPages/$DIRECTORY/MaxExpect@g" Results.html sed -i "s@COMMAND_LINE@MaxExpect $HTMLCOMMAND@g" Results.html sed -i 's@MaxExpect/ResultsPages@Predict1/ResultsPages@g' Results.html sed -i 's@src="MaxExpect.svg"@src="MaxExpect/MaxExpect.svg"@g' Results.html sed -i "s@getFile=Predict1/ResultsPages/$DIRECTORY/MaxExpect.ct@getFile=Predict1/ResultsPages/$DIRECTORY/MaxExpect/MaxExpect.ct@g" Results.html fi # Move all files created for this section into the MaxExpect directory. mkdir MaxExpect; mv *.ct MaxExpect/; mv *.ps MaxExpect/; mv *.pdf MaxExpect/; if (( $NUMSTRUCTURES == 1 )); then mv MaxExpect.jpeg MaxExpect/; fi mv *.svg MaxExpect/; mv Results.html MaxExpect/; fi #from top of max-expect ###################################################################### # If necessary, create another page of MaxExpect results annotated with SHAPE data. ###################################################################### if [[ ! -s errors.txt && "$SHAPEFILE" != "false" ]]; then writeStatus "Annotating MaxExpect structures with SHAPE data..." # Run the commands that create comprehensive PS and PDF files. runTool draw MaxExpect/MaxExpect.ct MaxExpect.ps -s $SHAPEFILE runTool ps2pdf MaxExpect.ps MaxExpect.pdf # If only one structure is present, create a JPEG and SVG file to be available to the user. # Otherwise, make 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 MaxExpect.ps | wc -l` if (( $NUMSTRUCTURES == 1 )); then #runTool gs -dNOPAUSE -dBATCH -q -r300 -dJPEGQ=100 -sDEVICE=jpeg -sOutputFile=MaxExpect.jpeg MaxExpect.ps runTool draw MaxExpect/MaxExpect.ct MaxExpect.svg -n 1 -s $SHAPEFILE --svg else typeset -i i END; let END=$NUMSTRUCTURES; let i=1; while (( i <= END )); do runTool draw MaxExpect/MaxExpect.ct ${i}.ps -n $i -s $SHAPEFILE #runTool ps2pdf ${i}.ps ${i}.pdf runTool draw MaxExpect/MaxExpect.ct ${i}.svg -n $i -s $SHAPEFILE --svg let i++; done fi fi writeStatus -d # 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" MaxExpect.svg then cp ../../../../Utilities/Pages/NoStructures.html Results.html rm -f MaxExpect* else if (( $NUMSTRUCTURES == 1 )); then copyTemplate ResultsPageSingleCTSingleStructure Results.html else copyTemplate ResultsPageSingleCTManyStructures Results.html sed -i "s@STRUCTURE_NUMBER@$END@g" Results.html rm -f extendedDivs.txt 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@INTERFACE_NAME@MaxExpect@g' Results.html sed -i "s@FULL_RESULTS_DIRECTORY@ResultsPages/$DIRECTORY/MaxExpect/SHAPE@g" Results.html sed -i "s@COMMAND_LINE@MaxExpect $HTMLCOMMAND@g" Results.html sed -i 's@MaxExpect/ResultsPages@Predict1/ResultsPages@g' Results.html sed -i 's@src="MaxExpect.svg"@src="MaxExpect/SHAPE/MaxExpect.svg"@g' Results.html sed -i "s@getFile=Predict1/ResultsPages/$DIRECTORY/MaxExpect.ct@getFile=Predict1/ResultsPages/$DIRECTORY/MaxExpect/SHAPE/MaxExpect.ct@g" Results.html # Move all SHAPE-annotated files into the SHAPE directory. mkdir MaxExpect/SHAPE; mv *.ps MaxExpect/SHAPE/; mv *.pdf MaxExpect/SHAPE/; if (( $NUMSTRUCTURES == 1 )); then mv MaxExpect.jpeg MaxExpect/SHAPE/; fi mv *.svg MaxExpect/SHAPE/; mv Results.html MaxExpect/SHAPE/; # Then, move all probability annotated files into the PFS directory and edit directory names accordingly. sed -i 's@MaxExpect/@MaxExpect/PFS/@g' MaxExpect/Results.html sed -i 's@MaxExpect"@MaxExpect/PFS"@g' MaxExpect/Results.html sed -i 's@MaxExpect\&@MaxExpect/PFS\&@g' MaxExpect/Results.html mkdir MaxExpect/PFS; mv MaxExpect/*.ps MaxExpect/PFS/; mv MaxExpect/*.pdf MaxExpect/PFS/; if (( $NUMSTRUCTURES == 1 )); then mv MaxExpect/MaxExpect.jpeg MaxExpect/PFS/; fi mv MaxExpect/*.svg MaxExpect/PFS/; mv MaxExpect/Results.html MaxExpect/PFS/; # Correct any subdirectory assignments for files that weren't actually moved. awk '/CT/ { gsub(/PFS\//, "") }; { print }' MaxExpect/PFS/Results.html > temp.out; mv temp.out MaxExpect/PFS/Results.html; awk '/MaxExpect.html/ { gsub(/PFS\//, "") }; { print }' MaxExpect/PFS/Results.html > temp.out; mv temp.out MaxExpect/PFS/Results.html; awk '/CT/ { gsub(/SHAPE\//, "") }; { print }' MaxExpect/SHAPE/Results.html > temp.out; mv temp.out MaxExpect/SHAPE/Results.html; awk '/MaxExpect.html/ { gsub(/SHAPE\//, "") }; { print }' MaxExpect/SHAPE/Results.html > temp.out; mv temp.out MaxExpect/SHAPE/Results.html; # Put the two annotation results pages together into one big one reflecting the entire MaxExpect section. copyTemplate ResultsPageManyAlignedStructures Results.html sed -i '/results header starts/,/command line ends/d' Results.html sed -n "/results header starts/,/download links end/p" MaxExpect/PFS/Results.html > combinedTemp.txt echo "
" >> combinedTemp.txt sed "s@id=\"@id=\"1@g" combinedTemp.txt >> combined.txt sed -n "/image box starts/,/command line ends/p" MaxExpect/SHAPE/Results.html > combinedTemp.txt echo "
" >> combinedTemp.txt sed "s@id=\"@id=\"2@g" combinedTemp.txt >> combined.txt sed -i 'N;/id="main"/r combined.txt' Results.html rm -f combined*.txt mv Results.html MaxExpect/; fi fi ###################################################################### # Do the ProbKnot calculation. ###################################################################### # Create the unique script variables necessary for this calculation. COMMAND=`echo $FULLCOMMAND | cut -d ';' -f '4'` HTMLCOMMAND=`echo $FULLHTML | cut -d ';' -f '4'` if [[ ! -s errors.txt ]]; then # Run the commands that create comprehensive CT, PS, and PDF files. writeStatus "Running ProbKnot..." runTool ProbKnot $COMMAND writeStatus -d "Drawing ProbKnot Structures (Combined)..." runTool draw ProbKnot.ct ProbKnot.ps -p partition/partition.pfs runTool ps2pdf ProbKnot.ps ProbKnot.pdf writeStatus -d # 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 ProbKnot.ps | wc -l` writeStatus "Drawing ProbKnot Structures (Individual)..." if (( $NUMSTRUCTURES == 1 )); then #runTool gs -dNOPAUSE -dBATCH -q -r300 -dJPEGQ=100 -sDEVICE=jpeg -sOutputFile=ProbKnot.jpeg ProbKnot.ps runTool draw ProbKnot.ct ProbKnot.svg -n 1 -p partition/partition.pfs --svg else if [[ ! -s errors.txt ]]; then SEQLENGTH=`head -n 1 ProbKnot.ct | awk '{print $1}'` let SEQLENGTH++; awk '{print > (NR%"'"$SEQLENGTH"'"?i:i++)".ct";}' i=1 ProbKnot.ct fi typeset -i i END; let END=$NUMSTRUCTURES; let i=1; while (( i <= END )); do runTool draw ProbKnot.ct ${i}.ps -n $i -p partition/partition.pfs #runTool ps2pdf ${i}.ps ${i}.pdf runTool draw ProbKnot.ct ${i}.svg -n $i -p partition/partition.pfs --svg let i++; done fi writeStatus -d 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" ProbKnot.svg then cp ../../../../Utilities/Pages/NoStructures.html Results.html rm -f ProbKnot* else if (( $NUMSTRUCTURES == 1 )); then copyTemplate ResultsPageSingleCTSingleStructure Results.html else copyTemplate ResultsPageSingleCTManyStructures Results.html sed -i "s@STRUCTURE_NUMBER@$END@g" Results.html rm -f extendedDivs.txt 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 INTERFACEDESC=`grep -r --after-context=1 ProbKnot.html ../../../../index.html | tail -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1` sed -i "s@Results@Results
($INTERFACEDESC)@g" Results.html sed -i 's@INTERFACE_PAGE@ProbKnot/ProbKnot.html@g' Results.html sed -i 's@INTERFACE_NAME@ProbKnot@g' Results.html sed -i "s@FULL_RESULTS_DIRECTORY@ResultsPages/$DIRECTORY/ProbKnot@g" Results.html sed -i "s@COMMAND_LINE@ProbKnot $HTMLCOMMAND@g" Results.html sed -i 's@ProbKnot/ResultsPages@Predict1/ResultsPages@g' Results.html sed -i 's@src="ProbKnot.svg"@src="ProbKnot/ProbKnot.svg"@g' Results.html sed -i "s@getFile=Predict1/ResultsPages/$DIRECTORY/ProbKnot.ct@getFile=Predict1/ResultsPages/$DIRECTORY/ProbKnot/ProbKnot.ct@g" Results.html fi # Move all files created for this section into the ProbKnot directory. mkdir ProbKnot; mv *.ct ProbKnot/; mv *.ps ProbKnot/; mv *.pdf ProbKnot/; if (( $NUMSTRUCTURES == 1 )); then mv ProbKnot.jpeg ProbKnot/; fi mv *.svg ProbKnot/; mv Results.html ProbKnot/; fi # from top of ProbKnot ###################################################################### # If necessary, create another page of ProbKnot results annotated with SHAPE data. ###################################################################### if [[ ! -s errors.txt && "$SHAPEFILE" != "false" ]]; then writeStatus "Annotating ProbKnot Structures with SHAPE data..." # Run the commands that create comprehensive PS and PDF files. runTool draw ProbKnot/ProbKnot.ct ProbKnot.ps -s $SHAPEFILE runTool ps2pdf ProbKnot.ps ProbKnot.pdf # If only one structure is present, create a JPEG and SVG file to be available to the user. # Otherwise, make 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 ProbKnot.ps | wc -l` if (( $NUMSTRUCTURES == 1 )); then #runTool gs -dNOPAUSE -dBATCH -q -r300 -dJPEGQ=100 -sDEVICE=jpeg -sOutputFile=ProbKnot.jpeg ProbKnot.ps runTool draw ProbKnot/ProbKnot.ct ProbKnot.svg -n 1 -s $SHAPEFILE --svg else typeset -i i END; let END=$NUMSTRUCTURES; let i=1; while (( i <= END )); do runTool draw ProbKnot/ProbKnot.ct ${i}.ps -n $i -s $SHAPEFILE #runTool ps2pdf ${i}.ps ${i}.pdf runTool draw ProbKnot/ProbKnot.ct ${i}.svg -n $i -s $SHAPEFILE --svg let i++; done fi fi writeStatus -d writeStatus "Generating SHAPE-Annotated ProbKnot Results..." # 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" ProbKnot.svg then cp ../../../../Utilities/Pages/NoStructures.html Results.html rm -f ProbKnot* else if (( $NUMSTRUCTURES == 1 )); then copyTemplate ResultsPageSingleCTSingleStructure Results.html else copyTemplate ResultsPageSingleCTManyStructures Results.html sed -i "s@STRUCTURE_NUMBER@$END@g" Results.html rm -f extendedDivs.txt 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@INTERFACE_NAME@ProbKnot@g' Results.html sed -i "s@FULL_RESULTS_DIRECTORY@ResultsPages/$DIRECTORY/ProbKnot/SHAPE@g" Results.html sed -i "s@COMMAND_LINE@ProbKnot $HTMLCOMMAND@g" Results.html sed -i 's@ProbKnot/ResultsPages@Predict1/ResultsPages@g' Results.html sed -i 's@src="ProbKnot.svg"@src="ProbKnot/SHAPE/ProbKnot.svg"@g' Results.html sed -i "s@getFile=Predict1/ResultsPages/$DIRECTORY/ProbKnot.ct@getFile=Predict1/ResultsPages/$DIRECTORY/ProbKnot/SHAPE/ProbKnot.ct@g" Results.html # Move all SHAPE-annotated files into the SHAPE directory. mkdir ProbKnot/SHAPE; mv *.ps ProbKnot/SHAPE/; mv *.pdf ProbKnot/SHAPE/; if (( $NUMSTRUCTURES == 1 )); then mv ProbKnot.jpeg ProbKnot/SHAPE/; fi mv *.svg ProbKnot/SHAPE/; mv Results.html ProbKnot/SHAPE/; # Then, move all probability annotated files into the PFS directory and edit directory names accordingly. sed -i 's@ProbKnot/@ProbKnot/PFS/@g' ProbKnot/Results.html sed -i 's@ProbKnot"@ProbKnot/PFS"@g' ProbKnot/Results.html sed -i 's@ProbKnot\&@ProbKnot/PFS\&@g' ProbKnot/Results.html mkdir ProbKnot/PFS; mv ProbKnot/*.ps ProbKnot/PFS/; mv ProbKnot/*.pdf ProbKnot/PFS/; if (( $NUMSTRUCTURES == 1 )); then mv ProbKnot/ProbKnot.jpeg ProbKnot/PFS/; fi mv ProbKnot/*.svg ProbKnot/PFS/; mv ProbKnot/Results.html ProbKnot/PFS/; # Correct any subdirectory assignments for files that weren't actually moved. awk '/CT/ { gsub(/PFS\//, "") }; { print }' ProbKnot/PFS/Results.html > temp.out; mv temp.out ProbKnot/PFS/Results.html; awk '/ProbKnot.html/ { gsub(/PFS\//, "") }; { print }' ProbKnot/PFS/Results.html > temp.out; mv temp.out ProbKnot/PFS/Results.html; awk '/CT/ { gsub(/SHAPE\//, "") }; { print }' ProbKnot/SHAPE/Results.html > temp.out; mv temp.out ProbKnot/SHAPE/Results.html; awk '/ProbKnot.html/ { gsub(/SHAPE\//, "") }; { print }' ProbKnot/SHAPE/Results.html > temp.out; mv temp.out ProbKnot/SHAPE/Results.html; # Put the two annotation results pages together into one big one reflecting the entire ProbKnot section. copyTemplate ResultsPageManyAlignedStructures Results.html sed -i '/results header starts/,/command line ends/d' Results.html sed -n "/results header starts/,/download links end/p" ProbKnot/PFS/Results.html > combinedTemp.txt echo "
" >> combinedTemp.txt sed "s@id=\"@id=\"1@g" combinedTemp.txt >> combined.txt sed -n "/image box starts/,/command line ends/p" ProbKnot/SHAPE/Results.html > combinedTemp.txt echo "
" >> combinedTemp.txt sed "s@id=\"@id=\"2@g" combinedTemp.txt >> combined.txt sed -i 'N;/id="main"/r combined.txt' Results.html rm -f combined*.txt mv Results.html ProbKnot/; fi writeStatus -d fi ###################################################################### # Check for errors, then create the results page. ###################################################################### # If an error results page was not already made, put the results pages together into one big one. if [[ ! -s Results.html ]]; then copyTemplate ResultsPageManyAlignedStructures Results.html sed -i '/results header starts/,/command line ends/d' Results.html COMBINEDHEADER='

RNAstructure Predict a Secondary Structure Results

' echo -e $COMBINEDHEADER > combined.txt sed -n "/results header starts/,/command line ends/p" Fold/Results.html > combinedTemp.txt echo "
" >> combinedTemp.txt sed "s@id=\"@id=\"1@g" combinedTemp.txt >> combined.txt sed -n "/results header starts/,/command line ends/p" MaxExpect/Results.html > combinedTemp.txt echo "
" >> combinedTemp.txt sed "s@id=\"@id=\"2@g" combinedTemp.txt >> combined.txt sed -n "/results header starts/,/command line ends/p" ProbKnot/Results.html > combinedTemp.txt echo "
" >> combinedTemp.txt sed "s@id=\"@id=\"3@g" combinedTemp.txt >> combined.txt sed -n "/results header starts/,/command line ends/p" partition/Results.html > combinedTemp.txt sed "s@id=\"@id=\"4@g" combinedTemp.txt >> combined.txt sed -i 'N;/id="main"/r combined.txt' Results.html rm -f combined*.txt sed -i 's@INTERFACE_PAGE@Predict1/Predict1.html@g' Results.html sed -i 's@INTERFACE_NAME@Predict a Secondary Structure@g' Results.html fi ###################################################################### # Perform end-of-calculation tasks ###################################################################### calcCompleted #send results email, notify web client, etc