Bio::SeqFeature::Tools TypeMapper
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Summary
Bio::SeqFeature::Tools::TypeMapper - maps $seq_feature->primary_tag
Package variables
No package variables defined.
Inherit
Bio::Root::Root
Synopsis
  use Bio::SeqIO;
use Bio::SeqFeature::Tools::TypeMapper;
# first fetch a genbank SeqI object $seqio = Bio::SeqIO->new(-file=>'AE003644.gbk', -format=>'GenBank'); $seq = $seqio->next_seq(); $tm = Bio::SeqFeature::Tools::TypeMapper->new; # map all the types in the sequence $tm->map_types(-seq=>$seq, {CDS=>'ORF', variation=>sub { my $f = shift; $f->length > 1 ? 'variation' : 'SNP' }, }); # alternatively, use the hardcoded SO mapping $tm->map_types_to_SO(-seq=>$seq);
Description
This class implements an object for mapping between types; for
example, the types in a genbank feature table, and the types specified
in the Sequence Ontology.
You can specify your own mapping, either as a simple hash index, or by
providing your own subroutines.
Methods
newDescriptionCode
typemapDescriptionCode
map_typesDescriptionCode
map_types_to_SODescriptionCode
get_relationship_type_by_parent_childDescriptionCode
Methods description
newcode    nextTop
 Title   : new
Usage : $unflattener = Bio::SeqFeature::Tools::TypeMapper->new();
Function: constructor
Example :
Returns : a new Bio::SeqFeature::Tools::TypeMapper
Args : see below
typemapcodeprevnextTop
 Title   : typemap
Usage : $obj->typemap($newval)
Function:
Example :
Returns : value of typemap (a scalar)
Args : on set, new value (a scalar or undef, optional)
map_typescodeprevnextTop
 Title   : map_types
Usage :
Function:
Example :
Returns :
Args :
map_types_to_SOcodeprevnextTop
 Title   : map_types_to_SO
Usage :
Function:
Example :
Returns :
Args :
hardcodes the genbank to SO mapping
Based on revision 1.22 of SO
Please see the actual code for the mappings
Taken from
http://song.sourceforge.net/FT_SO_map.txt
get_relationship_type_by_parent_childcodeprevnextTop
 Title   : get_relationship_type_by_parent_child
Usage : $type = $tm->get_relationship_type_by_parent_child($parent_sf, $child_sf);
Usage : $type = $tm->get_relationship_type_by_parent_child('mRNA', 'protein');
Function: given two features where the parent contains the child,
will determine what the relationship between them in
Example :
Returns :
Args : parent SeqFeature, child SeqFeature OR
parent type string, child type string OR
bioperl Seq::FeatureHolderI hierarchies are equivalent to unlabeled
graphs (where parent nodes are the containers, and child nodes are the
features being contained). For example, a feature of type mRNA can
contain features of type exon.
Some external representations (eg chadoxml or chaosxml) require that
the edges in the feature relationship graph are labeled. For example,
the type between mRNA and exon would be part_of. Although it
stretches the bioperl notion of containment, we could have a CDS
contained by an mRNA (for example, the
Bio::SeqFeature::Tools::Unflattener module takes genbank records
and makes these kind of links. The relationship here would be
produced_by
In chado speak, the child is the subject feature and the parent is
the object feature
Methods code
newdescriptionprevnextTop
sub new {
    my($class,@args) = @_;
    my $self = $class->SUPER::new(@args);

    my($typemap) =
	$self->_rearrange([qw(TYPEMAP
			     )],
                          @args);

    $typemap  && $self->typemap($typemap);
    return $self; # success - we hope!
}
typemapdescriptionprevnextTop
sub typemap {
    my $self = shift;

    return $self->{'typemap'} = shift if @_;
    return $self->{'typemap'};
}
map_typesdescriptionprevnextTop
sub map_types {
   my ($self,@args) = @_;

   my($sf, $seq, $type_map) =
     $self->_rearrange([qw(FEATURE
                           SEQ
			   TYPE_MAP
                          )],
                          @args);
   if (!$sf && !$seq) {
       $self->throw("you need to pass in either -feature or -seq");
   }

   my @sfs = ($sf);
   if ($seq) {
       $seq->isa("Bio::SeqI") || $self->throw("$seq NOT A SeqI");
       @sfs = $seq->get_all_SeqFeatures;
   }
   $type_map = $type_map || $self->type_map;
   foreach my $sf (@sfs) {

       $sf->isa("Bio::SeqFeatureI") || $self->throw("$sf NOT A SeqFeatureI");
       $sf->isa("Bio::FeatureHolderI") || $self->throw("$sf NOT A FeatureHolderI");

       my $type = $sf->primary_tag;
       my $mtype = $type_map->{$type};
       if ($mtype) {
	   if (ref($mtype)) {
	       if (ref($mtype) eq 'CODE') {
		   $mtype = $mtype->($sf);
	       }
	       else {
		   $self->throw('must be scalar or CODE ref');
	       }
	   }
	   $sf->primary_tag($mtype);
       }
   }
   return;
}
map_types_to_SOdescriptionprevnextTop
sub map_types_to_SO {
   my ($self,@args) = @_;

   # note : some of the FT_SO mappings are commented out and overriden...
push(@args, (-type_map=>{ "FT term" => "SO term", "-" => "located_sequence_feature", "-10_signal" => "minus_10_signal", "-35_signal" => "minus_35_signal", "3'UTR" => "three_prime_UTR", "3'clip" => "three_prime_clip", "5'UTR" => "five_prime_UTR", "5'clip" => "five_prime_clip", "CAAT_signal" => "CAAT_signal", "CDS" => "CDS", "C_region" => "undefined", "D-loop" => "D_loop", "D_segment" => "D_gene", "GC_signal" => "GC_rich_region", "J_segment" => "undefined", "LTR" => "long_terminal_repeat", "N_region" => "undefined", "RBS" => "ribosome_entry_site", "STS" => "STS", "S_region" => "undefined", "TATA_signal" => "TATA_box", "V_region" => "undefined", "V_segment" => "undefined", "attenuator" => "attenuator", "conflict" => "undefined", "enhancer" => "enhancer", "exon" => "exon", "gap" => "gap", "gene" => "gene", "iDNA" => "iDNA", "intron" => "intron", "mRNA" => "mRNA", "mat_peptide" => "mature_peptide", # "misc_RNA" => "transcript",
"misc_binding" => "binding_site", "misc_difference" => "sequence_difference", "misc_feature" => "region", "misc_recomb" => "recombination_feature", "misc_signal" => "regulatory_region", "misc_structure" => "sequence_secondary_structure", "modified_base" => "modified_base_site", "old_sequence" => "undefined", "operon" => "operon", "oriT" => "origin_of_transfer", "polyA_signal" => "polyA_signal_sequence", "polyA_site" => "polyA_site", "precursor_RNA" => "primary_transcript", "prim_transcript" => "primary_transcript", "primer_bind" => "primer_binding_site", "promoter" => "promoter", "protein_bind" => "protein_binding_site", "rRNA" => "rRNA", "repeat_region" => "repeat_region", "repeat_unit" => "repeat_unit", "satellite" => "satellite_DNA", "scRNA" => "scRNA", "sig_peptide" => "signal_peptide", "snRNA" => "snRNA", "snoRNA" => "snoRNA", # "source" => "databank_entry",
"stem_loop" => "stem_loop", "tRNA" => "tRNA", "terminator" => "terminator", "transit_peptide" => "transit_peptide", "unsure" => "undefined", "variation" => "sequence_variant", # this is the most generic form for RNAs;
# we always represent the processed form of
# the transcript
misc_RNA=>'processed_transcript', # not sure about this one...
source=>'contig', rep_origin=>'origin_of_replication', Protein=>'protein', })); return $self->map_types(@args);
}
get_relationship_type_by_parent_childdescriptionprevnextTop
sub get_relationship_type_by_parent_child {
   my ($self,$parent,$child) = @_;
   $parent = ref($parent) ? $parent->primary_tag : $parent;
   $child = ref($child) ? $child->primary_tag : $child;

   my $type = 'part_of'; # default
# TODO - do this with metadata, or infer via SO itself
if (lc($child) eq 'protein') { $type = 'derives_from'; } if (lc($child) eq 'polypeptide') { $type = 'derives_from'; } return $type;
}
General documentation
FEEDBACKTop
Mailing ListsTop
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to the
Bioperl mailing lists Your participation is much appreciated.
  bioperl-l@bioperl.org                  - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
Reporting BugsTop
report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via the
web:
  http://bugzilla.open-bio.org/
AUTHOR - Chris MungallTop
Email: cjm@fruitfly.org
APPENDIXTop
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _