Skip to content

Commit

Permalink
Merge branch 'peter' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterFCKeen committed Oct 22, 2015
2 parents 1981277 + 93952e2 commit c8b04f8
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 40 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{{$NEXT}}

0.345 2015-10-16 09:38:21 Europe/London

0.344 2015-10-13 15:56:23 Europe/London

Added view and create links from project/experiment view to redmine
Expand Down
1 change: 0 additions & 1 deletion lib/LIMS2/Model/Plugin/ProcessTree.pm
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ sub get_design_data_for_well_id_list {
);

my $result_hash;

foreach my $result ( @{$sql_result} ) {
$result_hash->{$result->[2]} = {
'design_well_id' => $result->[0],
Expand Down
39 changes: 30 additions & 9 deletions lib/LIMS2/Model/Util/MutationSignatures.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use Hash::MoreUtils qw( slice_def );
use Data::Dumper;

sub get_mutation_signatures_barcode_data{
my ($model) = @_;
my ($model, $species) = @_;

my @processes = $model->schema->resultset('Process')->search(
{
Expand All @@ -32,18 +32,39 @@ sub get_mutation_signatures_barcode_data{

my @parent_well_ids;
my @all_data;
foreach my $process (@processes){
DEBUG "Generating information for process ".$process->id;
my @wells;

foreach my $process (@processes){
DEBUG "Generating information for process ".$process->id;
my ($parent_well) = $process->input_wells;
push @parent_well_ids, $parent_well->id;
my ($child_well) = $process->output_wells;
my $well = {
parent => $parent_well,
child => $child_well,
oxygen_condition => $process->get_parameter_value('oxygen_condition'),
number_of_doublings => $process->get_parameter_value('doublings')
};
push @wells, $well;
}

my $design_data = $model->get_design_data_for_well_id_list(\@parent_well_ids);

foreach my $well (@wells){
my ($parent_well) = $well->{parent};
my ($child_well) = $well->{child};

my $state = $parent_well->well_barcode->barcode_state->id;
my $well_id = $parent_well->{_column_data}->{id};
my $symbol = $model->retrieve_gene( { species => $species, search_term => $design_data->{$well_id}->{gene_id} } )->{gene_symbol};

my $data = {
parent_well_id => $parent_well->id,
parent_well_id => $well_id,
gene_id => $design_data->{$well_id}->{gene_id},
gene_symbol => $symbol,
parent_barcode => $parent_well->well_barcode->barcode,
state => $state,
oxygen_condition => $process->get_parameter_value('oxygen_condition'),
state => $state,
oxygen_condition => $well->{oxygen_condition},
};

# There should always be a doubling start event
Expand All @@ -53,7 +74,7 @@ sub get_mutation_signatures_barcode_data{
}

if($child_well){
$data->{number_of_doublings} = $process->get_parameter_value('doublings');
$data->{number_of_doublings} = $well->{number_of_doublings};
$data->{child_barcode} = ( $child_well->well_barcode ? $child_well->well_barcode->barcode : undef );
$data->{child_plate_name} = $child_well->plate->name;
$data->{child_well_name} = $child_well->name;
Expand All @@ -63,8 +84,8 @@ sub get_mutation_signatures_barcode_data{

push @all_data, $data;
}

return \@all_data;
}

1;
1;
4 changes: 2 additions & 2 deletions lib/LIMS2/WebApp/Controller/User/Barcodes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ sub mutation_signatures_barcodes : Path( '/user/mutation_signatures_barcodes' )
my ($self, $c) = @_;

try{
my $ms_barcode_data = get_mutation_signatures_barcode_data($c->model('Golgi'));
my $ms_barcode_data = get_mutation_signatures_barcode_data($c->model('Golgi'),$c->session->{selected_species});
my $barcodes_by_state = {};
foreach my $barcode (@$ms_barcode_data){
my $state = $barcode->{state};
Expand Down Expand Up @@ -1221,4 +1221,4 @@ sub _pick_list_display_data{
return \@data;
}

1;
1;
1 change: 0 additions & 1 deletion lib/LIMS2/WebApp/Controller/User/Experiments.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use Hash::MoreUtils qw( slice_def slice_exists);
use namespace::autoclean;
use Try::Tiny;
use List::MoreUtils qw( uniq );
use Data::Dumper;

BEGIN {extends 'Catalyst::Controller'; }

Expand Down
165 changes: 138 additions & 27 deletions root/site/user/barcodes/mutation_signatures_barcodes.tt
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,143 @@

<h1>Barcodes used for Mutation Signatures Doubling</h1>

<table class="table table-striped">
<tr>
<th>Parent Barcode</th>
<th>Start Date</th>
<th>Oxygen Condition</th>
<th>Doublings</th>
<th>Child Barcode</th>
<th>Child Plate Name</th>
<th>Child Well Name</th>
<th>Child Well Accepted?</th>
</tr>
<style type="text/css">
.popover {
max-width: 1100px;
width: auto;
}
.alignment {
font-family: Monaco,Menlo,Consolas,"Courier New",monospace;
font-size: 11px;
display: block;
font-weight: bold
}

.seq {
font-family:Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace;
font-size:15px;
}
#frozen_back span{
background-color:yellow;
}
#doubling_in_progress span{
background-color:yellow;
}
#discarded span{
background-color:yellow;
}
highlight {
font-weight: bold;
color: #FF0000;
}
</style>


<input type="text" class="span3" id="query" placeholder="Find in page" autocomplete="on" />
<button class="btn" onclick=searchThroughAccordion();>Find</button>

<div class="accordion" id="mutation_accordion">
[% FOREACH state IN ['frozen_back', 'doubling_in_progress', 'discarded'] %]
<tr>
<th colspan="8">Barcodes with state [% state %]:</th>
</tr>
[% FOREACH bc IN data.$state %]
<tr>
<td><a href="[% c.uri_for('/user/scan_barcode',{ barcode => bc.parent_barcode }) %]">[% bc.parent_barcode %]</a></td>
<td>[% bc.doubling_start %]</td>
<td>[% bc.oxygen_condition %]</td>
<td>[% bc.number_of_doublings %]</td>
<td><a href="[% c.uri_for('/user/scan_barcode',{ barcode => bc.child_barcode }) %]">[% bc.child_barcode %]</a></td>
<td>[% bc.child_plate_name %]</td>
<td>[% bc.child_well_name %]</td>
<td>[% bc.child_well_accepted_str %]</td>
</tr>
[% END %]
<p id="[% state %]_id"></p>
<div class="accordion-group">
<div class="accordion-heading">
<h4>
<a class="accordion-toggle" data-toggle="collapse" data-parent="#mutation_accordion" href=#[% state %] >Barcodes with state [% state %]:</a>
</h4>
</div>
<div id=[% state %] class="accordion-body collapse">
<div class="accordion-inner">
<table class="table table-striped">
<thead>
<tr>
<th>Parent Barcode</th>
<th>Gene ID</th>
<th>Gene Symbol</th>
<th>Start Date</th>
<th>Oxygen Condition</th>
<th>Doublings</th>
<th>Child Barcode</th>
<th>Child Plate Name</th>
<th>Child Well Name</th>
<th>Child Well Accepted?</th>
</tr>
</thead>
<tbody>
[% FOREACH bc IN data.$state %]
<tr>
<td><a href="[% c.uri_for('/user/scan_barcode',{ barcode => bc.parent_barcode }) %]">[% bc.parent_barcode %]</a></td>
<td>[% bc.gene_id %]</td>
<td>[% bc.gene_symbol %]</td>
<td>[% bc.doubling_start %]</td>
<td>[% bc.oxygen_condition %]</td>
<td>[% bc.number_of_doublings %]</td>
<td><a href="[% c.uri_for('/user/scan_barcode',{ barcode => bc.child_barcode }) %]">[% bc.child_barcode %]</a></td>
<td>[% bc.child_plate_name %]</td>
<td>[% bc.child_well_name %]</td>
<td>[% bc.child_well_accepted_str %]</td>
</tr>
[% END %]
</tbody>
</table>
</div>
</div>
</div>
[% END %]
</table>
</div>
<script type="text/javascript">

$(function() {

$('.accordion').on('show', function (e) {
$(e.target).prev('.accordion-heading').find('.accordion-toggle').addClass('active');
});

$('.accordion').on('hide', function (e) {
$(this).find('.accordion-toggle').not($(e.target)).removeClass('active');
});

});

function searchThroughAccordion() {
var states = ['frozen_back', 'doubling_in_progress', 'discarded'];

states.forEach(function(state) {
highlightSearch(state);
});
}

function highlightSearch(state) {
var text = document.getElementById("query").value;
if (text) {
var query = new RegExp("(" + text + ")(?![^<]*>|[^<>]*<\/>\S)", "gim");
var accordion = document.getElementById(state).innerHTML;
var clearAccord = accordion.replace(/(<span>|<\/span>)/igm, "");
document.getElementById(state + '_id').innerHTML = "No results found";
document.getElementById(state).innerHTML = clearAccord;
var newAccord = clearAccord.replace(query, "<span>$1</span>");
var count;
try {
count = newAccord.match(query).length;
} catch (err) {
count = 0;
}
document.getElementById(state + '_id').innerHTML = "Results found: " + count;

document.getElementById(state).innerHTML = newAccord;
document.getElementById(state + '_id').style = "color:red";
var ua = navigator.userAgent;
var browser = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];

if (browser[1] != "Firefox") {
if (count > 0 ){
$("#" + state).collapse("show");
}
else {
$("#" + state).collapse("hide");
}
}
}
}


</script>

0 comments on commit c8b04f8

Please sign in to comment.