Rev 14376 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 14376 | Rev 14689 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | my @other=('H'); |
15 | my @other=('H'); |
16 | my ($nbatom, $nbbond); |
16 | my ($nbatom, $nbbond); |
17 | my $cnt=1; my $nH=0; |
17 | my $cnt=1; my $nH=0; |
18 | my %hash = (); |
18 | my %hash = (); |
19 | my $hash = \%hash; |
19 | my $hash = \%hash; |
- | 20 | my %bond=(); |
|
- | 21 | my $bond = \%bond; |
|
20 | my %atom = (); |
22 | my %atom = (); |
21 | my $atom = \%atom; |
23 | my $atom = \%atom; |
22 | my $cntmax=10000; |
24 | my $cntmax=10000; |
23 | my @a=(); |
25 | my @a=(); |
24 | open(IN, "$file"); |
26 | open(IN, "$file"); |
Line 37... | Line 39... | ||
37 | elsif ( grep { $_ eq $a[3] } @other) {} |
39 | elsif ( grep { $_ eq $a[3] } @other) {} |
38 | else { |
40 | else { |
39 | #die( "$a[3]") |
41 | #die( "$a[3]") |
40 | } |
42 | } |
41 | } |
43 | } |
- | 44 | my $tt; |
|
42 | if ($cnt > $cntmax && $cnt <= $cntmax + $nbbond) { |
45 | if ($cnt > $cntmax && $cnt <= $cntmax + $nbbond) { |
43 | if (!($hash->{$a[0]}{name} =~ /H\b/) && !($hash->{$a[1]}{name} =~ /H\b/)) { |
46 | if (!($hash->{$a[0]}{name} =~ /H\b/) && !($hash->{$a[1]}{name} =~ /H\b/)) { |
44 | $hash->{$a[0]}{ |
47 | $hash->{$a[0]}{'hydrogen'}-= $a[2]; |
45 | $hash->{$a[1]}{ |
48 | $hash->{$a[1]}{'hydrogen'}-= $a[2]; |
- | 49 | $bond->{$cnt}=$a[0] . ',' . $a[1]; |
|
- | 50 | $tt=$cnt<= $cntmax ? $cnt: $cnt-$cntmax; |
|
- | 51 | $bond->{$a[0]}=!$bond->{$a[0]} ? $tt: $bond->{$a[0]}.','. $tt; |
|
- | 52 | $bond->{$a[1]}=!$bond->{$a[1]} ? $tt: $bond->{$a[1]}.','. $tt; |
|
46 | } |
53 | } |
47 | if (!($hash->{$a[0]}{name} =~ /H\b/) && ($hash->{$a[1]}{name} =~ /H\b/)) { |
54 | if (!($hash->{$a[0]}{name} =~ /H\b/) && ($hash->{$a[1]}{name} =~ /H\b/)) { |
48 | $hash->{$a[0]}{ |
55 | $hash->{$a[0]}{'hydrogenfichier'}++; |
49 | } |
56 | } |
50 | if (!($hash->{$a[1]}{name} =~ /H\b/) && ($hash->{$a[0]}{name} =~ /H\b/)) { |
57 | if (!($hash->{$a[1]}{name} =~ /H\b/) && ($hash->{$a[0]}{name} =~ /H\b/)) { |
51 | $hash->{$a[1]}{ |
58 | $hash->{$a[1]}{'hydrogenfichier'}++; |
52 | } |
59 | } |
53 | } |
60 | } |
54 | if ($_ =~s /M CHG//) { |
61 | if ($_ =~s /M CHG//) { |
55 | @a=split(" ", $_); |
62 | @a=split(" ", $_); |
56 | my $cc=1; |
63 | my $cc=1; |
57 | for my $ion (@a) { |
64 | for my $ion (@a) { |
58 | if ($cc%2==0) { |
65 | if ($cc%2==0) { |
59 | $hash->{$ion}{ |
66 | $hash->{$ion}{'hydrogen'} += $a[$cc]; |
60 | } |
67 | } |
61 | $cc++; |
68 | $cc++; |
62 | } |
69 | } |
63 | }; |
70 | }; |
64 | $cnt ++; |
71 | $cnt ++; |
Line 66... | Line 73... | ||
66 | close IN; |
73 | close IN; |
67 | my $nbhydrogen=''; |
74 | my $nbhydrogen=''; |
68 | for my $at (sort {$a<=>$b} keys %hash){ |
75 | for my $at (sort {$a<=>$b} keys %hash){ |
69 | $hash{$at}{'hydrogen'}=0 if (!(defined $hash{$at}{'hydrogen'}) || $hash{$at}{'hydrogen'}<0); |
76 | $hash{$at}{'hydrogen'}=0 if (!(defined $hash{$at}{'hydrogen'}) || $hash{$at}{'hydrogen'}<0); |
70 | $nH = $nH+ $hash{$at}{'hydrogen'}; |
77 | $nH = $nH+ $hash{$at}{'hydrogen'}; |
71 | $nbhydrogen .= "$at,$hash->{$at}{name},$hash->{$at}{ |
78 | $nbhydrogen .= "$at,$hash->{$at}{name},$hash->{$at}{'hydrogen'}\n"; |
72 | } |
79 | } |
73 | my $nbhydrogenfichier=''; |
80 | my $nbhydrogenfichier=''; |
74 | for my $at (sort {$a<=>$b} keys %hash){ |
81 | for my $at (sort {$a<=>$b} keys %hash){ |
75 | if(!($hash->{$at}{name} =~ /H\b/)){ |
82 | if(!($hash->{$at}{name} =~ /H\b/)){ |
76 | $hash{$at}{'hydrogenfichier'}=0 if (!(defined $hash{$at}{'hydrogenfichier'}) |
83 | $hash{$at}{'hydrogenfichier'}=0 if (!(defined $hash{$at}{'hydrogenfichier'}) |
77 | || $hash{$at}{'hydrogenfichier'}<0); |
84 | || $hash{$at}{'hydrogenfichier'}<0); |
78 | $nbhydrogenfichier .= "$at,$hash->{$at}{name},$hash->{$at}{ |
85 | $nbhydrogenfichier .= "$at,$hash->{$at}{name},$hash->{$at}{'hydrogenfichier'}\n"; |
79 | } |
86 | } |
80 | } |
87 | } |
81 | 88 | ||
82 | $atom{'H'}=$nH; |
89 | $atom{'H'}=$nH; |
83 | my $formula=$atom{'C'} > 0 ? 'C' : '' ; |
90 | my $formula=$atom{'C'} > 0 ? 'C' : '' ; |
Line 88... | Line 95... | ||
88 | for my $at (sort keys %atom){ |
95 | for my $at (sort keys %atom){ |
89 | next if (!(defined ($atom{$at})) || $atom{$at}==0 ); |
96 | next if (!(defined ($atom{$at})) || $atom{$at}==0 ); |
90 | next if ($at=~'C\b' || $at=~'H\b'); |
97 | next if ($at=~'C\b' || $at=~'H\b'); |
91 | $formula .= $atom{$at}==1? $at : $at . $atom{$at}; |
98 | $formula .= $atom{$at}==1? $at : $at . $atom{$at}; |
92 | } |
99 | } |
- | 100 | my $bondprint=""; |
|
- | 101 | for my $bd (sort {$a<=>$b} keys %bond){ |
|
- | 102 | next if (!(defined ($bond{$bd}))); |
|
- | 103 | if($bd <= $nbatom){ |
|
- | 104 | $bondprint .= "atom $bd,$bond{$bd}\n"; |
|
- | 105 | } else { |
|
- | 106 | my $bd1=$bd-$nbatom-4; $bondprint .= "bond $bd1,$bond{$bd}\n"; |
|
- | 107 | } |
|
- | 108 | } |
|
93 | print "$formula,[$nbhydrogen],[$nbhydrogenfichier]"; |
109 | print "$formula,[$nbhydrogen],[$nbhydrogenfichier],[$bondprint]"; |
- | 110 | ||
94 | EOF |
111 | EOF |