Subversion Repositories wimsdev

Rev

Rev 13418 | Rev 14376 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13418 Rev 14144
Line 56... Line 56...
56
    }
56
    }
57
  };
57
  };
58
  $cnt ++;
58
  $cnt ++;
59
}
59
}
60
close IN;
60
close IN;
-
 
61
my $nbhydrogen='';
61
for my $at (sort keys %hash){
62
for my $at (sort {$a<=>$b} keys %hash){
62
  $hash{$at}{hydrogen}=0 if (!(defined $hash{$at}{hydrogen}) || $hash{$at}{hydrogen}<0);
63
  $hash{$at}{'hydrogen'}=0 if (!(defined $hash{$at}{'hydrogen'}) || $hash{$at}{'hydrogen'}<0);
63
  $nH = $nH+ $hash{$at}{hydrogen};
64
  $nH = $nH+ $hash{$at}{'hydrogen'};
-
 
65
  $nbhydrogen .= "$at,$hash->{$at}{name},$hash->{$at}{hydrogen}\n";
64
}
66
}
65
$atom{'H'}=$nH;
67
$atom{'H'}=$nH;
66
my $formula=$atom{'C'} > 0 ? 'C' : '' ;
68
my $formula=$atom{'C'} > 0 ? 'C' : '' ;
67
$formula .= $atom{'C'} if $atom{'C'} > 1;
69
$formula .= $atom{'C'} if $atom{'C'} > 1;
68
$formula .= 'H' if $atom{'H'} > 0;
70
$formula .= 'H' if $atom{'H'} > 0;
Line 71... Line 73...
71
for my $at (sort keys %atom){
73
for my $at (sort keys %atom){
72
  next if (!(defined ($atom{$at})) || $atom{$at}==0 );
74
  next if (!(defined ($atom{$at})) || $atom{$at}==0 );
73
  next if ($at=~'C\b' || $at=~'H\b');
75
  next if ($at=~'C\b' || $at=~'H\b');
74
  $formula .= $atom{$at}==1? $at : $at . $atom{$at};
76
  $formula .= $atom{$at}==1? $at : $at . $atom{$at};
75
}
77
}
76
print $formula . "\n";
78
print "$formula,[$nbhydrogen]";
77
 
-
 
78
EOF
79
EOF