Advertisement
ProzacR

tikrinti_rezultatus

Jul 15th, 2011
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.95 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #VR
  3. #is *.mol isrenka ta kurio -SO2NH2 yra arciausiai Zn
  4.  
  5. use Chemistry::MacroMol;
  6. use Chemistry::File::MDLMol;
  7. use Chemistry::File::PDB;
  8. use List::Util qw[min max];
  9.  
  10.  
  11. while (@ARGV[$x]) {
  12. $macromol = Chemistry::MacroMol->read("@ARGV[$x]");
  13. #print "\nTikrinamas ", @ARGV[$x], ": ";
  14.  
  15. #imam Zn geroj padetyje
  16. $znmol = Chemistry::MacroMol->read("ZN.pdb");
  17. $Zn = $znmol->atoms_by_name('ZN');
  18. if ($topd > tikrinti(rastiN()) || $x == 0) {
  19. $topd = tikrinti(rastiN());
  20. $geriausias = $x;
  21. }
  22. $x++;
  23. }
  24. print @ARGV[$geriausias], "\n";
  25.  
  26. sub tikrinti {
  27. @d = ();
  28. $i = 0;
  29. while (@_[$i]) {
  30. #print @S[$b]->distance($Zn), " ";
  31. @d[$i] = @_[$i]->distance($Zn);
  32. $i++;
  33. }
  34. return min(@d);
  35. }
  36.  
  37.  
  38. while (@ARGV[$x]) {
  39. $macromol = Chemistry::MacroMol->read("@ARGV[$x]");
  40. print "\nKeiciamas ", @ARGV[$x], ": ";
  41. keisti();
  42. $x++;
  43. }
  44.  
  45. sub rastiN {
  46. @sulfonamidN = ();
  47.  
  48. #surenkami visi S atomai
  49. @all_atoms = $macromol->atoms;
  50. $a = 0;
  51. @S = ();
  52. while (@all_atoms[$a]) {
  53. push (@S, @all_atoms[$a]) if (@all_atoms[$a]->symbol eq 'S');
  54. $a++;
  55. }
  56.  
  57. #randami 6valenciu S atomu kaimynai
  58. @Skaimynai = ();
  59. $b = 0;
  60. while (@S[$b]) {
  61. push (@Skaimynai, @S[$b]->neighbors) if (@S[$b]->valence == 6);
  62. $b++;
  63. }
  64. #print "Skaimynai ", @Skaimynai;
  65.  
  66. #isrenkami kaimynai N
  67. @kaimynaiN = ();
  68. $c = 0;
  69. while (@Skaimynai[$c]) {
  70. push (@kaimynaiN, @Skaimynai[$c]) if (@Skaimynai[$c]->symbol eq 'N');
  71. $c++;
  72. }
  73. #print " kaimynaiN ", @kaimynaiN;
  74.  
  75. #randami ju kaimynai
  76. @Nkaimynai = ();
  77. $d = 0;
  78. while (@kaimynaiN[$d]) {
  79.   @Nkaimynai = @kaimynaiN[$d]->neighbors;
  80.   #isrenkami kaimynai H kuriu turi buti 2
  81.   @kaimynaiH = ();
  82.   $e = 0;
  83.   while (@Nkaimynai[$e]) {
  84.   push (@kaimynaiH, @Nkaimynai[$e]) if (@Nkaimynai[$e]->symbol eq 'H');
  85.   $e++;
  86.   }
  87.   #print " kaimynaiH ", @kaimynaiH;
  88.   if (@kaimynaiH == 2) {
  89.   push (@sulfonamidN, @kaimynaiN[$d]);
  90.   }
  91.   $d++;
  92.   @Nkaimynai = ();
  93. }
  94. #print " Nkaimynai ", @Nkaimynai;
  95. #print @sulfonamidN;
  96. return @sulfonamidN;
  97. print "\n";
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement