rino 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. data/Rakefile +1 -1
  2. data/ext/extconf.rb +1 -24
  3. data/ext/libinchi.so +0 -0
  4. data/ext/src/aux2atom.h +120 -39
  5. data/ext/src/comdef.h +3 -3
  6. data/ext/src/dispstru.c +2547 -0
  7. data/ext/src/dispstru.h +73 -0
  8. data/ext/src/extr_ct.h +5 -2
  9. data/ext/src/ichi.h +27 -11
  10. data/ext/src/ichi_bns.c +1800 -254
  11. data/ext/src/ichi_bns.h +205 -4
  12. data/ext/src/ichican2.c +197 -86
  13. data/ext/src/ichicano.c +8 -13
  14. data/ext/src/ichicano.h +2 -2
  15. data/ext/src/ichicans.c +11 -6
  16. data/ext/src/ichicant.h +2 -2
  17. data/ext/src/ichicomn.h +2 -2
  18. data/ext/src/ichicomp.h +19 -4
  19. data/ext/src/ichidrp.h +9 -5
  20. data/ext/src/ichierr.h +5 -3
  21. data/ext/src/ichiisot.c +2 -2
  22. data/ext/src/ichimain.c +461 -0
  23. data/ext/src/ichimain.h +23 -15
  24. data/ext/src/ichimak2.c +6 -6
  25. data/ext/src/ichimake.c +843 -42
  26. data/ext/src/ichimake.h +4 -2
  27. data/ext/src/ichimap1.c +5 -5
  28. data/ext/src/ichimap2.c +2 -2
  29. data/ext/src/ichimap4.c +34 -21
  30. data/ext/src/ichinorm.c +11 -5
  31. data/ext/src/ichinorm.h +3 -2
  32. data/ext/src/ichiparm.c +2 -2
  33. data/ext/src/ichiparm.h +232 -30
  34. data/ext/src/ichiprt1.c +35 -11
  35. data/ext/src/ichiprt2.c +78 -7
  36. data/ext/src/ichiprt3.c +300 -120
  37. data/ext/src/ichiqueu.c +17 -2
  38. data/ext/src/ichiread.c +6932 -0
  39. data/ext/src/ichiring.c +3 -2
  40. data/ext/src/ichiring.h +2 -2
  41. data/ext/src/ichirvr1.c +4891 -0
  42. data/ext/src/ichirvr2.c +6344 -0
  43. data/ext/src/ichirvr3.c +5499 -0
  44. data/ext/src/ichirvr4.c +3177 -0
  45. data/ext/src/ichirvr5.c +1166 -0
  46. data/ext/src/ichirvr6.c +1287 -0
  47. data/ext/src/ichirvr7.c +2319 -0
  48. data/ext/src/ichirvrs.h +882 -0
  49. data/ext/src/ichisize.h +2 -2
  50. data/ext/src/ichisort.c +5 -5
  51. data/ext/src/ichister.c +281 -86
  52. data/ext/src/ichister.h +9 -3
  53. data/ext/src/ichitaut.c +208 -9
  54. data/ext/src/ichitaut.h +13 -11
  55. data/ext/src/ichitime.h +16 -2
  56. data/ext/src/inchicmp.h +107 -0
  57. data/ext/src/inpdef.h +6 -3
  58. data/ext/src/libinchi_wrap.c +912 -0
  59. data/ext/src/lreadmol.h +34 -31
  60. data/ext/src/mode.h +244 -7
  61. data/ext/src/mol2atom.c +1060 -0
  62. data/ext/src/mol2atom.h +31 -0
  63. data/ext/src/readinch.c +239 -0
  64. data/ext/src/readmol.c +28 -0
  65. data/ext/src/{e_readmol.h → readmol.h} +7 -9
  66. data/ext/src/runichi.c +251 -177
  67. data/ext/src/strutil.c +444 -238
  68. data/ext/src/strutil.h +150 -11
  69. data/ext/src/util.c +176 -118
  70. data/ext/src/util.h +15 -3
  71. data/lib/rino.rb +71 -3
  72. data/test/test.rb +33 -4
  73. metadata +22 -34
  74. data/ext/ruby_inchi_main.so +0 -0
  75. data/ext/src/e_0dstereo.c +0 -3014
  76. data/ext/src/e_0dstereo.h +0 -31
  77. data/ext/src/e_comdef.h +0 -57
  78. data/ext/src/e_ctl_data.h +0 -147
  79. data/ext/src/e_ichi_io.c +0 -498
  80. data/ext/src/e_ichi_io.h +0 -40
  81. data/ext/src/e_ichi_parms.c +0 -37
  82. data/ext/src/e_ichi_parms.h +0 -41
  83. data/ext/src/e_ichicomp.h +0 -50
  84. data/ext/src/e_ichierr.h +0 -40
  85. data/ext/src/e_ichimain.c +0 -593
  86. data/ext/src/e_ichisize.h +0 -43
  87. data/ext/src/e_inchi_atom.c +0 -75
  88. data/ext/src/e_inchi_atom.h +0 -33
  89. data/ext/src/e_inpdef.h +0 -41
  90. data/ext/src/e_mode.h +0 -706
  91. data/ext/src/e_mol2atom.c +0 -649
  92. data/ext/src/e_readinch.c +0 -58
  93. data/ext/src/e_readmol.c +0 -54
  94. data/ext/src/e_readstru.c +0 -251
  95. data/ext/src/e_readstru.h +0 -33
  96. data/ext/src/e_util.c +0 -284
  97. data/ext/src/e_util.h +0 -61
  98. data/ext/src/ichilnct.c +0 -286
  99. data/ext/src/inchi_api.h +0 -670
  100. data/ext/src/inchi_dll.c +0 -1480
  101. data/ext/src/inchi_dll.h +0 -34
  102. data/ext/src/inchi_dll_main.c +0 -23
  103. data/ext/src/inchi_dll_main.h +0 -31
  104. data/ext/src/ruby_inchi_main.c +0 -558
@@ -2,8 +2,8 @@
2
2
  * International Union of Pure and Applied Chemistry (IUPAC)
3
3
  * International Chemical Identifier (InChI)
4
4
  * Version 1
5
- * Software version 1.00
6
- * April 13, 2005
5
+ * Software version 1.01
6
+ * July 21, 2006
7
7
  * Developed at NIST
8
8
  */
9
9
 
@@ -70,6 +70,8 @@
70
70
  #define iiEq2ISO 0x0080 /* isotopic */
71
71
  #define iiEq2INV 0x0100 /* equal to inverted (stereo sp3) or to numbering of inverted stereo */
72
72
 
73
+ #define iiEmpty 0x0200 /* item is empty while in the preceding layer the item is not empty */
74
+
73
75
  /*********************** Printing strings external declarations *******************************/
74
76
 
75
77
  extern const char sCompDelim[];
@@ -2,8 +2,8 @@
2
2
  * International Union of Pure and Applied Chemistry (IUPAC)
3
3
  * International Chemical Identifier (InChI)
4
4
  * Version 1
5
- * Software version 1.00
6
- * April 13, 2005
5
+ * Software version 1.01
6
+ * July 21, 2006
7
7
  * Developed at NIST
8
8
  */
9
9
 
@@ -38,18 +38,18 @@ int All_SC_Same( AT_RANK canon_rank1, /* canonical number */
38
38
  AT_RANK r1 = pRankStack1[0][n1];
39
39
  int iMax1 = (int)r1;
40
40
  int i1, s1;
41
- int bFound=0, stereo_atom_parity;
41
+ int bFound=0, stereo_atom_parity=-1;
42
42
 
43
43
  /* find one stereo atom such that canon_rank1 can be mapped on it */
44
44
  for ( i1 = 1; i1 <= iMax1 && r1 == pRankStack2[0][s1=(int)pRankStack2[1][iMax1-i1]]; i1++ ) {
45
45
  if ( at[s1].stereo_bond_neighbor[0] ) {
46
- bFound=0; /* at[s1] is not sp3-stereogenic: it belongs to stereobond */
46
+ bFound=0; /* at[s1] is not sp3-stereogenic: it belongs to a stereobond */
47
47
  break;
48
48
  } else
49
49
  if ( i1 == 1 ) {
50
50
  stereo_atom_parity = PARITY_VAL(at[s1].stereo_atom_parity);
51
51
  if ( !ATOM_PARITY_KNOWN(stereo_atom_parity) ) {
52
- bFound=0; /* at[s1] does not have KNOWN parity */
52
+ bFound=0; /* at[s1] does not have a KNOWN parity */
53
53
  break;
54
54
  }
55
55
  } else
@@ -2,8 +2,8 @@
2
2
  * International Union of Pure and Applied Chemistry (IUPAC)
3
3
  * International Chemical Identifier (InChI)
4
4
  * Version 1
5
- * Software version 1.00
6
- * April 13, 2005
5
+ * Software version 1.01
6
+ * July 21, 2006
7
7
  * Developed at NIST
8
8
  */
9
9
 
@@ -2,8 +2,8 @@
2
2
  * International Union of Pure and Applied Chemistry (IUPAC)
3
3
  * International Chemical Identifier (InChI)
4
4
  * Version 1
5
- * Software version 1.00
6
- * April 13, 2005
5
+ * Software version 1.01
6
+ * July 21, 2006
7
7
  * Developed at NIST
8
8
  */
9
9
 
@@ -67,7 +67,6 @@ int map_stereo_bonds4 (
67
67
  */
68
68
  int tpos1;
69
69
  AT_STEREO_DBLE prevBond;
70
-
71
70
  tpos1 = CurTreeGetPos( cur_tree );
72
71
 
73
72
  total_restart:
@@ -604,29 +603,29 @@ repeat_all:
604
603
  at_rank_canon_n1 = 0;
605
604
  at_rank_canon_n2 = 0;
606
605
  for ( i = 0; i < num1; i ++ ) {
607
- int at_from, at_to;
606
+ int at_from_n1, at_to_n1, at_no_n1_num_success = 0;
608
607
  istk2 = istk;
609
608
  if ( num1 == 2 ) {
610
609
  at_rank_canon_n1 = nCanonRankFrom[EN1[0].from_at];
611
610
  /* an additional neighbor mapping is necessary; */
612
611
  /* we need to map only one at_from1 neighbor to make all neighbors have different ranks */
613
612
 
614
- at_from = EN1[0].from_at;
615
- at_to = EN1[0].to_at[i];
613
+ at_from_n1 = EN1[0].from_at;
614
+ at_to_n1 = EN1[0].to_at[i];
616
615
 
617
616
  if ( tpos1 < CurTreeGetPos( cur_tree ) &&
618
617
  1 == CurTreeIsLastRank( cur_tree, at_rank_canon_n1 ) &&
619
- 1 == CurTreeIsLastAtomEqu( cur_tree, at_to, nSymmStereo ) )
618
+ 1 == CurTreeIsLastAtomEqu( cur_tree, at_to_n1, nSymmStereo ) )
620
619
  continue;
621
620
  /*
622
621
  if ( nSymmStereo && !pCS->bFirstCT ) {
623
- if ( i && nSymmStereo[at_to] == nSymmStereo[(int)EN1[0].to_at[0]] ) {
622
+ if ( i && nSymmStereo[at_to_n1] == nSymmStereo[(int)EN1[0].to_at[0]] ) {
624
623
  continue; // do not test stereo equivalent atoms except the first one
625
624
  }
626
625
  }
627
626
  */
628
627
  /* neighbors are tied. Untie them by breaking a tie on ONE of them. */
629
- ret1 = map_an_atom2( num_at_tg, num_max, at_from, at_to,
628
+ ret1 = map_an_atom2( num_at_tg, num_max, at_from_n1, at_to_n1,
630
629
  nTempRank, nNumMappedRanks[istk2], &nNumMappedRanks[istk2+1], pCS,
631
630
  NeighList, pRankStack1+nStackPtr[istk2], pRankStack2+nStackPtr[istk2],
632
631
  &bAddStack );
@@ -644,7 +643,7 @@ repeat_all:
644
643
  0 == CurTreeIsLastRank( cur_tree, at_rank_canon_n1 ) ) {
645
644
  CurTreeAddRank( cur_tree, at_rank_canon_n1 );
646
645
  }
647
- CurTreeAddAtom( cur_tree, at_to );
646
+ CurTreeAddAtom( cur_tree, at_to_n1 );
648
647
  }
649
648
 
650
649
 
@@ -668,27 +667,28 @@ repeat_all:
668
667
  num2 = parity2 > 0? 1:2;
669
668
  at_rank_canon_n2 = 0;
670
669
  for ( j = 0; j < num2; j ++ ) {
670
+ int at_from_n2, at_to_n2;
671
671
  istk3 = istk2;
672
672
  if ( num2 == 2 ) {
673
673
  at_rank_canon_n2 = nCanonRankFrom[EN2[0].from_at];
674
674
  /* we need to map only one at_from2 neighbor to make its neighbors have different ranks */
675
- at_from = EN2[0].from_at;
676
- at_to = EN2[0].to_at[j];
675
+ at_from_n2 = EN2[0].from_at;
676
+ at_to_n2 = EN2[0].to_at[j];
677
677
 
678
678
  if ( tpos1 < CurTreeGetPos( cur_tree ) &&
679
679
  1 == CurTreeIsLastRank( cur_tree, at_rank_canon_n2 ) &&
680
- 1 == CurTreeIsLastAtomEqu( cur_tree, at_to, nSymmStereo ) )
680
+ 1 == CurTreeIsLastAtomEqu( cur_tree, at_to_n2, nSymmStereo ) )
681
681
  continue;
682
682
 
683
683
  /*
684
684
  if ( nSymmStereo && !pCS->bFirstCT ) {
685
- if ( j && nSymmStereo[at_to] == nSymmStereo[(int)EN2[0].to_at[0]] ) {
685
+ if ( j && nSymmStereo[at_to_n2] == nSymmStereo[(int)EN2[0].to_at[0]] ) {
686
686
  continue; // do not test stereo equivalent atoms except the first one
687
687
  }
688
688
  }
689
689
  */
690
690
  /* neighbors are tied. Untie them by breaking a tie on ONE of them. */
691
- ret1 = map_an_atom2( num_at_tg, num_max, at_from, at_to,
691
+ ret1 = map_an_atom2( num_at_tg, num_max, at_from_n2, at_to_n2,
692
692
  nTempRank, nNumMappedRanks[istk3], &nNumMappedRanks[istk3+1], pCS,
693
693
  NeighList, pRankStack1+nStackPtr[istk3],
694
694
  pRankStack2+nStackPtr[istk3],
@@ -704,7 +704,7 @@ repeat_all:
704
704
  0 == CurTreeIsLastRank( cur_tree, at_rank_canon_n2 ) ) {
705
705
  CurTreeAddRank( cur_tree, at_rank_canon_n2 );
706
706
  }
707
- CurTreeAddAtom( cur_tree, at_to );
707
+ CurTreeAddAtom( cur_tree, at_to_n2 );
708
708
  }
709
709
 
710
710
  parity2 = parity_of_mapped_half_bond( at_from2, at_to2, at_from1, at_to1, at, &EN2[1],
@@ -749,7 +749,7 @@ repeat_all:
749
749
  /* remove failed atom2 from the tree */
750
750
  if ( tpos1 < CurTreeGetPos( cur_tree ) &&
751
751
  1 == CurTreeIsLastRank( cur_tree, at_rank_canon_n2 ) ) {
752
- CurTreeRemoveIfLastAtom( cur_tree, at_to );
752
+ CurTreeRemoveIfLastAtom( cur_tree, at_to_n2 );
753
753
  CurTreeRemoveLastRankIfNoAtoms( cur_tree );
754
754
  }
755
755
  continue; /* Reject: not a minimal CT. */
@@ -801,6 +801,7 @@ repeat_all:
801
801
  CurTreeKeepLastAtomsOnly( cur_tree, tpos1, 1 ); /* start over */
802
802
  nTotSuccess |= 2; /* Obtained a smaller CT */
803
803
  }
804
+ at_no_n1_num_success ++;
804
805
  } else {
805
806
  if ( bStereoIsBetterWasSetHere ) { /* rollback */
806
807
  pCS->bStereoIsBetter = 0;
@@ -808,7 +809,7 @@ repeat_all:
808
809
  }
809
810
  if ( tpos1 < CurTreeGetPos( cur_tree ) &&
810
811
  1 == CurTreeIsLastRank( cur_tree, at_rank_canon_n2 ) ) {
811
- CurTreeRemoveIfLastAtom( cur_tree, at_to );
812
+ CurTreeRemoveIfLastAtom( cur_tree, at_to_n2 );
812
813
  CurTreeRemoveLastRankIfNoAtoms( cur_tree );
813
814
  }
814
815
  }
@@ -819,6 +820,12 @@ repeat_all:
819
820
  1 == CurTreeIsLastRank( cur_tree, at_rank_canon_n2 ) ) {
820
821
  CurTreeRemoveLastRank( cur_tree );
821
822
  }
823
+ /* added 2006-07-20 */
824
+ if ( !at_no_n1_num_success && tpos1 < CurTreeGetPos( cur_tree ) &&
825
+ 1 == CurTreeIsLastRank( cur_tree, at_rank_canon_n1 ) ) {
826
+ CurTreeRemoveIfLastAtom( cur_tree, at_to_n1 );
827
+ }
828
+
822
829
  } /* end choices in mapping neighbors of the 1st half-bond */
823
830
  if ( tpos1 < CurTreeGetPos( cur_tree ) &&
824
831
  1 == CurTreeIsLastRank( cur_tree, at_rank_canon_n1 ) ) {
@@ -1174,7 +1181,7 @@ repeat_all:
1174
1181
 
1175
1182
  /*********************************************************************************
1176
1183
  *
1177
- * Unknown Stereocenter Parity case: possibly need to map stereo bond neighbors
1184
+ * Unknown Stereocenter Parity case: possibly need to map stereo center neighbors
1178
1185
  */
1179
1186
  if ( stereo_center_parity == sb_parity_calc )
1180
1187
  {
@@ -1230,14 +1237,20 @@ repeat_all:
1230
1237
  pCS->LinearCTStereoCarb[nNumMappedAtoms].parity = parity1;
1231
1238
  pCS->LinearCTStereoCarb[nNumMappedAtoms].at_num = at_rank_canon1;
1232
1239
  pCS->bRankUsedForStereo[at_from1] = 3;
1233
- pCS->bAtomUsedForStereo[at_to1] -= STEREO_AT_MARK;
1240
+ #if( FIX_ChCh_STEREO_CANON_BUG == 1 )
1241
+ if ( !bAllParitiesIdentical )
1242
+ #endif
1243
+ pCS->bAtomUsedForStereo[at_to1] -= STEREO_AT_MARK;
1234
1244
 
1235
1245
  ret = map_stereo_atoms4 ( at, num_atoms, num_at_tg, num_max, nCanonRankFrom, nAtomNumberCanonFrom, nCanonRankTo,
1236
1246
  nSymmRank, pRankStack1+nStackPtr[istk], pRankStack2+nStackPtr[istk],
1237
1247
  nTempRank, nMappedRanks[istk], nSymmStereo, NeighList,
1238
1248
  pCS, cur_tree, nNumMappedAtoms+1 );
1239
1249
  pCS->bRankUsedForStereo[at_from1] = 0;
1240
- pCS->bAtomUsedForStereo[at_to1] += STEREO_AT_MARK;
1250
+ #if( FIX_ChCh_STEREO_CANON_BUG == 1 )
1251
+ if ( !bAllParitiesIdentical )
1252
+ #endif
1253
+ pCS->bAtomUsedForStereo[at_to1] += STEREO_AT_MARK;
1241
1254
  if ( ret == 4 ) {
1242
1255
  return ret;
1243
1256
  }
@@ -2,8 +2,8 @@
2
2
  * International Union of Pure and Applied Chemistry (IUPAC)
3
3
  * International Chemical Identifier (InChI)
4
4
  * Version 1
5
- * Software version 1.00
6
- * April 13, 2005
5
+ * Software version 1.01
6
+ * July 21, 2006
7
7
  * Developed at NIST
8
8
  */
9
9
 
@@ -122,7 +122,10 @@ int MarkRingSystemsInp( inp_ATOM *at, int num_atoms )
122
122
  do {
123
123
  /* advance */
124
124
  advance_block:
125
- if ( (int)at[i=nStackAtom[nTopStackAtom]].valence > (j = (int)cNeighNumb[i]) ) {
125
+ /*if ( (int)at[i=nStackAtom[nTopStackAtom]].valence > (j = (int)cNeighNumb[i]) )*/
126
+ /* replaced due to missing sequence point */
127
+ if ( i=(int)nStackAtom[nTopStackAtom], j = (int)cNeighNumb[i], (int)at[i].valence > j )
128
+ {
126
129
  cNeighNumb[i] ++;
127
130
  u = (int)at[i].neighbor[j];
128
131
  if ( !nDfsNumber[u] ) {
@@ -199,7 +202,10 @@ advance_block:
199
202
  do {
200
203
  /* advance */
201
204
  advance_ring:
202
- if ( (int)at[i=nStackAtom[nTopStackAtom]].valence > (j = (int)cNeighNumb[i]) ) {
205
+ /*if ( (int)at[i=nStackAtom[nTopStackAtom]].valence > (j = (int)cNeighNumb[i]) )*/
206
+ /* replaced due to missing sequence point */
207
+ if ( i=(int)nStackAtom[nTopStackAtom], j = (int)cNeighNumb[i], (int)at[i].valence > j )
208
+ {
203
209
  cNeighNumb[i] ++;
204
210
  u = (int)at[i].neighbor[j];
205
211
  if ( !nDfsNumber[u] ) {
@@ -523,7 +529,7 @@ int remove_terminal_HDT( int num_atoms, inp_ATOM *at )
523
529
  at[i].component = i; /* temporarily save original numbering */
524
530
  /* get k = temp. hydrogen isotope/non-hydrogen atom type: */
525
531
  /* k=0:H, k=2:D, k=3:T, k=4=kMax: not a hydrogen */
526
- k = at[i].elname[1]? kMax : (p=strchr(szHDT, at[i].elname[0]))? p-szHDT : kMax;
532
+ k = at[i].elname[1]? kMax : (p=(char*)strchr(szHDT, at[i].elname[0]))? p-szHDT : kMax;
527
533
  /* set hydrogen isotope atw differences */
528
534
  /* Notes: k-value of isotopic H is incremented to correct iso_atw_diff value later. */
529
535
  /* 1H isotope cannot be detected here. */
@@ -2,8 +2,8 @@
2
2
  * International Union of Pure and Applied Chemistry (IUPAC)
3
3
  * International Chemical Identifier (InChI)
4
4
  * Version 1
5
- * Software version 1.00
6
- * April 13, 2005
5
+ * Software version 1.01
6
+ * July 21, 2006
7
7
  * Developed at NIST
8
8
  */
9
9
 
@@ -47,6 +47,7 @@ int free_t_group_info( T_GROUP_INFO *t_group_info );
47
47
  int make_a_copy_of_t_group_info( T_GROUP_INFO *t_group_info, T_GROUP_INFO *t_group_info_orig );
48
48
  int set_tautomer_iso_sort_keys( T_GROUP_INFO *t_group_info );
49
49
  int CountTautomerGroups( sp_ATOM *at, int num_atoms, T_GROUP_INFO *t_group_info );
50
+ int CountTautomerGroupsInpAt( inp_ATOM *at, int num_atoms, T_GROUP_INFO *t_group_info );
50
51
  int SortTautomerGroupsAndEndpoints( T_GROUP_INFO *t_group_info, int num_atoms, int num_at_tg, AT_RANK *nRank );
51
52
  int FillIsotopicAtLinearCT( int num_atoms, sp_ATOM* at, const AT_RANK *nAtomNumber,
52
53
  AT_ISOTOPIC *LinearCTIsotopic, int nMaxLenLinearCTIsotopic, int *pnLenLinearCTIsotopic );
@@ -2,8 +2,8 @@
2
2
  * International Union of Pure and Applied Chemistry (IUPAC)
3
3
  * International Chemical Identifier (InChI)
4
4
  * Version 1
5
- * Software version 1.00
6
- * April 13, 2005
5
+ * Software version 1.01
6
+ * July 21, 2006
7
7
  * Developed at NIST
8
8
  */
9
9
 
@@ -2,8 +2,8 @@
2
2
  * International Union of Pure and Applied Chemistry (IUPAC)
3
3
  * International Chemical Identifier (InChI)
4
4
  * Version 1
5
- * Software version 1.00
6
- * April 13, 2005
5
+ * Software version 1.01
6
+ * July 21, 2006
7
7
  * Developed at NIST
8
8
  */
9
9
 
@@ -62,7 +62,12 @@ int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *s
62
62
  int bDisplay = 0;
63
63
  int bNoStructLabels = 0;
64
64
  int bOutputMolfileOnly = 0;
65
+ int bOutputMolfileDT = 0;
66
+ int bOutputMolfileSplit = 0;
65
67
  int bForcedChiralFlag = 0;
68
+ #if( READ_INCHI_STRING == 1 )
69
+ int bDisplayIfRestoreWarnings = 0;
70
+ #endif
66
71
  #ifdef INCHI_LIB
67
72
  int bXml = INCHI_OUT_XML;
68
73
  #else
@@ -73,6 +78,16 @@ int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *s
73
78
  #ifdef STEREO_WEDGE_ONLY
74
79
  int bPointedEdgeStereo = STEREO_WEDGE_ONLY; /* NEWPS TG_FLAG_POINTED_EDGE_STEREO*/
75
80
  #endif
81
+ #if( FIX_ADJ_RAD == 1 )
82
+ int bFixAdjacentRad = 0;
83
+ #endif
84
+ #if( ADD_PHOSPHINE_STEREO == 1 )
85
+ int bAddPhosphineStereo = 0;
86
+ #endif
87
+ #if( ADD_ARSINE_STEREO == 1 )
88
+ int bAddArsineStereo = 0;
89
+ #endif
90
+ int bFixSp3bug = 0;
76
91
 
77
92
 
78
93
  ext[0] = ".mol";
@@ -207,10 +222,10 @@ int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *s
207
222
  } else
208
223
  #endif
209
224
  if ( !memicmp( pArg, "START:", 6 ) ) {
210
- ip->first_struct_number = (int)strtol(pArg+6, NULL, 10);
225
+ ip->first_struct_number = strtol(pArg+6, NULL, 10);
211
226
  } else
212
227
  if ( !memicmp( pArg, "END:", 4 ) ) {
213
- ip->last_struct_number = (int)strtol(pArg+4, NULL, 10);
228
+ ip->last_struct_number = strtol(pArg+4, NULL, 10);
214
229
  } else /* RSB: */
215
230
  if ( !memicmp( pArg, "RSB:", 4 ) ) {
216
231
  mdbr = (int)strtol(pArg+4, NULL, 10);
@@ -371,11 +386,28 @@ int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *s
371
386
  if ( !stricmp( pArg, "NoADP" ) ) {
372
387
  bTgFlagHardAddRenProtons = 0;
373
388
  } else
389
+ if ( !stricmp( pArg, "FixSp3bug" ) ) {
390
+ bFixSp3bug = 1;
391
+ } else
392
+ if ( !stricmp( pArg, "FB" ) ) {
393
+ bFixSp3bug = 1; /* fix all known v1 bugs */
394
+ } else
374
395
  #ifdef STEREO_WEDGE_ONLY
375
396
  if ( !stricmp( pArg, "NEWPS" ) ) {
376
397
  bPointedEdgeStereo = 1;
377
398
  } else
378
399
  #endif
400
+ #if( ADD_PHOSPHINE_STEREO == 1 )
401
+ if ( !stricmp( pArg, "SPXYZ" ) ) {
402
+ bAddPhosphineStereo = 1;
403
+ } else
404
+ #endif
405
+ #if( ADD_ARSINE_STEREO == 1 )
406
+ if ( !stricmp( pArg, "SASXYZ" ) ) {
407
+ bAddArsineStereo = 1;
408
+ } else
409
+ #endif
410
+
379
411
  if ( !stricmp( pArg, "PW" ) ) {
380
412
  ip->bSaveWarningStructsAsProblem = 1;
381
413
  } else {
@@ -517,10 +549,26 @@ int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *s
517
549
  if ( !stricmp( pArg, "SUU" ) ) { /* include omitted undef/unkn stereo */
518
550
  bVer1DefaultMode &= ~(REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU);
519
551
  } else
552
+ if ( !stricmp( pArg, "FixSp3bug" ) ) {
553
+ bFixSp3bug = 1;
554
+ } else
555
+ if ( !stricmp( pArg, "FB" ) ) {
556
+ bFixSp3bug = 1; /* fix all known v1 bugs */
557
+ } else
520
558
  #ifdef STEREO_WEDGE_ONLY
521
559
  if ( !stricmp( pArg, "NEWPS" ) ) {
522
560
  bPointedEdgeStereo = 1;
523
561
  } else
562
+ #endif
563
+ #if( ADD_PHOSPHINE_STEREO == 1 )
564
+ if ( !stricmp( pArg, "SPXYZ" ) ) {
565
+ bAddPhosphineStereo = 1;
566
+ } else
567
+ #endif
568
+ #if( ADD_ARSINE_STEREO == 1 )
569
+ if ( !stricmp( pArg, "SASXYZ" ) ) {
570
+ bAddArsineStereo = 1;
571
+ } else
524
572
  #endif
525
573
  if ( !stricmp( pArg, "RECMET" ) ) { /* do reconnect metals */
526
574
  bReconnectCoord = 1;
@@ -542,6 +590,12 @@ int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *s
542
590
  if ( !stricmp( pArg, "D" ) ) { /* display the structures */
543
591
  bDisplay |= 1;
544
592
  } else
593
+ #if( READ_INCHI_STRING == 1 )
594
+ if ( !stricmp( pArg, "DDSRC" ) ) {
595
+ bDisplayIfRestoreWarnings = 1; /* InChI->Structure debugging: Display Debug Structure Restore Components */
596
+ }
597
+ else
598
+ #endif
545
599
  if ( !stricmp( pArg, "NOLABELS" ) ) {
546
600
  bNoStructLabels = 1;
547
601
  } else
@@ -578,7 +632,32 @@ int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *s
578
632
  bXml |= INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS;
579
633
  bXml &= ~(INCHI_OUT_XML | INCHI_OUT_XML_TEXT_COMMENTS);
580
634
  } else
581
- if ( INPUT_NONE == ip->nInputType &&
635
+ #if( READ_INCHI_STRING == 1 )
636
+ if ( !stricmp( pArg, "InChI2InChI" ) ) {
637
+ /* Read InChI Identifiers and output InChI Identifiers */
638
+ ip->nInputType = INPUT_INCHI;
639
+ ip->bReadInChIOptions |= READ_INCHI_OUTPUT_INCHI;
640
+ ip->bReadInChIOptions &= ~READ_INCHI_TO_STRUCTURE;
641
+ } else
642
+ if ( !stricmp( pArg, "SplitInChI" ) ) {
643
+ /* Split InChI Identifiers into components */
644
+ ip->bReadInChIOptions |= READ_INCHI_SPLIT_OUTPUT;
645
+ } else
646
+ if ( !stricmp( pArg, "InChI2Struct" ) ) {
647
+ /* Split InChI Identifiers into components */
648
+ ip->bReadInChIOptions |= READ_INCHI_TO_STRUCTURE;
649
+ ip->bReadInChIOptions &= ~READ_INCHI_OUTPUT_INCHI;
650
+ ip->nInputType = INPUT_INCHI;
651
+ } else
652
+ if ( !stricmp( pArg, "KeepBalanceP" ) ) {
653
+ /* When spliting InChI Identifiers into components: */
654
+ /* If MobileH output then add p to each component; */
655
+ /* Otherwise add one more component containing balance */
656
+ /* of protons and exchangeable isotopic H */
657
+ ip->bReadInChIOptions |= READ_INCHI_KEEP_BALANCE_P;
658
+ } else
659
+ #endif
660
+ if ( /* INPUT_NONE == ip->nInputType &&*/
582
661
  !memicmp( pArg, "SDF:", 4 ) ) {
583
662
  /* SDfile label */
584
663
  k = 0;
@@ -587,11 +666,15 @@ int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *s
587
666
  if ( k ) {
588
667
  ip->pSdfLabel = ip->szSdfDataHeader;
589
668
  ip->pSdfValue = szSdfDataValue;
590
- ip->nInputType = INPUT_SDFILE;
669
+ if ( INPUT_NONE == ip->nInputType ) {
670
+ ip->nInputType = INPUT_SDFILE;
671
+ }
591
672
  } else {
592
673
  ip->pSdfLabel = NULL;
593
674
  ip->pSdfValue = NULL;
594
- ip->nInputType = INPUT_MOLFILE;
675
+ if ( INPUT_NONE == ip->nInputType ) {
676
+ ip->nInputType = INPUT_MOLFILE;
677
+ }
595
678
  }
596
679
  } else
597
680
  #if( ADD_CMLPP == 1 )
@@ -604,15 +687,26 @@ int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *s
604
687
  if ( !stricmp( pArg, "RECMET-" ) ) { /* do not reconnect metals (default) */
605
688
  bReconnectCoord = 0;
606
689
  } else
607
- if ( !stricmp( pArg, "OUTPUTSDF" ) ) { /* ourput SDfile */
690
+ if ( !stricmp( pArg, "OUTPUTSDF" ) ) { /* output SDfile */
608
691
  bOutputMolfileOnly = 1;
609
692
  } else
693
+ if ( !stricmp( pArg, "SdfAtomsDT" ) ) { /* output isotopes H as D and T in SDfile */
694
+ bOutputMolfileDT = 1;
695
+ } else
696
+ if ( !stricmp( pArg, "SdfSplit" ) ) { /* Split single Molfiles into disconnected components */
697
+ bOutputMolfileSplit = 1;
698
+ } else
610
699
  if ( !stricmp( pArg, "STDIO" ) ) {
611
700
  bNameSuffix = 0;
612
701
  } else
613
702
  if ( !stricmp( pArg, "DCR" ) ) {
614
703
  bDisplayCompositeResults = 1;
615
704
  } else
705
+ #if( FIX_ADJ_RAD == 1 )
706
+ if ( !stricmp( pArg, "FixRad" ) ) {
707
+ bFixAdjacentRad = 1;
708
+ } else
709
+ #endif
616
710
  /*============= Additional options ==========*/
617
711
  /* Tautomer perception off */
618
712
  if ( !stricmp( pArg, "EXACT" ) ) {
@@ -662,10 +756,10 @@ int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *s
662
756
  bDisconnectSalts = 0;
663
757
  } else
664
758
  if ( !memicmp( pArg, "START:", 6 ) ) {
665
- ip->first_struct_number = (int)strtol(pArg+6, NULL, 10);
759
+ ip->first_struct_number = strtol(pArg+6, NULL, 10);
666
760
  } else
667
761
  if ( !memicmp( pArg, "END:", 4 ) ) {
668
- ip->last_struct_number = (int)strtol(pArg+4, NULL, 10);
762
+ ip->last_struct_number = strtol(pArg+4, NULL, 10);
669
763
  } else /* RSB: */
670
764
  if ( !memicmp( pArg, "RSB:", 4 )) {
671
765
  mdbr = (int)strtol(pArg+4, NULL, 10);
@@ -734,7 +828,7 @@ int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *s
734
828
  szOutputPath[len++] = INCHI_PATH_DELIM;
735
829
  szOutputPath[len] = '\0';
736
830
  }
737
- if ( len > 0 && (r = strrchr( p, INCHI_PATH_DELIM ) ) && r[1] ) {
831
+ if ( len > 0 && (r = (char *)strrchr( p, INCHI_PATH_DELIM ) ) && r[1] ) {
738
832
  strcat( szOutputPath, r+1 );
739
833
  p = szOutputPath;
740
834
  }
@@ -757,7 +851,33 @@ int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *s
757
851
  }
758
852
  }
759
853
 
760
- #endif /* } ACD_LABS_VERSION */
854
+ #endif /* } NOT ACD_LABS_VERSION */
855
+
856
+
857
+ #if( READ_INCHI_STRING == 1 )
858
+ if ( INPUT_INCHI == ip->nInputType ) {
859
+ bCompareComponents = 0;
860
+ /*bDisplayCompositeResults = 0;*/
861
+ bOutputMolfileOnly = 0;
862
+ /*bNoStructLabels = 1;*/
863
+ bINChIOutputOptions |= INCHI_OUT_NO_AUX_INFO;
864
+ bINChIOutputOptions &= ~INCHI_OUT_SHORT_AUX_INFO;
865
+ bINChIOutputOptions &= ~INCHI_OUT_ONLY_AUX_INFO;
866
+ ip->bDisplayIfRestoreWarnings = bDisplayIfRestoreWarnings;
867
+
868
+ if ( !(bINChIOutputOptions &
869
+
870
+ (INCHI_OUT_SDFILE_ONLY |
871
+ INCHI_OUT_XML |
872
+ INCHI_OUT_PLAIN_TEXT |
873
+ INCHI_OUT_PLAIN_TEXT_COMMENTS |
874
+ INCHI_OUT_XML_TEXT_COMMENTS
875
+ ) ) ) {
876
+
877
+ bINChIOutputOptions |= INCHI_OUT_PLAIN_TEXT;
878
+ }
879
+ }
880
+ #endif
761
881
 
762
882
 
763
883
  if ( bVer1Options ) {
@@ -834,6 +954,10 @@ int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *s
834
954
  if ( bOutputMolfileOnly ) {
835
955
  bXml &= ~(INCHI_OUT_XML | INCHI_OUT_PLAIN_TEXT |
836
956
  INCHI_OUT_PLAIN_TEXT_COMMENTS | INCHI_OUT_XML_TEXT_COMMENTS | INCHI_OUT_TABBED_OUTPUT);
957
+ #if( SDF_OUTPUT_DT == 1 )
958
+ ip->bINChIOutputOptions |= bOutputMolfileDT? INCHI_OUT_SDFILE_ATOMS_DT : 0;
959
+ ip->bINChIOutputOptions |= bOutputMolfileSplit? INCHI_OUT_SDFILE_SPLIT : 0;
960
+ #endif
837
961
  }
838
962
  if ( bXml & INCHI_OUT_XML ) {
839
963
  bXml &= ~(INCHI_OUT_PLAIN_TEXT | INCHI_OUT_XML_TEXT_COMMENTS | INCHI_OUT_TABBED_OUTPUT);
@@ -882,6 +1006,17 @@ int ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *s
882
1006
  #ifdef STEREO_WEDGE_ONLY
883
1007
  ip->bTautFlags |= bPointedEdgeStereo? TG_FLAG_POINTED_EDGE_STEREO : 0;
884
1008
  #endif
1009
+ #if( FIX_ADJ_RAD == 1 )
1010
+ ip->bTautFlags |= bFixAdjacentRad? TG_FLAG_FIX_ADJ_RADICALS : 0;
1011
+ #endif
1012
+ #if( ADD_PHOSPHINE_STEREO == 1 )
1013
+ ip->bTautFlags |= bAddPhosphineStereo? TG_FLAG_PHOSPHINE_STEREO : 0;
1014
+ #endif
1015
+ #if( ADD_ARSINE_STEREO == 1 )
1016
+ ip->bTautFlags |= bAddArsineStereo? TG_FLAG_ARSINE_STEREO : 0;
1017
+ #endif
1018
+ ip->bTautFlags |= bFixSp3bug? TG_FLAG_FIX_SP3_BUG : 0;
1019
+
885
1020
  if ( !ip->nInputType ) {
886
1021
  ip->nInputType = INPUT_MOLFILE;
887
1022
  }
@@ -898,7 +1033,8 @@ int PrintInputParms( INCHI_FILE *log_file, INPUT_PARMS *ip )
898
1033
 
899
1034
  /* SDfile output */
900
1035
  if ( ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY ) {
901
- my_fprintf( log_file, "Output SDfile only\n" );
1036
+ my_fprintf( log_file, "Output SDfile only%s\n",
1037
+ (ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ATOMS_DT)? " (write H isotopes as D, T)":"" );
902
1038
  return 0;
903
1039
  }
904
1040
  /* tautomerism */
@@ -919,6 +1055,11 @@ int PrintInputParms( INCHI_FILE *log_file, INPUT_PARMS *ip )
919
1055
  }
920
1056
  }
921
1057
  my_fprintf( log_file, "\n");
1058
+ #if( FIX_ADJ_RAD == 1 )
1059
+ if ( ip->bTautFlags & TG_FLAG_FIX_ADJ_RADICALS ) {
1060
+ my_fprintf( log_file, "Fix Adjacent Radicals\n" );
1061
+ }
1062
+ #endif
922
1063
  i = 0;
923
1064
  /* isotopic */
924
1065
  if ( nMode & REQ_MODE_ISO ) {
@@ -960,11 +1101,27 @@ int PrintInputParms( INCHI_FILE *log_file, INPUT_PARMS *ip )
960
1101
  }
961
1102
  i = 0;
962
1103
  }
1104
+ #endif
963
1105
  if ( TG_FLAG_POINTED_EDGE_STEREO & ip->bTautFlags ) {
964
1106
  my_fprintf( log_file, "%sOnly narrow end of wedge points to stereocenter\n", i? "\n":"" );
965
1107
  i = 0;
966
1108
  }
1109
+ #if( ADD_PHOSPHINE_STEREO == 1 )
1110
+ if ( TG_FLAG_PHOSPHINE_STEREO & ip->bTautFlags ) {
1111
+ my_fprintf( log_file, "%sInclude phoshine stereochemistry\n", i? "\n":"" );
1112
+ i = 0;
1113
+ }
1114
+ #endif
1115
+ #if( ADD_ARSINE_STEREO == 1 )
1116
+ if ( TG_FLAG_ARSINE_STEREO & ip->bTautFlags ) {
1117
+ my_fprintf( log_file, "%sInclude arsine stereochemistry\n", i? "\n":"" );
1118
+ i = 0;
1119
+ }
967
1120
  #endif
1121
+ if ( TG_FLAG_FIX_SP3_BUG & ip->bTautFlags ) {
1122
+ my_fprintf( log_file, "%sFix bug leading to missing or undefined sp3 parity\n", i? "\n":"" );
1123
+ i = 0;
1124
+ }
968
1125
  } else {
969
1126
  my_fprintf( log_file, ", Stereo OFF");
970
1127
  }
@@ -1036,8 +1193,16 @@ int PrintInputParms( INCHI_FILE *log_file, INPUT_PARMS *ip )
1036
1193
  ip->nInputType == INPUT_MOLFILE? "MOLfile" :
1037
1194
  ip->nInputType == INPUT_SDFILE? "SDfile" :
1038
1195
  ip->nInputType == INPUT_CMLFILE? "CMLfile" :
1196
+ #if( READ_INCHI_STRING == 1 )
1197
+ ip->nInputType == INPUT_INCHI? "InChI (plain identifier)" :
1198
+ #endif
1199
+ #if( SPECIAL_BUILD == 1 )
1200
+ ip->nInputType == INPUT_INCHI_XML? "MoChI (xml)" :
1201
+ ip->nInputType == INPUT_INCHI_PLAIN? "MoChI (plain)" : "Unknown" );
1202
+ #else
1039
1203
  ip->nInputType == INPUT_INCHI_XML? "InChI (xml)" :
1040
1204
  ip->nInputType == INPUT_INCHI_PLAIN? "InChI (plain)" : "Unknown" );
1205
+ #endif
1041
1206
  if ( (ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE) &&
1042
1207
  ip->bGetMolfileNumber ) {
1043
1208
  my_fprintf( log_file, " (attempting to read Molfile number)" );
@@ -1066,10 +1231,10 @@ int PrintInputParms( INCHI_FILE *log_file, INPUT_PARMS *ip )
1066
1231
  my_fprintf( log_file, "%sUp to %d atoms per structure\n", i?"; ":"", MAX_ATOMS);
1067
1232
  i = 0;
1068
1233
  if ( ip->first_struct_number > 1 ) {
1069
- my_fprintf( log_file, "Skipping %d structure%s\n", ip->first_struct_number-1, ip->first_struct_number==2? "":"s" );
1234
+ my_fprintf( log_file, "Skipping %ld structure%s\n", ip->first_struct_number-1, ip->first_struct_number==2? "":"s" );
1070
1235
  }
1071
1236
  if ( ip->last_struct_number > 0 ) {
1072
- my_fprintf( log_file, "Terminate after structure #%d\n", ip->last_struct_number );
1237
+ my_fprintf( log_file, "Terminate after structure #%ld\n", ip->last_struct_number );
1073
1238
  }
1074
1239
  if ( ip->bSaveWarningStructsAsProblem && ip->path[3] && ip->path[3][0] ) {
1075
1240
  my_fprintf( log_file, "Saving warning structures into the problem file\n");
@@ -1144,8 +1309,7 @@ void HelpCommandLineParms( INCHI_FILE *f )
1144
1309
 
1145
1310
  #if ( bRELEASE_VERSION == 1 )
1146
1311
 
1147
- inchi_print_nodisplay( f, "%s ver %s.\n\nUsage:\ncInChI-1 inputFile [outputFile [logFile [problemFile]]] [%coption[ %coption...]]\n", INCHI_NAME, INCHI_VERSION, INCHI_OPTION_PREFX, INCHI_OPTION_PREFX);
1148
-
1312
+ inchi_print_nodisplay( f, "%s ver %s%s.\n\nUsage:\nc%s-%s inputFile [outputFile [logFile [problemFile]]] [%coption[ %coption...]]\n", INCHI_NAME, INCHI_VERSION, SPECIAL_BUILD_STRING, INCHI_NAME, INCHI_VERSION, INCHI_OPTION_PREFX, INCHI_OPTION_PREFX);
1149
1313
  inchi_print_nodisplay( f, "\nOptions:\n");
1150
1314
  inchi_print_nodisplay( f, " SNon Exclude stereo (Default: Include Absolute stereo)\n");
1151
1315
  inchi_print_nodisplay( f, " SRel Relative stereo\n");
@@ -1153,6 +1317,12 @@ void HelpCommandLineParms( INCHI_FILE *f )
1153
1317
  inchi_print_nodisplay( f, " SUCF Use Chiral Flag: On means Absolute stereo, Off - Relative\n");
1154
1318
  inchi_print_nodisplay( f, " SUU Include omitted unknown/undefined stereo\n");
1155
1319
  inchi_print_nodisplay( f, " NEWPS Narrow end of wedge points to stereocenter (default: both)\n");
1320
+ #if( ADD_PHOSPHINE_STEREO == 1 )
1321
+ inchi_print_nodisplay( f, " SPXYZ Include Phosphines Stereochemistry\n");
1322
+ #endif
1323
+ #if( ADD_ARSINE_STEREO == 1 )
1324
+ inchi_print_nodisplay( f, " SAsXYZ Include Arsines Stereochemistry\n");
1325
+ #endif
1156
1326
  inchi_print_nodisplay( f, " RecMet Include reconnected metals results\n");
1157
1327
  inchi_print_nodisplay( f, " FixedH Mobile H Perception Off (Default: On)\n");
1158
1328
  inchi_print_nodisplay( f, " AuxNone Omit auxiliary information (default: Include)\n");
@@ -1171,14 +1341,29 @@ void HelpCommandLineParms( INCHI_FILE *f )
1171
1341
  inchi_print_nodisplay( f, " Wnumber Set time-out per structure in seconds; W0 means unlimited\n");
1172
1342
  inchi_print_nodisplay( f, " SDF:DataHeader Read from the input SDfile the ID under this DataHeader\n");
1173
1343
  #if( ADD_CMLPP == 1 )
1174
- inchi_print_nodisplay( f, " CML Input in CML format (default for input file .CML extension) \n");
1344
+ inchi_print_nodisplay( f, " CML Input in CML format (default for input file .CML extension)\n");
1175
1345
  #endif
1176
1346
  inchi_print_nodisplay( f, " NoLabels Omit structure number, DataHeader and ID from %s output\n", INCHI_NAME);
1177
1347
  inchi_print_nodisplay( f, " Tabbed Separate structure number, %s, and AuxIndo with tabs\n", INCHI_NAME);
1178
1348
  inchi_print_nodisplay( f, " OutputSDF Convert %s created with default aux. info to SDfile\n", INCHI_NAME);
1349
+ #ifdef INCHI_MAIN
1350
+ inchi_print_nodisplay( f, " InChI2Struct Test mode: Mol/SDfile->%s->Structure->%s and a structure in AuxInfo format\n", INCHI_NAME, INCHI_NAME);
1351
+ #else
1352
+ /*
1353
+ inchi_print_nodisplay( f, " InChI2Struct Convert %s string into a structure in AuxInfo format and its %s\n", INCHI_NAME, INCHI_NAME);
1354
+ */
1355
+ #endif
1356
+ inchi_print_nodisplay( f, " InChI2InChI Convert %s string into %s string for validation purposes\n", INCHI_NAME, INCHI_NAME);
1357
+ #if ( SDF_OUTPUT_DT == 1 )
1358
+ inchi_print_nodisplay( f, " SdfAtomsDT Output Hydrogen Isotopes to SDfile as Atoms D and T\n");
1359
+ #endif
1179
1360
  inchi_print_nodisplay( f, " STDIO Use standard input/output streams\n");
1361
+ inchi_print_nodisplay( f, " FB (or FixSp3Bug) Fix bug leading to missing or undefined sp3 parity\n" );
1180
1362
  inchi_print_nodisplay( f, " WarnOnEmptyStructure Warn and produce empty %s for empty structure\n", INCHI_NAME);
1181
-
1363
+ #if( FIX_ADJ_RAD == 1 )
1364
+ inchi_print_nodisplay( f, " FixRad Fix Adjacent Radicals\n");
1365
+ #endif
1366
+
1182
1367
  #else
1183
1368
 
1184
1369
  inchi_print_nodisplay( f, "%s ver %s. Special testing version 12-12-2002.\n", INCHI_NAME, INCHI_VERSION);
@@ -1245,27 +1430,30 @@ int OpenFiles( FILE **inp_file, FILE **output_file, FILE **log_file, FILE **prb_
1245
1430
  */
1246
1431
  /* logfile -- open es early as possible */
1247
1432
  if ( !ip->path[2] || !ip->path[2][0] ) {
1248
- my_fprintf( stderr, "%s version %s%s\n", INCHI_NAME, INCHI_VERSION, bRELEASE_VERSION? "":" (For pre-release testing)" );
1433
+ my_fprintf( stderr, "%s version %s%s%s\n", INCHI_NAME, INCHI_VERSION, SPECIAL_BUILD_STRING, bRELEASE_VERSION? "":" (For pre-release testing)" );
1249
1434
  my_fprintf( stderr, "Log file not specified. Using standard error output.\n");
1250
1435
  *log_file = stderr;
1251
1436
  } else
1252
1437
  if ( !(*log_file = fopen( ip->path[2], "w" ) ) ) {
1253
- //my_fprintf( stderr, "%s version %s%s\n", INCHI_NAME, INCHI_VERSION, bRELEASE_VERSION? "":" (For pre-release testing)" );
1254
- //my_fprintf( stderr, "Cannot open log file '%s'. Using standard error output.\n", ip->path[2] );
1438
+ my_fprintf( stderr, "%s version %s%s%s\n", INCHI_NAME, INCHI_VERSION, SPECIAL_BUILD_STRING, bRELEASE_VERSION? "":" (For pre-release testing)" );
1439
+ my_fprintf( stderr, "Cannot open log file '%s'. Using standard error output.\n", ip->path[2] );
1255
1440
  *log_file = stderr;
1256
1441
  } else {
1257
- my_fprintf( *log_file, "%s version %s%s\n", INCHI_NAME, INCHI_VERSION, bRELEASE_VERSION? "":" (For pre-release testing)" );
1442
+ //my_fprintf( *log_file, "%s version %s%s%s\n", INCHI_NAME, INCHI_VERSION, SPECIAL_BUILD_STRING, bRELEASE_VERSION? "":" (For pre-release testing)" );
1258
1443
  //my_fprintf( *log_file, "Opened log file '%s'\n", ip->path[2] );
1259
1444
  }
1260
1445
  /* input file */
1261
- if ( (ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE || ip->nInputType == INPUT_CMLFILE) && ip->num_paths > 0 ) {
1446
+ if ( (ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE ||
1447
+ ip->nInputType == INPUT_CMLFILE || ip->nInputType == INPUT_INCHI) && ip->num_paths > 0 ) {
1262
1448
  const char *fmode = NULL;
1263
1449
  #if( defined(_MSC_VER)&&defined(_WIN32) || defined(__BORLANDC__)&&defined(__WIN32__) || defined(__GNUC__)&&defined(__MINGW32__)&&defined(_WIN32) )
1264
1450
  /* compilers that definitely allow fopen "rb" (binary read) mode */
1451
+ fmode = "rb";
1265
1452
  if ( !ip->path[0] || !ip->path[0][0] || !(*inp_file = fopen( ip->path[0], "rb" ) ) ) {
1266
1453
  my_fprintf( *log_file, "Cannot open input file '%s'. Terminating.\n", ip->path[0]? ip->path[0] : "<No name>" );
1267
1454
  goto exit_function;
1268
- } else {
1455
+ } else
1456
+ if ( ip->nInputType == INPUT_CMLFILE ) {
1269
1457
  int c;
1270
1458
  #ifdef CML_DEBUG
1271
1459
  printf ("cr %d lf %d ret %d\n", (int) '\r', (int) '\f', (int) '\n');
@@ -1280,7 +1468,7 @@ int OpenFiles( FILE **inp_file, FILE **output_file, FILE **log_file, FILE **prb_
1280
1468
  my_fprintf( *log_file, "Cannot open input file '%s' (2nd attempt). Terminating.\n", ip->path[0] );
1281
1469
  goto exit_function;
1282
1470
  }
1283
- //my_fprintf( *log_file, "Opened input file '%s'\n", ip->path[0] );
1471
+ my_fprintf( *log_file, "Opened input file '%s'\n", ip->path[0] );
1284
1472
  fmode = "r";
1285
1473
  } else {
1286
1474
  fclose( *inp_file );
@@ -1303,7 +1491,7 @@ int OpenFiles( FILE **inp_file, FILE **output_file, FILE **log_file, FILE **prb_
1303
1491
  #endif
1304
1492
  DetectInputINChIFileType( inp_file, ip, fmode );
1305
1493
  } else
1306
- if ( (ip->nInputType != INPUT_MOLFILE && ip->nInputType != INPUT_SDFILE && ip->nInputType != INPUT_CMLFILE) ) {
1494
+ if ( (ip->nInputType != INPUT_MOLFILE && ip->nInputType != INPUT_SDFILE && ip->nInputType != INPUT_CMLFILE && ip->nInputType != INPUT_INCHI) ) {
1307
1495
  my_fprintf( *log_file, "Input file type not specified. Terminating.\n");
1308
1496
  goto exit_function;
1309
1497
  } else {
@@ -1331,7 +1519,13 @@ int OpenFiles( FILE **inp_file, FILE **output_file, FILE **log_file, FILE **prb_
1331
1519
  }
1332
1520
  /* problem file */
1333
1521
  if ( ip->path[3] && ip->path[3][0] ) {
1334
- if ( !(*prb_file = fopen( ip->path[3], "w" ) ) ) {
1522
+ const char *fmode = "w";
1523
+ #if( defined(_MSC_VER)&&defined(_WIN32) || defined(__BORLANDC__)&&defined(__WIN32__) || defined(__GNUC__)&&defined(__MINGW32__)&&defined(_WIN32) )
1524
+ if ( ip->nInputType != INPUT_CMLFILE ) {
1525
+ fmode = "wb";
1526
+ }
1527
+ #endif
1528
+ if ( !(*prb_file = fopen( ip->path[3], fmode ) ) ) {
1335
1529
  my_fprintf( *log_file, "Cannot open problem file '%s'. Terminating.\n", ip->path[3] );
1336
1530
  goto exit_function;
1337
1531
  } else {
@@ -1344,7 +1538,7 @@ exit_function:
1344
1538
  return 0; /* failed */
1345
1539
 
1346
1540
  }
1347
- #define NUM_VERSIONS 4
1541
+ #define NUM_VERSIONS 6
1348
1542
  #define LEN_VERSIONS 64
1349
1543
  /*******************************************************************/
1350
1544
  static int bMatchOnePrefix( int len, char *str, int lenPrefix[],
@@ -1382,7 +1576,7 @@ int DetectInputINChIFileType( FILE **inp_file, INPUT_PARMS *ip, const char *fmod
1382
1576
  static int lenXmlMsgFatal;
1383
1577
  static int bInitilized = 0;
1384
1578
  int bINChI_plain = 0, bINChI_xml = 0, len, i;
1385
- if ( ip->nInputType == INPUT_INCHI_XML || ip->nInputType == INPUT_INCHI_PLAIN ) {
1579
+ if ( ip->nInputType == INPUT_INCHI_XML || ip->nInputType == INPUT_INCHI_PLAIN || ip->nInputType == INPUT_INCHI ) {
1386
1580
  return 1;
1387
1581
  }
1388
1582
  if ( !bInitilized ) {
@@ -1390,18 +1584,26 @@ int DetectInputINChIFileType( FILE **inp_file, INPUT_PARMS *ip, const char *fmod
1390
1584
  lenPlnVersion[1] = sprintf( szPlnVersion[1], "INChI=1.12Beta/" );
1391
1585
  lenPlnVersion[2] = sprintf( szPlnVersion[2], "INChI=1.0RC/" );
1392
1586
  lenPlnVersion[3] = sprintf( szPlnVersion[3], "InChI=1.0RC/" );
1587
+ lenPlnVersion[4] = sprintf( szPlnVersion[4], "InChI=1/" );
1588
+ lenPlnVersion[5] = sprintf( szPlnVersion[5], "MoChI=1a/" );
1393
1589
  lenPlnAuxVer[0] = sprintf( szPlnAuxVer[0], "AuxInfo=%s/", INCHI_VERSION );
1394
1590
  lenPlnAuxVer[1] = sprintf( szPlnAuxVer[1], "AuxInfo=1.12Beta/" );
1395
1591
  lenPlnAuxVer[2] = sprintf( szPlnAuxVer[2], "AuxInfo=1.0RC/" );
1396
1592
  lenPlnAuxVer[3] = sprintf( szPlnAuxVer[3], "AuxInfo=1.0RC/" );
1593
+ lenPlnAuxVer[4] = sprintf( szPlnAuxVer[4], "AuxInfo=1/" );
1594
+ lenPlnAuxVer[5] = sprintf( szPlnAuxVer[5], "AuxInfo=1a/" );
1397
1595
  lenXmlVersion[0] = sprintf( szXmlVersion[0], "<%s version=\"%s\">", INCHI_NAME, INCHI_VERSION );
1398
1596
  lenXmlVersion[1] = sprintf( szXmlVersion[1], "<INChI version=\"1.12Beta\">" );
1399
1597
  lenXmlVersion[2] = sprintf( szXmlVersion[2], "<INChI version=\"1.0RC\">" );
1400
1598
  lenXmlVersion[3] = sprintf( szXmlVersion[3], "<InChI version=\"1.0RC\">" );
1599
+ lenXmlVersion[4] = sprintf( szXmlVersion[4], "<InChI version=\"1\">" );
1600
+ lenXmlVersion[5] = sprintf( szXmlVersion[5], "<MoChI version=\"1a\">" );
1401
1601
  lenXmlIdentVer[0] = sprintf( szXmlIdentVer[0], "<identifier version=\"%s\"", INCHI_VERSION );
1402
1602
  lenXmlIdentVer[1] = sprintf( szXmlIdentVer[1], "<identifier version=\"1.12Beta\"" );
1403
1603
  lenXmlIdentVer[2] = sprintf( szXmlIdentVer[2], "<identifier version=\"1.0RC\"" );
1404
1604
  lenXmlIdentVer[3] = sprintf( szXmlIdentVer[3], "<identifier version=\"1.0RC\"" );
1605
+ lenXmlIdentVer[4] = sprintf( szXmlIdentVer[4], "<identifier version=\"1\"" );
1606
+ lenXmlIdentVer[5] = sprintf( szXmlIdentVer[5], "<identifier version=\"1a\"" );
1405
1607
  lenXmlMsgError = sprintf( szXmlMsgError, "<message type=\"error (no %s)\"", INCHI_NAME );
1406
1608
  lenXmlStruct = strlen(szXmlStruct);
1407
1609
  lenXmlMsgFatal = strlen(szXmlMsgFatal);