#!/bin/bash # Set the PBS info. #PBS -N PredictBi_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 'PredictBi' 'Predict a Bimolecular Secondary Structure' 'DIRECTORY_STRING' 'EMAIL_TO' DIRECTORY="DIRECTORY_STRING" FULLCOMMAND="COMMAND_STRING" FULLHTML="COMMAND_HTML_STRING" ###################################################################### # Do the bifold calculation. ###################################################################### # Create the unique script variables necessary for this calculation. COMMAND=`echo $FULLCOMMAND | cut -d ';' -f '1'` HTMLCOMMAND=`echo $FULLHTML | cut -d ';' -f '1'` # Run the commands that create comprehensive CT, PS, and PDF files. runTool bifold $COMMAND runTool draw bifold.ct bifold.ps runTool ps2pdf bifold.ps bifold.pdf # 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 bifold.ps | wc -l` if (( $NUMSTRUCTURES == 1 )); then runTool gs -dNOPAUSE -dBATCH -q -r300 -dJPEGQ=100 -sDEVICE=jpeg -sOutputFile=bifold.jpeg bifold.ps runTool draw bifold.ct bifold.svg -n 1 --svg else if [[ ! -s errors.txt ]]; then SEQLENGTH=`head -n 1 bifold.ct | awk '{print $1}'` let SEQLENGTH++; awk '{print > (NR%"'"$SEQLENGTH"'"?i:i++)".ct";}' i=1 bifold.ct fi typeset -i i END; let END=$NUMSTRUCTURES; let i=1; while (( i <= END )); do runTool draw bifold.ct ${i}.ps -n $i runTool ps2pdf ${i}.ps ${i}.pdf runTool draw bifold.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" bifold.svg then cp ../../../../Utilities/Pages/NoStructures.html Results.html rm -f bifold* 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 bifold.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@bifold/bifold.html@g' Results.html sed -i 's@INTERFACE_NAME@bifold@g' Results.html sed -i "s@FULL_RESULTS_DIRECTORY@ResultsPages/$DIRECTORY/bifold@g" Results.html sed -i "s@COMMAND_LINE@bifold $HTMLCOMMAND@g" Results.html sed -i 's@bifold/ResultsPages@PredictBi/ResultsPages@g' Results.html sed -i 's@src="bifold.svg"@src="bifold/bifold.svg"@g' Results.html sed -i "s@getFile=PredictBi/ResultsPages/$DIRECTORY/bifold.ct@getFile=PredictBi/ResultsPages/$DIRECTORY/bifold/bifold.ct@g" Results.html fi # Move all files created for this section into the bifold directory. mkdir bifold; mv *.ct bifold/; mv *.ps bifold/; mv *.pdf bifold/; if (( $NUMSTRUCTURES == 1 )); then mv bifold.jpeg bifold/; fi mv *.svg bifold/; mv Results.html bifold/; ###################################################################### # Do the DuplexFold calculation. ###################################################################### # 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. runTool DuplexFold $COMMAND runTool draw DuplexFold.ct DuplexFold.ps runTool ps2pdf DuplexFold.ps DuplexFold.pdf # 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 DuplexFold.ps | wc -l` if (( $NUMSTRUCTURES == 1 )); then runTool gs -dNOPAUSE -dBATCH -q -r300 -dJPEGQ=100 -sDEVICE=jpeg -sOutputFile=DuplexFold.jpeg DuplexFold.ps runTool draw DuplexFold.ct DuplexFold.svg -n 1 --svg else if [[ ! -s errors.txt ]]; then SEQLENGTH=`head -n 1 DuplexFold.ct | awk '{print $1}'` let SEQLENGTH++; awk '{print > (NR%"'"$SEQLENGTH"'"?i:i++)".ct";}' i=1 DuplexFold.ct fi typeset -i i END; let END=$NUMSTRUCTURES; let i=1; while (( i <= END )); do runTool draw DuplexFold.ct ${i}.ps -n $i runTool ps2pdf ${i}.ps ${i}.pdf runTool draw DuplexFold.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" DuplexFold.svg then cp ../../../../Utilities/Pages/NoStructures.html Results.html rm -f DuplexFold* 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 DuplexFold.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@DuplexFold/DuplexFold.html@g' Results.html sed -i 's@INTERFACE_NAME@DuplexFold@g' Results.html sed -i "s@FULL_RESULTS_DIRECTORY@ResultsPages/$DIRECTORY/DuplexFold@g" Results.html sed -i "s@COMMAND_LINE@DuplexFold $HTMLCOMMAND@g" Results.html sed -i 's@DuplexFold/ResultsPages@PredictBi/ResultsPages@g' Results.html sed -i 's@src="DuplexFold.svg"@src="DuplexFold/DuplexFold.svg"@g' Results.html sed -i "s@getFile=PredictBi/ResultsPages/$DIRECTORY/DuplexFold.ct@getFile=PredictBi/ResultsPages/$DIRECTORY/DuplexFold/DuplexFold.ct@g" Results.html fi # Move all files created for this section into the DuplexFold directory. mkdir DuplexFold; mv *.ct DuplexFold/; mv *.ps DuplexFold/; mv *.pdf DuplexFold/; if (( $NUMSTRUCTURES == 1 )); then mv DuplexFold.jpeg DuplexFold/; fi mv *.svg DuplexFold/; mv Results.html DuplexFold/; ###################################################################### # 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 Bimolecular Secondary Structure Results

' echo -e $COMBINEDHEADER > combined.txt sed -n "/results header starts/,/command line ends/p" bifold/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" DuplexFold/Results.html > 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 sed -i 's@INTERFACE_PAGE@PredictBi/PredictBi.html@g' Results.html sed -i 's@INTERFACE_NAME@Predict a Bimolecular Secondary Structure@g' Results.html fi ###################################################################### # Perform end-of-calculation tasks ###################################################################### calcCompleted #send results email, notify web client, etc