6 use Scalar::Util qw(looks_like_number);
10 use Utils qw($split_resid sort_resid);
14 DSSP::SCOP - Module to select DSSP records from SCOP description
18 my $dssp = DSSP::SCOP->new(read_file => "foo.dssp");
19 my @range = $dssp->get_range("A:33-416");
23 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.
27 The module inherits all the methods from the DSSP module.
29 =head2 $dssp->get_range("A:1-200,B:1-30")
31 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.
36 my ( $self, $defn ) = @_;
38 $defn =~ / / and croak "get_range('$defn') has a space in it, which isn't allowed";
39 my @ranges = split /,/, $defn;
47 my ( $chain, $range ) = split /:/, $_;
50 if ( $range =~ /([[:alnum:]]+)-([[:alnum:]]+)/ ) {
51 push @data, [ $self->select_positions( $chain, $1, $2 ) ];
56 confess "You shouldn't be here";
61 push @data, [ $self->get_chain_defs($chain) ];
66 if (/([[:alnum:]]+)-([[:alnum:]]+)/) {
67 my @chains = $self->chains;
69 die "Don't know which chain to select";
71 my ($chain) = @chains;
73 push @data, [ $self->select_positions( $chain, $1, $2 ) ];
78 for my $chain ( $self->chains ) {
79 push @data, [ $self->get_chain_defs($chain) ];
83 # Otherwise we don't know what it is
85 confess "Missed particular '$_'";
93 =head2 $self->select_positions($chain, $start, $end);
97 # Select those, $chain, $start, $end;
101 sub select_positions {
102 my ( $self, $chain, $start, $end ) = @_;
104 confess "Not passed all arguments" if grep { not defined } $chain, $start, $end;
105 confess "Not passed a valid chain" unless grep { $_ eq $chain } $self->chains;
107 my ( $flag, @positions ) = 0;
109 my ( $off, $start, $end ) = @_;
110 if ( 3 == grep { looks_like_number $_ } $off, $start, $end ) {
111 return 1 if $off >= $start and $off <= $end;
117 for my $pos ( $self->get_chain_defs($chain) ) {
119 push @positions, $pos if $flag;
125 ( $off eq $start or $test->( $off, $start, $end ) ) .. ( $off eq $end or $test->( $off, $start, $end ) )
127 # $test($off, $start, $end) $off >= $start and $off <= $end)
128 #($off eq $start or )
131 push @positions, $pos;