From 590b84028b429e589e402ace5875e99353a74b69 Mon Sep 17 00:00:00 2001 From: Tiago Grego <tgrego@ebi.ac.uk> Date: Thu, 8 Feb 2018 16:42:07 +0000 Subject: [PATCH] added new_fast() to Biotype and used it from BiotypeAdaptor --- modules/Bio/EnsEMBL/Biotype.pm | 20 ++++++++++++++++++++ modules/Bio/EnsEMBL/DBSQL/BiotypeAdaptor.pm | 20 ++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/modules/Bio/EnsEMBL/Biotype.pm b/modules/Bio/EnsEMBL/Biotype.pm index 11b7c5e104..9adef5a13c 100644 --- a/modules/Bio/EnsEMBL/Biotype.pm +++ b/modules/Bio/EnsEMBL/Biotype.pm @@ -64,6 +64,7 @@ use Bio::EnsEMBL::Storable; use Bio::EnsEMBL::Utils::Exception qw(throw deprecate warning); use Bio::EnsEMBL::Utils::Scalar qw(check_ref assert_ref); use Bio::EnsEMBL::Utils::Argument qw(rearrange); +use Scalar::Util qw(weaken isweak); use base qw(Bio::EnsEMBL::Storable); @@ -115,6 +116,25 @@ sub new { return $self; } +=head2 new_fast + + Arg [1] : hashref to be blessed + Description: Construct a new Bio::EnsEMBL::Biotype using the hashref. + Exceptions : none + Returntype : Bio::EnsEMBL::Biotype + +=cut + + +sub new_fast { + my ( $class, $hashref ) = @_; + + my $self = bless $hashref, $class; + weaken($self->{adaptor}) if ( ! isweak($self->{adaptor}) ); + + return $self; +} + =head2 name Arg [1] : (optional) string $name diff --git a/modules/Bio/EnsEMBL/DBSQL/BiotypeAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/BiotypeAdaptor.pm index 97ebb4144a..d1956332a6 100644 --- a/modules/Bio/EnsEMBL/DBSQL/BiotypeAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/BiotypeAdaptor.pm @@ -115,16 +115,16 @@ sub _objs_from_sth { while($sth->fetch()) { push( @biotypes, - my $feat = Bio::EnsEMBL::Biotype->new( - -BIOTYPE_ID => $dbID, - -NAME => $name, - -OBJECT_TYPE => $object_type, - -DB_TYPE => $db_type, - -ATTRIB_TYPE_ID => $attrib_type_id, - -DESCRIPTION => $description, - -BIOTYPE_GROUP => $biotype_group, - -SO_ACC => $so_acc, - ) + my $feat = Bio::EnsEMBL::Biotype->new_fast( { + 'dbID' => $dbID, + 'name' => $name, + 'object_type' => $object_type, + 'db_type' => $db_type, + 'attrib_type_id' => $attrib_type_id, + 'description' => $description, + 'biotype_group' => $biotype_group, + 'so_acc' => $so_acc, + } ) ); } -- GitLab