Archive Ensembl HomeArchive Ensembl Home
bio_ens_seqFeature.pm
Go to the documentation of this file.
00001 =head1 LICENSE
00002 
00003   Copyright (c) 1999-2012 The European Bioinformatics Institute and
00004   Genome Research Limited.  All rights reserved.
00005 
00006   This software is distributed under a modified Apache license.
00007   For license details, please see
00008 
00009     http://www.ensembl.org/info/about/code_licence.html
00010 
00011 =head1 CONTACT
00012 
00013   Please email comments or questions to the public Ensembl
00014   developers list at <dev@ensembl.org>.
00015 
00016   Questions may also be sent to the Ensembl help desk at
00017   <helpdesk@ensembl.org>.
00018 
00019 =head1 AUTHOR
00020 
00021 Juguang Xiao <juguang@tll.org.sg>
00022 
00023 =cut
00024 
00025 =head1 NAME
00026 
00027 Bio::EnsEMBL::Utils::Converter::bio_ens_seqFeature
00028 
00029 =head1 SYNOPISIS
00030 
00031 Please read Bio::EnsEMBL::Utils::Converter
00032 
00033 =head1 DESCRIPTION
00034 
00035 =head1 METHODS
00036 
00037 =cut
00038 
00039 package Bio::EnsEMBL::Utils::Converter::bio_ens_seqFeature;
00040 
00041 use strict;
00042 use vars qw(@ISA);
00043 use Bio::EnsEMBL::SeqFeature;
00044 use Bio::EnsEMBL::SimpleFeature;
00045 use Bio::EnsEMBL::Exon;
00046 use Bio::EnsEMBL::Utils::Converter::bio_ens;
00047 @ISA = qw(Bio::EnsEMBL::Utils::Converter::bio_ens);
00048 
00049 sub _convert_single {
00050     my ($self, $in) = @_;
00051     
00052     unless($in && defined($in) && $in->isa('Bio::SeqFeature::Generic')){
00053         $self->throw("a Bio::SeqFeature::Generic object needed");
00054     }
00055     
00056     my $seqFeature = $in;
00057     my $seq_id = $seqFeature->seq_id;
00058     unless(defined($seq_id) && $seq_id){
00059         $self->warn("No seq_id value. EnsEMBL SeqFeature will validate it");
00060         $seq_id = 'Unknown';
00061     }
00062     
00063     # Debated issue here. There are p_value and percent_id in EnsEMBL API and DB
00064     # schema, but not in bioperl. If in bioperl there are tags called p_value or
00065     # percent_id, then the values are passed, otherwise set the default 1.
00066     #
00067     # the problem arise when I try to converter the seqfeature for tmhmm to 
00068     # EnsEMBL seqFeature.
00069     # -- Juguang, 11 July '03
00070     my $score = $in->score || 0;
00071     my $percent_id;
00072     if($in->has_tag('percent_id')){
00073         ($percent_id) = $in->get_tag_values('percent_id');
00074     }else{
00075         $percent_id ||= 0;
00076     }
00077     my $p_value;
00078     if($in->has_tag('p_value')){
00079         ($p_value) = $in->get_tag_values('p_value');
00080     }elsif($in->has_tag('evalue')){
00081         ($p_value) = $in->get_tag_values('evalue');
00082     }else{
00083         $p_value ||= 1;
00084     }
00085     my $ens_seqFeature;
00086     my %args = (
00087         -start => $in->start,
00088         -end => $in->end,
00089         -strand => $in->strand,
00090         -score => $score,
00091         -analysis => $self->analysis,
00092         -source_tag => $in->source_tag,
00093         -seqname => $seq_id,
00094         -percent_id => $percent_id,
00095         -p_value => $p_value
00096     );
00097 
00098     my $output_module = $self->out;
00099     
00100     if($output_module eq 'Bio::EnsEMBL::SeqFeature'){
00101         
00102         $ens_seqFeature = new Bio::EnsEMBL::SeqFeature(%args);
00103     }elsif($self->out eq 'Bio::EnsEMBL::SimpleFeature'){
00104         $ens_seqFeature = new Bio::EnsEMBL::SimpleFeature(%args);
00105         # The field that there is in SimpleFeature, but not in SeqFeature.
00106         $ens_seqFeature->display_label('__NONE__');
00107     }elsif($self->out eq 'Bio::EnsEMBL::Exon'){
00108         $ens_seqFeature = Bio::EnsEMBL::Exon->new_fast(
00109             $self->contig, $seqFeature->start, $seqFeature->end, 
00110             $seqFeature->strand);
00111     }elsif($self->out eq 'Bio::EnsEMBL::ProteinFeature'){
00112         my $seq_id2 = $self->analysis->logic_name;
00113         unless(defined $self->translation_id){
00114             $self->throw('translation_id unset, in ProteinFeature conversion');
00115         }
00116         $args{'-seqname'} = $self->translation_id;
00117         $ens_seqFeature = Bio::EnsEMBL::ProteinFeature->new(
00118             -feature1 => Bio::EnsEMBL::SeqFeature->new(%args),
00119             -feature2 => Bio::EnsEMBL::SeqFeature->new(
00120                 -start => 0,
00121                 -end => 0,
00122                 -seqname => $seq_id2
00123             )
00124         );
00125     }else{
00126         $self->throw("[$output_module] as -out, not supported");
00127     }
00128     
00129     $ens_seqFeature->attach_seq($self->contig);
00130     return $ens_seqFeature;
00131 }
00132 
00133 1;