File: Clone.t

package info (click to toggle)
bioperl 1.7.7-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 35,888 kB
  • sloc: perl: 94,151; xml: 14,982; makefile: 20
file content (61 lines) | stat: -rw-r--r-- 2,587 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -*-Perl-*- Test Harness script for Bioperl

use strict;

BEGIN {
    use Bio::Root::Test;
    use Bio::SeqFeature::Generic;
    use Bio::Location::Split;

    test_begin(-tests => 17);
}

my $DEBUG = test_debug();

my $orig = Bio::SeqFeature::Generic->new(
                                       -start => 40,
                                       -end => 80,
                                       -strand => 1,
                                       -primary => 'exon',
                                       -source  => 'internal',
                                       -tag => {
                                           silly => 20,
                                           new => 1
                                           }
                                       );

# ----------
# Verify simple attributes work and are independent of each other
ok(my $clone = $orig->clone(),                'clone()');
ok($clone->start(140),                        'start() clone set');
is($clone->start(),     140,                  'start() clone get');
is($orig->start(),      40,                   'start() original unchanged');

# ----------
# Verify that arguments passed into clone() are applied to the cloned object
# and that the attributes are still independent.
ok($clone = $orig->clone(-start => 150, -end => 157),   'clone() with arguments');
is($orig->start(),       40,                  'start() orig get');
is($orig->end(),         80,                  'end() orig get');
is($clone->start(),     150,                  'start() clone get');
is($clone->end(),       157,                  'end() clone get');
ok($clone->start(140),                        'start() clone set');
is($clone->start(),     140,                  'start() clone get');
is($orig->start(),       40,                  'start() original unchanged');

# ----------
# Verify that object attributes can be cloned, and are independent after cloning
my $splitlocation = Bio::Location::Split->new();
$splitlocation->add_sub_Location(Bio::Location::Simple->new(
   -start=>1, -end=>30, -strand=>1
));
$splitlocation->add_sub_Location(Bio::Location::Simple->new(
   -start=>50, -end=>61, -strand=>1
));
ok($orig->location($splitlocation),                      'location() Bio::Location::Split');
ok($clone = $orig->clone(),                           'clone()');
ok(($clone->location->sub_Location())[1]->start(51),     'start() clone set');
is(($clone->location->sub_Location())[1]->start,     51, 'start() clone get');
is(($orig->location->sub_Location())[1]->start,      50, 'start() original unchanged');