A test to ensure Bio::PrimarySeqI->trunc() doesn't use clone() for a Bio::Seq::RichSe...
[bioperl-live.git] / t / Structure / IO.t
blob613341e9f56c8078e4ff283dbac368c6f4c6fba9
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN { 
7         use lib '.';
8     use Bio::Root::Test;
9     
10     test_begin(-tests => 14);
11         
12         use_ok('Bio::Structure::IO');
16 # test reading PDB format - single model, single chain
18 my $pdb_file = test_input_file('1BPT.pdb');
19 ok my $structin = Bio::Structure::IO->new(-file => $pdb_file, 
20                                                                                   -format => 'pdb');
21 ok my $struc = $structin->next_structure;
22 isa_ok $struc, "Bio::Structure::Entry";
24 # some basic checks, Structure objects are tested in Structure.t
25 my ($chain) = $struc->chain;
26 is($struc->residue, 97);
27 my ($atom) = $struc->get_atom_by_serial(367);
28 is($atom->id, "NZ");
29 is($struc->parent($atom)->id, "LYS-46");
30 my ($ann) = $struc->annotation->get_Annotations("author");
31 is($ann->as_text,
32         "Value: D.HOUSSET,A.WLODAWER,F.TAO,J.FUCHS,C.WOODWARD              ");
33 ($ann) = $struc->annotation->get_Annotations("header");
34 is($ann->as_text,
35         "Value: PROTEINASE INHIBITOR (TRYPSIN)          11-DEC-91   1BPT");
36 my $pseq = $struc->seqres;
37 is($pseq->subseq(1,20), "RPDFCLEPPYTGPCKARIIR");
40 # test reading PDB format - single model, multiple chains
42 $pdb_file = test_input_file('1A3I.pdb');
43 $structin = Bio::Structure::IO->new(-file => $pdb_file, 
44                                                                         -format => 'pdb');
45 $struc = $structin->next_structure;
47 my ($chaincount,$rescount,$atomcount);
48 for my $chain ($struc->get_chains) {
49         $chaincount++;
50    for my $res ($struc->get_residues($chain)) {
51                 $rescount++;
52       for my $atom ($struc->get_atoms($res)) {
53                         $atomcount++;
54                 }
55    }
58 is($chaincount, 4);  # 3 polypeptides and a group of hetero-atoms
59 is($rescount, 60);   # amino acid residues and solvent molecules
60 is($atomcount, 171); # ATOM and HETATM
63 # test reading PDB format - multiple models, single chain
65 #$pdb_file = test_input_file('1A11.pdb');
66 # TODO?
69 # test reading PDB format - chains with ATOMs plus HETATMs
71 #$pdb_file = test_input_file('8HVP.pdb');
72 # TODO?
75 # test writing PDB format
77 my $out_file = test_output_file();
78 my $structout = Bio::Structure::IO->new(-file => ">$out_file", 
79                                         -format => 'PDB');
80 $structout->write_structure($struc);
81 ok -s $out_file;