Permalink
Browse files

check in of updated web pages and new Util module

  • Loading branch information...
1 parent 80e4a4e commit 34b4f888345b658a23eb5983e12ea8fc870257cf @jm23 jm23 committed Jul 4, 2012
View
174 modules/VertRes/QCGrind/ViewUtil.pm 100755 → 100644
@@ -1,17 +1,25 @@
package VertRes::QCGrind::ViewUtil;
use base qw(VertRes::QCGrind::Util);
-#Extension of VertRes::QCGrind::Util for other tracking database view webpages (map_view, pending_view, sample_id_mapping)
-
+# QC Grind common variables and modules
use strict;
sub new {
my $self={};
$self->{SCRIPTS} = {
- MAP_DB_VIEW => 'map_database.pl',
- MAP_PROJ_VIEW => 'map_project.pl',
+ MAP_VIEW => 'map_view.pl',
+ MAP_PROJECTS_VIEW => 'map_projects_view.pl',
+ MAP_LANES_VIEW => 'map_lanes_view.pl',
+ PENDING_VIEW => 'pending_view.pl',
+ PENDING_REQ_VIEW => 'pending_requests_view.pl',
+ SAMPLE_MAPPING => 'sample_mapping.pl',
+ SAMPMAP_PROJECTS_VIEW => 'sample_mapping_projects_view.pl',
+ SAMPMAP_LANES_VIEW => 'sample_mapping_lanes_view.pl',
+ QCGRIND_LANE => '../qc_grind/lane_view.pl',
+ QCGRIND_SAMPLES => '../qc_grind/samples_view.pl',
};
+
$self->{CSS} = <<CSS ;
.centerFieldset {
@@ -31,6 +39,29 @@ text-align:left;
margin-right:auto;
}
+.coolfieldset, .coolfieldset.expanded{
+ border:1px solid #aaa;
+}
+
+.coolfieldset.collapsed{
+ border:0;
+ border-top:1px solid #aaa;
+}
+
+.coolfieldset legend{
+ padding-left:13px;
+ font-weight:bold;
+ cursor:pointer;
+}
+
+.coolfieldset legend, .coolfieldset.expanded legend{
+ background: transparent url(http://www.sanger.ac.uk/modelorgs/mousegenomes/images/expanded.gif) no-repeat center left;
+}
+
+.coolfieldset.collapsed legend{
+ background: transparent url(http://www.sanger.ac.uk/modelorgs/mousegenomes/images/collapsed.gif) no-repeat center left;
+}
+
table.summary {
border-collapse: collapse;
font: 0.9em Verdana, Arial, Helvetica, sans-serif;
@@ -68,16 +99,16 @@ table.summary tr.total th, table.summary tr.total td {
vertical-align:middle;
}
-tr:nth-child(2n+1) {
- background-color: #ecf1ef;
-}
-
input.btn {
font: bold 150% 'trebuchet ms',helvetica,sans-serif;
border:1px solid;
border-color: #707070 #000 #000 #707070;
}
+tr:nth-child(2n+1) {
+ background-color: #ecf1ef;
+}
+
input.btnhov {
cursor:pointer;
border-color: #c63 #930 #930 #c63;
@@ -133,19 +164,20 @@ CSS
return $self;
}
-sub displayDatabasesPage
-{
- my ($self, $title, $script) = @_;
- print qq[ <h2 align="center" style="font: normal 900 1.5em arial">$title</h2> ];
-
- my @main_dbs = qw (vrtrack_human_wgs vrtrack_human_wes vrtrack_mouse_wgs vrtrack_mouse_wes);
+
+sub displayDatabasesPage {
+ my ($self,$title,$cgi,$script,$alldb) = @_;
+
+ print qq[ <h2 align="center" style="font: normal 900 1.5em arial">$title</h2> ];
+
+ my @main_dbs = qw (vrtrack_human_wgs vrtrack_human_wes vrtrack_mouse_wgs vrtrack_mouse_wes);
print qq[
- <div class="centerFieldset">
- <fieldset style="width: 500px">
- <legend>Main Databases</legend>
+ <div class="centerFieldset">
+ <fieldset style="width: 500px">
+ <legend>Main Databases</legend>
];
foreach( @main_dbs ) {
- print $cgi->p("<a href='$script?db=$_'> $_ </a>");
+ print $cgi->p("<a href='$script?db=$_'> $_ </a>");
}
print qq[ </fieldset> </div> ];
@@ -159,24 +191,50 @@ sub displayDatabasesPage
print $cgi->p("<a href='$script?db=$_'> $_ </a>");
}
print qq[ </fieldset> </div> ];
-
- my %done;
- push (@main_dbs, @uk10k_dbs);
- foreach (@main_dbs) {
- $done{$_}++;
+ if ($alldb) {
+ my %done;
+ push (@main_dbs, @uk10k_dbs);
+ foreach (@main_dbs) {
+ $done{$_}++;
+ }
+ my @dbs = $self->fetchTrackingDatabases();
+ print qq[
+ <div class="centerFieldset">
+ <fieldset id="fieldset1" class="coolfieldset" style="width: 500px">
+ <legend>Other Databases (click to show/hide)</legend> <div>
+ ];
+ foreach( @dbs ) {
+ next if $done{$_};
+ print $cgi->p("<a href='$script?db=$_'> $_ </a>");
+ }
+ print qq[ </div> </fieldset> </div>
+ <script>
+ \$('#fieldset1').coolfieldset({collapsed:true});
+ </script>];
}
-
- my @dbs = fetchTrackingDatabases();
+}
+
+sub displayDatabasePage
+{
+ my ($self,$title,$cgi,$vrtrack,$db,$init_script,$lanes_script) = @_;
+
print qq[
+ <h2 align="center" style="font: normal 900 1.5em arial"><a href="$init_script">$title</a></h2>
+ <h3 align="center" style="font: normal 700 1.5em arial">Database : $db</h3>
<div class="centerFieldset">
<fieldset style="width: 500px">
- <legend>Other Databases</legend>
+ <legend>Select study to View</legend>
];
- foreach( @dbs ) {
- next if $done{$_};
- print $cgi->p("<a href='$script?db=$_'> $_ </a>");
+ my @projects = sort {$a->name cmp $b->name} @{$vrtrack->projects()};
+ foreach my $project (@projects)
+ {
+ my $id = $project->id();
+ print qq[<p><a href="$lanes_script?db=$db&amp;proj_id=$id">].$project->name().qq[</a></p>];
}
- print qq[ </fieldset> </div> ];
+ print qq[
+ </fieldset>
+ </div>
+ ];
}
sub fetchTrackingDatabases
@@ -198,5 +256,61 @@ sub fetchTrackingDatabases
return @dbs;
}
+sub getDatabaseID
+{
+ my ($self, $db) = @_;
+ my $db_id;
+ my $web_db = 'vrtrack_web_index';
+ my $vrtrack = $self->connectToDatabase($web_db);
+ $self->displayError( "Failed to connect to web database: $web_db" ) unless defined( $vrtrack );
+ my $sql = qq[SELECT db_id FROM tracking_database where db_name = ?];
+ my $sth = $vrtrack->{_dbh}->prepare($sql);
+ if ($sth->execute($db)) {
+ my ($id);
+ $sth->bind_col(1, \$id);
+ while ($sth->fetch) {
+ $db_id = $id;
+ }
+ }
+ return $db_id;
+}
+
+sub getSampleMappings
+{
+ my ($self, $db_id, $pid) = @_;
+ my %mappings;
+ my $web_db = 'vrtrack_web_index';
+ my $vrtrack = $self->connectToDatabase($web_db);
+ $self->displayError( "Failed to connect to web database: $web_db" ) unless defined( $vrtrack );
+ my $sql = qq[SELECT supplier_name, accession_number, sanger_sample_name FROM sample_id_mapping where db_id = ? and project_id = ?];
+ my $sth = $vrtrack->{_dbh}->prepare($sql);
+ if ($sth->execute($db_id, $pid)) {
+ my ($supp, $acc, $sang);
+ $sth->bind_columns(\($supp, $acc, $sang));
+ while ($sth->fetch) {
+ push @{ $mappings{$sang} }, ($supp, $acc);
+ }
+ }
+ return %mappings;
+}
+
+sub fetchProjectName
+{
+ my ($self, $db_id, $pid) = @_;
+ my $pname;
+ my $web_db = 'vrtrack_web_index';
+ my $vrtrack = $self->connectToDatabase($web_db);
+ $self->displayError( "Failed to connect to web database: $web_db" ) unless defined( $vrtrack );
+ my $sql = qq[SELECT project_name FROM db_projects where project_id = ? and db_id =?];
+ my $sth = $vrtrack->{_dbh}->prepare($sql);
+ if ($sth->execute($pid, $db_id)) {
+ my ($name);
+ $sth->bind_col(1, \$name);
+ while ($sth->fetch) {
+ $pname = $name;
+ }
+ }
+ return $pname;
+}
1;
View
0 web_code/lookseq/lookseq.html 100644 → 100755
No changes.
View
1 web_code/lookseq/lookseq.js 100644 → 100755
@@ -1046,6 +1046,7 @@ function initialize_display () {
document.getElementById('display_annotation').checked = b['annotation'] ? true : false ;
document.getElementById('display_gc').checked = b['gc'] ? true : false ;
document.getElementById('display_coverage').checked = b['coverage'] ? true : false ;
+ document.getElementById('show_arrows').checked = b['orientation'] ? true : false ;
if ( indel_zoom != 'auto' ) document.getElementById('indel_zoom').value = indel_zoom ;
}
@@ -0,0 +1,149 @@
+#!/usr/local/bin/perl -T
+
+BEGIN {
+ $ENV{VRTRACK_HOST} = 'mcs4a';
+ $ENV{VRTRACK_PORT} = 3306;
+ $ENV{VRTRACK_RO_USER} = 'vreseq_ro';
+ $ENV{VRTRACK_RW_USER} = 'vreseq_rw';
+ $ENV{VRTRACK_PASSWORD} = 't3aml3ss';
+};
+
+use strict;
+use warnings;
+use URI;
+
+use SangerPaths qw(core team145);
+use SangerWeb;
+use VRTrack::VRTrack;
+use VRTrack::Project;
+use VertRes::Utils::VRTrackFactory;
+use VertRes::QCGrind::ViewUtil;
+
+my $utl = VertRes::QCGrind::ViewUtil->new();
+
+my $title = 'Map View';
+
+my $sw = SangerWeb->new({
+ 'title' => $title,
+ 'banner' => q(),
+ 'inifile' => SangerWeb->document_root() . q(/Info/header.ini),
+ 'jsfile' => ['http://jsdev.sanger.ac.uk/prototype.js','http://jsdev.sanger.ac.uk/toggle.js','ttp://jsdev.sanger.ac.uk/scriptaculous/scriptaculous.js','http://jsdev.sanger.ac.uk/sidebar.js','http://jsdev.sanger.ac.uk/urchin.js','http://jsdev.sanger.ac.uk/zebra.js','http://js.sanger.ac.uk/sorttable_v2.js',],
+ 'style' => $utl->{CSS},
+});
+
+my $cgi = $sw->cgi();
+
+my $db = $cgi->param('db');
+my $pid = $cgi->param('proj_id');
+
+unless ($db) {
+ print $sw->header();
+ $utl->displayError( "No database ID",$sw );
+}
+my $vrtrack = $utl->connectToDatabase($db);
+
+$utl->displayError( "No Project ID",$sw ) unless $pid;
+
+print $sw->header();
+displayProjectLanesPage($cgi,$vrtrack,$db,$pid);
+print $sw->footer();
+exit;
+
+#######
+
+sub displayProjectLanesPage
+{
+ my ($cgi, $vrtrack, $database, $projectID) = @_;
+
+ my $init_script = $utl->{SCRIPTS}{MAP_VIEW};
+ my $qcgrind_script = $utl->{SCRIPTS}{QCGRIND_LANE};
+ my $project = VRTrack::Project->new( $vrtrack, $projectID );
+ displayError( "Cant get project: $projectID" ) unless $project;
+
+ my $samples = $project->samples();
+ displayError( "Cant get samples for project: $projectID" ) unless $samples;
+
+ my $pname = $project->name;
+ print qq[
+ <h2 align="center" style="font: normal 900 1.5em arial"><a href="$init_script">Map View</a></h2>
+ <h3 align="center" style="font: normal 700 1.5em arial">Project: $pname</h3>
+ ];
+
+ print qq[
+ <div class="centerFieldset">
+ <fieldset >
+ <legend>Lane data</legend>
+ <table width="60%">
+ <tr>
+ <th>Library</th>
+ <th>Improved</th>
+ <th>Called</th>
+ <th>Name</th>
+ ];
+
+ my @lanes;
+ my %mappers;
+ foreach( sort { $a->ssid() <=> $b->ssid() } @$samples)
+ {
+ my @libraries = sort {$a->name cmp $b->name} @{$_->libraries()};
+ foreach( @libraries )
+ {
+ my $library = $_;
+ my @lanes_ = @{ $library->lanes() };
+ foreach my $lane ( @lanes_ )
+ {
+ push( @lanes, $lane );
+ my @mapstats = @{ $lane->mappings() };
+ foreach my $mapstat (@mapstats)
+ {
+ if( $mapstat->mapper() )
+ {
+ my $mapper = $mapstat->mapper();
+ $mappers{ $mapper->name().qq[ v].$mapper->version() } = 1;
+ }
+ }
+ }
+ }
+ }
+
+ foreach my $mname ( sort( keys( %mappers ) ) )
+ {
+ print qq[<th>$mname</th>];
+ }
+ print qq[</tr>];
+
+ foreach my $lane ( @lanes )
+ {
+ print qq[<tr>];
+ my $id = $lane->id();
+ my $library = VRTrack::Library->new($vrtrack, $lane->library_id());
+ my $libName = $library->name();
+ my $improved = $lane->is_processed('improved') ? 'yes' : 'no';
+ my $called = $lane->is_processed('snp_called') ? 'yes' : 'no';
+ print qq[<td>$libName</td><td>$improved</td><td>$called</td><td><a href="$qcgrind_script?lane_id=$id&db=$database">].$lane->name().qq[</a></td>];
+ my @mappings = @{ $lane->mappings() };
+ my %lane_mappers;
+ foreach my $mapstat ( @mappings )
+ {
+ if( $mapstat->mapper() && $mapstat->raw_bases() && $mapstat->raw_bases() > 0 )
+ {
+ my $mapper = $mapstat->mapper();
+ $lane_mappers{ $mapper->name().qq[ v].$mapper->version() } = 1;
+ }
+ }
+ foreach my $mapper ( sort( keys( %mappers ) ) )
+ {
+ if( $lane_mappers{ $mapper } )
+ {
+ print qq[<td>yes</td>];
+ }
+ else{print qq[<td>no</td>];}
+ }
+ print qq[</tr>];
+ }
+ print qq[
+ </table>
+ </fieldset>
+ </div>
+ ];
+}
Oops, something went wrong.

0 comments on commit 34b4f88

Please sign in to comment.