Emmanuel,
Are you trying to wrap bioperl modules? The use of $self->_rearrange()
gives it away, not to mention the 'so:xxxxx' (sequence ontology).
You should probably use delegation, or something like MooseX::NonMoose;
bioperl's class structure has issues (believe me, I'm a core dev for the
project).
chris
(PS: FWIW, I'm rewriting some of the core modules in Moose but they need
serious work)
On Fri, 2010-03-05 at 15:49 +0100, Emmanuel Quevillon wrote:
> Stevan Little wrote:
> >
> > On Mar 5, 2010, at 9:06 AM, Emmanuel Quevillon wrote:
> >> Joel Bernstein wrote:
> >>> On 5 Mar 2010, at 13:37, Emmanuel Quevillon wrote:
> >>>> By the way, I use a self coded 'new' method to create my object.
> >>>> Would it be the problem?
> >>>
> >>> Yes. But you omitted the code that doesn't work, so... Good luck!
> >>>
> >>> /joel
> >>
> >> oops sorry,
> >>
> >> sub new {
> >>
> >> my($class, %args) = @_;
> >>
> >> my $self = $class->SUPER::new(%args);
> >>
> >> $self->_init(%args);
> >> $self->_build_types(%args);
> >> return $self;
> >> }
> >>
> >> Later in the code is try $self->so_type(), nothing is returned...
> >
> > Honestly, this should work, however you very well might be doing
> > something in _init or _build_types that causes the problem. Perhaps
> > showing us some more code would help.
> >
> > You might also try changing your "new" to this:
> >
> > sub BUILD {
> > my($self, $args) = @_;
> > $self->_init(%$args);
> > $self->_build_types(%$args);
> > }
> >
> > .. which is a little more Moosey.
> >
> > - stevan
> >
> I tried without success :
>
> Here are the methods :
>
> sub BUILD {
>
> my($self, $args) = @_;
>
> $self->_init(%$args);
> $self->_build_types(%$args);
>
> }
>
>
> sub _init {
>
> my($self, %args) = @_;
>
> my($output, $cut_type, $format, $style) =
> $self->_rearrange([qw/OUTPUT CUT_TYPES FORMAT STYLE/], %args);
>
> $format && $self->_set_format (lc($format));
> $cut_type && $self->_set_cut_types($cut_type);
> $self->_set_style (lc($style) || 'text');
> $self->_set_output($output);
>
> return $self;
> }
>
> sub _build_types {
>
> my($self, %args) = @_;
>
> $self->{_types} = [ ];
>
> foreach my $type (sort { $a cmp $b } @{$self->cut_types()}){
> $type = lc($type);
> my $obj = "Bio::Restriction::Analysis::FramedCut::$type";
> $self->add_type($obj->new(%args));
> }
>
> return;
> }
>
> If I put some print into these method, nothing is printed out on my
> screen. Looks like there are not called at all. :(
>
> I'm really lost :(
>