view release on metacpan or search on metacpan
lib/Bio/EnsEMBL/DBSQL/ArchiveStableIdAdaptor.pm view on Meta::CPAN
# standard Ensembl IDs
} elsif ($stable_id =~ /.*G\d+(\.\d+)?$/) {
$id_type = "Gene";
} elsif ($stable_id =~ /.*T\d+(\.\d+)?$/) {
$id_type = "Transcript";
} elsif ($stable_id =~ /.*P\d+(\.\d+)?$/) {
$id_type = "Translation";
} elsif ($stable_id =~ /.*E\d+(\.\d+)?$/) {
$id_type = "Exon";
# if guessing fails, look in db
} else {
my $sql = qq(
SELECT type from stable_id_event
WHERE old_stable_id = ?
OR new_stable_id = ?
);
my $sth = $self->prepare($sql);
$sth->execute($stable_id, $stable_id);
($id_type) = $sth->fetchrow_array;
$sth->finish;
lib/Bio/EnsEMBL/DBSQL/CoordSystemAdaptor.pm view on Meta::CPAN
my $key2 = $cs2->name();
$key2 .= ':' . $cs2->version() if ($cs2->version());
my $path = $self->{'_mapping_paths'}->{"$key1|$key2"};
return $path if($path);
$path = $self->{'_mapping_paths'}->{"$key2|$key1"};
if(!$path) {
# No path was explicitly defined, but we might be able to guess a
# suitable path. We only guess for missing 2 step paths.
my %mid1;
my %mid2;
foreach my $path (values(%{$self->{'_mapping_paths'}})) {
next if(@$path != 2);
my $match = undef;
if($path->[0]->equals($cs1)) {
lib/Bio/EnsEMBL/DBSQL/TranslationAdaptor.pm view on Meta::CPAN
) );
# Get all alternative translations.
my $translations = [];
while ( $sth->fetch() ) {
if ( !defined($translation_id) ) { next }
my ( $start_exon, $end_exon );
# this will load all the exons whenever we load the translation
# but I guess thats ok ....
foreach my $exon ( @{ $transcript->get_all_Exons() } ) {
if ( $exon->dbID() == $start_exon_id ) { $start_exon = $exon }
if ( $exon->dbID() == $end_exon_id ) { $end_exon = $exon }
}
if ( !( defined($start_exon) && defined($end_exon) ) ) {
throw(
sprintf(
"Could not find start or end exon in transcript_id=%d\n",
lib/Bio/EnsEMBL/DBSQL/TranslationAdaptor.pm view on Meta::CPAN
$seq_start, $seq_end, $stable_id,
$version, $created_date, $modified_date
) = $sth->fetchrow_array();
$sth->finish();
if ( !defined($translation_id) ) { return undef }
my ( $start_exon, $end_exon );
# this will load all the exons whenever we load the translation
# but I guess thats ok ....
foreach my $exon ( @{ $transcript->get_all_Exons() } ) {
if ( $exon->dbID() == $start_exon_id ) { $start_exon = $exon }
if ( $exon->dbID() == $end_exon_id ) { $end_exon = $exon }
}
if ( !( defined($start_exon) && defined($end_exon) ) ) {
throw(
sprintf( "Could not find start or end exon in transcript_id=%d\n",
$transcript->dbID() ) );
lib/Bio/EnsEMBL/DBSQL/TranslationAdaptor.pm view on Meta::CPAN
$sth->execute();
$sth->bind_columns( \$transcript_id, \$translation_id, \$start_exon_id, \$end_exon_id,
\$seq_start, \$seq_end, \$stable_id, \$version,
\$created_date, \$modified_date );
while($sth->fetch()) {
my ($start_exon, $end_exon);
# this will load all the exons whenever we load the translation
# but I guess thats ok ....
my $tr = $trans_hash{$transcript_id};
foreach my $exon (@{$tr->get_all_Exons()}) {
if(!$start_exon && $exon->dbID() == $start_exon_id ) {
$start_exon = $exon;
last if($end_exon);
}
if(!$end_exon && $exon->dbID() == $end_exon_id ) {
lib/Bio/EnsEMBL/External/ExternalFeatureAdaptor.pm view on Meta::CPAN
my $mapper = $asma->fetch_by_CoordSystems($from_coord_system,
$coord_system);
my %slice_cache;
my $slice_adaptor = $self->ensembl_db->get_SliceAdaptor();
my $slice_setter;
#convert the coordinates of each of the features retrieved
foreach my $fseq_region (keys %features) {
my $feats = $features{$fseq_region};
next if(!$feats);
$slice_setter = _guess_slice_setter($feats) if(!$slice_setter);
foreach my $f (@$feats) {
my($sr_id, $start, $end, $strand) =
$mapper->fastmap($fseq_region,$f->start,$f->end,$f->strand,
$from_coord_system);
#maps to gap
next if(!defined($sr_id));
#maps to unexpected seq region, probably error in the externally
lib/Bio/EnsEMBL/External/ExternalFeatureAdaptor.pm view on Meta::CPAN
$f->start($start);
$f->end($end);
$f->strand($strand);
push @out, $f;
}
}
} else {
#we already know the seqregion the featues are on, we just have
#to put them on the slice
@out = @{$features{$slice_seq_region}};
my $slice_setter = _guess_slice_setter(\@out);
foreach my $f (@out) {
&$slice_setter($f,$slice);
}
}
# convert from assembly coords to slice coords
# handle the circular slice case
my $seq_region_len = $slice->seq_region_length();
foreach my $f (@out) {
lib/Bio/EnsEMBL/External/ExternalFeatureAdaptor.pm view on Meta::CPAN
$f->start($f_start);
$f->end($f_end);
$f->strand($f_strand);
}
return \@out;
}
sub _guess_slice_setter {
my $features = shift;
#we do not know what type of features these are. They might
#be bioperl features or old ensembl features, hopefully they are new
#style features. Try to come up with a setter method for the
#slice.
return undef if(!@$features);
my ($f) = @$features;
lib/Bio/EnsEMBL/PredictionTranscript.pm view on Meta::CPAN
-SEQ_START => 1,
-SEQ_END => $end_exon->length(),
-SEQ => $tmpSeq->translate()->seq());
}
=head2 translate
Arg [1] : Boolean, emulate the behavior of old bioperl versions where
an incomplete final codon of 2 characters is padded and guessed
Function : Give a peptide translation of all exons currently in
the PT. Gives empty string when none is in.
Returntype: a Bio::Seq as in transcript->translate()
Exceptions: none
Caller : general
Status : Stable
=cut
lib/Bio/EnsEMBL/PredictionTranscript.pm view on Meta::CPAN
if ( $codon_table->is_ter_codon( substr( $dna, -3, 3 ) ) ) {
substr( $dna, -3, 3, '' );
}
} elsif ( CORE::length($dna) % 3 == 2 ) {
# If we have a partial codon of 2 bp we need to decide if we
# trim it or not to fix some bad behaviour in older bioperl
# versions
if ( $complete_codon ) {
# If we want to do the bad behavior of bioperl 1.6.1 and older
# where we guess the last codon if inomplete, pad an N
# to the mrna sequence
$dna .= 'N';
} else {
# Otherwise trim those last two bp off so the behavior is
# consistent across bioperl versions
substr( $dna, -2, 2, '' );
}
}
my $bioseq = new Bio::Seq( -id => $self->display_id,
lib/Bio/EnsEMBL/Registry.pm view on Meta::CPAN
so, every time a set of features is retrieved,
they will come from the database instead of the
cache. This option is only recommended for advanced
users, specially if you need to store and retrieve
features. It might reduce performance when querying
the database if not used properly. If in doubt, do
not use it or ask in the developer mailing list.
Arg [5]: (optional) boolean
This option will make load_all() throw if the configuration file
is missing and cannot be guessed from the environment
Example : Bio::EnsEMBL::Registry->load_all();
Returntype : Int count of the DBAdaptor instances which can be found in the
registry due to this method being called. Will never be negative
Exceptions : Throws if $throw_if_missing is set and ($config_file is missing
and cannot be guessed from the environment
Status : Stable
=cut
sub load_all {
my ($class, $config_file, $verbose, $no_clear, $no_cache, $throw_if_missing ) = @_;
if ( !defined($config_file) ) {
if ( defined( $ENV{ENSEMBL_REGISTRY} ) ) {
if (-e $ENV{ENSEMBL_REGISTRY}) {
$config_file = $ENV{ENSEMBL_REGISTRY};
} else {
warning("\$ENV{ENSEMBL_REGISTRY} points to a file ('$ENV{ENSEMBL_REGISTRY}') that does not exist.\n");
}
} elsif ( defined( $ENV{HOME} ) ) {
if (-e ($ENV{HOME} . "/.ensembl_init")) {
$config_file = $ENV{HOME} . "/.ensembl_init";
}
}
if ($throw_if_missing and !defined($config_file) ) {
throw("No registry configuration to load, and no default could be guessed.\n");
}
} elsif ($throw_if_missing and !(-e $config_file)) {
throw(sprintf("Configuration file '%s' does not exist. Registry configuration not loaded.\n", $config_file ));
}
$verbose ||= 0;
$no_clear ||= 0;
$no_cache ||= 0;
my $original_count = $class->get_DBAdaptor_count();
lib/Bio/EnsEMBL/Transcript.pm view on Meta::CPAN
# Exit the loop when we've found the last exon
last if $ex eq $end_exon;
}
return \@translateable;
}
=head2 translate
Arg [1] : Boolean, emulate the behavior of old bioperl versions where
an incomplete final codon of 2 characters is padded and guessed
Example : none
Description: Return the peptide (plus eventual stop codon) for
this transcript. Does N-padding of non-phase
matching exons. It uses translateable_seq
internally. Returns undef if this Transcript does
not have a translation (i.e. pseudogene).
Returntype : Bio::Seq or undef
Exceptions : none
Caller : general
Status : Stable
lib/Bio/EnsEMBL/Transcript.pm view on Meta::CPAN
if ( $codon_table->is_ter_codon( substr( $mrna, -3, 3 ) ) ) {
substr( $mrna, -3, 3, '' );
}
} elsif ( CORE::length($mrna) % 3 == 2 ) {
# If we have a partial codon of 2 bp we need to decide if we
# trim it or not to fix some bad behaviour in older bioperl
# versions
if ( $complete_codon ) {
# If we want to do the bad behavior of bioperl 1.6.1 and older
# where we guess the last codon if inomplete, pad an N
# to the mrna sequence
$mrna .= 'N';
} else {
# Otherwise trim those last two bp off so the behavior is
# consistent across bioperl versions
substr( $mrna, -2, 2, '' );
}
}
if ( CORE::length($mrna) < 1 ) { return undef }
lib/Bio/EnsEMBL/TranscriptFactory.pm view on Meta::CPAN
}
$exon->phase ($endphase);
$endphase = $exon->end_phase;
}
$transcript->translation($translation);
return $transcript;
}
sub fset2transcript_guess_phases {
my ($fset,$contig) = @_;
my $transcript = new Bio::EnsEMBL::Transcript;
$transcript->temporary_id($contig->id . "." . $fset->id);
my @exons;
my $count = 1;
lib/Bio/EnsEMBL/Utils/Cache.pm view on Meta::CPAN
my($key, $value) = @_;
my $length = 0;
my %refs;
my @data = ($$key, $$value);
while(my $elem = shift @data) {
next if $refs{$elem};
$refs{$elem} = 1;
if(ref $elem && $elem =~ /(SCALAR|HASH|ARRAY)/) {
my $type = $1;
$length += $REF_SIZE; # guess, 16 bytes per ref, probably more
if (($type eq 'SCALAR')) {
$length += length($$elem);
} elsif (($type eq 'HASH')) {
while (my($k,$v) = each %$elem) {
for my $kv($k,$v) {
if ((ref $kv)) {
push(@data, $kv);
} else {
$length += length($kv);
}
lib/Bio/EnsEMBL/Utils/Converter.pm view on Meta::CPAN
my ($caller, @args) = @_;
my $class = ref($caller) || $caller;
if($class =~ /Bio::EnsEMBL::Utils::Converter::(\S+)/){
my $self = $class->SUPER::new(@args);
$self->_initialize(@args);
return $self;
}else{
my %params = @args;
@params{map {lc $_} keys %params} = values %params;
my $module = $class->_guess_module($params{-in}, $params{-out});
return undef unless($class->_load_module($module));
return "$module"->new(@args);
}
}
# This would be invoked by sub-module's _initialize.
sub _initialize {
my ($self, @args) = @_;
my ($in, $out) = $self->_rearrange([qw(IN OUT)], @args);
$self->in($in);
$self->out($out);
}
=head2 _guess_module
Usage : $module = $class->_guess_module(
'Bio::EnsEMBL::SimpleFeature',
'Bio::EnsEMBL::Generic'
);
=cut
sub _guess_module {
my ($self, $in, $out) = @_;
if($in =~ /^Bio::EnsEMBL::(\S+)/ and $out =~ /^Bio::EnsEMBL::(\S+)/){
$self->throw("Cannot convert between EnsEMBL objects.\n[$in] to [$out]");
}elsif($in =~ /^Bio::EnsEMBL::(\S+)/){
return 'Bio::EnsEMBL::Utils::Converter::ens_bio';
}elsif($out =~ /^Bio::EnsEMBL::(\S+)/){
return 'Bio::EnsEMBL::Utils::Converter::bio_ens';
}else{
$self->throw("Cannot convert between non-EnsEMBL objects.\n[$in] to [$out]");
}
lib/Bio/EnsEMBL/Utils/Converter/bio_ens.pm view on Meta::CPAN
=cut
sub new {
my ($caller, @args) = @_;
my $class = ref($caller) || $caller;
if($class eq 'Bio::EnsEMBL::Utils::Converter::bio_ens'){
my %params = @args;
@params{map{lc $_} keys %params} = values %params;
my $module = $class->_guess_module($params{-in}, $params{-out});
return undef unless ($class->_load_module($module));
return "$module"->new(@args);
}else{
my $self = $class->SUPER::new(@args);
# $self->_initialize(@args);
return $self;
}
}
sub _initialize {
lib/Bio/EnsEMBL/Utils/Converter/bio_ens.pm view on Meta::CPAN
}else{
# No contig information
}
if(defined $translation_id){
$self->translation_id($translation_id);
}
}
sub _guess_module {
my ($self, $in, $out) = @_;
my $tail;
if($in eq 'Bio::Search::HSP::GenericHSP'){
$tail = 'bio_ens_hsp';
}elsif($in eq 'Bio::SeqFeature::Generic'){
$tail = 'bio_ens_seqFeature';
}elsif($in eq 'Bio::SeqFeature::FeaturePair'){
$tail = 'bio_ens_featurePair';
}elsif($in eq 'Bio::Pipeline::Analysis'){
$tail = 'bio_ens_analysis';
lib/Bio/EnsEMBL/Utils/Converter/ens_bio.pm view on Meta::CPAN
Please see Bio::EnsEMBL::Utils::Converter::new
=cut
sub new {
my ($caller, @args) = @_;
my $class = ref($caller) || $caller;
if($class eq 'Bio::EnsEMBL::Utils::Converter::ens_bio'){
my %params = @args;
@params{map{lc $_} keys %params} = values %params;
my $module = $class->_guess_module($params{-in}, $params{-out});
return undef unless ($class->_load_module($module));
return "$module"->new(@args);
}else{
my $self = $class->SUPER::new(@args);
# $self->_initialize(@args);
return $self;
}
}
# Unlike bio_ens, ens_bio does not need _initialize method for analysis and
# contig information.
#
sub _guess_module {
my ($self, $in, $out) = @_;
my $tail;
if($in eq 'Bio::EnsEMBL::SeqFeature'){
$tail = 'ens_bio_seqFeature';
}elsif($in eq 'Bio::Ens::EMBL::FeaturePair'){
$tail = 'ens_bio_featurePair';
}else{
$self->throw("[$in] to [$out], not supported");
}
return "Bio::EnsEMBL::Utils::Converter::$tail";