BioMart::Formatter
ADF
Toolbar
Summary
BioMart::Formatter::ADF
Package variables
No package variables defined.
Inherit
Synopsis
The ADF Formatter returns ADF Formatter data for a BioMart query
Description
The ADF Formatter first of all removes any user chosen attributes from
the BioMart::Query object and adds the appropiate attributes required
for ADF data calculation. These attributes are defined in 'adf' exportables
for the Dataset being processed. After this initial processing the query is
run and the ResultTable is processed row by row to calculate the correct
structural data for ADF output
Methods
_new | No description | Code |
getDisplayNames | No description | Code |
isSpecial | No description | Code |
nextRow | No description | Code |
processQuery | No description | Code |
resultTable | No description | Code |
Methods description
None available.
Methods code
sub _new
{ my ($self) = @_;
$self->SUPER::_new();
}
} |
sub getDisplayNames
{ my $self = shift;
my $atts = $self->get('query')->getAllAttributes;
my $header = "Reporter Name\t";
foreach my $att(@{$atts}){
$header .= "Reporter BioSequence Database Entry [".$att->displayName."]\t";
}
return "$header\n"; } |
sub isSpecial
{ return 1;
}
1; } |
sub nextRow
{ my $self = shift;
my $rtable = $self->get('result_table');
my $row = $rtable->nextRow;
if (!$row){
return;
}
return $$row[0]."\n"; } |
sub processQuery
{ my ($self, $query) = @_;
$self->set('original_attributes',[@{$query->getAllAttributes()}])
if ($query->getAllAttributes());
my $final_dataset_order = $query->finalDatasetOrder();
my $registry = $query->getRegistry();
$query->removeAllAttributes();
foreach my $dataset_name(reverse @$final_dataset_order){
my $dataset = $registry->getDatasetByName($query->virtualSchema,
$dataset_name);
if ($dataset->getExportables('adf',
$query->getInterfaceForDataset($dataset_name))){
my $id_list_filter;
my $dset_filters = $query->getAllFilters($dataset_name);
foreach my $dset_filter (@{$dset_filters}){
if ($dset_filter->multipleValues eq '1') {
$id_list_filter = $dset_filter;
last;
}
}
if ($id_list_filter){
my $attribute_entry = $id_list_filter->attribute;
$query->addAttributeWithoutLinking($attribute_entry) if ($attribute_entry);
}
else{
BioMart::Exception::Usage->throw("ADF format can only be used with uploaded IDs");
}
my $attribute_list = $dataset->getExportables('adf',
$query->getInterfaceForDataset($dataset_name));
$query->addAttributes($attribute_list->getAllAttributes);
last;
}
}
if (!$query->getAllAttributes()){
BioMart::Exception::Usage->throw("ADF format not applicable for this dataset");
}
$self->set('query',$query);
return $query; } |
sub resultTable
{ my ($self,$result_table) = @_;
if ($result_table){
my $new_result_table = BioMart::AttributeTable->new();
my %results;
while (my $row = $result_table->nextRow){
if ($results{$$row[0]}){
my @entries;
if ($results{$$row[0]} !~ /$$row[2]/){ chop $results{$$row[0]};
@entries = split(/\t/,$results{$$row[0]});
for (my $k=1; $k <= @entries; $k++){
$entries[$k] .= ';'.$$row[$k] if ($$row[$k] ne $entries[$k]);
}
$results{$$row[0]} = join("\t",@entries);
}
}
else{
$results{$$row[0]} = join("\t",@$row);
}
}
my @id_filter_list;
my $query = $self->get('query');
my $final_dataset_order = $query->finalDatasetOrder();
my $registry = $query->getRegistry();
foreach my $dataset_name(reverse @$final_dataset_order){
my $dataset = $registry->getDatasetByName($query->virtualSchema,
$dataset_name);
if ($dataset->getExportables('adf',
$query->getInterfaceForDataset($dataset_name))){
my $dset_filters = $query->getAllFilters($dataset_name);
foreach my $dset_filter (@{$dset_filters}){
if ($dset_filter->multipleValues eq '1') {
my $val_table = $dset_filter->getTable;
my $rows = $val_table->getRows();
foreach my $row (@{$rows}){
next unless (defined($$row[0])); push @id_filter_list, $$row[0];
}
last;
}
}
}
}
foreach (@id_filter_list){
if ($results{$_}){
$new_result_table->addRow([$results{$_}]);
}
else{
$new_result_table->addRow([$_]);
}
}
$self->set('result_table',$new_result_table);
}
return $self->get('result_table'); } |
General documentation