Advertisement
ProzacR

another text parser

Feb 22nd, 2013
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.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. die "usage VR_bindingdb_parse.pl file.sdf" if (@ARGV != 1);
  14. $FILE = $ARGV[0];
  15. open FILE, "<", $FILE or die $!;
  16. $x=0;
  17. while(<FILE>) {
  18.  chop($_);
  19.  next if ($_ =~ /^$/);   #jei eilute tuscia praleidziam
  20.  if ($_ =~ /\$\$\$\$/) { #jei eiluteje yra: $$$$
  21.   $x++;
  22.   $key = 'molecule';
  23.   next;
  24.  }
  25.  #print $x, $_;
  26.  if ($_ =~ /^\>/) {      #jei eilute prasideda: >
  27.   chop();
  28.   $_ =~ s/>  <//;
  29.   $key = $_;
  30.  } else {
  31.   push @{ $lines[$x]{$key} }, $_;
  32.  }
  33. }
  34. close FILE;
  35. print STDERR Dumper \@lines;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement