1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77:
<?php
namespace AnalyseModule;
class ConservancyPresenter extends \BaseModule\BasePresenter {
protected $conservancyComparator;
public function renderDefault() {
if (isset($this->request->getPost()['analyse']) && count($this->request->getPost()['analyse']) > 1) {
if (isset($this->request->getPost()['winsize'])) {
$winsize = $this->request->getPost()['winsize'];
} else {
$winsize = null;
}
$accessions = $this->request->getPost()['analyse'];
$sequences = $this->conservancyComparator->execute($accessions, $winsize);
$this->template->sequences = $sequences;
$this->template->tmpDir = $this->conservancyComparator->getTmpDir();
$this->template->winSize = $this->conservancyComparator->getWinSize();
} else {
$this->template->noAccessions = true;
}
}
public function renderDetail($tmpdir, $winsize, $accession) {
$this->template->path = $this->template->basePath . "/" . str_replace('++', '/', rawurldecode($tmpdir)) . "/" . $accession . "_win" . $winsize . "_ss_compare.svg";
$this->template->accession = $accession;
}
public function actionExport($tmpdir, $winsize) {
$tmpPath = str_replace('++', '/', rawurldecode($tmpdir)) . DIRECTORY_SEPARATOR;
$svgs = json_decode($this->getHttpRequest()->getPost('svgs'), true);
$zipPath = $this->conservancyComparator->export($tmpPath, $svgs, $winsize);
$this->sendResponse(new \Nette\Application\Responses\FileResponse($zipPath));
}
protected function createComponentAnalyseForm() {
$form = new \BaseModule\Form;
$form->addSelect('winsize', 'Set window size', array(20 => '20', 40 => '40', 60 => '60'))->setDefaultValue($this->conservancyComparator->getWinSize());
$form->addSubmit('compare', 'Rerun comparison');
return $form;
}
}