Diff for /loncom/homework/convertjme.pl between versions 1.8 and 1.9

version 1.8, 2003/10/20 16:25:33 version 1.9, 2003/12/08 18:36:58
Line 72  if ($loncapa) { Line 72  if ($loncapa) {
     $ps = $ENV{'cgi.'.$id.'.PS'};      $ps = $ENV{'cgi.'.$id.'.PS'};
     @JMEstring=&unescape($ENV{'cgi.'.$id.'.JME'});      @JMEstring=&unescape($ENV{'cgi.'.$id.'.JME'});
 } else {  } else {
     my @JMEstring = @ARGV;      @JMEstring = @ARGV;
     $width = shift @JMEstring;      $width = shift @JMEstring;
     $png = 1;      $png = 1;
     $ps = 1;      $ps = 1;
Line 86  my @modulator_structs=split(/\|/,$modula Line 86  my @modulator_structs=split(/\|/,$modula
 my @product_structs=split(/\|/,$products);  my @product_structs=split(/\|/,$products);
   
   
   
 my @all_structs=(@reactant_structs,@modulator_structs,@product_structs);  my @all_structs=(@reactant_structs,@modulator_structs,@product_structs);
   
 #get size of image and initialize image and globals  #get size of image and initialize image and globals
Line 200  foreach my $struct (@all_structs) { Line 199  foreach my $struct (@all_structs) {
     my @adjacent = map {0} 0..$natoms-1;      my @adjacent = map {0} 0..$natoms-1;
     my @bondsx = map {0} 0..$natoms-1;      my @bondsx = map {0} 0..$natoms-1;
     my @bondsy = map {0} 0..$natoms-1;      my @bondsy = map {0} 0..$natoms-1;
       my @aldehyde = map {0} 0..$natoms-1;
     for (my $i = 0; $i < $nbonds; $i++) {      for (my $i = 0; $i < $nbonds; $i++) {
  $bonds[$atomA[$i]] += ($bondType[$i]>0) ? $bondType[$i] : 1;   $bonds[$atomA[$i]] += ($bondType[$i]>0) ? $bondType[$i] : 1;
  $bonds[$atomB[$i]] += ($bondType[$i]>0) ? $bondType[$i] : 1;   $bonds[$atomB[$i]] += ($bondType[$i]>0) ? $bondType[$i] : 1;
Line 211  foreach my $struct (@all_structs) { Line 211  foreach my $struct (@all_structs) {
  $bondsy[$atomA[$i]] += $y[$atomB[$i]] - $y[$atomA[$i]];   $bondsy[$atomA[$i]] += $y[$atomB[$i]] - $y[$atomA[$i]];
  $bondsx[$atomB[$i]] += $x[$atomA[$i]] - $x[$atomB[$i]];   $bondsx[$atomB[$i]] += $x[$atomA[$i]] - $x[$atomB[$i]];
  $bondsy[$atomB[$i]] += $y[$atomA[$i]] - $y[$atomB[$i]];   $bondsy[$atomB[$i]] += $y[$atomA[$i]] - $y[$atomB[$i]];
   
    if ( @bondType[$i] == 2) {
       @aldehyde[@atomA[$i]] ++ if (@name[@atomB[$i]] eq "O");
       @aldehyde[@atomB[$i]] ++ if (@name[@atomA[$i]] eq "O");
    }
   
     }      }
   
      
 # Draw bonds  # Draw bonds
     for (my $i = 0; $i < $nbonds; $i++) {      for (my $i = 0; $i < $nbonds; $i++) {
  my $xa = $x[$atomA[$i]];   my $xa = $x[$atomA[$i]];
Line 268  foreach my $struct (@all_structs) { Line 275  foreach my $struct (@all_structs) {
  }   }
  elsif ($bondType[$i] == 2 &&   elsif ($bondType[$i] == 2 &&
        (($adjacent[$atomA[$i]] == 1 && $adjacent[$atomB[$i]] > 2)||         (($adjacent[$atomA[$i]] == 1 && $adjacent[$atomB[$i]] > 2)||
  ($adjacent[$atomB[$i]] == 1 && $adjacent[$atomA[$i]] > 2))) {   ($adjacent[$atomB[$i]] == 1 && $adjacent[$atomA[$i]] > 2)||
    @name[@atomA[$i]] eq "O" || @name[@atomB[$i]] eq "O")) {
     # centered bond      # centered bond
     my $xperp = $doubleWidth*$sina;      my $xperp = $doubleWidth*$sina;
     my $yperp = $doubleWidth*$cosa;      my $yperp = $doubleWidth*$cosa;
Line 322  foreach my $struct (@all_structs) { Line 330  foreach my $struct (@all_structs) {
     for (my $i = 0; $i < $natoms; $i++) {      for (my $i = 0; $i < $natoms; $i++) {
  my ($formula,$sign,$charge) =   my ($formula,$sign,$charge) =
     ($name[$i] =~ /(\w+)([\+|\-])?(\d)?/);      ($name[$i] =~ /(\w+)([\+|\-])?(\d)?/);
  if ($png) {  
     $sign = "&#8211;" if ($sign eq "-");  # replace by n-dash  
  }  
  if ($formula ne "C" || $sign ne ""||   if ($formula ne "C" || $sign ne ""||
     $adjacent[$i] < 2 || ($adjacent[$i] == 2 && $bonds[$i] == 4)) {      $adjacent[$i] < 2 || ($adjacent[$i] == 2 && $bonds[$i] == 4) || (@aldehyde[$i] == 1 && @bonds[$i] == 3)) {
     # don't show C, unless charged, terminal, or linear      # don't show C, unless charged, terminal, or linear
     my $nH = 0;      my $nH = 0;
     if (exists $valence{$formula}) {      if (exists $valence{$formula}) {
Line 545  sub printCharge_png { Line 550  sub printCharge_png {
     my ($sign,$charge,$x,$y) = @_;      my ($sign,$charge,$x,$y) = @_;
     my $yy = 662;      my $yy = 662;
   
       $sign = "&#8211;" if ($sign eq "-");  # replace by n-dash
     $charge = "" if ($charge == 1);      $charge = "" if ($charge == 1);
     $charge .= $sign;      $charge .= $sign;
           

Removed from v.1.8  
changed lines
  Added in v.1.9


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>