BioPerl
view release on metacpan or search on metacpan
Bio/Structure/SecStr/DSSP/Res.pm view on Meta::CPAN
Args : if none => returns residue ids of all residues of all
chains (in order); if chain id is given, returns just the residue
ids of residues in that chain
=cut
# Can't use the standard interface for getting the amino acid,
# pdb_resnum, etc. in this method because we don't *know* the residue
# indentifiers - we are building a list of them.
sub residues {
my $self = shift;
my $chain = shift;
my @residues;
my $num_res = $self->_numResLines();
my $aa;
for ( my $i = 1; $i <= $num_res; $i++ ) {
# find what character was in the slot for tha amino acid code,
# if it's a '!' we know this is not a *real* amino acid, it's
# a chain discontinuity marker
$aa = $self->{ 'Res' }->[ $i ]->{ 'amino_acid' };
if ( $aa ne '!' ) {
if ( !$chain ||
$chain eq $self->{ 'Res' }->[ $i ]->{ 'pdb_chain' } ) {
push( @residues,
$self->{ 'Res' }->[ $i ]->{ 'pdb_resnum' }.
$self->{ 'Res' }->[ $i ]->{ 'insertionco' }.
":".
$self->{ 'Res' }->[ $i ]->{ 'pdb_chain' } );
}
}
}
return @residues;
}
=head2 getSeq
Title : getSeq
Usage : returns a Bio::PrimarySeq object which represents a good
guess at the sequence of the given chain
Function : For most chains of most entries, the sequence returned by
this method will be very good. However, it is inherently
unsafe to rely on DSSP to extract sequence information about
a PDB entry. More reliable information can be obtained from
the PDB entry itself.
Example : $pso = $dssp_obj->getSeq( 'A' );
Returns : (pointer to) a PrimarySeq object
Args : Chain identifier. If none given, ' ' is assumed. If no ' '
chain, the first chain is used.
=cut
sub getSeq {
my $self = shift;
my $chain = shift;
my ( $pot_chain,
$seq,
$frag_num,
$frag,
$curPdbNum,
$lastPdbNum,
$gap_len,
$i,
$id,
);
my @frags;
if ( !( $chain ) ) {
$chain = ' ';
}
if ( $self->{ 'Seq' }->{ $chain } ) {
return $self->{ 'Seq' }->{ $chain };
}
my $contSegs_pnt = $self->_contSegs();
# load up specified chain
foreach $pot_chain ( @{ $contSegs_pnt } ) {
if ( $pot_chain->[ 2 ] eq $chain ) {
push( @frags, $pot_chain );
}
}
# if that didn't work, just get the first one
if ( !( @frags ) ) {
$chain = $contSegs_pnt->[ 0 ]->[ 2 ];
foreach $pot_chain ( @{ $contSegs_pnt } ) {
if ( $pot_chain->[ 2 ] eq $chain ) {
push( @frags, $pot_chain );
}
}
}
# now build the sequence string
$seq = "";
$frag_num = 0;
foreach $frag ( @frags ) {
$frag_num++;
if ( $frag_num > 1 ) { # we need to put in some gap seq
$curPdbNum = $self->_pdbNum( $frag->[ 0 ] );
$gap_len = $curPdbNum - $lastPdbNum - 1;
if ( $gap_len > 0 ) {
$seq .= 'u' x $gap_len;
}
else {
$seq .= 'u';
}
}
for ( $i = $frag->[ 0 ]; $i <= $frag->[ 1 ]; $i++ ) {
$seq .= $self->_resAA( $i );
}
$lastPdbNum = $self->_pdbNum( $i - 1 );
}
$id = $self->pdbID();
$id .= ":$chain";
$self->{ 'Seq' }->{ $chain } = Bio::PrimarySeq->new ( -seq => $seq,
-id => $id,
-moltype => 'protein'
);
return $self->{ 'Seq' }->{ $chain };
}
=head1 INTERNAL METHODS
=cut
=head2 _pdbChain
Title : _pdbChain
Usage : returns the pdb chain id of given residue
Function :
Example : $chain_id = $dssp_obj->pdbChain( DSSP_KEY );
Returns : scalar
Args : DSSP_KEY ( dssp or pdb )
=cut
sub _pdbChain {
my $self = shift;
my $dssp_key = shift;
return $self->{ 'Res' }->[ $dssp_key ]->{ 'pdb_chain' };
}
=head2 _resAA
Title : _resAA
Usage : fetches the 1 char amino acid code, given a dssp id
Function :
Example : $aa = $dssp_obj->_resAA( dssp_id );
Returns : 1 character scalar string
Args : dssp_id
=cut
sub _resAA {
my $self = shift;
my $dssp_key = shift;
return $self->{ 'Res' }->[ $dssp_key ]->{ 'amino_acid' };
}
=head2 _pdbNum
( run in 0.905 second using v1.01-cache-2.11-cpan-364913b4093 )