BioMart::Formatter
SAME_TSV
Toolbar
Summary
BioMart::Formatter::SAME_TSV
Package variables
No package variables defined.
Included modules
Inherit
Synopsis
The SAME_TSV Formatter returns tab separated tabular data
for a BioMart query's ResultTable
Description
When given a BioMart::ResultTable containing the results of
a BioMart::Query the SAME_TSV Formatter will return tabular output
with one line for each row of data in the ResultTable and tabs
separating the individual entries in each row. The getDisplayNames
and getFooterText can be used to return appropiately formatted
headers and footers respectively
Methods
_new | No description | Code |
getDisplayNames | No description | Code |
getFormatterDisplayName | No description | Code |
nextRow | No description | Code |
processQuery | No description | Code |
Methods description
None available.
Methods code
sub _new
{ my ($self) = @_;
$self->SUPER::_new();
$self->attr('reference',0); } |
sub getDisplayNames
{ my $self = shift;
my @displayNames = $self->getTextDisplayNames();
if ($self->get('reference')){
$displayNames[-1] .= " (Reference)";
}
map { s/$FIELD_DELIMITER/\$FIELD_DELIMITER/g } @displayNames;
return join($FIELD_DELIMITER, @displayNames) . $RECORD_DELIMITER;
}
1; } |
sub getFormatterDisplayName
{ return 'Same as reference (tab separated)'; } |
sub nextRow
{ my $self = shift;
my $rtable = $self->get('result_table');
my $row = $rtable->nextRow;
if (!$row){
return;
}
my $reference;
if ($self->get('reference')){
$reference= $$row[-1];
if (!$reference){
return "\n";
}
}
my $result_seen;
for (my $i = 0; $i < @{$row}; $i++) {
if (($i != @{$row} - 1) && ($$row[$i] ne $reference) && $$row[$i] && $reference){
$$row[$i] = '' if ($$row[$i] =~ /^[ACGT]$/);
}
if ($reference){
$result_seen = 1 if ($$row[$i] =~ /^[ACGT]$/ && ($i != @{$row} - 1));
}
else{
$result_seen = 1 if ($$row[$i] =~ /^[ACGT]$/ );
}
$$row[$i] = q{} unless defined ($$row[$i]);
$$row[$i] =~ s/$FIELD_DELIMITER/\$FIELD_DELIMITER/g;
}
if ($result_seen){
return join($FIELD_DELIMITER, @{$row}) . $RECORD_DELIMITER;
}
else{
return "\n";
} } |
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];
$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());
$self->set('query',$query);
return $query; } |
General documentation