Repository navigation
Expand file tree
/
Copy pathStrainView.pm
More file actions
executable file
·140 lines (106 loc) · 4.37 KB
/
Copy pathStrainView.pm
File metadata and controls
executable file
·140 lines (106 loc) · 4.37 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package WebComponent::StrainView;
use strict;
use warnings;
use base qw( WebComponent );
use FIGMODEL;
1;
=pod
=head1 NAME
StrainView - view currently selected strain
=head1 DESCRIPTION
WebComponent for a strain select box
=head1 METHODS
=over 4
=item * B<new> ()
Called when the object is initialized. Expands SUPER::new.
=cut
sub new {
my $self = shift->SUPER::new(@_);
$self->application->register_component('TabView', 'StrainTV');
$self->application->register_component('IntervalTable', 'interval_table');
$self->application->register_component('GeneTable', 'strain_view_gene_table');
$self->application->register_component('GrowthData', 'growth_display');
$self->application->register_component('RollerBlind', 'strain_view_rb');
return $self;
}
=item * B<output> ()
Returns the html output of the ModelSelect component.
=cut
sub output {
my ($self) = @_;
my $html = "";
# Getting various application objects
my $application = $self->application();
my $model = $application->data_handle('FIGMODEL');
my $user = $application->session->user;
my $cgi = $application->cgi();
my $CGI_Page = $cgi->param( 'page' );
# getting web components
my $interval_table = $application->component('interval_table');
my $strain_tv = $application->component('StrainTV');
my $growth_display = $application->component('growth_display');
my $gene_table = $application->component('strain_view_gene_table');
# getting the strain data
my $StrainTable = $model->GetDBTable("STRAIN TABLE");
my $SimulationTable = $model->GetDBTable("STRAIN SIMULATIONS");
my $IntervalTable = $model->GetDBTable("INTERVAL TABLE");
# Get CGI parameters
my $Strain = $cgi->param( 'id' );
# Configer that Strain was provided (should be done by WebPage, but check again to be sure)
unless(defined($Strain)) {
$application->redirect('StrainSelect');
$application->add_message('info', "No strain selected, please select a strain to view.");
$application->do_redirect();
exit;
}
my $row = $StrainTable->get_row_by_key($Strain, "ID");
unless($row) {
$application->add_message('Warning', "No interval with ID $Strain.");
exit;
}
# Get simulation results
my $sim = $SimulationTable->get_row_by_key($Strain, 'ID');
# Get growth output.
my $growthstr = $growth_display->output($Strain);
my $Intervals = $row->{'INTERVALS'};
my $IntervalTabText .= $interval_table->output(900, 0, join(',', @{$Intervals}));
my $PredictionsTabText = "Will eventually predict fitness of new strains; suggest changes.";
if(defined($sim->{'PREDICTIONS'})) { $PredictionsTabText = join(',', @{$sim->{'PREDICTIONS'}}); }
my $GeneInformationTabText = $gene_table->output(900, 'figstr|224308.1.'.$Strain);
my $DiscussionTabText = "Will eventually have a comment system for discussions.";
# Configure the Tab View element
$strain_tv->width(900);
$strain_tv->height(400);
$strain_tv->add_tab('Gene Information', $GeneInformationTabText);
$strain_tv->add_tab('Intervals knocked out', $IntervalTabText);
$strain_tv->add_tab('Predictions', $PredictionsTabText);
$strain_tv->add_tab('Discussion', $DiscussionTabText);
my $genomeSize = 4214814;
my $geneCount = 0;
my $rxnCount = 0;
foreach my $interval (@{$Intervals}) {
my $intervalRow = $IntervalTable->get_row_by_key($interval, 'ID');
unless(defined($intervalRow)) { next; }
my $start = $intervalRow->{'START'}->[0];
my $stop = $intervalRow->{'END'}->[0];
$genomeSize = $genomeSize - ($stop - $start);
my $genes = $model->genes_of_interval($start,$stop,'224308.1');
$geneCount += @{$genes};
}
# Existing strain selected, find strain, load, print data
$html .= "<h2>Strain " . $Strain . "</h2>";
$html .= "<div style='padding-left: 10px;'>";
$html .= "<a href='seedviewer.cgi?page=StrainViewer&id=".$Strain.
"&act=NEW' >Create new strain using this one</a><br/>";
$html .= "<table>";
$html .= "<tr><th>Strain Size / Genome Size</th><td>". ($genomeSize/1000) .
' / 4214.814 Kbp</td></tr>';
$html .= '<tr><th>Intervals</th><td>'.@{$Intervals}.'</td></tr>';
$html .= '<tr><th>Genes knocked out</th><td>'.$geneCount.'</td></tr>';
$html .= '<tr><th>Reactions knocked out</th><td>'.$rxnCount.'</td></tr>';
$html .= "<tr><th>Growth</th><td>" . $growthstr . "</td></tr>";
$html .= "</table>";
$html .= "</div>";
$html .= "<div style='clear: right;'>" . $strain_tv->output() . "</div>";
return $html;
}