Advertisement
ProzacR

rasti_N_prieSO2NH2

Aug 30th, 2011
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.44 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #VR
  3. #randa S-C-SO2NH2
  4.  
  5. use Chemistry::MacroMol;
  6. use Chemistry::File::MDLMol;
  7.  
  8. if(!-d "N_ligandai") {
  9. mkdir("N_ligandai", 0777);
  10. }
  11.  
  12. while (@ARGV[$x]) {
  13. $macromol = Chemistry::MacroMol->read("@ARGV[$x]");
  14. print "\nTikrinamas ", @ARGV[$x], ": ";
  15. rasti();
  16. $x++;
  17. }
  18.  
  19. sub rasti {
  20.  
  21. #surenkami visi S atomai
  22. @all_atoms = $macromol->atoms;
  23. $a = 0;
  24. @S = ();
  25. while (@all_atoms[$a]) {
  26. push(@S, @all_atoms[$a]) if (@all_atoms[$a]->symbol eq 'S');
  27. $a++;
  28. }
  29.  
  30. #randami 6valenciu S atomu kaimynai
  31. @Skaimynai = ();
  32. $b = 0;
  33. while (@S[$b]) {
  34. push (@Skaimynai, @S[$b]->neighbors) if (@S[$b]->valence == 6);
  35. $b++;
  36. }
  37. #print "Skaimynai ", @Skaimynai;
  38.  
  39. #isrenkami kaimynai C
  40. @kaimynaiC = ();
  41. $c = 0;
  42. while (@Skaimynai[$c]) {
  43. push(@kaimynaiC, @Skaimynai[$c]) if (@Skaimynai[$c]->symbol eq 'C');
  44. $c++;
  45. }
  46. #print " kaimynaiC ", @kaimynaiC;
  47.  
  48. #randami ju kaimynai
  49. @Ckaimynai = ();
  50. $d = 0;
  51. while (@kaimynaiC[$d]) {
  52.      @Ckaimynai = @kaimynaiC[$d]->neighbors;
  53.      @kaimynaiS = ();
  54.      $e = 0;
  55.      #randami kaimynai N
  56.      while (@Ckaimynai[$e]) {
  57.       push(@kaimynaiS, @Ckaimynai[$e]) if (@Ckaimynai[$e]->symbol eq 'N');
  58.       $e++;
  59.       }
  60.      #print " kaimynaiS ", @kaimynaiS;
  61.      if (@kaimynaiS == 1) {
  62.      $out = @ARGV[$x];
  63.      $macromol->write("N_ligandai/${out}");
  64.      $macromol = ();
  65.      print "OK!";
  66.      last;
  67.      }
  68.   $d++;
  69.   @Ckaimynai = ();
  70.   }
  71. #print " Nkaimynai ", @Nkaimynai;
  72. print "\n";
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement