allpy
changeset 1117:7451c70b3789
pair-cores/web: copy pair-cores.cpp to compare-aln-3d.cpp
update Makefile
update .hgignore
author | Boris Nagaev <bnagaev@gmail.com> |
---|---|
date | Wed, 28 Nov 2012 14:42:15 +0400 |
parents | 45da1d3a60c3 |
children | f61814d8bef5 |
files | .hgignore pair_cores/web/Makefile pair_cores/web/compare-aln-3d.cpp |
diffstat | 3 files changed, 179 insertions(+), 5 deletions(-) [+] |
line diff
1.1 --- a/.hgignore Wed Nov 28 00:35:35 2012 +0400 1.2 +++ b/.hgignore Wed Nov 28 14:42:15 2012 +0400 1.3 @@ -34,7 +34,7 @@ 1.4 pair_cores/web/wc 1.5 pair_cores/web/*.o 1.6 pair_cores/web/*root 1.7 -pair_cores/web/pair-cores.wt 1.8 +pair_cores/web/*.wt 1.9 *.zip 1.10 1.11 # Temporary files from sphinx
2.1 --- a/pair_cores/web/Makefile Wed Nov 28 00:35:35 2012 +0400 2.2 +++ b/pair_cores/web/Makefile Wed Nov 28 14:42:15 2012 +0400 2.3 @@ -2,7 +2,7 @@ 2.4 all: build environment 2.5 2.6 .PHONY: build 2.7 -build: pair-cores.wt 2.8 +build: pair-cores.wt compare-aln-3d.wt 2.9 2.10 .PHONY: environment 2.11 environment: wc 2.12 @@ -23,7 +23,7 @@ 2.13 2.14 wc_hpp = $(wc_cpp:.cpp=.hpp) wc/src/global.hpp 2.15 2.16 -sources = $(wc_cpp) pair-cores.cpp 2.17 +sources = $(wc_cpp) 2.18 objects = $(sources:.cpp=.o) 2.19 headers = $(wc_hpp) 2.20 2.21 @@ -39,8 +39,11 @@ 2.22 2.23 $(wc_cpp) $(wc_hpp): wc 2.24 2.25 -pair-cores.wt: $$(objects) 2.26 - $(LINK) $(LFLAGS) $(objects) $(LIBS) -o $@ 2.27 +pair-cores.wt: $$(objects) pair-cores.o 2.28 + $(LINK) $(LFLAGS) $^ $(LIBS) -o $@ 2.29 + 2.30 +compare-aln-3d.wt: $$(objects) compare-aln-3d.o 2.31 + $(LINK) $(LFLAGS) $^ $(LIBS) -o $@ 2.32 2.33 wc: 2.34 wget https://bitbucket.org/starius/wt-classes/get/1.4.0.tar.gz -O - | \
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/pair_cores/web/compare-aln-3d.cpp Wed Nov 28 14:42:15 2012 +0400 3.3 @@ -0,0 +1,171 @@ 3.4 +#include <boost/bind.hpp> 3.5 + 3.6 +#include <Wt/WApplication> 3.7 +#include <Wt/WEnvironment> 3.8 +#include <Wt/WIntValidator> 3.9 +#include <Wt/WDoubleValidator> 3.10 +#include <Wt/WLineEdit> 3.11 +#include <Wt/WTextArea> 3.12 +#include <Wt/WCheckBox> 3.13 +#include <Wt/WTemplate> 3.14 +#include <Wt/WFileUpload> 3.15 +#include <Wt/WPushButton> 3.16 + 3.17 +#include "wc/src/Wbi.hpp" 3.18 +#include "wc/src/util.hpp" 3.19 + 3.20 +using namespace Wt; 3.21 +using namespace Wt::Wc; 3.22 + 3.23 +TaskNumberQueue queue(100); 3.24 + 3.25 +std::string name_gen(TextFileInput* input_aln, 3.26 + std::string extension) { 3.27 + TextFileInput* input = input_aln; 3.28 + std::string file = input->file_upload()->clientFileName().toUTF8(); 3.29 + std::string without_extension = file.substr(0, file.find_last_of(".")); 3.30 + if (without_extension.empty()) { 3.31 + without_extension = "pair-cores"; 3.32 + } 3.33 + return without_extension + "." + extension; 3.34 +} 3.35 + 3.36 +class PairCoresApp : public WApplication { 3.37 +public: 3.38 + PairCoresApp(const WEnvironment& env); 3.39 + 3.40 +private: 3.41 + void reset_contents(); 3.42 + 3.43 + void do_nothing() 3.44 + { } 3.45 + 3.46 + static Wt::WString tr(const char* key) { 3.47 + return Wt::WString::tr(key); 3.48 + } 3.49 +}; 3.50 + 3.51 +PairCoresApp::PairCoresApp(const WEnvironment& env): 3.52 + WApplication(env) { 3.53 + enableUpdates(true); 3.54 + std::string approot = config_value("approot", ""); 3.55 + messageResourceBundle().use(approot + "wc-locales/wtclasses"); 3.56 + messageResourceBundle().use(approot + "locales/pair-cores-web"); 3.57 + useStyleSheet("css/pair-cores.css"); 3.58 + reset_contents(); 3.59 +} 3.60 + 3.61 +void PairCoresApp::reset_contents() { 3.62 + root()->clear(); 3.63 + // 3.64 + new Wt::WTemplate(tr("pair.main.Header"), root()); 3.65 + if (!environment().ajax()) { 3.66 + WPushButton* refresh = new WPushButton(tr("pair.main.Refresh"), root()); 3.67 + refresh->clicked().connect(this, &PairCoresApp::do_nothing); 3.68 + } 3.69 + WPushButton* reset = new WPushButton(tr("pair.main.Reset"), root()); 3.70 + reset->clicked().connect(this, &PairCoresApp::reset_contents); 3.71 + // 3.72 + TableTask* task = new TableTask(root()); 3.73 + // 3.74 + TextFileInput* input_aln = new TextFileInput("-i"); 3.75 + input_aln->text_area()->setColumns(60); 3.76 + input_aln->text_area()->setRows(12); 3.77 + task->add_input(input_aln, tr("pair.in.Alignment")); 3.78 + // 3.79 + WLineEdit* delta_edit = new WLineEdit("2.0"); 3.80 + delta_edit->setValidator(new WDoubleValidator(0, 10)); 3.81 + delta_edit->validator()->setMandatory(true); 3.82 + LineEditInput* delta = new LineEditInput(delta_edit, "-d"); 3.83 + task->add_input(delta, tr("pair.in.Delta")); 3.84 + // 3.85 + WLineEdit* width_edit = new WLineEdit("3"); 3.86 + width_edit->setValidator(new WIntValidator(3, 9999)); 3.87 + width_edit->validator()->setMandatory(true); 3.88 + LineEditInput* width = new LineEditInput(width_edit, "-w"); 3.89 + task->add_input(width, tr("pair.in.Width")); 3.90 + // 3.91 + BoolInput* blocks3d = new BoolInput(new WCheckBox(), "--blocks3d"); 3.92 + task->add_input(blocks3d, tr("pair.in.Blocks3D")); 3.93 + // 3.94 + BoolInput* ioss = new BoolInput(new WCheckBox(), "-e"); 3.95 + ioss->set_value_if_true("True"); 3.96 + task->add_input(ioss, tr("pair.in.SS")); 3.97 + // 3.98 + WLineEdit* pair_timeout_edit = new WLineEdit("10"); 3.99 + pair_timeout_edit->setValidator(new WIntValidator(-1, 30 * 24 * 3600)); 3.100 + pair_timeout_edit->validator()->setMandatory(true); 3.101 + LineEditInput* pair_timeout = new LineEditInput(pair_timeout_edit, 3.102 + "--pair-timeout"); 3.103 + task->add_input(pair_timeout, tr("pair.in.Pair_timeout")); 3.104 + // 3.105 + WLineEdit* blocks3d_timeout_edit = new WLineEdit("-1"); 3.106 + blocks3d_timeout_edit->setValidator(new WIntValidator(-1, 30 * 24 * 3600)); 3.107 + blocks3d_timeout_edit->validator()->setMandatory(true); 3.108 + LineEditInput* blocks3d_timeout = new LineEditInput(blocks3d_timeout_edit, 3.109 + "--blocks3d-timeout"); 3.110 + task->add_input(blocks3d_timeout, tr("pair.in.Blocks3D_timeout")); 3.111 + // 3.112 + // outputs 3.113 + // 3.114 + boost::function<std::string(std::string)> name_gen2 = boost::bind(name_gen, 3.115 + input_aln, _1); 3.116 + // 3.117 + ViewFileOutput* homology = new ViewFileOutput("-y"); 3.118 + homology->set_suggested_gen(boost::bind(name_gen2, "hom")); 3.119 + homology->set_selectable(false); 3.120 + task->add_output(homology, tr("pair.out.Homology")); 3.121 + // 3.122 + ViewFileOutput* pair_blocks = new ViewFileOutput("-b"); 3.123 + pair_blocks->set_suggested_gen(boost::bind(name_gen2, "blocks")); 3.124 + task->add_output(pair_blocks, tr("pair.out.Pair_blocks")); 3.125 + // 3.126 + ViewFileOutput* pair_html = new ViewFileOutput("-H", 3.127 + &FileOutput::unique_name, 3.128 + "application/octet-stream", 3.129 + "text/html"); 3.130 + pair_html->set_suggested_gen(boost::bind(name_gen2, "html")); 3.131 + task->add_output(pair_html, tr("pair.out.Pair_html")); 3.132 + // 3.133 + ViewFileOutput* pymol = new ViewFileOutput("-p"); 3.134 + pymol->set_suggested_gen(boost::bind(name_gen2, "pml")); 3.135 + task->add_output(pymol, tr("pair.out.Pymol")); 3.136 + // 3.137 + ViewFileOutput* high_pymol = new ViewFileOutput("--high-blocks-pymol"); 3.138 + high_pymol->set_suggested_gen(boost::bind(name_gen2, "pml")); 3.139 + task->add_output(high_pymol, tr("pair.out.High_pymol")); 3.140 + // 3.141 + ViewFileOutput* high_blocks = new ViewFileOutput("--high-blocks"); 3.142 + high_blocks->set_suggested_gen(boost::bind(name_gen2, "blocks")); 3.143 + task->add_output(high_blocks, tr("pair.out.High_blocks")); 3.144 + // 3.145 + ViewFileOutput* high_html = new ViewFileOutput("--high-blocks-html", 3.146 + &FileOutput::unique_name, 3.147 + "application/octet-stream", 3.148 + "text/html"); 3.149 + high_html->set_suggested_gen(boost::bind(name_gen2, "html")); 3.150 + task->add_output(high_html, tr("pair.out.High_html")); 3.151 + // 3.152 + PrintFileOutput* execution_log = new PrintFileOutput("&>"); 3.153 + execution_log->set_suggested_gen(boost::bind(name_gen2, "log")); 3.154 + execution_log->set_selectable(false); 3.155 + task->add_output(execution_log, tr("pair.out.Log")); 3.156 + // 3.157 + task->set_runner(new ForkingRunner("pair-cores --no-read-local")); 3.158 + task->set_queue(&queue); 3.159 + new TaskCountup(task, root()); 3.160 + // 3.161 + new WBreak(root()); 3.162 + new Wt::WTemplate(tr("pair.main.Example"), root()); 3.163 + new Wt::WTemplate(tr("pair.main.Example_fasta"), root()); 3.164 + new Wt::WTemplate(tr("pair.main.Rfbr"), root()); 3.165 +} 3.166 + 3.167 +WApplication* createPairCoresApp(const WEnvironment& env) { 3.168 + return new PairCoresApp(env); 3.169 +} 3.170 + 3.171 +int main(int argc, char** argv) { 3.172 + return WRun(argc, argv, &createPairCoresApp); 3.173 +} 3.174 +