in reply to Re^2: Convert numbers from a binary file to texts
in thread Convert numbers from a binary file to texts

Totally untested Partly tested; ignoring any index if it is present as the spec doesn't mention it; and making no attempt to present the contain data in any useful way since I don't know what it represents; but it should be pretty close:

#! perl -slw use strict; my $fname = $ARGV[ 0 ]; open IN, '<:raw', $fname or die $!; read( IN, my $header, 31 ); my( $sig, $ver, $iOff, $iLen, $reads, $hLen, $kLen, $flows, $fmt ) = u +npack 'a4 N Q N N n n n C', $header; print "sig: $sig ver:$ver iOff:$iOff iLen:$iLen reads:$reads hLen:$hLe +n kLen:$kLen flows:$flows fmt:$fmt"; read( IN, my $varHead, $hLen - 31 ); my( $flowchars, $keySeq ) = unpack "a$flows a$kLen", $varHead; print "flowchars: $flowchars\nkeySeq:$keySeq\n"; for my $read ( 1 .. $reads ) { my $buffer; read( IN, $buffer, 16 ); my( $hLen, $nLen, $bases, $cqLeft, $cqRight, $caLeft, $caRight ) = + unpack 'n n N n n n n', $buffer; read( IN, $buffer, 8*int( ( $nLen + 7 ) / 8 ) ); my $name = unpack "a$nLen", $buffer; read( IN, $buffer, 2*$flows ); my @signal = unpack "n$flows", $buffer; read( IN, $buffer, $bases ); my @posns = unpack "C$bases", $buffer; read( IN, $buffer, $bases ); my @scores = unpack "C$bases", $buffer; read( IN, $buffer, 8*int( ( 4*$bases + 7 ) /8 ) ); ## discard padd +ing ## do something useful with data here. print "Name: $name\nSignal: [ @signal ]\nPosns: [ @posns ]\nScores +: [ @scores ]\n"; last if eof( IN ); }

Output from the partial file in the OP:


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.