Skip to content

Commit

Permalink
fixed bugs; updated pathway statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Goll committed Oct 15, 2010
1 parent 3ebb372 commit 75ec8ba
Show file tree
Hide file tree
Showing 24 changed files with 288 additions and 171 deletions.
2 changes: 1 addition & 1 deletion app/config/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 24 additions & 7 deletions app/controllers/app_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down Expand Up @@ -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);

}
}
Expand Down
46 changes: 30 additions & 16 deletions app/controllers/browse_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
// }
// }

Expand Down Expand Up @@ -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);
}


Expand All @@ -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);
// }
// }

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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');
Expand Down
38 changes: 20 additions & 18 deletions app/controllers/compare_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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]);
Expand All @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/components/matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/components/r.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ function writeWilcoxonMatrix($selectedDatasets,&$counts) {
$this->Session->write('selectedDatasets',$populations);

$counts = $newCounts;

return;
}
}
Expand Down
Loading

0 comments on commit 75ec8ba

Please sign in to comment.