Skip to content

Commit

Permalink
skip tests if the cloning class used happens to be Storable, see bug …
Browse files Browse the repository at this point in the history
…#3447
  • Loading branch information
Chris Fields committed Sep 10, 2013
1 parent ff265fc commit cf8e084
Showing 1 changed file with 72 additions and 67 deletions.
139 changes: 72 additions & 67 deletions t/SeqTools/SeqUtils.t
Original file line number Diff line number Diff line change
Expand Up @@ -584,74 +584,79 @@ my ($fragment_feat_lig) = grep ($_->primary_tag eq 'frag_feat1', $product->get_S
ok( $fragment_feat_lig, 'the fragment feature1 is now a feature of the product');
is_deeply( [$fragment_feat_lig->start, $fragment_feat_lig->end], [17,19], 'start and end of a feature on the fragment are correct after insertion with "flip" option');

# test clone_obj option (create new objects via clone not 'new')
my $foo_seq_obj = Bio::Seq::Foo->new(
-seq =>'aaaaaaaaaaccccccccccggggggggggtttttttttt',
-display_id => 'seq1',
-desc => 'some sequence for testing'
);
for ($composite_feat1, $feature1, $feature2, $feature3, $feature4, $feature5) {
$foo_seq_obj->add_SeqFeature( $_ );
}
$foo_seq_obj->annotation($coll);

dies_ok(
sub {
$product = Bio::SeqUtils->delete( $foo_seq_obj, 11, 20, { clone_obj => 0} );
},
"Trying to delete from an object of a custom Bio::Seq subclass that doesn't allow calling 'new' throws an error"
);

lives_ok(
sub {
$product = Bio::SeqUtils->delete( $foo_seq_obj, 11, 20, { clone_obj => 1} );
},
"Deleting from Bio::Seq::Foo does not throw an error when using the 'clone_obj' option to clone instead of calling 'new'"
);

isa_ok( $product, 'Bio::Seq::Foo');

# just repeat some of the tests for the cloned feature
ok(
grep ($_ eq 'deletion of 10bp',
map ($_->get_tag_values('note'),
grep ($_->primary_tag eq 'misc_feature', $product->get_SeqFeatures)
)
),
"the product has an additional 'misc_feature' and the note specifies the lengths of the deletion'"
);
($composite_feat1_del) = grep ($_->primary_tag eq 'comp_feat1', $product->get_SeqFeatures);
ok ($composite_feat1_del, "The composite feature is still present");
isa_ok( $composite_feat1_del, 'Bio::SeqFeature::Generic');
isa_ok( $composite_feat1_del->location, 'Bio::Location::Split', "a composite feature that spanned the deletion site has been split up, Location");

# ligate with clone_obj
dies_ok(
sub {
$product = Bio::SeqUtils->ligate(
-recipient => $foo_seq_obj,
-fragment => $fragment_obj,
-left => 10,
-right => 31,
-flip => 1
);
},
"'ligate' without clone_obj option dies with a Bio::Seq::Foo object that can't call new"
);

lives_ok(
sub {
$product = Bio::SeqUtils->ligate(
-recipient => $foo_seq_obj,
-fragment => $fragment_obj,
-left => 10,
-right => 31,
-flip => 1,
-clone_obj => 1,
);
},
"'ligate' with clone_obj option works with a Bio::Seq::Foo object that can't call new"
);
SKIP: {
skip("Storable::dclone not supported yet for Bio::SeqUtils, see ", 9) if $Bio::Root::Root::CLONE_CLASS eq 'Storable';

# test clone_obj option (create new objects via clone not 'new')
my $foo_seq_obj = Bio::Seq::Foo->new(
-seq =>'aaaaaaaaaaccccccccccggggggggggtttttttttt',
-display_id => 'seq1',
-desc => 'some sequence for testing'
);
for ($composite_feat1, $feature1, $feature2, $feature3, $feature4, $feature5) {
$foo_seq_obj->add_SeqFeature( $_ );
}
$foo_seq_obj->annotation($coll);

dies_ok(
sub {
$product = Bio::SeqUtils->delete( $foo_seq_obj, 11, 20, { clone_obj => 0} );
},
"Trying to delete from an object of a custom Bio::Seq subclass that doesn't allow calling 'new' throws an error"
);

lives_ok(
sub {
$product = Bio::SeqUtils->delete( $foo_seq_obj, 11, 20, { clone_obj => 1} );
},
"Deleting from Bio::Seq::Foo does not throw an error when using the 'clone_obj' option to clone instead of calling 'new'"
);

isa_ok( $product, 'Bio::Seq::Foo');

# just repeat some of the tests for the cloned feature
ok(
grep ($_ eq 'deletion of 10bp',
map ($_->get_tag_values('note'),
grep ($_->primary_tag eq 'misc_feature', $product->get_SeqFeatures)
)
),
"the product has an additional 'misc_feature' and the note specifies the lengths of the deletion'"
);
($composite_feat1_del) = grep ($_->primary_tag eq 'comp_feat1', $product->get_SeqFeatures);
ok ($composite_feat1_del, "The composite feature is still present");
isa_ok( $composite_feat1_del, 'Bio::SeqFeature::Generic');
isa_ok( $composite_feat1_del->location, 'Bio::Location::Split', "a composite feature that spanned the deletion site has been split up, Location");

# ligate with clone_obj
dies_ok(
sub {
$product = Bio::SeqUtils->ligate(
-recipient => $foo_seq_obj,
-fragment => $fragment_obj,
-left => 10,
-right => 31,
-flip => 1
);
},
"'ligate' without clone_obj option dies with a Bio::Seq::Foo object that can't call new"
);

lives_ok(
sub {
$product = Bio::SeqUtils->ligate(
-recipient => $foo_seq_obj,
-fragment => $fragment_obj,
-left => 10,
-right => 31,
-flip => 1,
-clone_obj => 1,
);
},
"'ligate' with clone_obj option works with a Bio::Seq::Foo object that can't call new"
);
}

sub uniq_sort {
my @args = @_;
Expand Down

0 comments on commit cf8e084

Please sign in to comment.