MMTSB
Tool Set Documentation

Difference between revisions of "analyze.pl"

From MMTSB
Jump to: navigation, search
 
Line 6: Line 6:
 
== Description ==
 
== Description ==
  
 +
This tool runs the perl function given in the script file for the structure given as argument. The perl function has to be named <TT>analyze</TT>. It is
 +
passed a <TT>Molecule</TT> object as argument and expects one or more
 +
values to be returned.
 +
 +
An example for a function that calculates the end-to-end distance for the
 +
N- and C-terminal C-alpha atoms of the first chain from a given structure
 +
is given in the following:
 +
 +
  sub analyze {
 +
    my $mol=shift;
 +
    my @data=(); 
 +
    my $res=$mol->{chain}->[0]->{res};
 +
    my $atom=$mol->{chain}->[0]->{atom};
 +
 +
    my $ca1;
 +
    for (my $ia=$res->[0]->{start}; $ia<=$res->[0]->{end}; $ia++) {
 +
      $ca1=$atom->[$ia] if ($atom->[$ia]->{atomname} eq "CA");
 +
        $ca1=$atom->[$ia];
 +
      }
 +
    }
 +
 +
  my $ca2;
 +
  for (my $ia=$res->[$#{$res}]->{start}; $ia<=$res->[$#{$res}]->{end}; $ia++) {
 +
    if ($atom->[$ia]->{atomname} eq "CA") {
 +
      $ca2=$atom->[$ia];
 +
    }
 +
  }
 +
 +
  my $dx=$ca1->{xcoor}-$ca2->{xcoor};
 +
  my $dy=$ca1->{ycoor}-$ca2->{ycoor};
 +
  my $dz=$ca1->{zcoor}-$ca2->{zcoor};
 +
 +
  push(@data, sqrt($dx*$dx+$dy*$dy+$dz*$dz));
 +
 +
  return @data;
 +
}
 +
 +
1;
  
 
== Options ==
 
== Options ==

Revision as of 01:36, 28 July 2009

Usage

usage: analyze.pl -function file [pdbFile]

Show source


Description

This tool runs the perl function given in the script file for the structure given as argument. The perl function has to be named analyze. It is passed a Molecule object as argument and expects one or more values to be returned.

An example for a function that calculates the end-to-end distance for the N- and C-terminal C-alpha atoms of the first chain from a given structure is given in the following:

 sub analyze {
   my $mol=shift;
   my @data=();  
   my $res=$mol->{chain}->[0]->{res};
   my $atom=$mol->{chain}->[0]->{atom};

   my $ca1;
   for (my $ia=$res->[0]->{start}; $ia<=$res->[0]->{end}; $ia++) {
     $ca1=$atom->[$ia] if ($atom->[$ia]->{atomname} eq "CA");
       $ca1=$atom->[$ia];
     }
   }
 my $ca2;
 for (my $ia=$res->[$#{$res}]->{start}; $ia<=$res->[$#{$res}]->{end}; $ia++) {
   if ($atom->[$ia]->{atomname} eq "CA") {
     $ca2=$atom->[$ia];
   }
 }
 my $dx=$ca1->{xcoor}-$ca2->{xcoor};
 my $dy=$ca1->{ycoor}-$ca2->{ycoor};
 my $dz=$ca1->{zcoor}-$ca2->{zcoor};
 push(@data, sqrt($dx*$dx+$dy*$dy+$dz*$dz));
 return @data;

}

1;

Options

-help 
usage information


Examples