In article <hans.engkvist-1012991328060001 at pan.genpat.uu.se>, hans.engkvist at REMOVEFORREPLYgenpat.uu.se (Hans Engkvist) writes:
>Hello,
>someone here who knows?
>I would like to do my own analysis of the data in a ABI sequencing gel file.
>Unfortuantely I can't figure out in what format/file type the data is in.
>Is it a image format? Other kind of matrix data?
I had to figure this out by working backwords from a trace file, and
dumping the data in different hex formats using a true hack of a program I
wrote called DATASNIFFER.FOR. See ABI.TXT after my signature for the
layout I arrived at. I did this on an OpenVMS Alpha machine so byte orders
needed to be reversed relative to the Macintosh types used in the the file.
I also wrote a small fortran program to test my observations/convert an
ABI file to a text format. It's called ABIBREAKOUT.FOR and also
follows my signature. Note that to use it you'll have to be sure that
float is a 4 byte IEEE value and you may need to change around the byte
swapping routines if your machine goes the other way.
Just for good measure, I put DATASNIFFER.FOR in here too.
Use any or all of it as you wish.
Regards,
David Mathog
mathog at seqaxp.bio.caltech.edu
Manager, sequence analysis facility, biology division, Caltech
**************************************************************************
*** abi.txt ************************************************************
!Absolute positions here start at 1 and INCLUDE 128 byte MacBinary header
!Offsets in an ABI file are C standard - they start 0 for the first byte and
! do NOT include the MacBinary header (which may or may not be present)
!Convert these absolute positions to offsets by subtracting 129 (and vice versa)
!
! Byte order from Macintosh is REVERSE of that under OpenVMS on ALPHA
!
!INT1 = unsigned integer 1
!INT2 = unsigned integer 2, most significant byte at N+1, least at N
! Except for Matrix, where it is a signed integer 2, holding
! value * 1000
!INT4 = unsigned integer 4, most significant byte at N+3, least at N
!INT10 = unknown 10 byte data structure that some fields use
!INT28 = FLAG structures
!FLT4 = signed floating point number, 4 bytes, IEEE float format
!
! consist of:
! FLAG = 4 INT1 = text, case specific (apparently) like "DATA"
! INSTANCE = INT4, the instance of this type of FLAG, >= 1.
! DATATYPE = INT2, the data type this flag structure contains. Known
! types are:
! 1023 FLAG structures (28 bytes)
! 2 Text (no count byte, see 18 below) Used for text
! <4 bytes and stored as immediate values, or long
! text, like DNA sequences
! 4 (Series) of INT2
! 7 (Series) of FLT4
! 10 DATE structure (4 bytes)
! 11 TIME structure (4 bytes)
! 12 ?? (Series) of INT10, used by THUM
! 13 ?? (Series) of INT1, used by AUTO and CAGT
! 18 Text (first byte is length, rest is text)
! DATASIZE = INT2, the size of the data type in bytes
! NRECORDS = INT4, the number of records of this datatype present
! NBYTES = INT4, the number of bytes in all of these records
! VALUE = 4 bytes. A space that holds one of these:
! 1. INT4 POINTER to actual data elsewhere in file (value of
! zero for a pointer indicates no field contents)
! OR
! 2. The DATA itself (packed into this space, may leave
! zero bytes)
! REMAINDER = If the VALUE does not use all 4 bytes.
! SPARE = INT4. Not quite sure yet what this does, but it looks
! like it might be just uninitialized data.
!
!FLAGs are 4 consecutive bytes, visible ASCII characters, like "DATA"
!"text" = string of bytes
129 VALUE = (A,B,I,F) "FLAG" 4 X INT1 (ABI File type marker)
133 VALUE = 0 INT1 (unknown purpose)
134 VALUE = 65 INT1 ("e") (unknown purpose)
135 tdir FLAG (Pointer to Multiple FLAG region)
INSTANCE = 1 INT4
DATATYPE = 1023 INT2
DATASIXE = 28 INT2
NRECORDS = 69 INT4
NBYTES = 2240 INT4
VALUE = POINTER to Front of Multiple FLAG region INT4
SPARE = 30594184 INT4
160 VALUE = FFx, padding up to and including offset 128 N X INT2
257 THUM structure 1, INT10 (???)
267 THUM structure 2, INT10 (???)
277 MACHINE length INT1
278 MACHINE text
284 RUN STARTED AT TITLE length INT1
285 RUN STARTED AT TITLE text N X INT1
300 RUN STOPPED AT TITLE length INT1
301 RUN STOPPED AT TITLE text N X INT1
316 MATRIX FILE 1 length INT1
317 MATRIX FILE 1 text N X INT1
342 MATRIX FILE 2 length INT1
343 MATRIX FILE 2 text N X INT1
368 GEL FILE NAME length INT1
369 GEL FILE NAME text N X INT1
377 GEL FILE PATH length INT1
378 GEL FILE PATH text N X INT1
437 MATRIX 1 (4 x 4 INT2) "Primer Matrix"
501 MATRIX 2 (4 x 4 INT2) "Taq Term. Matrix"
565 MATRIX 3 (4 x 4 INT2) "T7 Term. Matrix"
469 MATRIX 101 (4 x 4 INT2) These three seem to be duplicates of the
533 MATRIX 102 (4 x 4 INT2) first three
615 MATRIX 103 (4 x 4 INT2)
Values for MATRIX structures are Inverse Matrix * 1000
stored as signed INT2
629 SAMPLE length INT1
630 SAMPLE text N X INT1
642 DYESET/PRIMER 1 length INT1
643 DYESET/PRIMER 1 text N X INT1
666 DYESET/PRIMER 2 length INT1
667 DYESET/PRIMER 2 text N X INT1
690 COMMENT TITLE length INT1
691 COMMENT TITLE text N X INT1
699 VOLTAGE? N X INT2
1159 CURRENT? N X INT2
2079 POWER? N X INT2
1619 TEMPERATURE N X INT2
2539 RAW G TRACE N X INT2
17243 RAW A TRACE N X INT2
31947 RAW C TRACE N X INT2
46651 RAW T TRACE N X INT2
61355 PROCESSED TRACE G N X INT2
79445 PROCESSED TRACE A N X INT2
97175 PROCESSED TRACE C N X INT2
115625 PROCESSED TRACE T N X INT2
133715 BASE TO TRACE ARRAY 1 N X INT2
135139 CALLED SEQUENCE 1 N X INT1
135851 BASE TO TRACE ARRAY 2 N X INT2
137275 CALLED SEQUENCE 2 N X INT1
137987 #(G,A,T,C) in CALLED SEQUENCE 2 4 X INT2
137995 BASECALLER length INT1
137996 BASECALLER text N X INT1
138001 BASECALLER VERSION length INT1
138002 BASECALLER VERSION text N X INT1
138013 AEPt FLAG (Number of Scans)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 1 INT4
NBYTES = 2 INT4
VALUE = 7352 INT2
REMAINDER= 0 INT2
SPARE = 0 INT4
138041 AEPt FLAG (Number of Scans)
INSTANCE = 2 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 1 INT4
NBYTES = 1 INT4
VALUE = 7352 INT2
REMAINDER= 0 INT2
SPARE = 0 INT4
138069 ASPF FLAG (???)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 1 INT4
NBYTES = 1 INT4
VALUE = 0 INT2
REMAINDER= 0 INT2
SPARE = 0 INT4
138097 ASPt FLAG (Base Call Start, Primer Peak Loc.?)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 1 INT4
NBYTES = 2 INT4
VALUE = 805 INT2
REMAINDER= 0 INT2
SPARE = 0 INT4
138125 ASPt FLAG (Base Call Start, Primer Peak Loc.?)
INSTANCE = 2 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 1 INT4
NBYTES = 2 INT4
VALUE = 805 INT2
REMAINDER= 0 INT2
SPARE = 0 INT4
138153 AUTO FLAG (???)
INSTANCE = 1 INT4
DATATYPE = 13 INT2
DATASIZE = 1 INT2
NRECORDS = 3 INT4
NBYTES = 3 INT4
VALUE = (0,0,0) 3 X INT1
REMAINDER= 0 INT1
SPARE = 0 INT4
138181 B1Pt FLAG (Base Call 1 Start)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 1 INT4
NBYTES = 2 INT4
VALUE = 805 INT2
REMAINDER= 0 INT2
SPARE = 0 INT4
138209 B1Pt FLAG (Base Call 2 Start)
INSTANCE = 2 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 1 INT4
NBYTES = 2 INT4
VALUE = 805 INT2
REMAINDER= 0 INT2
SPARE = 0 INT4
138237 CAGT FLAG (???)
INSTANCE = 1 INT4
DATATYPE = 13 INT2
DATASIZE = 1 INT2
NRECORDS = 4 INT4
NBYTES = 4 INT4
VALUE = (0,0,0,0) 4 X INT1
SPARE = 0 INT4
138265 CMBF FLAG (Comb field/file??)
INSTANCE = 1 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 1 INT4
NBYTES = 1 INT4
VALUE = 0 INT1
REMAINDER= (0,0,0) 3 X INT1
SPARE = 0 INT4
138293 CMNT FLAG (Comment field)
INSTANCE = 1 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 1 INT4
NBYTES = 1 INT4
VALUE = POINTER to COMMENT FIELD INT4
SPARE = 0 INT4
138321 CTTL FLAG (Comment Title)
INSTANCE = 1 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 9 INT4
NBYTES = 9 INT4
VALUE = POINTER TO COMMENT TITLE, INT4
SPARE = 0 INT4
138349 DATA FLAG (Raw G Trace)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 7352 INT4
NBYTES = 14704 INT4
VALUE = POINTER TO RAW G TRACE INT4
SPARE = 0 INT4
138377 DATA FLAG (Raw A Trace)
INSTANCE = 2 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 7352 INT4
NBYTES = 14704 INT4
VALUE = POINTER TO RAW A TRACE INT4
SPARE = 0 INT4
138405 DATA FLAG (Raw C Trace)
INSTANCE = 3 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 7352 INT4
NBYTES = 14704 INT4
VALUE = POINTER TO RAW C TRACE INT4
SPARE = 0 INT4
138433 DATA FLAG (Raw T Trace)
INSTANCE = 4 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 7352 INT4
NBYTES = 14704 INT4
VALUE = POINTER TO RAW T TRACE INT4
SPARE = 0 INT4
138461 DATA FLAG (Voltage?)
INSTANCE = 5 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 230 INT4
NBYTES = 460 INT4
VALUE = POINTER TO VOLTAGE? INT4
SPARE = 0 INT4
138489 DATA FLAG (Current?)
INSTANCE = 6 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 230 INT4
NBYTES = 460 INT4
VALUE = POINTER TO CURRENT? INT4
SPARE = 0 INT4
138517 DATA FLAG (Power?)
INSTANCE = 7 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 230 INT4
NBYTES = 460 INT4
VALUE = POINTER TO POWER? INT4
SPARE = 0 INT4
138545 DATA FLAG (Temperature?)
INSTANCE = 8 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 230 INT4
NBYTES = 460 INT4
VALUE = POINTER TO TEMPERATURE INT4
SPARE = 0 INT4
138573 DATA FLAG ( Final G Trace)
INSTANCE = 9 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 9045 INT4
NBYTES = 18090 INT4
VALUE = POINTER TO PROCESSED TRACE G INT4
SPARE = 30594116 INT4
138601 DATA FLAG ( Final A Trace)
INSTANCE = 10 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 9045 INT4
NBYTES = 18090 INT4
VALUE = POINTER TO PROCESSED TRACE A INT4
SPARE = 30594152 INT4
138629 DATA FLAG ( Final C Trace)
INSTANCE = 11 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 9045 INT4
NBYTES = 18090 INT4
VALUE = POINTER TO PROCESSED TRACE C INT4
SPARE = 30594172 INT4
138657 DATA FLAG ( Final T Trace)
INSTANCE = 12 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 9045 INT4
NBYTES = 18090 INT4
VALUE = POINTER TO PROCESSED TRACE T INT4
SPARE = 30594136 INT4
138685 EVNT FLAG ( Run started at title)
INSTANCE = 1 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 16 INT4
NBYTES = 16 INT4
VALUE = POINTER to RUN STARTED AT TITLE
SPARE = 0 INT4
138713 EVNT FLAG ( Run stopped at title)
INSTANCE = 2 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 16 INT4
NBYTES = 16 INT4
VALUE = POINTER to RUN STOPPED AT TITLE
SPARE = 0 INT4
138741 FWO_ FLAG ( Field order )
INSTANCE = 1 INT4
DATATYPE = 2 INT2
DATASIZE = 1 INT2
NRECORDS = 4 INT4
NBYTES = 4 INT4
VALUE = "GATC" 4 X INT1
SPARE = 0 INT4
138769 GLEN FLAG (Gel file name)
INSTANCE = 1 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 9 INT4
NBYTES = 9 INT4
VALUE = POINTER TO GEL FILE NAME INT4
SPARE = 0 INT4
138797 GELP FLAG (Gel file path)
INSTANCE = 1 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 60 INT4
NBYTES = 60 INT4
VALUE = POINTER TO GEL FILE PATH INT4
SPARE = 0 INT4
138825 LANE FLAG (number of lane)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 1 INT2
NRECORDS = 2 INT4
NBYTES = 2 INT4
VALUE = (0,8) 2 X INT2
SPARE = 0 INT4
138853 MCHN FLAG (Name of machine)
INSTANCE = 1 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 7 INT4
NBYTES = 7 INT4
VALUE = POINTER to MACHINE, INT4
SPARE = 0 INT4
138881 MODL FLAG (Name of model)
INSTANCE = 1 INT4
DATATYPE = 2 INT2
DATASIZE = 1 INT2
NRECORDS = 4 INT4
NBYTES = 4 INT4
VALUE = "<SP>373" 4 X INT1
SPARE = 0 INT4
138909 MTRX FLAG (Matrix 1 "Primer Matrix")
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 16 INT4
NBYTES = 32 INT4
VALUE = POINTER to MATRIX 1 INT4
SPARE = 0 INT4
138937 MTRX FLAG (Matrix 2 "Taq Term. Matrix")
INSTANCE = 2 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 16 INT4
NBYTES = 32 INT4
VALUE = POINTER to MATRIX 2 INT4
SPARE = 0 INT4
138965 MTRX FLAG (Matrix 3 "T7 Term. Matrix")
INSTANCE = 3 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 16 INT4
NBYTES = 32 INT4
VALUE = POINTER to MATRIX 3 INT4
SPARE = 0 INT4
138993 MTRX FLAG (Matrix 101)
INSTANCE = 101 INT4 <-- Out of ORDER, missing a bunch in between
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 16 INT4
NBYTES = 32 INT4
VALUE = POINTER to MATRIX 101 INT4
SPARE = 30594132 INT4
139021 MTRX FLAG (Matrix 102)
INSTANCE = 102 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 16 INT4
NBYTES = 32 INT4
VALUE = POINTER to MATRIX 102 INT4
SPARE = 30594128 INT4
139049 MTRX FLAG (Matrix 103)
INSTANCE = 103 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 16 INT4
NBYTES = 32 INT4
VALUE = POINTER to MATRIX 103 INT4
SPARE = 30671314 INT4
139077 MTXF FLAG (Matrix File)
INSTANCE = 1 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 26 INT4
NBYTES = 26 INT4
VALUE = POINTER to MATRIX FILE 1 INT4
SPARE = 0 INT4
139105 MTXF FLAG (Matrix File)
INSTANCE = 2 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 26 INT4
NBYTES = 26 INT4
VALUE = POINTER to MATRIX FILE 2 INT4
SPARE = 30594148 INT4
139133 NAVG FLAG (Number of Channels Averaged)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 1 INT4
NBYTES = 2 INT4
VALUE = 3 INT2
REMAINDER= 0 INT2
SPARE = 0 INT4
139161 NChn FLAG (Number of Channels in Machine)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 1 INT4
NBYTES = 2 INT4
VALUE = 388 INT2
REMAINDER= 0 INT2
SPARE = 0 INT4
139189 NLNE FLAG (Number of Lanes on Gel) 48 lanes
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 1 INT4
NBYTES = 2 INT4
VALUE = 48 INT2
REMAINDER= 0 INT2
SPARE = 0 INT4
139217 PBAS FLAG (Called Sequence 1)
INSTANCE = 1 INT4
DATATYPE = 2 INT2
DATASIZE = 1 INT2
NRECORDS = 712 INT4
NBYTES = 712 INT4
VALUE = POINTER to CALLED SEQUENCE 1 INT4
SPARE = 30594160 INT4
139245 PBAS FLAG (Called Sequence 2)
INSTANCE = 2 INT4
DATATYPE = 2 INT2
DATASIZE = 1 INT2
NRECORDS = 712 INT4
NBYTES = 712 INT4
VALUE = POINTER to CALLED SEQUENCE 2 INT4
SPARE = 30594164 INT4
139273 PDMF FLAG (Dyeset/Primer 1)
INSTANCE = 1 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 24 INT4
NBYTES = 24 INT4
VALUE = POINTER to DYESET/PRIMER 1 INT4
SPARE = 0 INT4
139301 PDMF FLAG (Dyeset/Primer 2)
INSTANCE = 2 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 24 INT4
NBYTES = 24 INT4
VALUE = POINTER to DYESET/PRIMER 2 INT4
SPARE = 30594144 INT4
139329 PLOC FLAG (Base to Trace 1)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 712 INT4
NBYTES = 1424 INT4
VALUE = POINTER TO BASE to TRACE ARRAY 1 INT4
SPARE = 30594192 INT4
139357 PLOC FLAG (Base to Trace 2)
INSTANCE = 2 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 712 INT4
NBYTES = 1424 INT4
VALUE = POINTER TO BASE to TRACE ARRAY 2 INT4
SPARE = 30594124 INT4
139385 PPOS FLAG (Primer Position in raw)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 1 INT4
NBYTES = 2 INT4
VALUE = 940 INT2
REMAINDER= 0 INT2
SPARE = 0 INT4
139413 PPOS FLAG (Primer position in raw)
INSTANCE = 2 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 1 INT4
NBYTES = 2 INT4
VALUE = 940 INT2
REMAINDER= 0 INT2
SPARE = 0 INT4
139441 RSPN FLAG (???)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 1 INT4
NBYTES = 2 INT4
VALUE = 3 INT2
REMAINDER= 0 INT2
SPARE = 0 INT4
139469 RUND FLAG (Date Started)
INSTANCE = 1 INT4
DATATYPE = 10 INT2
DATASIZE = 4 INT2
NRECORDS = 1 INT4
NBYTES = 4 INT4
VALUE = (1997 INT2 (year),2 INT1 (month), 14 INT1 (day) )
SPARE = 0 INT4
139497 RUND FLAG (Date stopped)
INSTANCE = 2 INT4
DATATYPE = 10 INT2
DATASIZE = 4 INT2
NRECORDS = 1 INT4
NBYTES = 4 INT4
VALUE = (1997 INT2 (year),2 INT1 (month), 15 INT1 (day) )
SPARE = 0 INT4
139525 RUNT FLAG (Time started)
INSTANCE = 1 INT4
DATATYPE = 11 INT2
DATASIZE = 4 INT2
NRECORDS = 1 INT4
NBYTES = 4 INT4
VALUE = (16 (h), 36 (m), 40 (s), 0 (ignored) ) 4 X INT1
SPARE = 0 INT4
139553 RUNT FLAG (Time ended)
INSTANCE = 2 INT4
DATATYPE = 11 INT2
DATASIZE = 4 INT2
NRECORDS = 1 INT4
NBYTES = 4 INT4
VALUE = (4 (h), 37 (m), 11 (s), 0 (ignored) ) 4 X INT1
SPARE = 0 INT4
139581 S/N% FLAG (Sum of Each Base Type)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 4 INT4
NBYTES = 8 INT4
VALUE = POINTER to #(G,A,T,C) in CALLED SEQUENCE 2 INT4
SPARE = 0 INT4
139609 SMPL FLAG (Sample Name)
INSTANCE = 1 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 13 INT4
NBYTES = 13 INT4
VALUE = POINTER TO SAMPLE INT4
SPARE = 0 INT4
139637 SPAC FLAG (Base Spacing Used)
INSTANCE = 1 INT4
DATATYPE = 7 INT2
DATASIZE = 4 INT2
NRECORDS = 1 INT4
NBYTES = 4 INT4
VALUE = 9.67 FLT4
SPARE = 0 INT4
139665 SPAC FLAG (Basecaller)
INSTANCE = 2 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 6 INT4
NBYTES = 6 INT4
VALUE = POINTER to BASECALLER INT4
SPARE = 30594140 INT4
139693 SPAC FLAG (Base Spacing Calculated)
INSTANCE = 3 INT4
DATATYPE = 7 INT2
DATASIZE = 4 INT2
NRECORDS = 1 INT4
NBYTES = 4 INT4
VALUE = 9.67 FLT4
SPARE = 0 INT4
139721 SVER FLAG (Collection Version)
INSTANCE = 1 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 4 INT4
NBYTES = 4 INT4
VALUE = "<count=3>2.0" 4 X INT1
SPARE = 0 INT4
139749 SVER FLAG (Basecaller Version)
INSTANCE = 2 INT4
DATATYPE = 18 INT2
DATASIZE = 1 INT2
NRECORDS = 12 INT4
NBYTES = 12 INT4
VALUE = POINTER to BASECALLER VERSION INT4
SPARE = 30594196 INT4
139777 THUM FLAG (???)
INSTANCE = 1 INT4
DATATYPE = 12 INT2
DATASIZE = 10 INT2
NRECORDS = 1 INT4
NBYTES = 10 INT4
VALUE = POINTER to THUM structure 1 INT4
SPARE = 30594112 INT4
139805 THUM FLAG (???)
INSTANCE = 2 INT4
DATATYPE = 12 INT2
DATASIZE = 10 INT2
NRECORDS = 1 INT4
NBYTES = 10 INT4
VALUE = POINTER to THUM structure 2 INT4
SPARE = 30594120 INT4
139833 TRKC FLAG (Tracking Channels???)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 2 INT4
NBYTES = 4 INT4
VALUE = (70, 69) 2 X INT2
SPARE = 0 INT4
139861 TRKI FLAG (???)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 1 INT4
NBYTES = 2 INT4
VALUE = 32 INT2
REMAINDER = 0 INT2
SPARE = 0 INT4
139889 TRKP FLAG (???)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 2 INT4
NBYTES = 4 INT4
VALUE = (0, 1246) 2 X INT2
SPARE = 0 INT4
139917 drty FLAG ( End of file?)
INSTANCE = 1 INT4
DATATYPE = 4 INT2
DATASIZE = 2 INT2
NRECORDS = 1 INT4
NBYTES = 2 INT4
VALUE = 0 INT2
REMAINDER= 0 INT2
SPARE = 0 INT4
139945 Zeroes to end of file
*** abibreakout.for ********************************************************
c ABIBreakout.FOR
C 26-FEB-1997 David Mathog
C
C This program opens an ABI trace file and then dumps fields
C to a text format.
C For OpenVMS/ALPHA - compile with /float=IEEE_FLOAT
C Other platforms - you may need to change byte swapping routines.
C *****************************************************
c
implicit none
integer*4 MAXFILE
parameter (MAXFILE=2**20)
character*1 array(MAXFILE) !A 1Mb array to hold the file
character*120 infile,outfile, search
integer flagsum
parameter (flagsum=40)
character*7 flagtypes(flagsum)
integer*4 irec,brec,istat,incount,inlen,numstrings,ipoint
integer*4 begin,length,step,swap,slen
integer*4 inlenarray(10)
integer*4 lastbyte
integer*4 offset
integer*4 action
c
character*4 flag
integer*4 datatype,datasize
integer*4 instance,nrecords,nbytes,value
integer*4 spare
c
byte sbyte(80,10)
logical ok
c
logical flagcompare
c
data flagtypes/
1 ' tdir 0' !jump to offset, no action
1 ,' AEPt 1' !immediate single value
1 ,' ASPF 1' !immediate single value
1 ,' ASPt 1' !immediate single value
1 ,' AUTO 2' !immediate multiple value
1 ,' B1Pt 1' !immediate single value
1 ,' CAGT 2' !immediate multiple value
1 ,' CMBF 3' !indirect multiple value
1 ,' CMNT 3' !indirect multiple value
1 ,' CTTL 3' !indirect multiple value
1 ,' DATA 3' !indirect multiple value
1 ,' EVNT 3' !indirect multiple value
1 ,' FWO_ 2' !immediate multiple value
1 ,' GLEN 3' !indirect multiple value
1 ,' GELP 3' !indirect multiple value
1 ,' LANE 2' !immediate multiple value
1 ,' MCHN 3' !indirect multiple value
1 ,' MODL 2' !immediate multiple value
1 ,' MTRX 3' !indirect multiple value
1 ,' MTXF 3' !indirect multiple value
1 ,' NAVG 1' !immediate single value
1 ,' NCHn 1' !immediate single value
1 ,' NLNE 1' !immediate single value
1 ,' PBAS 3' !indirect multiple value
1 ,' PDMF 3' !indirect multiple value
1 ,' PLOC 3' !indirect multiple value
1 ,' PPOS 1' !immediate single value
1 ,' RSPN 1' !immediate single value
1 ,' RUND 1' !immediate single value
1 ,' RUNT 1' !immediate single value
1 ,' S/N% 3' !indirect multiple value
1 ,' SMPL 3' !indirect multiple value
1 ,' SPAC 6' !immediate single value or indirect multiple value
1 ,' SVER 5' !immediate or indirect multiple value
1 ,' THUM 4' !indirect single value
1 ,' TRKC 2' !immediate multiple value
1 ,' TRKI 1' !immediate single value
1 ,' TRKP 2' !immediate multiple value
1 ,' TRKP 2' !immediate multiple value
1 ,' drty 0' !jump to offset, no action
1/
external flagcompare
c
c
c
write(6,*)'ABIbreakout'
write(6,*)' This program converts a binary ABI file to'
write(6,*)' a text format.'
c
write(6,*)' '
write(6,*)'Input the name of the file to process'
read(5,'(q,a)')inlen,infile(1:inlen)
c
open(unit=10
1 ,file=infile(1:inlen)
1 ,form='UNFORMATTED',status='OLD'
1 ,ORGANIZATION='SEQUENTIAL'
1 ,RECORDTYPE='FIXED'
1 ,READONLY,iostat=istat)
if(istat.ne.0)stop 'Fatal error, something wrong with input file'
c
inquire(10,RECL=irec) !longwords, because unformmated
if(irec.lt.0)then !error...
stop 'ABIBreakout fatal error, illegal record size'
else
brec=irec*4 !bytes/record
write(6,*)' '
write(6,*)'Each record is ',brec,' bytes long'
end if
c
write(6,*)' '
write(6,*)'Now reading in the input file'
ipoint=1
incount=0
istat = 0
do while(istat .ge. 0 .and. ipoint .le. MAXFILE - brec + 1)
call getrec(array(ipoint),irec*4,istat)
if(istat.eq.0)then
ipoint=ipoint+brec
incount = incount + 1
end if
end do
lastbyte = incount*brec
write(6,*)' '
write(6,*)'Read in ',incount,' records'
write(6,*)'Read in ',lastbyte,' bytes'
write(6,*)' '
close(10)
c
write(6,*)'Input the name of the output file'
read(5,'(q,a)')inlen,infile(1:inlen)
open(unit=11
1 ,file=infile(1:inlen)
1 ,form='FORMATTED',status='NEW'
1 ,CARRIAGECONTROL='LIST'
1 ,iostat=istat)
if(istat.ne.0)stop 'Fatal error, something wrong with output file'
C
C Determine if it is a MacBinary or not by the position of the ABIF
C flag
C
if(flagcompare(array(1),'ABIF'))then
offset = 1 !correction from file pointer to Fortran array pointers
ipoint = 7 !position of first FLAG structure
else if(flagcompare(array(129),'ABIF'))then
offset = 129
ipoint = 135
else
stop 'Fatal error - input file is not an ABI trace file'
end if
call getflag(array(ipoint)
1 ,flag,instance,datatype,datasize,nrecords
1 ,nbytes,value,spare,1)
call getaction(flagtypes,flagsum,flag,instance,action)
if(action .ne. 0)stop 'Fatal error, input file invalid'
ipoint = offset + value
action = 1
c
c
do while(action .ne. 0)
call getflag(array(ipoint)
1 ,flag,instance,datatype,datasize,nrecords
1 ,nbytes,value,spare,0)
call getaction(flagtypes,flagsum,flag,instance,action)
C
C Matrix overlays an odd, signed integer 2 onto the unsigned
C integer 2 datatype (4). Make up a datatype for use in this
C program that does not exist in ABI files
C
if(flag .eq. 'MTRX')datatype = 1004
call writefield(11, array,action, offset
1 ,flag,instance,datatype,datasize
1 ,nrecords,nbytes,value,spare)
ipoint = ipoint + 28
end do
close (11)
stop 'ABIBreakout: normal completion'
end
subroutine getrec(scratch,size,stat)
implicit none
integer*4 size,stat
character*1 scratch(size)
read(10,iostat=stat)scratch
return
end
subroutine tellem(array,begin,length,step,swap)
implicit none
integer*4 begin,length,step,swap,i,j,k
byte array(*)
byte ba(4),btemp
integer*2 wa(2),wtemp
integer*4 la, longword
integer*4 sbyte,sword
integer*4 ubyte,uword
character*2 outc
equivalence (ba,wa,la)
c
write(6,2000)'*******************************************************************************'
write(6,2000)'|-Abs-Position--|-Rel-Position--|---byte-----|---word----------------|-----longword-------|char|'
write(6,2000)' int hex int hex int uint hex int uint int hex'
do i =begin,begin+length-1,step
c
c load the 4 bytes into the equivalenced byte array
c
k = i
do j=1,4
ba(j)=array(k)
k = k + 1
end do
c
c pull off the byte and unsigned byte
c
sbyte=ba(1)
ubyte=jiand('ff'x,la)
c
c pull off the word and unsigned word
c
sword=wa(1)
uword=jiand('ffff'x,la)
c
c pull off the longword
c
longword=la
c
c swap as needed
c
if(swap .eq. 1)then
c
la = uword
btemp=ba(1)
ba(1)=ba(2)
ba(2)=btemp
uword=la
c
la = sword
btemp=ba(1)
ba(1)=ba(2)
ba(2)=btemp
sword=wa(1)
c
la = longword
do j = 0,1
btemp=ba(4-j)
ba(4-j)=ba(j+1)
ba(j+1)=btemp
end do
longword=la
end if
c
c
if(ubyte .ge. '40'o .and. ubyte .le. '177'o)then
outc=char(ubyte)
if(ubyte .eq.'40'o)outc='SP'
else
outc='**'
endif
write(6,1000)i,i,i-begin,i-begin,sbyte,ubyte,ubyte,sword,uword,
1 longword,longword,outc
end do
1000 format(2(' ',i7,' ',z8),2(' ',i4),' ',z2,3(' ',i11),' ',z8,' ',a)
2000 format(' ',a)
return
end
logical function flagcompare(array,text)
implicit none
character*1 array(4)
character*4 text
c
integer i
c
flagcompare = .true.
do i = 1,4
if(array(i) .ne. text(i:i))then
flagcompare = .false.
return
end if
end do
return
end
subroutine getflag(array
1 ,flag,instance,datatype,datasize,nrecords
1 ,nbytes
1 ,value
1 ,spare,swap)
implicit none
c
character*1 array(28)
character*4 flag
integer*4 datatype,datasize
integer*4 instance,nrecords,nbytes
integer*4 value
integer*4 spare,swap
c
integer*4 i
c
character*1 ca(4)
byte ba(4)
integer*2 wa(2)
integer*4 la
real*4 ra
equivalence (ca,ba,wa,la)
c
c extract flag
c
do i = 1,4
flag(i:i) = array(i)
end do
c
c extract instance
c
do i = 1,4
ca(i)=array(9-i)
end do
instance = la
c
c extract datatype and datasize
c
do i = 1,4
ca(i)=array(13-i)
end do
datatype=wa(2)
datasize=wa(1)
c
c extract Nrecords
c
do i = 1,4
ca(i)=array(17-i)
end do
nrecords = la
c
c extract Nbytes
c
do i = 1,4
ca(i)=array(21-i)
end do
nbytes = la
c
c extract value - swap or not depend on SWAP
c
if(swap .eq. 1)then
do i = 1,4
ca(i)=array(25 - i)
end do
else
do i = 1,4
ca(i)=array(20+i)
end do
end if
value = la
c
c extract spare
c
do i = 1,4
ca(i)=array(29-i)
end do
spare = la
c
return
end
subroutine getaction(flagtypes,num,flag,instance,action)
implicit none
integer*4 action,num,instance
character*4 flag
character*7 flagtypes(num)
c
integer*4 i,k
c
do i = 1,num
k = index(flagtypes(i),flag)
if(k .ne. 0)then
action = ichar(flagtypes(i)(7:7)) - ichar('0')
c
c The SVER field is screwy, the first instance is IMMEDIATE MULTIPLE
c and the second instance is INDIRECT MULTIPLE. Blame ABI
c for some silly programming.
c
if(action .eq. 5)then
if(instance .eq. 1)then
action = 2
else
action = 3
end if
end if
c
c The SPAC field is screwy, the first instance is IMMEDIATE SINGLE
c and the second instance is INDIRECT MULTIPLE with a completely
c different data type, and the third is back to IMMEDIATE SINGLE
c again. Blame ABI for some silly programming.
c
if(action .eq. 6)then
if(instance .eq. 2)then
action = 3
else
action = 1
end if
end if
c
return
end if
end do
action = -1
c
return
end
subroutine writefield(unit, array,action, offset
1 ,flag,instance,datatype,datasize,nrecords
1 ,nbytes,value,spare)
implicit none
c
character*1 array(1)
integer*4 unit,action,offset
integer*4 instance,datatype,datasize
integer*4 nrecords, nbytes
integer*4 value,spare
character*4 flag
c
real*4 rtemp
integer*4 i,k,ipoint
logical novel
c
character*1 ca(4)
byte ba(4),btemp
integer*2 wa(2)
integer*4 la
real*4 ra
equivalence (ca,ba,wa,la,ra)
c
c perform the appropriate action. If action <=0 nothing happens
c
novel = .false.
if(action .eq. 1)then !immediate single value
la = value
if(datatype .eq. 2)then
write(unit,1002)flag,instance,value
else if(datatype .eq. 4)then
btemp=ba(2)
ba(2)=ba(1)
ba(1)=btemp
write(unit,1004)flag,instance,wa(1)
else if(datatype .eq. 7)then
do i = 1,2
btemp = ba(5-i)
ba(5-i) = ba(i)
ba(i) = btemp
end do
write(unit,1007)flag,instance,ra
else if(datatype .eq. 10)then
btemp=ba(2)
ba(2)=ba(1)
ba(1)=btemp
write(unit,1010)flag,instance,wa(1),ba(3),ba(4)
else if(datatype .eq. 11)then
write(unit,1011)flag,instance,ba(1),ba(2),ba(3)
else if(datatype .eq. 18)then
i = ichar(ca(1))+1
k = 2
write(unit,1018)flag,instance,(ba(k),k=2,i)
else
novel = .true.
end if
else if(action .eq. 2)then !immediate multiple value
la = value
if(datatype .eq. 2)then
write(unit,1002)flag,instance,value
else if(datatype .eq. 4)then
do i = 1,2
btemp = ba(5-i)
ba(5-i) = ba(i)
ba(i) = btemp
end do
write(unit,2004)flag,instance,wa(1),wa(2)
else if(datatype .eq. 13)then
i = nbytes
write(unit,2013)flag,instance,(ba(i),k=1,i)
else if(datatype .eq. 18)then
k = jiand('ff'x,value)
la = value
write(unit,3018)flag,instance,( ca(i),i=2,1+k)
else
novel = .true.
end if
else if(action .eq. 3)then !indirect multiple value
la = value ! always an offset into the file
do i = 1,2
btemp = ba(5-i)
ba(5-i) = ba(i)
ba(i) = btemp
end do
ipoint = la + offset !now we know where in the array
c
if(datatype .eq. 2)then
if(ipoint .ne. offset)then
write(unit,3002)flag,instance,(array(i),i=ipoint,ipoint+nbytes-1)
else
write(unit,1002)flag,instance,'NONE'
end if
else if(datatype .eq. 4)then
wa(2)=0
if(ipoint .ne. offset)then
write(unit,3004)flag,instance
do i = 1, nrecords
ca(2)=array(ipoint)
ipoint = ipoint + 1
ca(1)=array(ipoint)
ipoint = ipoint + 1
write(unit,30045)i,la
end do
else
write(unit,1002)flag,instance,'NONE'
endif
else if(datatype .eq. 1004)then
wa(2)=0
if(ipoint .ne. offset)then
write(unit,3004)flag,instance
do i = 1, nrecords
ca(2)=array(ipoint)
ipoint = ipoint + 1
ca(1)=array(ipoint)
ipoint = ipoint + 1
rtemp = float(wa(1))/1000.
write(unit,30046)i,rtemp
end do
else
write(unit,1002)flag,instance,'NONE'
endif
else if(datatype .eq. 18)then
if(ipoint .ne. offset)then
write(unit,3018)flag,instance,(array(i),i=ipoint+1,ipoint+nbytes-1)
else
write(unit,1002)flag,instance,'NONE'
end if
else
novel = .true.
end if
else if(action .eq. 4)then !indirect single value
la = value ! always an offset into the file
do i = 1,2
btemp = ba(5-i)
ba(5-i) = ba(i)
ba(i) = btemp
end do
ipoint = la + offset !now we know where in the array
c
if(datatype .eq. 12)then !THUM structures
write(unit,4012)flag,instance,(ichar(array(i)),i=ipoint,ipoint+9)
else
novel = .true.
end if
end if
c
if(novel)then
write(6,9000)flag,instance,datatype,datasize
1 ,nrecords,nbytes,value,spare
end if
9000 format(' Novel FLAG structure encountered',/
1 ' FLAG: ',a4,/
1 ' instance ',i6,/
1 ' datatype ',i6,/
1 ' datasize ',i6,/
1 ' nrecords ',i6,/
1 ' nbytes ',i6,/
1 ' value(hex) ',z8,/
1 ' spare(hex) ',z8)
1002 format('>',a4,i6,' ',a4)
1004 format('>',a4,i6,' ',i6)
1007 format('>',a4,i6,' ',f9.3)
1010 format('>',a4,i6,' ',i6,'(y)',i3,'(m)',i3,'(d)')
1011 format('>',a4,i6,' ',i6,'(h)',i3,'(m)',i3,'(s)')
1018 format('>',a4,i6,' ',a4)
2004 format('>',a4,i6,2(' ',i6))
2013 format('>',a4,i6,4(' ',z6))
3002 format('>',a4,i6,' ',/,5000(50a,/))
3004 format('>',a4,i6, '(Pos,Value)')
30045 format(' ',i6,',',i6)
30046 format(' ',i6,',',f7.3)
3018 format('>',a4,i6,' ',256a)
4012 format('>',a4,i6,' ',z2,9(',',z2))
return
end
*** datasniffer.for ************************************************************
c DataSniffer.FOR
C 20-FEB-1997 David Mathog
C
C This program dumps data from a binary file in arbitrary
C formats. It uses pointers in an awful way and is probably
C extremely nonportable.
C *****************************************************
c
implicit none
integer*4 MAXFILE
parameter (MAXFILE=2**20)
byte array(MAXFILE) !A 1Mb array to hold the file
character*120 infile,search
integer*4 irec,brec,istat,incount,inlen,numstrings,ipoint
integer*4 begin,length,step,swap,slen
integer*4 inlenarray(10)
integer*4 lastbyte
byte sbyte(80,10)
logical ok
c
c
c
write(6,*)'DataSniffer'
write(6,*)' This program examines the data in a binary file'
c
write(6,*)' '
write(6,*)'Input the name of the file to process'
read(5,'(q,a)')inlen,infile(1:inlen)
c
open(unit=10
1 ,file=infile(1:inlen)
1 ,form='UNFORMATTED',status='OLD'
1 ,ORGANIZATION='SEQUENTIAL'
1 ,RECORDTYPE='FIXED'
1 ,READONLY,iostat=istat)
if(istat.ne.0)stop 'Fatal error, something wrong with that file'
c
inquire(10,RECL=irec) !longwords, because unformmated
if(irec.lt.0)then !error...
stop 'SearchFixed fatal error, illegal record size'
else
brec=irec*4 !bytes/record
write(6,*)' '
write(6,*)'Each record is ',brec,' bytes long'
end if
c
write(6,*)' '
write(6,*)'Now reading in the input file'
ipoint=1
incount=0
istat = 0
do while(istat .ge. 0 .and. ipoint .le. MAXFILE - brec + 1)
call getrec(array(ipoint),irec,istat)
if(istat.eq.0)then
ipoint=ipoint+brec
incount = incount + 1
end if
end do
lastbyte = incount*brec
write(6,*)' '
write(6,*)'Read in ',incount,' records'
write(6,*)'Read in ',lastbyte,' bytes'
write(6,*)' '
close(10)
C
C
C
length = 1
write(6,*)'You will now be prompted for regions to examine as'
write(6,*)' Begin, Length, step, swap'
write(6,*)' Begin: position to begin (in bytes, 1 = first byte)'
write(6,*)' Length: to examine (in bytes), 0 exits'
write(6,*)' Step: between outputs, (in bytes), (>0)'
write(6,*)' Swap: (0 = as is, anything else= reverse byte order)'
write(6,*)' Values in decimal (16)or hex (10x)'
do while(length .ne. 0)
write(6,*)' '
write(6,*)'Examine region:'
read(5,'(q,a)')slen,search(1:slen)
call sparse(search(1:slen),begin,length,step,swap,istat)
if(istat .eq. 0)then
if(begin .lt. 1.)then
begin = 1
write(6,*)'Cannot search before first byte, starting at 1'
end if
if(begin + length - 1 .gt. lastbyte)then
length = lastbyte - begin + 1
write(6,*)'Truncating search at end of file'
endif
if(length .gt. 0)call tellem(array,begin,length,step,swap)
else
istat = 0
endif
end do
stop 'SearchFixed: normal completion'
end
subroutine getrec(scratch,size,stat)
implicit none
integer*4 size,stat,scratch(size)
read(10,iostat=stat)scratch
return
end
subroutine tellem(array,begin,length,step,swap)
implicit none
integer*4 begin,length,step,swap,i,j,k
byte array(*)
byte ba(4),btemp
integer*2 wa(2),wtemp
integer*4 la, longword
integer*4 sbyte,sword
integer*4 ubyte,uword
character*2 outc
equivalence (ba,wa,la)
c
write(6,2000)'*******************************************************************************'
write(6,2000)'|-Abs-Position--|-Rel-Position--|---byte-----|---word----------------|-----longword-------|char|'
write(6,2000)' int hex int hex int uint hex int uint int hex'
do i =begin,begin+length-1,step
c
c load the 4 bytes into the equivalenced byte array
c
k = i
do j=1,4
ba(j)=array(k)
k = k + 1
end do
c
c pull off the byte and unsigned byte
c
sbyte=ba(1)
ubyte=jiand('ff'x,la)
c
c pull off the word and unsigned word
c
sword=wa(1)
uword=jiand('ffff'x,la)
c
c pull off the longword
c
longword=la
c
c swap as needed
c
if(swap .eq. 1)then
c
la = uword
btemp=ba(1)
ba(1)=ba(2)
ba(2)=btemp
uword=la
c
la = sword
btemp=ba(1)
ba(1)=ba(2)
ba(2)=btemp
sword=wa(1)
c
la = longword
do j = 0,1
btemp=ba(4-j)
ba(4-j)=ba(j+1)
ba(j+1)=btemp
end do
longword=la
end if
c
c
if(ubyte .ge. '40'o .and. ubyte .le. '177'o)then
outc=char(ubyte)
if(ubyte .eq.'40'o)outc='SP'
else
outc='**'
endif
write(6,1000)i,i,i-begin,i-begin,sbyte,ubyte,ubyte,sword,uword,
1 longword,longword,outc
end do
1000 format(2(' ',i7,' ',z8),2(' ',i4),' ',z2,3(' ',i11),' ',z8,' ',a)
2000 format(' ',a)
return
end
subroutine pretellem(bytestring,numbytes,offset,size,recnum)
c
c this subroutine ensures that the output contains only
c printable ascii characters, and that if it is within 10 of the
c end, that the ends are padded correctly.
c
c state = 0 is before
c state = 1 is 1 before
c state = 2 is in
c state = 3 is 1 past
c state = 4 is more than one past
c
implicit none
external printable
integer*4 count,dest,source,state
integer*4 numbytes,offset,size,recnum
byte bytestring(numbytes)
byte passbytes(256)
byte printable
c
c paste in the part that matched
c
source=offset-10 !pointer inside text buffer
dest=1 !pointer to xfer array
if(source.lt.0)then !the paste can begen left of, on, or right
state=0 !the first byte of the buffer
else if(source.eq.0)then
state=1
else
state=2
end if
do count=1,size+20
if(state.eq.0)then !>1 left of text buffer
passbytes(dest)=ichar('*')
if(source.eq.-1)state=state+1 ! if 2 left, change state
else if(state.eq.1)then ! 1 left of text buffer
passbytes(dest)=ichar(']')
state=state+1 !only here 1 cycle
else if(state.eq.2)then !inside text buffer
passbytes(dest)=printable(bytestring(source))
if(source.eq.numbytes)state=state+1
! last byte, increment state
else if(state.eq.3)then ! 1 right of text buffer
passbytes(dest)=ichar('[')
state=state+1 !only here one cycle
else !>1 right of text buffer
passbytes(dest)=ichar('*') !no tests needed
end if
source=source+1
dest=dest+1
end do
call tellem(passbytes,size+20,offset,recnum)
return
end
byte function printable(bchar)
implicit none
byte bchar
if(bchar.lt.32)then
printable='52'o !this is a *
else if(bchar.gt.'176'o)then
printable='52'o
else
printable=bchar
end if
return
end
subroutine deadtellem(bytestring,numbytes,offset,size,recnum)
c
c this subroutine ensures that the output contains only
c printable ascii characters, and that if it is within 10 of the
c end, that the ends are padded correctly.
c
c state = 0 is before
c state = 1 is 1 before
c state = 2 is in
c state = 3 is 1 past
c state = 4 is more than one past
c
implicit none
external printable
integer*4 i,j,k,state
integer*4 numbytes,offset,size,recnum
byte bytestring(numbytes)
byte passbytes(256)
byte printable
c
c
c paste in the part that matched
c
k=offset
j=11
do i=1,size
passbytes(j)=printable(bytestring(k))
k=k+1
j=j+1
end do
c
c paste in the part before the part that matched
c
k=offset-1
j=10
do i=1,10
if(k.gt.0)then !still inside the record
passbytes(j)=printable(bytestring(k))
else if(k.eq.0)then !oops, just left the record
passbytes(j)='|'
else !well outside of the record
passbytes(j)='*'
end if
k=k-1
j=j-1
end do
c
c paste in the part after the part that matched
c
k=offset+size !the first byte past the search
j=10+size !string and where it gets put
do i=1,10
if(k.lt.numbytes)then !still inside the record
passbytes(j)=printable(bytestring(k))
else if(k.eq.numbytes)then !oops, just left the record
passbytes(j)='|'
else !well outside of the record
passbytes(j)='*'
end if
k=k+1
j=j+1
end do
call tellem(passbytes,size+20,offset,recnum)
return
end
subroutine converttobyte(sbyte,search,inlen)
implicit none
integer*4 inlen,i
byte sbyte(inlen)
character search*(*)
do i=1,inlen
sbyte(i)=ichar(search(i:i))
end do
return
end
c
c convert a string to begin, length, step
c
c string fields are either 1232 or 1A3x
c
subroutine sparse(string,begin,length,step,swap,istat)
implicit none
integer*4 begin,length,step,swap,slen,istat
integer*4 front,back,isix,jstat
character*(*) string
c
istat = -1
slen=len(string)
if(slen .lt. 1)return
front=1
back=front + index(string(front:slen),',') - 1
isix=front + max(index(string(front:back),'x'),index(string(front:back),'X')) - 1
if(back .eq. 0)return
if(isix .ge. front)then
if(isix-1 .lt. front)return
read(string(front:isix-1),1000,iostat=jstat)begin
else
if(back-1 .lt. front)return
read(string(front:back-1),*,iostat=jstat)begin
end if
if(jstat .ne. 0)return
c
front = back + 1
back=front + index(string(front:slen),',') - 1
isix=front + max(index(string(front:back),'x'),index(string(front:back),'X')) - 1
if(back .eq. 0)return
if(isix .ge. front)then
if(isix-1 .lt. front)return
read(string(front:isix-1),1000,iostat=jstat)length
else
if(back-1 .lt. front)return
read(string(front:back-1),*,iostat=jstat)length
end if
if(jstat .ne. 0)return
c
front = back + 1
back=front + index(string(front:slen),',') - 1
isix=front + max(index(string(front:back),'x'),index(string(front:back),'X')) - 1
if(back .eq. 0)return
if(isix .ge. front)then
if(isix-1 .lt. front)return
read(string(front:isix-1),1000,iostat=jstat)step
else
if(back-1 .lt. front)return
read(string(front:back-1),*,iostat=jstat)step
end if
if(jstat .ne. 0)return
c
front = back + 1
back=slen
isix=front + max(index(string(front:back),'x'),index(string(front:back),'X')) - 1
if(isix .ge. front)then
if(isix-1 .lt. front)return
read(string(front:isix-1),1000,iostat=jstat)swap
else
if(back .lt. front)return
read(string(front:back),*,iostat=jstat)swap
end if
if(jstat .ne. 0)return
1000 format(z8)
c
istat = 0
if(swap .ne. 0)swap = 1
return
end