Advertisement
ProzacR

SASA

Jan 3rd, 2013
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.39 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. # SASA using Shrake-Rupley algorithm
  4. # calculate Solvent Accessible Surface Area
  5. # SASA
  6. # VR 2013
  7.  
  8. use Math::Trig;
  9. use Data::Dumper;
  10.  
  11.  
  12. #H2O radius:
  13. $prad=1.4;
  14.  
  15. #tasku sk. aplink atomus (daugiau tiksliau: ~simtai):
  16. $M=500;
  17.  
  18. #atoms example 0,1,...  (x,y,z,radius):
  19. @N[0] = [1,2,3,4];
  20. @N[1] = [0,1,2,3];
  21.  
  22.  
  23. $i = 0;
  24. $irad = 0;
  25.  
  26. while(@N[$i]) {
  27.  print "skersmuo: ", $N[$i][3];
  28.  $irad=$N[$i][3] + $prad;
  29.  while ($k<$M) {
  30.   $u=rand();
  31.   $v=rand();
  32.   $theta=2*pi*$u;
  33.   $phi=acos(2*$v-1);
  34.   $x=cos($theta)*sin($phi);
  35.   $y=sin($theta)*sin($phi);
  36.   $z=cos($phi);
  37.   #sukuriamas taskas:
  38.   $point[0]=$N[$i][0]+$x*$irad;
  39.   $point[1]=$N[$i][1]+$y*$irad;
  40.   $point[2]=$N[$i][2]+$z*$irad;
  41.   push @{$pts[$i][$k]}, @point;
  42.  $k++;
  43.  }
  44. $i++;
  45. $k = 0;
  46. }
  47.  
  48. #tasku visuma:
  49. #print Dumper \@pts;
  50.  
  51. #eit per atomus ir istrinti taskus kurie kito atomo kelyje:
  52. $i = 0;
  53. $k = 0;
  54.  
  55. while(@N[$i]) {
  56.  $irad=$N[$i][3] + $prad;
  57.  $Mp=$M;
  58.  while ($k<$M) {
  59.   #pt(:)=pts(i,k,:)
  60.   $fail=0;
  61.   $j=$i+1;
  62.   while(@N[$j]) {
  63.    $jrad=$N[$j][3] + $prad;
  64.    #jcoord=(/x,y,z/) of atom j
  65.    $r=sqrt(( ($pts[$i][$k][0]-$N[$j][0])+($pts[$i][$k][1]-$N[$j][1])+($pts[$i][$k][2]-$N[$j][2]) )**2);
  66.    if($r <= $jrad) {
  67.     $fail=1;
  68.    }
  69.   $j++;
  70.   }
  71.   if($fail) {
  72.    $Mp--;
  73.   }
  74.  $k++;
  75.  }
  76.  #SASA atomu i:
  77.  $sasa[$i]=4*pi*$irad*$irad*$Mp/$M;
  78. $i++;
  79. $k = 0;
  80. }
  81.  
  82. print "sasa: \n";
  83. print Dumper \@sasa;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement