File: Structure.t

package info (click to toggle)
bioperl 1.4-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 20,336 kB
  • ctags: 8,476
  • sloc: perl: 119,890; xml: 6,001; lisp: 121; makefile: 57
file content (149 lines) | stat: -rw-r--r-- 3,590 bytes parent folder | download | duplicates (3)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# -*-Perl-*-
## Bioperl Test Harness Script for Modules
## $Id: Structure.t,v 1.5 2001/12/14 17:12:20 jason Exp $

# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.t'

use strict;

BEGIN { 
    # to handle systems with no installed Test module
    # we include the t dir (where a copy of Test.pm is located)
    # as a fallback
    eval { require Test; };
    if( $@ ) { 
	use lib 't';
    }
    use Test;
    plan tests => 52;
}
use Bio::Structure::Entry;
use Bio::Structure::Model;
use Bio::Structure::Chain;
use Bio::Structure::Residue;
use Bio::Structure::Atom;

ok(1);


my $entry = Bio::Structure::Entry->new;
ok(1);
ok defined  $entry;
ok ref($entry), 'Bio::Structure::Entry';

my $model = Bio::Structure::Model->new;
ok(1);
ok defined $model;
ok ref($model), 'Bio::Structure::Model';

my $chain = Bio::Structure::Chain->new;
ok(1);
ok defined $chain;
ok ref($chain), 'Bio::Structure::Chain';

my $residue = Bio::Structure::Residue->new;
ok(1);
ok defined $residue;
ok ref($residue), 'Bio::Structure::Residue';

my $atom = Bio::Structure::Atom->new;
ok(1);
ok defined $atom;
ok ref($atom), 'Bio::Structure::Atom';

# adding/removing to Entry
my $m1 = Bio::Structure::Model->new;
$entry->model($m1);
ok $entry->model,1;
my $m2 = Bio::Structure::Model->new;
$entry->add_model($m2);
ok $entry->get_models, 2;

$entry->model($m2);
ok $entry->model, 1;
my @m = ($m1, $m2);
$entry->model(\@m);
ok $entry->model, 2;

# does $m2 gest orphaned
$entry->model($m1);
ok $entry->parent($m2), undef;


# adding/removing to Model 
my $c1 = Bio::Structure::Chain->new;
$entry->add_chain($model,$c1);
ok $entry->get_chains($model),1;
my $c2 = Bio::Structure::Chain->new;
$entry->add_chain($model,$c2);
ok $entry->get_chains($model), 2;
ok ref($entry->parent($c1)), 'Bio::Structure::Model';
ok $entry->parent($c1), $entry->parent($c2);


# adding/removing to Chain 
my $r1 = Bio::Structure::Residue->new;
$entry->add_residue($chain,$r1);
ok $entry->get_residues($chain),1;
my $r2 = Bio::Structure::Residue->new;
$entry->add_residue($chain,$r2);
ok $entry->get_residues($chain), 2;

ok ref($entry->parent($r2)), 'Bio::Structure::Chain';
ok $entry->parent($r1), $entry->parent($r2);

# adding/removing to Residue 
$entry->add_atom($residue,$atom);
ok $entry->get_atoms($residue),1;
my $a2 = Bio::Structure::Atom->new;
my $a3 = Bio::Structure::Atom->new;
my $a4 = Bio::Structure::Atom->new;
my $a5 = Bio::Structure::Atom->new;
my $a6 = Bio::Structure::Atom->new;
$entry->add_atom($residue,$a2);
ok $entry->get_atoms($residue), 2;

my @a = ($a3, $a4, $a5);
$entry->add_atom($r2,\@a);
ok $entry->get_atoms($r2), 3;

ok ref($entry->parent($a2)), 'Bio::Structure::Residue';
ok $entry->parent($a3), $entry->parent($a5);



$atom->x(10.234);
ok $atom->x, 10.234;
my $y = 12.345;
$atom->y($y);
ok $atom->y, $y;
my $z = $atom->x - $y;
$atom->z($z);
ok $atom->z, -2.111;
my @xyz = $atom->xyz;
ok (scalar (@xyz), 3);

ok $xyz[0], 10.234;
ok $xyz[1], 12.345;
ok $xyz[2], -2.111;

my $e2 = Bio::Structure::Entry->new(-id => "Entry 2");
ok (1);
ok $e2->id, "Entry 2";
my $m3 = Bio::Structure::Model->new(-id => "Model 2");
ok (1);
ok $m3->id, "Model 2";
my $c3 = Bio::Structure::Chain->new(-id => "Chain 2");
ok (1);
ok $c3->id, "Chain 2";
my $r3 = Bio::Structure::Residue->new(-id => "Residue 2");
ok (1);
ok $r3->id, "Residue 2";
$a2 = Bio::Structure::Atom->new(-id => "Atom 2");
ok (1);
ok $a2->id, "Atom 2";

$entry->add_atom($r3,$a6);
$entry->add_residue($c3,$r3);
ok $entry->parent( $entry->parent($a6) )->id , "Chain 2";