\n};
Readonly my $HEADERFIELD_TMPL1 => qq{ %s | \n};
Readonly my $HEADERFIELD_TMPL2 => qq{ %s | \n};
Readonly my $NORMALFIELD_TMPL1 => qq{ \n};
Readonly my $ROW_END_TMPL => qq{ |
\n};
sub _new {
my ($self) = @_;
$self->SUPER::_new();
$self->attr('reference',0);
}
sub getFormatterDisplayName {
return 'Same as reference';
}
sub processQuery {
my ($self, $query) = @_;
my $filters = $query->getAllFilters();
my @filts;
foreach my $filter(@{$filters}){
if ($filter->name eq 'reference_strain'){
my $rows = $filter->get('attribute_table')->getRows();
my $ref_strain = ${$$rows[0]}[0];
# remove the filter
$ref_strain =~ s/\//\_/g;
$ref_strain =~ s/ /\_/g;
$ref_strain =~ s/\+/\_/g;
$ref_strain =~ s/\./\_/g;
$ref_strain =~ s/\-/\_/g;
$query->addAttribute(lc($ref_strain));
$self->set('reference',1);
}
else{
push @filts,$filter;
}
}
$query->removeAllFilters();
$query->addFilters(\@filts);
$self->set('original_attributes',[@{$query->getAllAttributes()}])
if ($query->getAllAttributes());
$query = $self->setHTMLAttributes($query);
$self->set('query',$query);
return $query;
}
sub nextRow {
my $self = shift;
my $rtable = $self->get('result_table');
# print the data with urls if available
my $new_row;
my $row = $rtable->nextRow;
if (!$row){
return;
}
map { $_ = q{} unless defined ($_); } @$row;
my $attribute_positions = $self->get('attribute_positions');
my $attribute_url_positions = $self->get('attribute_url_positions');
my $attribute_url = $self->get('attribute_url');
#my $dataset1_end = $self->get('dataset1_end');
my $reference;
if ($self->get('reference')){
$reference = $$row[$$attribute_positions[-1]];
if (!$reference){
return "\n";
}
}
my $result_seen;
for (my $i = 0; $i < @{$attribute_positions}; $i++){
if (($i != @{$attribute_positions} - 1) && ($$row[$$attribute_positions[$i]] ne $reference) && $$row[$$attribute_positions[$i]] && $reference){
$$row[$$attribute_positions[$i]] = '' if ($$row[$$attribute_positions[$i]] =~ /^[ACGT]$/);
}
if ($reference){
$result_seen = 1 if ($$row[$$attribute_positions[$i]] =~ /^[ACGT]$/ && ($i != @{$attribute_positions} - 1));
}
else{
$result_seen = 1;
}
if ($$row[$$attribute_positions[$i]] eq 'C'){
$$row[$$attribute_positions[$i]] = qw(bgcolor="yellow">).'C';
}
elsif ($$row[$$attribute_positions[$i]] eq 'G'){
$$row[$$attribute_positions[$i]] = qw(bgcolor="green">).'G';
}
elsif ($$row[$$attribute_positions[$i]] eq 'A'){
$$row[$$attribute_positions[$i]] = qw(bgcolor="red">).'A';
}
elsif ($$row[$$attribute_positions[$i]] eq 'T'){
$$row[$$attribute_positions[$i]] = qw(bgcolor="orange">).'T';
}
else{
$$row[$$attribute_positions[$i]] = qw(>).$$row[$$attribute_positions[$i]];
}
if ($$attribute_url[$i]){
my @url_data = map {$$row[$_]} @{$$attribute_url_positions[$i]};
my $url_string = sprintf($$attribute_url[$i],@url_data);
$url_string =~ s/>//g;
push @{$new_row}, '