get working for spanish .xwd. .pdb remains.

This commit is contained in:
ehouse 2004-06-09 04:09:19 +00:00
parent b4e6078d28
commit 153d2ae34d

View file

@ -87,13 +87,19 @@ sub readFaces($$$) {
return $nChars; return $nChars;
} # readFaces } # readFaces
sub skipBitmaps($) { sub skipBitmap($) {
my ( $fh ) = @_; my ( $fh ) = @_;
my $buf; my $buf;
sysread( $fh, $buf, 1 ); sysread( $fh, $buf, 1 );
my $nCols = unpack( 'C', $buf ); my $nCols = unpack( 'C', $buf );
die "not doing real bitmaps yet" if $nCols; if ( $nCols > 0 ) {
sysread( $fh, $buf, 1 );
my $nRows = unpack( 'C', $buf );
my $nBytes = (($nRows * $nCols) + 7) / 8;
sysread( $fh, $buf, $nBytes );
} }
} # skipBitmap
sub getSpecials($$$) { sub getSpecials($$$) {
my ( $fh, $nSpecials, $specRef ) = @_; my ( $fh, $nSpecials, $specRef ) = @_;
@ -105,8 +111,8 @@ sub getSpecials($$$) {
my $len = unpack( 'C', $buf ); my $len = unpack( 'C', $buf );
sysread( $fh, $buf, $len ); sysread( $fh, $buf, $len );
push( @specials, $buf ); push( @specials, $buf );
skipBitmaps( $fh ); skipBitmap( $fh );
skipBitmaps( $fh ); skipBitmap( $fh );
} }
@{$specRef} = @specials; @{$specRef} = @specials;
@ -141,6 +147,17 @@ sub nodeSizeFromFlags($) {
} }
} # nodeSizeFromFlags } # nodeSizeFromFlags
sub mergeSpecials($$) {
my ( $facesRef, $specialsRef ) = @_;
for ( my $i = 0; $i < @$facesRef; ++$i ) {
my $ref = ord($$facesRef[$i]);
if ( $ref < 32 ) {
$$facesRef[$i] = $$specialsRef[$ref];
print STDERR "set $ref to $$specialsRef[$ref]\n";
}
}
}
sub prepXWD($$$$) { sub prepXWD($$$$) {
my ( $path, $facRef, $nodesRef, $startRef ) = @_; my ( $path, $facRef, $nodesRef, $startRef ) = @_;
@ -164,6 +181,7 @@ sub prepXWD($$$$) {
my @specials; my @specials;
getSpecials( *INFILE, $nSpecials, \@specials ); getSpecials( *INFILE, $nSpecials, \@specials );
mergeSpecials( $facRef, \@specials );
sysread( INFILE, $buf, 4 ); sysread( INFILE, $buf, 4 );
$$startRef = unpack( 'N', $buf ); $$startRef = unpack( 'N', $buf );
@ -246,10 +264,10 @@ sub parseNode($$$$$) {
# . "next=$$nextEdge; ci=$$chrIndex\n", $node; # . "next=$$nextEdge; ci=$$chrIndex\n", $node;
} # parseNode } # parseNode
sub printStr($) { sub printStr($$) {
my ( $strRef ) = @_; my ( $strRef, $facesRef ) = @_;
print join( "", @$strRef ), "\n"; print join( "", map {$$facesRef[$_]} @$strRef), "\n";
} # printStr } # printStr
@ -268,10 +286,9 @@ sub printDAWGInternal($$$$) {
parseNode( $node, \$chrIndex, \$nextEdge, \$accepting, \$lastEdge ); parseNode( $node, \$chrIndex, \$nextEdge, \$accepting, \$lastEdge );
die "index $chrIndex out of range" if $chrIndex > 26 || $chrIndex < 0; push( @$str, $chrIndex );
push( @$str, $$facesRef[$chrIndex] );
if ( $accepting ) { if ( $accepting ) {
printStr( $str ); printStr( $str, $facesRef );
} }
if ( $nextEdge != 0 ) { if ( $nextEdge != 0 ) {
@ -314,6 +331,15 @@ if ( $gFileType eq "xwd" ){
prepXWD( $gInFile, \@faces, \@nodes, \$startIndex ); prepXWD( $gInFile, \@faces, \@nodes, \$startIndex );
} elsif ( $gFileType eq "pdb" ) { } elsif ( $gFileType eq "pdb" ) {
prepPDB( $gInFile, \@faces, \@nodes, \$startIndex ); prepPDB( $gInFile, \@faces, \@nodes, \$startIndex );
print STDERR join( ",", @faces), "\n";
} }
printDAWG( \@nodes, $startIndex, \@faces ); printDAWG( \@nodes, $startIndex, \@faces );
if ( $gASCIIFacesFileName ) {
open FACES, "> $gASCIIFacesFileName";
foreach my $face (@faces) {
print FACES pack('cc', 0, $face );
}
close FACES;
}