Craig A. James wrote: > Chris Morley wrote: >> In the V2000 MOL file interpreter in the trunk code (potentially for >> v2.3.0), numbers need to be right-justified in their fields. So the >> first molecule in the drugbank dataset ( http://www.drugbank.ca/ ) >> fails silently with 0 atoms, 0 bonds. I cannot find a justification >> requirement for any number in the specification. Is there a reason for >> OB to reject left-justified numbers? (I think v2.2.3 accepted them.) > > That may be a side effect of some code I added a while back to prevent > core dumps on badly formed SD files. It wasn't checking these fields, > and non-numeric data and other junk would make it segfault. I'll look > at the CTAB spec and see if there's any requirement one way or the > other, but it seems like a harmless enough "extension" even if the spec > doesn't allow it.
I looked through the MDL V2000 CTAB spec, and there's nothing that says a field has to be right justified. Since the original software spec was designed for FORTRAN code, I thought I'd check the FORTRAN spec, which specifically says that trailing blanks in an integer field are ignored. http://www.fortran.com/F77_std/rjcnf0001-sh-13.html#sh-13.5.8 "If a BN edit descriptor [i.e. a blank character] is encountered in a format specification, all such blank characters in succeeding numeric input fields are ignored. The effect of ignoring blanks is to treat the input field as if blanks had been removed, the remaining portion of the field right-justified, and the blanks replaced as leading blanks. However, a field of all blanks has the value zero." So if we wanted to go with the original spirit of the CTAB spec, we'd allow blanks after a number, and an all-blank field is the same as a "0" field. Chris, can you test this on your file? Craig $ svn diff mdlformat.cpp Index: mdlformat.cpp =================================================================== --- mdlformat.cpp (revision 3495) +++ mdlformat.cpp (working copy) @@ -1388,7 +1388,7 @@ char *end; if (s == NULL) return 0; int n = strtol(s, &end, 10); - if (*end != '\0') return 0; + if (*end != '\0' && *end != ' ') return 0; return n; } @@ -1397,7 +1397,7 @@ char *end; if (s == NULL) return 0; int n = strtoul(s, &end, 10); - if (*end != '\0') return 0; + if (*end != '\0' && *end != ' ') return 0; return n; } } ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ OpenBabel-Devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbabel-devel
