Sunday, June 25, 2006

Line Endings and LEaP programs

AFAIK, Apple has not declared a standard line ending for Mac OS X even now. But the convention of MacOS 9 is using CR (a single Carriage-Return character) while the nature of UNIX in Mac OS X is favoring LF (a single Line-Feed character) as the default line ending. Also the line ending of DOS/Windows is CRLF (a Carriage-Return + Line-Feed pair).

Both DOS and MacOS 9 line endings show ^M under UNIX but different style. Therefore if you use LEaP to import text file (e.g. PDB file) from Windows or from Mac, it's highly possible that LEaP doesn't like the format at all. The "default" text editor in Mac OS X TextEdit.app can recognize either of the 3 kind of the line ending but it probably simply us CR.

From the AMBER Mail Reflector, Professor Di Giorgio complaint about the problem loading PDB file in LEaP program, and I checked the file the professor posted on the reflector, I not only found CR endings also separated LF endings! So I recommend to use a perl script (I call it: mac2unix) to fix the problem,

#!/usr/bin/perl -pi
chomp;
s/\r/\n/g;
Use nano command to create this file, and then chmod +x this file. Later you can just do ./mac2unix Desktop/znnew.pdb to convert the line endings.

References:
  1. Apple Computer 2006. Changing Line Endings. In Xcode 2.3 User Guide.
  2. Di Giorgio. 2006. Difficulty loading a pdb file. In The AMBER Mail Reflector