From 75ec8bab5c2c00ae4b95741ee803a430906c4f61 Mon Sep 17 00:00:00 2001 From: Johannes Goll Date: Fri, 15 Oct 2010 10:32:44 -0400 Subject: [PATCH] fixed bugs; updated pathway statistics --- app/config/core.php | 2 +- app/controllers/app_controller.php | 31 +++++-- app/controllers/browse_controller.php | 46 +++++++---- app/controllers/compare_controller.php | 38 ++++----- app/controllers/components/matrix.php | 2 +- app/controllers/components/r.php | 2 +- app/controllers/components/solr.php | 94 ++++++++++++++-------- app/controllers/libraries_controller.php | 48 +++++------ app/controllers/populations_controller.php | 20 +++-- app/controllers/projects_controller.php | 14 ++-- app/controllers/search_controller.php | 9 +-- app/controllers/users_controller.php | 41 +++++----- app/controllers/view_controller.php | 4 +- app/models/library.php | 12 ++- app/models/population.php | 8 +- app/views/browse/apis_taxonomy.ctp | 4 +- app/views/browse/blast_taxonomy.ctp | 2 +- app/views/browse/enzymes.ctp | 2 +- app/views/browse/gene_ontology.ctp | 2 +- app/views/browse/pathways.ctp | 5 +- app/views/dashboard/index.ctp | 26 +++++- app/views/helpers/tree.php | 8 +- app/views/view/result_panel.ctp | 7 +- app/webroot/css/dashboard.css | 32 ++++++-- 24 files changed, 288 insertions(+), 171 deletions(-) diff --git a/app/config/core.php b/app/config/core.php index 98ba4d2..df27225 100755 --- a/app/config/core.php +++ b/app/config/core.php @@ -43,7 +43,7 @@ * In development mode, you need to click the flash message to continue. */ - Configure::write('debug', '1'); + Configure::write('debug', '0'); /** * Application wide charset encoding diff --git a/app/controllers/app_controller.php b/app/controllers/app_controller.php index c9f5169..6cccbc5 100644 --- a/app/controllers/app_controller.php +++ b/app/controllers/app_controller.php @@ -23,7 +23,12 @@ **/ class AppController extends Controller { - var $persistModel = true; + //$persistModel = true speeds up site by caching model classes. However it has to be + //treated with caution. It caused a chache exception and returned imcomplete + //model objects google"$persistModel cakephp incomplete object". Setting this to false + //until the root cause for this exception has been identified. + var $persistModel = false; + var $helpers = array('Session','Html', 'Form','Javascript','Ajax'); var $components = array('Session','Cookie','RequestHandler','Authsome' => array('model' => 'User')); @@ -186,24 +191,36 @@ function beforeFilter() { } } else if(in_array($url,$this->projectAdminUrls)) { - $projectId = $parameters[0]; $this->loadModel('Project'); + + + if($controller === 'libraries') { + $this->loadModel('Library'); + $projectId = $this->Library->getProjectIdById($parameters[0]); + } + elseif($controller === 'populations') { + $this->loadModel('Population'); + $projectId = $this->Population->getProjectIdById($parameters[0]); + } + else { + $projectId = $parameters[0]; + } + if($this->Project->isProjectAdmin($projectId,$currentUserId)) { - return; + return; } } - else { + else if(!in_array($url,$this->adminAccessUrls)) { if($userGroup === INTERNAL_USER_GROUP) { return; } } - $this->Session->setFlash("You don't have permissions to view this page."); - $this->redirect("/dashboard/index"); + $this->redirect("/dashboard/index",null,true); } else { $this->Session->setFlash("Please log in."); - $this->redirect("/dashboard/index"); + $this->redirect("/dashboard/index",null,true); } } diff --git a/app/controllers/browse_controller.php b/app/controllers/browse_controller.php index f228e31..afc393b 100644 --- a/app/controllers/browse_controller.php +++ b/app/controllers/browse_controller.php @@ -86,7 +86,7 @@ function blastTaxonomy($dataset='CBAYVIR',$expandTaxon=1,$query='*:*') { catch(Exception $e) { debug("$query AND blast_tree:{$taxon['Taxonomy']['taxon_id']}"); $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + $this->redirect('/projects/index',null,true); } //set count @@ -116,7 +116,7 @@ function blastTaxonomy($dataset='CBAYVIR',$expandTaxon=1,$query='*:*') { } catch(Exception $e) { $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + $this->redirect('/projects/index',null,true); } $numHits = (int) $result->response->numFound; $facets = $result->facet_counts; @@ -191,7 +191,7 @@ function apisTaxonomy($dataset='CBAYVIR',$expandTaxon=1,$query='*:*') { } catch(Exception $e) { $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + $this->redirect('/projects/index',null,true); } //set count $taxon['Taxonomy']['count'] = $count; @@ -221,7 +221,7 @@ function apisTaxonomy($dataset='CBAYVIR',$expandTaxon=1,$query='*:*') { } catch(Exception $e) { $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + $this->redirect('/projects/index',null,true); } $numHits = (int) $result->response->numFound; $facets = $result->facet_counts; @@ -307,7 +307,7 @@ function enzymes($dataset='CBAYVIR',$expandTaxon='root',$query = '*:*') { } catch (Exception $e) { $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + $this->redirect('/projects/index',null,true); } //set count $taxon['Enzymes']['count'] = $count; @@ -338,7 +338,7 @@ function enzymes($dataset='CBAYVIR',$expandTaxon='root',$query = '*:*') { } catch(Exception $e){ $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + $this->redirect('/projects/index',null,true); } $numHits = (int) $result->response->numFound; @@ -433,7 +433,7 @@ function geneOntology($dataset='CBAYVIR',$expandTaxon='root',$query='*:*') { } catch(Exception $e){ $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + $this->redirect('/projects/index',null,true); } #FIXME temporary fix for GO parsing error // if($count==0) { @@ -444,7 +444,7 @@ function geneOntology($dataset='CBAYVIR',$expandTaxon='root',$query='*:*') { // } // catch(Exception $e){ // $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); -// $this->redirect('/projects/index'); +// $this->redirect('/projects/index',null,true); // } // } @@ -487,7 +487,7 @@ function geneOntology($dataset='CBAYVIR',$expandTaxon='root',$query='*:*') { } catch(Exception $e){ $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + $this->redirect('/projects/index',null,true); } @@ -503,7 +503,7 @@ function geneOntology($dataset='CBAYVIR',$expandTaxon='root',$query='*:*') { // } // catch(Exception $e){ // $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); -// $this->redirect('/projects/index'); +// $this->redirect('/projects/index',null,true); // } // } @@ -575,13 +575,23 @@ function pathways($dataset='CBAYVIR',$expandNode = 16905,$query='*:*') { $parentLevel = $parent['Pathway']['level']; $pathwayUrl = "http://www.genome.jp/kegg-bin/show_pathway?ec".str_pad($parent['Pathway']['kegg_id'],5,0,STR_PAD_LEFT); - //get pathway facets and overall counts - if($parentLevel === 'enzyme') { - $parentSolrResults = $this->Solr->getPathwayFacets($query,$dataset,$parentLevel,$expandNode,$children,$parent['Pathway']['ec_id']); - $parentName = $parent['Pathway']['name']." (".$parent['Pathway']['ec_id'].")"; + //get pathway facets and overall counts + try { + if($parentLevel === 'enzyme') { + $parentSolrResults = $this->Solr->getPathwayFacets($query,$dataset,$parentLevel,$expandNode,$children,$parent['Pathway']['ec_id']); + $parentName = $parent['Pathway']['name']." (".$parent['Pathway']['ec_id'].")"; + } + else { + $parentSolrResults = $this->Solr->getPathwayFacets($query,$dataset,$parentLevel,$expandNode,$children); + } } - else { - $parentSolrResults = $this->Solr->getPathwayFacets($query,$dataset,$parentLevel,$expandNode,$children); + catch(Exception $e){ + $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); + if($this->Session->check($function.'.browse.query')) { + $this->Session->delete($function.'.browse.query'); + } + $this->redirect('/projects/index',null,true); + //$this->redirect('/browse/pathways',$dataset,false); } $childArray = array(); @@ -673,6 +683,10 @@ public function dowloadFacets($dataset,$node,$mode,$numHits,$query = "*:*") { $this->autoRender=false; $query = urldecode($query); + + if($mode === PATHWAY) { + $node = base64_decode($node); + } #get facet data from session $facets = $this->Session->read($mode.'.facets'); diff --git a/app/controllers/compare_controller.php b/app/controllers/compare_controller.php index d20b669..44f5e34 100644 --- a/app/controllers/compare_controller.php +++ b/app/controllers/compare_controller.php @@ -339,7 +339,7 @@ private function taxonomy($facetField = 'blast_tree') { $totalCounts = $this->Session->read('totalCounts'); if($option == METASTATS || $option == WILCOXON) { - $this->transformPopulationsIntoLibraries($selectedDatasets); + $totalCounts = $this->transformPopulationsIntoLibraries($selectedDatasets,$filter); } #write session variables @@ -368,9 +368,7 @@ private function taxonomy($facetField = 'blast_tree') { } unset($taxonResults); - - - + //populate count matrix with solr facet counts using solr's filter query foreach($selectedDatasets as $dataset) { @@ -466,7 +464,7 @@ function geneOntology() { $totalCounts = $this->Session->read('totalCounts'); if($option == METASTATS || $option == WILCOXON) { - $this->transformPopulationsIntoLibraries($selectedDatasets); + $totalCounts = $this->transformPopulationsIntoLibraries($selectedDatasets,$filter); } #write session variables @@ -576,7 +574,7 @@ function enzymes() { $totalCounts = $this->Session->read('totalCounts'); if($option == METASTATS || $option == WILCOXON) { - $this->transformPopulationsIntoLibraries($selectedDatasets); + $totalCounts = $this->transformPopulationsIntoLibraries($selectedDatasets,$filter); } #write session variables @@ -692,10 +690,10 @@ function hmms() { } if($option == METASTATS || $option == WILCOXON) { - $this->transformPopulationsIntoLibraries($selectedDatasets); + $totalCounts = $this->transformPopulationsIntoLibraries($selectedDatasets,$filter); } - #write session variables + //write session variables $this->Session->write("$mode.level", $level); $this->Session->write('levels',$levels); $this->Session->write('mode',$mode); @@ -731,7 +729,7 @@ function hmms() { } catch(Exception $e){ $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + $this->redirect('/projects/index',null,true); } $facets = $result->facet_counts->facet_fields->hmm_id; @@ -783,7 +781,7 @@ function clusters() { $totalCounts = $this->Session->read('totalCounts'); if($option == METASTATS || $option == WILCOXON) { - $this->transformPopulationsIntoLibraries($selectedDatasets); + $totalCounts = $this->transformPopulationsIntoLibraries($selectedDatasets,$filter); } if($minCount==0) { @@ -809,7 +807,7 @@ function clusters() { } catch(Exception $e){ $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + $this->redirect('/projects/index',null,true); } $facets = $result->facet_counts->facet_fields->cluster_id; @@ -905,7 +903,7 @@ function environmentalLibraries() { $totalCounts = $this->Session->read('totalCounts'); if($option == METASTATS || $option == WILCOXON) { - $this->transformPopulationsIntoLibraries($selectedDatasets); + $totalCounts = $this->transformPopulationsIntoLibraries($selectedDatasets,$filter); } //specify facet behaviour (fetch all facets) @@ -995,7 +993,7 @@ function pathways() { $totalCounts = $this->Session->read('totalCounts'); if($option == METASTATS || $option == WILCOXON) { - $this->transformPopulationsIntoLibraries($selectedDatasets); + $totalCounts = $this->transformPopulationsIntoLibraries($selectedDatasets,$filter); } #write session variables @@ -1076,7 +1074,7 @@ function commonNames() { $totalCounts = $this->Session->read('totalCounts'); if($option == METASTATS || $option == WILCOXON) { - $this->transformPopulationsIntoLibraries($selectedDatasets); + $totalCounts = $this->transformPopulationsIntoLibraries($selectedDatasets,$filter); } #write session variables @@ -1099,7 +1097,7 @@ function commonNames() { } catch(Exception $e){ $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + $this->redirect('/projects/index',null,true); } $facets = $result->facet_counts->facet_fields->com_name; @@ -1229,8 +1227,8 @@ function flipAxis() { } //split the two populations into their libraries; store population - //names and start position of secontd population - private function transformPopulationsIntoLibraries(&$selectedDatasets) { + //names and store position of second population; return adjusted total count array + private function transformPopulationsIntoLibraries(&$selectedDatasets,$filter) { $this->Session->write('populations',$selectedDatasets); $librariesA = $this->Population->getLibraries($selectedDatasets[0]); @@ -1240,13 +1238,17 @@ private function transformPopulationsIntoLibraries(&$selectedDatasets) { $countB = count($librariesB); $selectedDatasets = array_merge($librariesA,$librariesB); + $totalCounts = $this->getTotalCounts($filter,$selectedDatasets); + $this->Session->write('startIndexPopulationB',count($librariesA)+1); $this->Session->write('libraryCountPopulationA',$countA); $this->Session->write('libraryCountPopulationB',$countB); + + return $totalCounts; } #returns associative array containing the total peptide counts for all selected datasets - #conuts are used to generate relative and relative row counts + #counts are used to generate relative and relative row counts private function getTotalCounts($filter,$datasets) { $totalCounts = array(); diff --git a/app/controllers/components/matrix.php b/app/controllers/components/matrix.php index 34a7b38..7e71c88 100644 --- a/app/controllers/components/matrix.php +++ b/app/controllers/components/matrix.php @@ -161,7 +161,7 @@ private function absoluteToRelativeCounts($datasets,&$counts,$precision = 4) { $absoluteCount = $row[$dataset]; #get the total count for the dataset - $totalCount = $this->totalCounts[$dataset]; + $totalCount = $this->totalCounts[$dataset]; #calculate relative counts (precision=4) if($totalCount==0) { diff --git a/app/controllers/components/r.php b/app/controllers/components/r.php index 70f16b7..85f4c54 100644 --- a/app/controllers/components/r.php +++ b/app/controllers/components/r.php @@ -529,7 +529,7 @@ function writeWilcoxonMatrix($selectedDatasets,&$counts) { $this->Session->write('selectedDatasets',$populations); $counts = $newCounts; - + return; } } diff --git a/app/controllers/components/solr.php b/app/controllers/components/solr.php index 257f935..6ca64fc 100644 --- a/app/controllers/components/solr.php +++ b/app/controllers/components/solr.php @@ -168,12 +168,17 @@ public function deleteIndex($dataset) { * @access private */ private function unloadCore($dataset) { - $this->executeUrl($this->getSolrUrl(SOLR_MASTER_HOST,SOLR_PORT)."/solr/admin/cores?action=UNLOAD&core=$dataset"); - - //unload slave core if a Solr slave host has been defined in the METAREP configuration file - if(defined('SOLR_SLAVE_HOST')) { - $this->executeUrl($this->getSolrUrl(SOLR_SLAVE_HOST,SOLR_PORT)."/solr/admin/cores?action=UNLOAD&core=$dataset"); + try { + $this->executeUrl($this->getSolrUrl(SOLR_MASTER_HOST,SOLR_PORT)."/solr/admin/cores?action=UNLOAD&core=$dataset"); + + //unload slave core if a Solr slave host has been defined in the METAREP configuration file + if(defined('SOLR_SLAVE_HOST')) { + $this->executeUrl($this->getSolrUrl(SOLR_SLAVE_HOST,SOLR_PORT)."/solr/admin/cores?action=UNLOAD&core=$dataset"); + } } + catch (Exception $e) { + throw new Exception($e); + } } /** @@ -185,13 +190,17 @@ private function unloadCore($dataset) { * @return void * @access private */ - private function createCore($projectId,$dataset) { - $this->executeUrl($this->getSolrUrl(SOLR_MASTER_HOST,SOLR_PORT)."/solr/admin/cores?action=CREATE&name=$dataset&instanceDir=".SOLR_INSTANCE_DIR."&dataDir=".SOLR_DATA_DIR."/$projectId/$dataset"); - - //create slave core if a Solr slave host has been defined in the METAREP configuration file - if(defined('SOLR_SLAVE_HOST')) { - $this->executeUrl($this->getSolrUrl(SOLR_SLAVE_HOST,SOLR_PORT)."/solr/admin/cores?action=CREATE&name=$dataset&instanceDir=".SOLR_INSTANCE_DIR."&dataDir=".SOLR_DATA_DIR."/$projectId/$dataset"); + private function createCore($projectId,$dataset) { + try { + $this->executeUrl($this->getSolrUrl(SOLR_MASTER_HOST,SOLR_PORT)."/solr/admin/cores?action=CREATE&name=$dataset&instanceDir=".SOLR_INSTANCE_DIR."&dataDir=".SOLR_DATA_DIR."/$projectId/$dataset"); + //create slave core if a Solr slave host has been defined in the METAREP configuration file + if(defined('SOLR_SLAVE_HOST')) { + $this->executeUrl($this->getSolrUrl(SOLR_SLAVE_HOST,SOLR_PORT)."/solr/admin/cores?action=CREATE&name=$dataset&instanceDir=".SOLR_INSTANCE_DIR."&dataDir=".SOLR_DATA_DIR."/$projectId/$dataset"); + } } + catch (Exception $e) { + throw new Exception($e); + } } /** @@ -203,8 +212,14 @@ private function createCore($projectId,$dataset) { */ private function commitAndOptimize($dataset) { $solr = new Apache_Solr_Service( SOLR_MASTER_HOST, SOLR_PORT, "/solr/$dataset"); - $solr->commit(); - $solr->optimize(); + + try { + $solr->commit(); + $solr->optimize(); + } + catch (Exception $e) { + throw new Exception($e); + } } /** @@ -224,25 +239,35 @@ private function getSolrUrl($host,$port) { * Merges Solr indices * **@param Integer $projectId Project ID - * @param Sttring $core name of new index file/core after merging + * @param Sttring $ } + catch (Exception $e) { + throw new Exception($e); + } core name of new index file/core after merging * @param Array $datasets Datasets to be mergede * @return void * @access private */ public function mergeIndex($projectId,$core,$datasets) { - #create cores - $this->createCore($projectId,$core); - - #populate newly created core with existing cores - $url = $this->getSolrUrl(SOLR_MASTER_HOST,SOLR_PORT)."/solr/admin/cores?action=mergeindexes&core=$core"; - #add index information for cores that are going to be merged + //create merge url string + $mergeUrl = $this->getSolrUrl(SOLR_MASTER_HOST,SOLR_PORT)."/solr/admin/cores?action=mergeindexes&core=$core"; + + //add index information for cores that are going to be merged foreach($datasets as $dataset) { - $url .= "&indexDir=".SOLR_DATA_DIR."/$projectId/$dataset/index"; + $mergeUrl .= "&indexDir=".SOLR_DATA_DIR."/$projectId/$dataset/index"; } - $this->executeUrl($url); - $this->commitAndOptimize($core); + try { + $this->log("Create Core: $projectId,$core"); + $this->createCore($projectId,$core); + $this->log("Execute Merge Url: $mergeUrl"); + $this->executeUrl($mergeUrl,3600); + $this->log("Commit & Optimize Core: $core"); + $this->commitAndOptimize($core); + } + catch (Exception $e) { + throw new Exception($e); + } } /** @@ -252,15 +277,15 @@ public function mergeIndex($projectId,$core,$datasets) { * @return void * @access public */ - public function executeUrl($url) { + public function executeUrl($url,$timeout = 600) { + //write request to log file $this->log("solr request: $url",LOG_DEBUG); try { $solr = new Apache_Solr_Service(); - $response = $solr->_sendRawGet($url); - $response=serialize($response); - + $response = $solr->_sendRawGet($url,$timeout); + $response = serialize($response); //write response to log file $this->log("solr response: $response",LOG_DEBUG); } @@ -323,14 +348,15 @@ public function getPathwayCount($filter,$dataset,$level,$pathwayId,$pathwayEnzym $result = $this->search($dataset,$filter,0,0,$solrArguments); } catch(Exception $e){ - $this->set('exception',SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + //rethrow exception + throw new Exception($e); } if(!$result->facet_counts->facet_queries) { - $this->set('exception',SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); - } + //rethrow exception + throw new Exception($e); + } + $facetsQueryResults = $result->facet_counts->facet_queries; foreach($facetsQueryResults as $facetQuery =>$count) { @@ -386,8 +412,8 @@ public function getPathwayFacets($filter,$dataset,$level,$nodeId,$children,$ecId $result = $this->search($dataset,$filter,0,0,$solrArguments,true); } catch(Exception $e){ - $this->set('exception',SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + //rethrow exception + throw new Exception($e); } unset($facetQueries); diff --git a/app/controllers/libraries_controller.php b/app/controllers/libraries_controller.php index ddabdbb..e0d2085 100755 --- a/app/controllers/libraries_controller.php +++ b/app/controllers/libraries_controller.php @@ -32,7 +32,7 @@ function edit($id = null) { if (!$id && empty($this->data)) { $this->Session->setFlash("Invalid library id."); - $this->redirect("/projects/view/$projectId"); + $this->redirect("/projects/view/$projectId",null,true); } if (!empty($this->data)) { if ($this->Library->save($this->data)) { @@ -44,14 +44,14 @@ function edit($id = null) { Cache::delete($projectId.'project'); $this->Session->setFlash("Library changes have been saved."); - $this->redirect("/projects/view/$projectId"); + $this->redirect("/projects/view/$projectId",null,true); } } if (empty($this->data)) { $this->data = $this->Library->read(null, $id); if(empty($this->data)) { $this->Session->setFlash("Invalid library id."); - $this->redirect("/projects/index"); + $this->redirect("/projects/index",null,true); } } $projects = $this->Library->Project->find('list'); @@ -59,26 +59,26 @@ function edit($id = null) { } function delete($id = null) { -// $this->loadModel('Library'); -// -// if (!$id) { -// $this->flash(__('Invalid Library', true), array('action'=>'index')); -// } -// else{ -// $this->data = $this->Library->read(null, $id); -// $projectId = $this->data['Library']['project_id']; -// -// if($this->Library->delete($id)) { -// -// $this->Solr->deleteIndex($this->data['Library']['name']); -// -// //delete project view cache -// Cache::delete($projectId.'project'); -// -// $this->flash(__('Library deleted', true), array('action'=>'index')); -// $this->redirect("/projects/view/$projectId"); -// } -// } + $this->loadModel('Library'); + + if (!$id) { + $this->flash(__('Invalid Library', true), array('action'=>'index')); + } + else{ + $this->data = $this->Library->read(null, $id); + $projectId = $this->data['Library']['project_id']; + + if($this->Library->delete($id)) { + + $this->Solr->deleteIndex($this->data['Library']['name']); + + //delete project view cache + Cache::delete($projectId.'project'); + + $this->flash(__('Library deleted', true), array('action'=>'index')); + $this->redirect("/projects/view/$projectId",null,true); + } + } } //future implementation @@ -87,7 +87,7 @@ function delete($id = null) { // $this->Library->create(); // if ($this->Library->save($this->data)) { // $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); - // $this->redirect('/projects/index'); + // $this->redirect('/projects/index',null,true); // } else { // } // } diff --git a/app/controllers/populations_controller.php b/app/controllers/populations_controller.php index 13d4050..e3e5731 100644 --- a/app/controllers/populations_controller.php +++ b/app/controllers/populations_controller.php @@ -132,12 +132,19 @@ function add($projectId = 0) { $dataset = $this->data['Population']['name']; //start solr index merging process - $this->Solr->mergeIndex($projectId,$dataset,$libraries); + try { + $this->Solr->mergeIndex($projectId,$dataset,$libraries); + } + catch (Exception $e) { + $this->Population->delete($populationId); + $this->Session->setFlash(__('Solr Index Merge Exception. Population could not be generated.'.$e->getMessage(), true)); + $this->setAction('delete',$populationId); + } //delete project view cache Cache::delete($projectId.'project'); - $this->redirect("/populations/ajaxView/$populationId"); + $this->redirect("/populations/ajaxView/$populationId",null,true); } else { $this->set(compact('projectId','projects','datasets')); @@ -181,11 +188,8 @@ function edit($id = null) { Cache::delete($projectId.'project'); $this->Session->setFlash("Population changes have been saved."); - $this->redirect("/projects/view/$projectId"); + $this->redirect("/projects/view/$projectId",null,true); } - else { - - } } if (empty($this->data)) { $this->Library->recursive = 1; @@ -211,7 +215,7 @@ function delete($id = null) { if (!$id) { $this->flash(__('Invalid Population', true), array('action'=>'index')); } - else { + else { $this->data = $this->Population->read(null, $id); $populationName = $this->data['Population']['name']; $projectId = $this->data['Project']['id']; @@ -224,7 +228,7 @@ function delete($id = null) { //delete project view cache Cache::delete($projectId.'project'); - $this->redirect("/projects/view/$projectId"); + $this->redirect("/projects/view/$projectId",null,true); } } } diff --git a/app/controllers/projects_controller.php b/app/controllers/projects_controller.php index f690c19..ab3c1a8 100755 --- a/app/controllers/projects_controller.php +++ b/app/controllers/projects_controller.php @@ -66,7 +66,7 @@ function view($id = null) { if(!$id) { $this->Session->setFlash(__('Invalid Project.', true)); - $this->redirect(array('action'=>'index')); + $this->redirect(array('action'=>'index'),null,true); } else { //cache project view page @@ -101,7 +101,7 @@ function add() { $this->Project->create(); if ($this->Project->save($this->data)) { $this->Session->setFlash(__('The Project has been saved', true)); - $this->redirect(array('action'=>'index')); + $this->redirect(array('action'=>'index'),null,true); } else { $this->Session->setFlash(__('The Project could not be saved. Please, try again.', true)); } @@ -132,18 +132,18 @@ function add() { * @access public */ function edit($id = null) { - $this->loadModel('Projectmake test'); + $this->loadModel('Project'); $this->loadModel('User'); if (!$id && empty($this->data)) { $this->Session->setFlash(__('Invalid Project', true)); - $this->redirect(array('action'=>'index')); + $this->redirect(array('action'=>'index'),null,true); } if (!empty($this->data)) { if ($this->Project->save($this->data)) { $this->Session->setFlash(__('The Project has been saved',true)); - $this->redirect("/dashboard"); + $this->redirect("/dashboard",null,true); } else { $this->Session->setFlash(__('The Project could not be saved. Please, try again.', true)); } @@ -180,11 +180,11 @@ function delete($id = null) { $this->loadModel('User'); if (!$id) { $this->Session->setFlash(__('Invalid id for Project', true)); - $this->redirect(array('action'=>'index')); + $this->redirect(array('action'=>'index'),null,true); } if ($this->Project->delete($id)) { $this->Session->setFlash(__('Project deleted', true)); - $this->redirect(array('action'=>'index')); + $this->redirect(array('action'=>'index'),null,true); } } diff --git a/app/controllers/search_controller.php b/app/controllers/search_controller.php index bf293b0..5f5216d 100644 --- a/app/controllers/search_controller.php +++ b/app/controllers/search_controller.php @@ -120,7 +120,7 @@ function index($dataset='CBAYVIR',$page=1,$sessionQueryId=null) { } else { $this->Session->setFlash("Your search session has expired. Please reenter your query."); - $this->redirect(array('controller'=>'search','action' => 'index', $dataset)); + $this->redirect(array('controller'=>'search','action' => 'index', $dataset),null,true); } } @@ -372,7 +372,7 @@ public function count($dataset) { } catch(Exception $e) { $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + $this->redirect('/projects/index',null,true); } return $this->Solr->count($dataset); } @@ -436,14 +436,13 @@ public function dowloadData($dataset,$numHits,$sessionQueryId) { #get rows in batches of 10,000 and add to content string for($i=0;$i<$numHits+20000;$i+=20000) { - - + try{ $result = $this->Solr->search($dataset,$query,$i,20000,$solrArguments); } catch (Exception $e) { $this->Session->setFlash("METAREP Lucene Query Exception. Please correct your query and try again."); - $this->redirect(array('action' => 'search', $solrArguments)); + $this->redirect(array('action' => 'index'),null,true); } $rows = $result->response->docs; diff --git a/app/controllers/users_controller.php b/app/controllers/users_controller.php index b38ee2b..7d7a396 100644 --- a/app/controllers/users_controller.php +++ b/app/controllers/users_controller.php @@ -53,10 +53,10 @@ function edit($id=null) { $this->Session->setFlash('Account information has been saved.'); if($currentUsername === 'admin') { - $this->redirect('/users/index'); + $this->redirect('/users/index',null,true); } else { - $this->redirect('/dashboard'); + $this->redirect('/dashboard',null,true); } } else { @@ -82,20 +82,20 @@ function feedback() { $feedback = urldecode($feedback); $this->User->sendFeedbackConfirmation($userName,$userEmail,$feedbackType,$feedback); $this->Session->setFlash('Thank you very much for your feedback. An email confirmation has been sent to your account.'); - $this->redirect('/dashboard'); + $this->redirect('/dashboard',null,true); } function delete($id) { $this->loadModel('User'); $this->User->delete($id); $this->Session->setFlash('User was deleted.'); - $this->redirect('/users/index'); + $this->redirect('/users/index',null,true); } function logout() { $this->Authsome->logout(); $this->Session->setFlash('You are now logged out.'); - $this->redirect('/dashboard'); + $this->redirect('/dashboard',null,true); } function register() { @@ -104,14 +104,14 @@ function register() { #if no user exists redirect to dashboard if ($user) { - $this->redirect("/dashboard"); + $this->redirect("/dashboard",null,true); } else { if ($this->data) { $this->loadModel('User'); if ($this->User->save($this->data)) { $this->Session->setFlash("Thank you you very much for registering. Please check your email to activate your METAREP account."); - $this->redirect("/dashboard"); + $this->redirect("/dashboard",null,true); } else { $this->data['User']['password'] = null; @@ -131,11 +131,11 @@ function activatePassword() { $return = $this->User->activatePassword($this->data); if ($return) { $this->Session->setFlash("Your new password has been saved. Please log in."); - $this->redirect("/dashboard"); + $this->redirect("/dashboard",null,true); } else { $this->Session->setFlash("Your new password could not be saved. Please check your email and click the password reset link again"); - $this->redirect("/dashboard"); + $this->redirect("/dashboard",null,true); } } } @@ -150,10 +150,11 @@ function activatePassword() { function changePassword() { $this->loadModel('User'); + if ($this->data) { if ($this->User->changePassword($this->data)) { $this->Session->setFlash("Your password has been changed."); - $this->redirect("/dashboard"); + $this->redirect("/dashboard",null,true); } } else { @@ -181,11 +182,11 @@ function editProjectUsers($projectId=null) { if($this->Project->save($this->data)) { $this->Session->setFlash("Your user project permissions have been saved."); - $this->redirect("/dashboard"); + $this->redirect("/dashboard",null,true); } else { $this->Session->setFlash("Your new project permissions could not be saved."); - $this->redirect("/dashboard"); + $this->redirect("/dashboard",null,true); } } else { @@ -225,7 +226,7 @@ function guestLogin(){ if (!$user) { $this->Session->setFlash('Unknown user or wrong password'); - $this->redirect('/dashboard'); + $this->redirect('/dashboard',null,true); } $this->Session->write("User",$user); @@ -233,7 +234,7 @@ function guestLogin(){ $this->Session->write("UserGroup.id",$user["UserGroup"]["id"]); $this->Session->write("UserGroup.name",$user["UserGroup"]["name"]); - $this->redirect('/projects/index'); + $this->redirect('/projects/index',null,true); } @@ -244,12 +245,12 @@ function login() { #on success if ($this->User->activateAccount($_GET)) { $this->Session->setFlash("Thank you. Your METAREP account has been activated. Please login."); - $this->redirect("/dashboard"); + $this->redirect("/dashboard",null,true); } #on failure else { $this->Session->setFlash("There was a problem with your account information. Please contact ".METAREP_SUPPORT_EMAIL); - $this->redirect("/dashboard"); + $this->redirect("/dashboard",null,true); $this->flash("Sorry. There were problems in your account activation.",Configure::read('httpRootUrl').'/users/login'); } } @@ -265,7 +266,7 @@ function login() { //if authentification failed if (!$user) { $this->Session->setFlash('Unknown user or wrong password'); - $this->redirect('/dashboard'); + $this->redirect('/dashboard',null,true); } $remember = (!empty($this->data['User']['remember'])); @@ -279,7 +280,7 @@ function login() { $this->Session->write("UserGroup.id",$user["UserGroup"]["id"]); $this->Session->write("UserGroup.name",$user["UserGroup"]["name"]); - $this->redirect('/dashboard'); + $this->redirect('/dashboard',null,true); } } @@ -289,10 +290,10 @@ function forgotPassword() { $email = $this->data["User"]["email"]; if ($this->User->forgotPassword($email)) { $this->Session->setFlash('Please check your email.'); - $this->redirect('/dashboard'); + $this->redirect('/dashboard',null,true); } else { $this->Session->setFlash('Your email is invalid or not registered.'); - $this->redirect('/dashboard'); + $this->redirect('/dashboard',null,true); } } } diff --git a/app/controllers/view_controller.php b/app/controllers/view_controller.php index 1dce68d..986fb78 100644 --- a/app/controllers/view_controller.php +++ b/app/controllers/view_controller.php @@ -135,7 +135,7 @@ function facet($dataset='CBAYVIR',$sessionId,$facetField,$prefix ='',$limit=20) } catch(Exception $e) { $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + $this->redirect('/projects/index',null,true); } $numHits= (int) $result->response->numFound; @@ -195,7 +195,7 @@ function pathways($dataset,$sessionId,$facetField) { } catch(Exception $e) { $this->Session->setFlash(SOLR_CONNECT_EXCEPTION); - $this->redirect('/projects/index'); + $this->redirect('/projects/index',null,true); } $numHits= (int) $result->response->numFound; diff --git a/app/models/library.php b/app/models/library.php index bfa32a6..67e43ce 100755 --- a/app/models/library.php +++ b/app/models/library.php @@ -59,13 +59,19 @@ class Library extends AppModel { ) ), ); - + + public function getProjectIdById($id) { + $this->contain('Project.id'); + $library = $this->find('first', array('fields'=>array('Library.id'),'conditions' => array('Library.name' => $id))); + return $library['Project']['id']; + } + public function getProjectName($dataset) { - $this->contain('Project'); + $this->contain('Project.name'); $library = $this->find('first', array('conditions' => array('Library.name' => $dataset))); return $library['Project']['name']; } - + public function getNameById($id) { $library = $this>findById($id); return $library['Library']['name']; diff --git a/app/models/population.php b/app/models/population.php index 78e1f61..0074527 100644 --- a/app/models/population.php +++ b/app/models/population.php @@ -38,9 +38,15 @@ class Population extends AppModel { ), ); + public function getProjectIdById($id) { + $this->contain('Project.id'); + $population = $this->find('first', array('fields'=>array('Population.id'),'conditions' => array('Population.id' => $id))); + return $population['Project']['id']; + } + public function getProjectName($dataset) { $this->contain('Project.name'); - $population = $this->find('first', array('conditions' => array('Population.name' => $dataset))); + $population = $this->find('first', array('fields'=>array('Population.id'),'conditions' => array('Population.name' => $dataset))); return $population['Project']['name']; } diff --git a/app/views/browse/apis_taxonomy.ctp b/app/views/browse/apis_taxonomy.ctp index a86b274..57b9ffb 100644 --- a/app/views/browse/apis_taxonomy.ctp +++ b/app/views/browse/apis_taxonomy.ctp @@ -68,7 +68,7 @@ else { } else { $treeData = $session->read($mode.'.tree'); - echo $tree->taxonomy($dataset,$treeData,$taxon,'blastTaxonomy'); + echo $tree->taxonomy($dataset,$treeData,$taxon,'apisTaxonomy'); } ?> @@ -79,7 +79,7 @@ else {
Taxonomic Distribution - div('browse-download-classification', $html->link($html->image("download-medium.png"), array('controller'=> 'browse','action'=>'downloadChildCounts',$dataset,$taxon,$mode,$numHits,urlencode($filter)),array('escape' => false)));?> + div('browse-download-classification', $html->link($html->image("download-medium.png"), array('controller'=> 'browse','action'=>'downloadChildCounts',$dataset,$taxon,$mode,array_sum($childCounts),urlencode($filter)),array('escape' => false)));?>

pieChart('',$childCounts,$numHits,"700x300"); diff --git a/app/views/browse/blast_taxonomy.ctp b/app/views/browse/blast_taxonomy.ctp index 19a0996..1554fc5 100644 --- a/app/views/browse/blast_taxonomy.ctp +++ b/app/views/browse/blast_taxonomy.ctp @@ -87,7 +87,7 @@ else {
Taxonomic Distribution - div('browse-download-classification', $html->link($html->image("download-medium.png"), array('controller'=> 'browse','action'=>'downloadChildCounts',$dataset,$taxon,$mode,$numHits,urlencode($filter)),array('escape' => false)));?> + div('browse-download-classification', $html->link($html->image("download-medium.png"), array('controller'=> 'browse','action'=>'downloadChildCounts',$dataset,$taxon,$mode,array_sum($childCounts),urlencode($filter)),array('escape' => false)));?>

Enzyme Classification - div('browse-download-classification', $html->link($html->image("download-medium.png"), array('controller'=> 'browse','action'=>'downloadChildCounts',$dataset,$node,$mode,$numHits,urlencode($filter)),array('escape' => false)));?> + div('browse-download-classification', $html->link($html->image("download-medium.png"), array('controller'=> 'browse','action'=>'downloadChildCounts',$dataset,$node,$mode,array_sum($childCounts),urlencode($filter)),array('escape' => false)));?>

pieChart('',$childCounts,$numHits,"700x300"); diff --git a/app/views/browse/gene_ontology.ctp b/app/views/browse/gene_ontology.ctp index b086a0b..8d2355b 100644 --- a/app/views/browse/gene_ontology.ctp +++ b/app/views/browse/gene_ontology.ctp @@ -78,7 +78,7 @@ else {
Gene Ontology Distribution - div('browse-download-classification', $html->link($html->image("download-medium.png"), array('controller'=> 'browse','action'=>'downloadChildCounts',$dataset,$node,$mode,$numHits,urlencode($filter)),array('escape' => false)));?> + div('browse-download-classification', $html->link($html->image("download-medium.png"), array('controller'=> 'browse','action'=>'downloadChildCounts',$dataset,$node,$mode,array_sum($childCounts),urlencode($filter)),array('escape' => false)));?>

Pathway Classification - div('browse-download-classification', $html->link($html->image("download-medium.png"), array('controller'=> 'browse','action'=>'downloadChildCounts',$dataset,$node,$mode,$numHits,urlencode($filter)),array('escape' => false)));?> + div('browse-download-classification', $html->link($html->image("download-medium.png"), array('controller'=> 'browse','action'=>'downloadChildCounts',$dataset,$node,$mode,array_sum($childCounts),urlencode($filter)),array('escape' => false)));?>

@@ -92,7 +92,8 @@ else { echo $facet->enzymeTable($childCounts,$numHits); } else { - if($level != 'enzyme') { + if($level != 'enzyme') { + echo $facet->pieChart('',$childCounts,$numHits,"700x300"); } } diff --git a/app/views/dashboard/index.ctp b/app/views/dashboard/index.ctp index a5dfea6..d003065 100755 --- a/app/views/dashboard/index.ctp +++ b/app/views/dashboard/index.ctp @@ -63,7 +63,7 @@
Download Publication
- div('comparator-download', $html->link($html->image("download-medium.png",array("title" => 'Publication')), 'http://bioinformatics.oxfordjournals.org/content/early/2010/08/26/bioinformatics.btq455.full.pdf+html',array('escape' => false,'target' => '_blank')));?> + div('comparator-download', $html->link($html->image("download-medium.png",array("title" => 'Publication')), 'http://bioinformatics.oxfordjournals.org/content/26/20/2631.full.pdf+html',array('escape' => false,'target' => '_blank')));?> @@ -138,9 +138,30 @@ Powered By link($html->image("solr.jpg",array("title" => 'Solr','class'=>'img-alignment')), 'http://lucene.apache.org/solr',array('escape' => false,'target' => '_blank'));?> link($html->image("cake.png",array("title" => 'CakePHP','class'=>'img-alignment')), 'http://cakephp.org/',array('escape' => false,'target' => '_blank'));?> -
+ +
+
+ +
+ + +
+
+ Share + + + + +| +More +
+
+ + +
+ + diff --git a/app/views/helpers/tree.php b/app/views/helpers/tree.php index 1201c16..67e0369 100644 --- a/app/views/helpers/tree.php +++ b/app/views/helpers/tree.php @@ -79,7 +79,7 @@ private function taxonNode($dataset,&$html,$level,$selectedTaxon,$mode) { $class ="class=\"last\""; } - $html .="
  • ".$link." (".$taxonEntry['rank'].") [".number_format($taxonEntry['count'])." peptides]"; + $html .="
  • ".$link." (".$taxonEntry['rank'].") [".number_format($taxonEntry['count'])." hits]"; //if has children if($taxonEntry['children'] != null){ @@ -120,7 +120,7 @@ private function pathwayNode($dataset,&$html,$level,$selectedEc) { $class ="class=\"last\""; } - $html .="
  • ".$link." (".$taxonEntry['level'].") [".number_format($taxonEntry['count'])." peptides]"; + $html .="
  • ".$link." (".$taxonEntry['level'].") [".number_format($taxonEntry['count'])." hits]"; //if has children if($taxonEntry['children'] !=null){ @@ -160,7 +160,7 @@ private function ecNode($dataset,&$html,$level,$selectedEc) { $class ="class=\"last\""; } - $html .="
  • ".$link." (".$taxonEntry['rank'].") [".number_format($taxonEntry['count'])." peptides]"; + $html .="
  • ".$link." (".$taxonEntry['rank'].") [".number_format($taxonEntry['count'])." hits]"; //if has children if($taxonEntry['children'] !=null){ @@ -195,7 +195,7 @@ private function goNode($dataset,&$html,$level,$selectedGo) { if($counter==count($level)) { $class ="class=\"last\""; } - $html .="
  • ".$link." [".number_format($taxonEntry['count'])." peptides]"; + $html .="
  • ".$link." [".number_format($taxonEntry['count'])." hits]"; //if has children if($taxonEntry['children'] !=null){ diff --git a/app/views/view/result_panel.ctp b/app/views/view/result_panel.ctp index 93e6e56..addba4a 100644 --- a/app/views/view/result_panel.ctp +++ b/app/views/view/result_panel.ctp @@ -26,9 +26,12 @@ read($sessionId); - $facetCounts= $viewResults['facetCounts']; - $filters = $viewResults['filters']; + $facetCounts= $viewResults['facetCounts']; $numHits = $viewResults['numHits']; + + if(isset($viewResults['filters'])) { + $filters = $viewResults['filters']; + } if(isset($viewResults['limit'])) { $limit = $viewResults['limit']; diff --git a/app/webroot/css/dashboard.css b/app/webroot/css/dashboard.css index f9de2bf..c5ed870 100644 --- a/app/webroot/css/dashboard.css +++ b/app/webroot/css/dashboard.css @@ -32,7 +32,7 @@ CSS for dash board page position: absolute; top: 145px; left:650px; - width:300px; + width:270px; height:260px; font-size: 1em; } @@ -57,9 +57,9 @@ CSS for dash board page .dash-board-news-panel { position: absolute; - top: 390px; + top: 355px; left:650px; - width:300px; + width:270px; height:60px; font-size: 1em; scroll: auto; @@ -67,16 +67,27 @@ CSS for dash board page .dash-board-powered-by-panel { position: absolute; - top: 610px; + top: 585px; left:650px; - width:300px; + width:270px; + height:100px; + font-size: 1em; + scroll: auto; + +} + +.dash-board-share-panel { + position: absolute; + top: 675px; + left:650px; + width:270px; height:100px; font-size: 1em; scroll: auto; } .img-alignment { - float:left; margin: 0 0 0px 40px; + float:left; margin: 0 0 0px 5px; width: auto; height: 50px ; } @@ -84,7 +95,7 @@ CSS for dash board page .input { margin:0px; padding:0px; - width: 250px; + width: 240px; } form { @@ -94,7 +105,12 @@ form { form div.submit { margin:0px; - padding:5 0 10 0px; + padding:20 0 10 0px; + padding-right:34px; + padding-left:0px; + padding-top:15px; + float:left; + font-weight:bold; } input[type=submit] {