some more README tweaks
[bioperl-live.git] / examples / structure / structure-io.pl
blob8cec9b4fff0e291e30ff1195ad95b8e00fb86cbd
1 #!/bin/perl
2 # Getting Entry, Chain, Residue, and Atom objects given a PDB file
4 use Bio::Structure::IO;
5 use strict;
7 my $file = shift or die "No PDB file\n";
8 my $structio = Bio::Structure::IO->new(-file => $file);
9 my $struc = $structio->next_structure;
11 for my $chain ($struc->get_chains) {
12 my $chainid = $chain->id;
13 # one-letter chaincode if present, 'default' otherwise
14 for my $res ($struc->get_residues($chain)) {
15 my $resid = $res->id;
16 # format is 3-lettercode - dash - residue number, e.g. PHE-20
17 my $atoms = $struc->get_atoms($res);
18 # actually a list of atom objects, used here to get a count
19 print join "\t", $chainid,$resid,$atoms,"\n";