Advertisement
ProzacR

another text parser 2

Feb 25th, 2013
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.65 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #
  3. # nuskaityti bindingdb sdf failus
  4. # H-Se/DB26984_50278320.sdf kaip testas imtas
  5. #
  6. # VR
  7. #
  8.  
  9. #use warnings;
  10. use Data::Dumper;
  11.  
  12.  
  13. #nuskaityti failus i @molekules
  14. die "usage VR_bindingdb_parse.pl file.sdf 'TARGET Biomolecule'" if (@ARGV != 2);
  15. $FILE = $ARGV[0];
  16. $target = $ARGV[1];
  17. open FILE, "<", $FILE or die $!;
  18. $x=0;
  19. $key='str';
  20. while(<FILE>) {
  21.  chop($_);
  22.  next if ($_ =~ /^$/);   #jei eilute tuscia praleidziam
  23.  if ($_ =~ /\$\$\$\$/) { #jei eiluteje yra: $$$$
  24.   $x++;
  25.   $key = 'str';
  26.   next;
  27.  }
  28.  #print $x, $_;
  29.  if ($_ =~ /^\>/) {      #jei eilute prasideda: >
  30.   chop();
  31.   $_ =~ s/>  <//;
  32.   $key = $_;
  33.  } else {
  34.   #$molekules[molekules nr.]{irasas}
  35.   push @{ $molekules[$x]{$key} }, $_;
  36.  }
  37. }
  38. close FILE;
  39. #print STDERR Dumper \@molekules;
  40. print STDERR $FILE, " ", $target, "\n";
  41.  
  42.  
  43. #rasti nuo kur prasideda kitokia molekule
  44. #pirmoji kita yra $ta_pati+1
  45. kita();
  46. sub kita {
  47. $y=0;
  48. $ta_pati=0;
  49. while($molekules[$y]{'str'}) {
  50.  #print STDERR Dumper $molekules[$y]{'str'}, "\n";
  51.  $z=0;
  52.  while($molekules[$y]{'str'}[$z]) {
  53.   #jei z eilute nesutampa y ir y+1 nors karta tai kita molekule
  54.   if ($molekules[$y]{'str'}[$z] ne $molekules[$y+1]{'str'}[$z]) {
  55.    $ta_pati=$y;
  56.    #print STDERR $y, " :", $molekules[$y]{'str'}[$z], " ir ", $molekules[$y+1]{'str'}[$z], "\n";
  57.    last;
  58.   }
  59.   $z++;
  60.  }
  61.  last if ($ta_pati);
  62.  $y++;
  63. }
  64. }
  65. #print STDERR Dumper $molekules[0], "\n";
  66.  
  67.  
  68. #eiti per molekules iki pirmos tos pacios ir
  69. #nuo pirmos tos pacios eiti per visas ir rasti vienoda 'TARGET Biomolecule'
  70. $x=0;
  71. $skaitiklis=0;
  72. while($x <= $ta_pati) {
  73. $y=$ta_pati+1;
  74.  while($molekules[$y]{'str'}[0]) {
  75.   if (($target eq $molekules[$x]{'TARGET Biomolecule'}[0]) && ($target eq $molekules[$y]{'TARGET Biomolecule'}[0])) {
  76.   #print STDERR "Target: ", $molekules[$x]{'TARGET Biomolecule'}[0], "\n";
  77.   print STDERR "Ki ", $molekules[$x]{'BindingDB Display Name'}[0], " molekulei: ", $molekules[$x]{'Enzymologic: Ki nM'}[0], " nM\n";
  78.   print STDERR "Ki ", $molekules[$y]{'BindingDB Display Name'}[0], " molekulei: ", $molekules[$y]{'Enzymologic: Ki nM'}[0], " nM\n";
  79.   #kiek x molekule geresne uz y nM skaitiklis
  80.   $skaitiklis=$skaitiklis+($molekules[$x]{'Enzymologic: Ki nM'}[0]-$molekules[$y]{'Enzymologic: Ki nM'}[0]);
  81.   }
  82.  $y++;
  83.  }
  84. $x++;
  85. }
  86. print $molekules[0]{'BindingDB Display Name'}[0], " geriau uz ", $molekules[$ta_pati+1]{'BindingDB Display Name'}[0],
  87. " vidutiniskai\t", $skaitiklis/$x, "\tnM\n";
  88. #print STDERR "Ki ", $molekules[0]{'BindingDB Display Name'}[0], " molekulei:\n";
  89. #print STDERR Dumper @pirma;
  90. #print STDERR "Ki ", $molekules[$ta_pati+1]{'BindingDB Display Name'}[0], " molekulei:\n";
  91. #print STDERR Dumper @antra;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement