New INSTALL.WIN doc (from wiki)
[bioperl-live.git] / t / StructIO.t
blob5236a7e4263a9aa0d35514d635be520fa481fad0
1 # -*-Perl-*-
2 ## Bioperl Test Harness Script for Modules
3 ## $Id$
5 # Before `make install' is performed this script should be runnable with
6 # `make test'. After `make install' it should work as `perl test.t'
8 use strict;
10 BEGIN { 
11         # to handle systems with no installed Test module
12         # we include the t dir (where a copy of Test.pm is located)
13         # as a fallback
14         eval { require Test; };
15         if( $@ ) { 
16                 use lib 't';
17         }
18         use Test;
19         plan tests => 14;
22 use Bio::Structure::Entry;
23 use Bio::Structure::IO;
24 use Bio::Root::IO;
25 ok(1);
27 # test reading PDB format - single model, single chain
29 my $pdb_file = Bio::Root::IO->catfile("t","data","1BPT.pdb");
30 my $structin = Bio::Structure::IO->new(-file => $pdb_file, 
31                                                                                                         -format => 'pdb');
32 ok(1);
33 my $struc = $structin->next_structure;
34 ok(1);
35 ok(ref($struc), "Bio::Structure::Entry");
37 # some basic checks, Structure objects are tested in Structure.t
38 my ($chain) = $struc->chain;
39 ok($struc->residue, 97);
40 my ($atom) = $struc->get_atom_by_serial(367);
41 ok($atom->id, "NZ");
42 ok($struc->parent($atom)->id, "LYS-46");
43 my ($ann) = $struc->annotation->get_Annotations("author");
44 ok($ann->as_text,
45         "Value: D.HOUSSET,A.WLODAWER,F.TAO,J.FUCHS,C.WOODWARD              ");
46 ($ann) = $struc->annotation->get_Annotations("header");
47 ok($ann->as_text,
48         "Value: PROTEINASE INHIBITOR (TRYPSIN)          11-DEC-91   1BPT");
49 my $pseq = $struc->seqres;
50 ok($pseq->subseq(1,20), "RPDFCLEPPYTGPCKARIIR");
53 # test reading PDB format - single model, multiple chains
55 $pdb_file = Bio::Root::IO->catfile("t","data","1A3I.pdb");
56 $structin = Bio::Structure::IO->new(-file => $pdb_file, 
57                                                                                                 -format => 'pdb');
58 $struc = $structin->next_structure;
60 my ($chaincount,$rescount,$atomcount);
61 for my $chain ($struc->get_chains) {
62         $chaincount++;
63    for my $res ($struc->get_residues($chain)) {
64                 $rescount++;
65       for my $atom ($struc->get_atoms($res)) {
66                         $atomcount++;
67                 }
68    }
71 ok($chaincount, 4);  # 3 polypeptides and a group of hetero-atoms
72 ok($rescount, 60);   # amino acid residues and solvent molecules
73 ok($atomcount, 171); # ATOM and HETATM
76 # test reading PDB format - multiple models, single chain
78 $pdb_file = Bio::Root::IO->catfile("t","data","1A11.pdb");
81 # test reading PDB format - chains with ATOMs plus HETATMs
83 $pdb_file = Bio::Root::IO->catfile("t","data","8HVP.pdb");
86 # test writing PDB format
88 my $out_file = Bio::Root::IO->catfile("t","data","temp-pdb1bpt.ent");
89 my $structout = Bio::Structure::IO->new(-file => ">$out_file", 
90                                         -format => 'PDB');
91 $structout->write_structure($struc);
92 ok(1);
94 END {
95         unlink $out_file if -e $out_file;