Advertisement
ProzacR

converts -SO2NH2 into -SO2NH

Jul 11th, 2011
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.46 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #VR
  3. #keicia SO2NH2 grupe i SO2NH
  4.  
  5. use Chemistry::MacroMol;
  6. use Chemistry::File::MDLMol;
  7.  
  8. if(!-d "anijon_ligandai") {
  9. mkdir("anijon_ligandai", 0777);
  10. }
  11.  
  12. while (@ARGV[$x]) {
  13. $macromol = Chemistry::MacroMol->read("@ARGV[$x]");
  14. print "\nKeiciamas ", @ARGV[$x], ": ";
  15. keisti();
  16. $x++;
  17. }
  18.  
  19. sub keisti {
  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 N
  40. @kaimynaiN = ();
  41. $c = 0;
  42. while (@Skaimynai[$c]) {
  43. push(@kaimynaiN, @Skaimynai[$c]) if (@Skaimynai[$c]->symbol eq 'N');
  44. $c++;
  45. }
  46. #print " kaimynaiN ", @kaimynaiN;
  47.  
  48. #randami ju kaimynai
  49. @Nkaimynai = ();
  50. $d = 0;
  51. while (@kaimynaiN[$d]) {
  52.   @Nkaimynai = @kaimynaiN[$d]->neighbors;
  53.   #isrenkami kaimynai H kuriu turi buti 2
  54.   @kaimynaiH = ();
  55.   $e = 0;
  56.   while (@Nkaimynai[$e]) {
  57.   push(@kaimynaiH, @Nkaimynai[$e]) if (@Nkaimynai[$e]->symbol eq 'H');
  58.   $e++;
  59.   }
  60.   #print " kaimynaiH ", @kaimynaiH;
  61.   if (@kaimynaiH == 2) {
  62.   @kaimynaiH[0]->delete;
  63.   $out = @ARGV[$x];
  64.   $macromol->write("anijon_ligandai/${out}");
  65.   $macromol = ();
  66.   print "OK!";
  67.   last;
  68.   }
  69.   $d++;
  70.   @Nkaimynai = ();
  71. }
  72. #print " Nkaimynai ", @Nkaimynai;
  73.  
  74. print "\n";
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement