On Mar 5, 2010, at 10:35 AM, Emmanuel Quevillon wrote:

> Hi Chris,
> 
> I know you're a core dev;)
> Well not a wrapper I'm just extending restriction::analysis and wanted to do 
> it with moose. But apparently it is much difficult than expected.
> Moreover I'm nit really comfortable with moose, I must admit I don't 
> understand all the concepts :(.
> I didn't realize 'rearrange' would break moose. But anyway it looks like even 
> the subs around moose'new methods are not called. It is really obscure for me 
> at this time.

It's not that it breaks moose (or vice versa).  BioPerl has a specific named 
argument syntax and related methods that are problematic when mixed with Moose; 
in BioPerl all named arguments in bioperl start with '-' to distinguish them 
from simple positional arguments.  With Moose OTOH, I think everything is 
treated as named by default in the constructor (e.g. no '-' needed), but the 
behavior can be overridden with BUILDARGS (please correct me if I'm wrong moose 
illuminati).  

Regardless I'm pretty sure _rearrange() doesn't work w/o '-', so I could 
definitely foresee some problems here going back and forth between Moose and 
BioPerl without doing some work in BUILDARGS.

> Either I'll stay with the current biopel code structure or if someone has an 
> explanation....

I wouldn't want to dissuade you from using Moose; I'm using it extensively in 
non-bioperl-based work, along with DBIx::Class.  Hence the reason I'm writing 
up a library of Moose-based BioPerl classes.

Anyway, I suggest MooseX::NonMoose (I see Stevan and Jesse have already 
responded likewise) and going from there.

> Anyway thanks for your helps
> 
> Emmanuel

np.

chris

> Le 5 mars 2010 à 16:53, Chris Fields <[email protected]> a écrit :
> 
>> 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 :(
>>> 
>> 
> 
> 
> Le 5 mars 2010 à 16:53, Chris Fields <[email protected]> a écrit :
> 
>> 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 :(
>>> 
>> 
>> 

Reply via email to