SHOW:
|
|
- or go back to the newest paste.
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" if (@ARGV != 1); | |
15 | $FILE = $ARGV[0]; | |
16 | open FILE, "<", $FILE or die $!; | |
17 | $x=0; | |
18 | $key='str'; | |
19 | while(<FILE>) { | |
20 | chop($_); | |
21 | next if ($_ =~ /^$/); #jei eilute tuscia praleidziam | |
22 | - | $key = 'molecule'; |
22 | + | |
23 | $x++; | |
24 | $key = 'str'; | |
25 | next; | |
26 | } | |
27 | #print $x, $_; | |
28 | if ($_ =~ /^\>/) { #jei eilute prasideda: > | |
29 | chop(); | |
30 | $_ =~ s/> <//; | |
31 | - | push @{ $lines[$x]{$key} }, $_; |
31 | + | |
32 | } else { | |
33 | #$molekules[molekules nr.]{irasas} | |
34 | push @{ $molekules[$x]{$key} }, $_; | |
35 | - | print STDERR Dumper \@lines; |
35 | + | |
36 | } | |
37 | close FILE; | |
38 | #print STDERR Dumper \@molekules; | |
39 | print $FILE, "\n"; | |
40 | ||
41 | ||
42 | #rasti nuo kur prasideda kitokia molekule | |
43 | #pirmoji kita yra $ta_pati+1 | |
44 | kita(); | |
45 | sub kita { | |
46 | $y=0; | |
47 | print $y; | |
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[$ta_pati+1]{'str'}, "\n"; |