allpy
changeset 995:818263bbcd1a
add web interface for pair-cores
It needs some fixes. At least, it is compilable.
author | Boris Nagaev <bnagaev@gmail.com> |
---|---|
date | Sat, 03 Mar 2012 01:52:46 +0400 |
parents | e8c9f0a3482e |
children | 14defe89de86 |
files | .hgignore NEWS pair_cores/web/Makefile pair_cores/web/README.rst pair_cores/web/pair-cores.cpp pair_cores/web/run.sh |
diffstat | 6 files changed, 243 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- a/.hgignore Sat Mar 03 16:05:58 2012 +0400 1.2 +++ b/.hgignore Sat Mar 03 01:52:46 2012 +0400 1.3 @@ -31,6 +31,10 @@ 1.4 blocks3d/wt/files/resources 1.5 blocks3d/html.htm 1.6 pair_cores/html.htm 1.7 +pair_cores/web/wc 1.8 +pair_cores/web/*.o 1.9 +pair_cores/web/*root 1.10 +pair_cores/web/pair-cores.wt 1.11 *.zip 1.12 1.13 # Temporary files from sphinx
2.1 --- a/NEWS Sat Mar 03 16:05:58 2012 +0400 2.2 +++ b/NEWS Sat Mar 03 01:52:46 2012 +0400 2.3 @@ -8,6 +8,7 @@ 2.4 * new: add method blocks_from_homology() (allpy.structure) 2.5 * new: add MonomerHomology-based high blocks building algo to pair-cores 2.6 * new: print default values of command line args in help message (pair_cores) 2.7 + * new: add web interface for pair-cores 2.8 2.9 1.4.1 2.10
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/pair_cores/web/Makefile Sat Mar 03 01:52:46 2012 +0400 3.3 @@ -0,0 +1,52 @@ 3.4 + 3.5 +all: build environment 3.6 + 3.7 +.PHONY: build 3.8 +build: pair-cores.wt 3.9 + 3.10 +.PHONY: environment 3.11 +environment: wc 3.12 + mkdir -p approot 3.13 + cd approot && ln -fs ../wc/locales 3.14 + mkdir -p docroot/resources 3.15 + cd docroot/resources && ln -fs /usr/share/Wt/resources/* . 3.16 + cd docroot/resources && rm -fr Wc 3.17 + cd docroot/resources && mkdir -p Wc 3.18 + cd docroot/resources/Wc && ln -fs ../../../wc/css/ 3.19 + cd docroot/resources/Wc && ln -fs ../../../wc/js/ 3.20 + 3.21 +.SECONDEXPANSION: 3.22 + 3.23 +wc_cpp = wc/src/Wbi.cpp wc/src/TableForm.cpp wc/src/util.cpp \ 3.24 + wc/src/Countdown.cpp wc/src/TimeDuration.cpp wc/src/rand.cpp 3.25 + 3.26 +wc_hpp = $(wc_cpp:.cpp=.hpp) wc/src/global.hpp 3.27 + 3.28 +sources = $(wc_cpp) pair-cores.cpp 3.29 +objects = $(sources:.cpp=.o) 3.30 +headers = $(wc_hpp) 3.31 + 3.32 +WT_CONNECTOR=http 3.33 +CXX = g++ 3.34 +LINK = g++ 3.35 +LIBS += -lboost_signals -lboost_system -lboost_thread -lboost_filesystem 3.36 +LIBS += -lcurl -lssl 3.37 +LIBS += -lwt 3.38 +LIBS += -lwt$(WT_CONNECTOR) 3.39 + 3.40 +%.o: %.cpp $$(headers) 3.41 + $(CXX) -c $(CXXFLAGS) $< -o $@ 3.42 + 3.43 +$(wc_cpp) $(wc_hpp): wc 3.44 + 3.45 +pair-cores.wt: $$(objects) 3.46 + $(LINK) $(LFLAGS) $(LIBS) $(objects) -o $@ 3.47 + 3.48 +wc: 3.49 + wget https://bitbucket.org/starius/wt-classes/get/1.3.1.tar.gz -O - | \ 3.50 + tar -xz 3.51 + mkdir -p wc 3.52 + cp -a starius-wt-classes-*/* wc 3.53 + rm -r starius-wt-classes-* 3.54 + $(MAKE) -C wc js/jquery.countdown.js 3.55 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/pair_cores/web/README.rst Sat Mar 03 01:52:46 2012 +0400 4.3 @@ -0,0 +1,44 @@ 4.4 +Pair-cores web interface 4.5 +======================== 4.6 + 4.7 +Here is a web-interface for pair-cores program from allpy package. 4.8 + 4.9 +Requirements 4.10 +------------ 4.11 + 4.12 + * pair-cores command (hg rev e8c9f0a3482e +) 4.13 + * Wt library 3.1.10+ 4.14 + * curl library 4.15 + * ssl library 4.16 + 4.17 +Wt-classes library is included in this web ui, you do not need 4.18 +to have it installed. However it is linked with curl and openssl libraries, 4.19 +so these libraries should be installed. 4.20 + 4.21 +Build 4.22 +----- 4.23 + 4.24 + $ make build 4.25 + 4.26 +This will build pair-cores.wt executable, linked with wt http connector. 4.27 +To build fcgi linked program, pass "WT_CONNECTOR=fcgi" to make. 4.28 + 4.29 +To test it, some files are needed: 4.30 + 4.31 + $ make environment 4.32 + 4.33 +Run test script: 4.34 + 4.35 + $ sh run.sh 4.36 + 4.37 +Links 4.38 +----- 4.39 + 4.40 +For more information please visit: 4.41 + * allpy (and pair-cores) homepage: 4.42 + http://kodomo.fbb.msu.ru/trac/allpy 4.43 + * Distributed version control system of wt-classes: 4.44 + https://bitbucket.org/starius/wt-classes/ 4.45 + * Wt homepage: 4.46 + http://webtoolkit.eu/ 4.47 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/pair_cores/web/pair-cores.cpp Sat Mar 03 01:52:46 2012 +0400 5.3 @@ -0,0 +1,139 @@ 5.4 +#include <boost/bind.hpp> 5.5 + 5.6 +#include <Wt/WApplication> 5.7 +#include <Wt/WIntValidator> 5.8 +#include <Wt/WDoubleValidator> 5.9 +#include <Wt/WLineEdit> 5.10 +#include <Wt/WCheckBox> 5.11 +#include <Wt/WFileUpload> 5.12 + 5.13 +#include "wc/src/Wbi.hpp" 5.14 + 5.15 +using namespace Wt; 5.16 +using namespace Wt::Wc; 5.17 + 5.18 +TaskNumberQueue queue(100); 5.19 + 5.20 +bool validate(AbstractTask* task, TextFileInput* input_markup, 5.21 + TextFileInput* input_aln) { 5.22 + if (input_markup->state() != input_aln->state()) { 5.23 + task->set_message(""); 5.24 + return true; 5.25 + } else { 5.26 + task->set_message("Input alignment or input markup must be specified"); 5.27 + return false; 5.28 + } 5.29 +} 5.30 + 5.31 +std::string name_gen(TextFileInput* input_markup, TextFileInput* input_aln, 5.32 + std::string extension) { 5.33 + TextFileInput* input = input_markup->state() == AbstractInput::VALID ? 5.34 + input_markup : input_aln; 5.35 + std::string file = input->file_upload()->clientFileName().toUTF8(); 5.36 + std::string without_extension = file.substr(0, file.find_last_of(".")); 5.37 + if (without_extension.empty()) { 5.38 + without_extension = "pair-cores"; 5.39 + } 5.40 + return without_extension + "." + extension; 5.41 +} 5.42 + 5.43 +class PairCoresApp : public WApplication { 5.44 +public: 5.45 + PairCoresApp(const WEnvironment& env); 5.46 +}; 5.47 + 5.48 +PairCoresApp::PairCoresApp(const WEnvironment& env): 5.49 + WApplication(env) { 5.50 + enableUpdates(true); 5.51 + messageResourceBundle().use(Wt::WApplication::appRoot() + 5.52 + "locales/wtclasses"); 5.53 + TableTask* task = new TableTask(root()); 5.54 + // 5.55 + TextFileInput* input_markup = new TextFileInput("-m"); 5.56 + input_markup->set_required(false); 5.57 + task->add_input(input_markup, "Input pdb markup file"); 5.58 + // 5.59 + TextFileInput* input_aln = new TextFileInput("-i"); 5.60 + input_aln->set_required(false); 5.61 + task->add_input(input_aln, "Input alignment file"); 5.62 + // 5.63 + WLineEdit* delta_edit = new WLineEdit(); 5.64 + delta_edit->setValidator(new WDoubleValidator(0, 10)); 5.65 + LineEditInput* delta = new LineEditInput(delta_edit, "-d"); 5.66 + task->add_input(delta, "Distance spreading"); 5.67 + // 5.68 + WLineEdit* width_edit = new WLineEdit(); 5.69 + width_edit->setValidator(new WIntValidator(3, 9999)); 5.70 + LineEditInput* width = new LineEditInput(width_edit, "-w"); 5.71 + task->add_input(width, "Min width of a block"); 5.72 + // 5.73 + BoolInput* blocks3d = new BoolInput(new WCheckBox(), "--blocks3d"); 5.74 + task->add_input(blocks3d, "Use blocks3d algorithm for high blocks"); 5.75 + // 5.76 + BoolInput* ioss = new BoolInput(new WCheckBox(), "-e", "True", "False"); 5.77 + task->add_input(ioss, "Ignore cores, owned by one SS element"); 5.78 + // 5.79 + WLineEdit* pair_timeout_edit = new WLineEdit(); 5.80 + pair_timeout_edit->setValidator(new WIntValidator(-1, 30 * 24 * 3600)); 5.81 + LineEditInput* pair_timeout = new LineEditInput(pair_timeout_edit, 5.82 + "--pair-timeout"); 5.83 + task->add_input(pair_timeout, 5.84 + "Bron-Kerbosh (pair cores) timeout (-1 - unlimited)"); 5.85 + // 5.86 + WLineEdit* blocks3d_timeout_edit = new WLineEdit(); 5.87 + blocks3d_timeout_edit->setValidator(new WIntValidator(-1, 30 * 24 * 3600)); 5.88 + LineEditInput* blocks3d_timeout = new LineEditInput(blocks3d_timeout_edit, 5.89 + "--blocks3d-timeout"); 5.90 + task->add_input(blocks3d_timeout, 5.91 + "Bron-Kerbosh (blocks3d) timeout (-1 - unlimited)"); 5.92 + // 5.93 + // outputs 5.94 + // 5.95 + boost::function<std::string(std::string)> name_gen2 = boost::bind(name_gen, 5.96 + input_markup, input_aln, _1); 5.97 + // 5.98 + ViewFileOutput* homology = new ViewFileOutput("-y"); 5.99 + homology->set_suggested_gen(boost::bind(name_gen2, "hom")); 5.100 + homology->set_selectable(false); 5.101 + task->add_output(homology, "Output homology file"); 5.102 + // 5.103 + ViewFileOutput* pair_blocks = new ViewFileOutput("-b"); 5.104 + pair_blocks->set_suggested_gen(boost::bind(name_gen2, "blocks")); 5.105 + task->add_output(pair_blocks, "Output pair cores file"); 5.106 + // 5.107 + ViewFileOutput* pair_html = new ViewFileOutput("-H", 5.108 + &FileOutput::unique_name, 5.109 + "application/octet-stream", 5.110 + "text/html"); 5.111 + pair_html->set_suggested_gen(boost::bind(name_gen2, "html")); 5.112 + task->add_output(pair_html, "Output pair cores HTML file"); 5.113 + // 5.114 + ViewFileOutput* pymol = new ViewFileOutput("-p"); 5.115 + pymol->set_suggested_gen(boost::bind(name_gen2, "pml")); 5.116 + task->add_output(pymol, "Output PyMol file"); 5.117 + // 5.118 + ViewFileOutput* high_blocks = new ViewFileOutput("--high-blocks"); 5.119 + high_blocks->set_suggested_gen(boost::bind(name_gen2, "blocks")); 5.120 + task->add_output(high_blocks, "Output text file with high blocks"); 5.121 + // 5.122 + ViewFileOutput* blocks3d_html = new ViewFileOutput("--high-blocks-html", 5.123 + &FileOutput::unique_name, 5.124 + "application/octet-stream", 5.125 + "text/html"); 5.126 + blocks3d_html->set_suggested_gen(boost::bind(name_gen2, "html")); 5.127 + task->add_output(blocks3d_html, "Output HTML file with high blocks"); 5.128 + // 5.129 + task->set_runner(new ForkingRunner("pair-cores")); 5.130 + task->set_queue(&queue); 5.131 + task->set_validator(boost::bind(validate, task, input_markup, input_aln)); 5.132 + new TaskCountup(task, root()); 5.133 +} 5.134 + 5.135 +WApplication* createPairCoresApp(const WEnvironment& env) { 5.136 + return new PairCoresApp(env); 5.137 +} 5.138 + 5.139 +int main(int argc, char** argv) { 5.140 + return WRun(argc, argv, &createPairCoresApp); 5.141 +} 5.142 +