UniProtReportDumper.pm
Go to the documentation of this file.
00001 =head1 LICENSE
00002 
00003 Copyright [2009-2016] EMBL-European Bioinformatics Institute
00004 
00005 Licensed under the Apache License, Version 2.0 (the "License");
00006 you may not use this file except in compliance with the License.
00007 You may obtain a copy of the License at
00008 
00009      http://www.apache.org/licenses/LICENSE-2.0
00010 
00011 Unless required by applicable law or agreed to in writing, software
00012 distributed under the License is distributed on an "AS IS" BASIS,
00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 See the License for the specific language governing permissions and
00015 limitations under the License.
00016 
00017 =head1 CONTACT
00018 
00019   Please email comments or questions to the public Ensembl
00020   developers list at <dev@ensembl.org>.
00021 
00022   Questions may also be sent to the Ensembl help desk at
00023   <helpdesk@ensembl.org>.
00024 
00025 =head1 NAME
00026 
00027 Bio::EnsEMBL::MetaData::MetaDataDumper::UniProtReportDataDumper
00028 
00029 =head1 SYNOPSIS
00030 
00031 =head1 DESCRIPTION
00032 
00033 Implementation to dump metadata details to a TSV format file for use by UniProtKB.
00034 See Bio::EnsEMBL::MetaData::MetaDataDumper for method details.
00035 
00036 =head1 SEE ALSO
00037 Bio::EnsEMBL::MetaData::MetaDataDumper
00038 
00039 =head1 AUTHOR
00040 
00041 Dan Staines
00042 
00043 =cut
00044 
00045 use strict;
00046 use warnings;
00047 
00048 package Bio::EnsEMBL::MetaData::MetaDataDumper::UniProtReportDumper;
00049 use base qw( Bio::EnsEMBL::MetaData::MetaDataDumper );
00050 use Bio::EnsEMBL::Utils::Argument qw(rearrange);
00051 use Carp;
00052 
00053 sub new {
00054   my ($proto, @args) = @_;
00055   my $self = $proto->SUPER::new(@args);
00056   $self->{file} ||= 'uniprot_report.txt';
00057   return $self;
00058 }
00059 
00060 sub start {
00061   my ($self, $divisions, $file, $dump_all) = @_;
00062   $self->SUPER::start($divisions, $file, $dump_all);
00063   for my $fh (values %{$self->{files}}) {
00064       print $fh '#'. join("\t",
00065                        qw(name species division taxonomy_id assembly_id assembly_name genebuild nProteinCoding nProteinCodingUniProtKBSwissProt nProteinCodingUniProtKBTrEMBL uniprotCoverage)
00066     ) .
00067     "\n";
00068   }
00069   return;
00070 }
00071 
00072 sub _write_metadata_to_file {
00073   my ($self, $md, $fh) = @_; 
00074   print $fh join(
00075                 "\t",
00076                 ($md->name(),
00077                  $md->species(),
00078                  $md->division(),
00079                  $md->taxonomy_id(),
00080                  $md->assembly_id()   || '',
00081                  $md->assembly_name() || '',
00082                  $md->genebuild()     || '',
00083                  $md->annotations()->{nProteinCoding},
00084                  $md->annotations()->{nProteinCodingUniProtKBSwissProt},
00085                  $md->annotations()->{nProteinCodingUniProtKBTrEMBL},
00086                  sprintf("%.2f", $md->get_uniprot_coverage($md)),
00087                  "\n"));
00088   return;
00089 }
00090 
00091 1;
00092