Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #VR
- #randa S-C-SO2NH2
- use Chemistry::MacroMol;
- use Chemistry::File::MDLMol;
- if(!-d "N_ligandai") {
- mkdir("N_ligandai", 0777);
- }
- while (@ARGV[$x]) {
- $macromol = Chemistry::MacroMol->read("@ARGV[$x]");
- print "\nTikrinamas ", @ARGV[$x], ": ";
- rasti();
- $x++;
- }
- sub rasti {
- #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 C
- @kaimynaiC = ();
- $c = 0;
- while (@Skaimynai[$c]) {
- push(@kaimynaiC, @Skaimynai[$c]) if (@Skaimynai[$c]->symbol eq 'C');
- $c++;
- }
- #print " kaimynaiC ", @kaimynaiC;
- #randami ju kaimynai
- @Ckaimynai = ();
- $d = 0;
- while (@kaimynaiC[$d]) {
- @Ckaimynai = @kaimynaiC[$d]->neighbors;
- @kaimynaiS = ();
- $e = 0;
- #randami kaimynai N
- while (@Ckaimynai[$e]) {
- push(@kaimynaiS, @Ckaimynai[$e]) if (@Ckaimynai[$e]->symbol eq 'N');
- $e++;
- }
- #print " kaimynaiS ", @kaimynaiS;
- if (@kaimynaiS == 1) {
- $out = @ARGV[$x];
- $macromol->write("N_ligandai/${out}");
- $macromol = ();
- print "OK!";
- last;
- }
- $d++;
- @Ckaimynai = ();
- }
- #print " Nkaimynai ", @Nkaimynai;
- print "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement