6 use Scalar::Util qw(looks_like_number);
9 use Utils qw($split_resid sort_resid);
13 DSSP::SCOP - Module to select DSSP records from SCOP description
17 my $dssp = DSSP::SCOP->new(read_file => "foo.dssp");
18 my @range = $dssp->get_range("A:33-416");
22 A module that provides a method of selecting a range of residues from a DSSP file. The description of the range is in the format used by SCOP version 1.65 in the dir.des file.
26 The module inherits all the methods from the DSSP module.
28 =head2 $dssp->get_range("A:1-200,B:1-30")
30 Returns the DSSP::Position objects from within the range given. These are in the same order as they are presented in the DSSP file. They are returned as an array of array's, with each range having it's own array.
35 my ( $self, $defn ) = @_;
37 $defn =~ / / and croak "get_range('$defn') has a space in it, which isn't allowed";
38 my @ranges = split /,/, $defn;
46 my ( $chain, $range ) = split /:/, $_;
49 if ( $range =~ /([[:alnum:]]+)-([[:alnum:]]+)/ ) {
50 push @data, [ $self->select_positions( $chain, $1, $2 ) ];
55 confess "You shouldn't be here";
60 push @data, [ $self->get_chain_defs($chain) ];
65 if (/([[:alnum:]]+)-([[:alnum:]]+)/) {
66 my @chains = $self->chains;
68 die "Don't know which chain to select";
70 my ($chain) = @chains;
72 push @data, [ $self->select_positions( $chain, $1, $2 ) ];
77 for my $chain ( $self->chains ) {
78 push @data, [ $self->get_chain_defs($chain) ];
82 # Otherwise we don't know what it is
84 confess "Missed particular '$_'";
92 =head2 $self->select_positions($chain, $start, $end);
96 # Select those, $chain, $start, $end;
100 sub select_positions {
101 my ( $self, $chain, $start, $end ) = @_;
103 confess "Not passed all arguments" if grep { not defined } $chain, $start, $end;
104 confess "Not passed a valid chain" unless grep { $_ eq $chain } $self->chains;
106 my ( $flag, @positions ) = 0;
108 my ( $off, $start, $end ) = @_;
109 if ( 3 == grep { looks_like_number $_ } $off, $start, $end ) {
110 return 1 if $off >= $start and $off <= $end;
116 for my $pos ( $self->get_chain_defs($chain) ) {
118 push @positions, $pos if $flag;
124 ( $off eq $start or $test->( $off, $start, $end ) ) .. ( $off eq $end or $test->( $off, $start, $end ) )
126 # $test($off, $start, $end) $off >= $start and $off <= $end)
127 #($off eq $start or )
130 push @positions, $pos;