Reflection files format: Difference between revisions

(Created page with "CCP4 reflection files are binary files that are usually read by routines from CCP4 libraries. However, sometimes one wants to read them with a different programming language o...")
 
Line 198: Line 198:
The CCP4 LCF (labelled column format) files were phased-out in the early 90's but some interesting data still lingers on half-inch tapes so, if they can be read, the LCF files can be converted to ASCII or other formats for safe-keeping, or further use.  
The CCP4 LCF (labelled column format) files were phased-out in the early 90's but some interesting data still lingers on half-inch tapes so, if they can be read, the LCF files can be converted to ASCII or other formats for safe-keeping, or further use.  
Jonathan Cooper has worked out how to read them, mainly using Python, and [https://readingccp4lcffiles.blogspot.com/ documents this].
Jonathan Cooper has worked out how to read them, mainly using Python, and [https://readingccp4lcffiles.blogspot.com/ documents this].
A Fortran program (lcf_dump) to accomplish this is:
<pre>
! reads cell from LCF file - Kay Diederichs 7/2019 .
! TODO - determine ncol, offset from data in file
! reading VAX format is easy with the ifort compiler since it understands VAX REAL format:
! ifort lcf_dump.f90 -o lcf_dump
IMPLICIT NONE
! LCF items
INTEGER(2) :: header(8)
INTEGER(2), ALLOCATABLE :: refdat(:)
REAL :: cell(6)
CHARACTER :: separator*12 ! length may depend on machine that wrote LCF file
! program variables
INTEGER :: i,ncol,offset
CHARACTER :: string*120
i=COMMAND_ARGUMENT_COUNT()
IF (i/=3) STOP 'usage: lcf_dump <name.LCF> ncol offset'
! read command line
CALL GET_COMMAND_ARGUMENT(1,string)  ! expects LCF filename on command line
! OPEN(CONVERT=...) options are documented at
! https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference-open-convert-specifier
OPEN(1,FILE=string,ACCESS='STREAM',ACTION='READ',CONVERT='VAXG')
WRITE(*,*) 'LCF file: ',TRIM(string)
CALL GET_COMMAND_ARGUMENT(2,string)  ! expects NCOL
READ(string,*) ncol
ALLOCATE(refdat(ncol))
CALL GET_COMMAND_ARGUMENT(3,string)  ! expects NCOL
READ(string,*) offset
WRITE(*,*) 'ncol, offset:',ncol,offset
! read header and cell
READ(1) header,separator  ! reads 8*2+12 bytes. ends after byte 28
WRITE(*,'(a,8(i0,1x))') ' header: ',header
DO i=1,6
  READ(1) cell(i),separator  ! reads 6*(4+12) bytes. ends after byte 124
END DO
WRITE(*,'(a,6f10.4)') ' cell:',cell
! read column labels and comment
string=''
DO i=1,22
  READ(1)string(1+(i-1)*4:i*4),separator
END DO
WRITE(*,'(a)') TRIM(string)
! read reflections
READ(1) refdat(1:2) ! needed for positioning - what is their meaning?
DO
  READ(1) refdat
  IF (refdat(1)==32767) EXIT
  WRITE(*,*) refdat
END DO
END
</pre>
1,330

edits