Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #VR
- #keicia SO2NH2 grupe i SO2NH
- use Chemistry::MacroMol;
- use Chemistry::File::MDLMol;
- if(!-d "anijon_ligandai") {
- mkdir("anijon_ligandai", 0777);
- }
- while (@ARGV[$x]) {
- $macromol = Chemistry::MacroMol->read("@ARGV[$x]");
- print "\nKeiciamas ", @ARGV[$x], ": ";
- keisti();
- $x++;
- }
- sub keisti {
- #surenkami visi S atomai
- @all_atoms = $macromol->atoms;
- $a = 0;
- @S = ();
- while (@all_atoms[$a]) {
- push(@S, @all_atoms[$a]) if (@all_atoms[$a]->symbol eq 'S');
- $a++;
- }
- #randami 6valenciu S atomu kaimynai
- @Skaimynai = ();
- $b = 0;
- while (@S[$b]) {
- push (@Skaimynai, @S[$b]->neighbors) if (@S[$b]->valence == 6);
- $b++;
- }
- #print "Skaimynai ", @Skaimynai;
- #isrenkami kaimynai N
- @kaimynaiN = ();
- $c = 0;
- while (@Skaimynai[$c]) {
- push(@kaimynaiN, @Skaimynai[$c]) if (@Skaimynai[$c]->symbol eq 'N');
- $c++;
- }
- #print " kaimynaiN ", @kaimynaiN;
- #randami ju kaimynai
- @Nkaimynai = ();
- $d = 0;
- while (@kaimynaiN[$d]) {
- @Nkaimynai = @kaimynaiN[$d]->neighbors;
- #isrenkami kaimynai H kuriu turi buti 2
- @kaimynaiH = ();
- $e = 0;
- while (@Nkaimynai[$e]) {
- push(@kaimynaiH, @Nkaimynai[$e]) if (@Nkaimynai[$e]->symbol eq 'H');
- $e++;
- }
- #print " kaimynaiH ", @kaimynaiH;
- if (@kaimynaiH == 2) {
- @kaimynaiH[0]->delete;
- $out = @ARGV[$x];
- $macromol->write("anijon_ligandai/${out}");
- $macromol = ();
- print "OK!";
- last;
- }
- $d++;
- @Nkaimynai = ();
- }
- #print " Nkaimynai ", @Nkaimynai;
- print "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement